Ad Widget

Collapse

Auto discovery of network topology

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • naim
    Junior Member
    • Jun 2006
    • 13

    #1

    Auto discovery of network topology

    if multiple addresses can be defined per host, the with the help of auto discovery feature, zabbix could discover network topology in a matter of one hour, at least in my case.
    here is how I do it (how i describe below works for nagios, but its not much work to change it to work in zabbix)::
    1) Host list(s) is generated using autodiscovery feature, just IP address enough, hostname or alias a plus
    2) Sample trace script to determine parents, 99% accurate if you choose carefully data to run script on. Sure, its faster to write the whole thing into one C program, it takes me about 70 minutes to map about 650 hosts.
    Code:
    #!/usr/bin/perl -w
    # (C) Virtual ISP S.A.L.
    # Denys Fedoryshchenko
    my $debug = 1;
    
    use strict;
    my $x;
    my @hops;
    my @hosts;
    my $hop;
    my $unknown;
    my $lasthost;
    my %db;
    
    my $filename = shift(@ARGV);
    
    if (!$filename) {
        print "ERROR!\n".$0." hosts.cfg\n";
        exit;
    }
    
    sub traceroute {
            my $dsthost = shift(@_);
            my $host;
            undef @hops;
            print("Tracing host: $dsthost\n");
            my @hops = `/usr/sbin/traceroute -w 2 -n -I $dsthost 2>/dev/null`;
            $hop = pop(@hops); #Ignore it is last hop
            print($hop." last hop, ignoring\n") if ($debug == 1) ;
            $hop = pop(@hops);
            if (!$hop) { return("1HOPAWAY"); }
            print($hop." this hop is parent\n") if ($debug == 1) ;
            #WORKAROUND ON PACKETLOSS (asestriks)
            ($unknown,$host) = split(' ',$hop);
            ($unknown,$unknown,$host) = split(' ',$hop) if ($host eq '*') ;
            ($unknown,$unknown,$unknown,$host) = split(' ',$hop) if ($host eq '*') ;
            if ($host eq '*') { return("UNKNOWN"); }
            return($host);
    
    }
    open(FILE2,'>'.$filename.".new");
    open(FILE,'<'.$filename);
    
    print(FILE2 "# host_name(s) \n#");
    while (<FILE>) {
        if (/host_name\s+([A-Z0-9\-\.]+)\s+/i) {
            $lasthost = $1;
    #       print (FILE2 $lasthost.",");
        }
        if (/address\s+([0-9\.\,]+)\s+$/) {
            @hosts = split(/\,/,$1);
            while($x = shift(@hosts)) {         
                print("Adding ".$x." as ".$lasthost."\n") if ($debug == 1);
                $db{$x} = $lasthost;
            }
        }
    }
    close(FILE);
    print "\n\n";
    
    open(FILE,'<'.$filename);
    
    while (<FILE>) {
        print FILE2 $_;
        if (/address\s+([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/) {
            $hop = traceroute($1);
            if ($db{$hop}) { 
                print("Found! $db{$hop}\n");
                print(FILE2 "\tparent\t\t".$db{$hop}."\n");
            } elsif ($hop ne '1HOPAWAY' && $hop ne 'UNKNOWN') { 
                print("Not found IP in list - $hop !!! You must have this host in hosts.cfg so program can get name of it and set as parent\n");
            } elsif ($hop eq 'UNKNOWN') { 
                print(FILE2 "#PARENT-NOT-DETECTED\n");
            }
        }
    }
    close(FILE);
    close(FILE2);
    3) Map automatically generated, most probably a mess, that confirms to no specific topology really, just how i like it, spaghetti style :P

    So the only step missing is to have zabbix allow multiple address definitions per host, its only logical, i dont understand why its not done this way.
  • zabbix_zen
    Senior Member
    • Jul 2009
    • 426

    #2
    Sorry to revive an old thread.

    Last time I checked the Manual it says ZABBIX 'does NOT provide: Discovery of network topology'


    Have there been any further thoughts on this?

    Comment

    • gpmidi
      Member
      • Aug 2009
      • 62

      #3
      Auto Mapping

      Including the ability to map would be awesome. You could probably reuse code from (or directly call) an existing mapping program. There are several open source ones out there.
      -Paul

      Comment

      Working...