diff options
Diffstat (limited to 'collectors/snmpfetchng.pl')
-rwxr-xr-x | collectors/snmpfetchng.pl | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/collectors/snmpfetchng.pl b/collectors/snmpfetchng.pl index 5c4b053..2f12032 100755 --- a/collectors/snmpfetchng.pl +++ b/collectors/snmpfetchng.pl @@ -22,13 +22,13 @@ $dbh->{RaiseError} = 1; my $qualification = <<"EOF"; (last_updated IS NULL OR now() - last_updated > poll_frequency) AND (locked='f' OR now() - last_updated > '15 minutes'::interval) -AND mgmt_v4_addr is not null +AND (mgmt_v4_addr is not null or mgmt_v6_addr is not null) EOF # Borrowed from snmpfetch.pl our $qswitch = $dbh->prepare(<<"EOF") SELECT - sysname,switch,host(mgmt_v4_addr) as ip,community, + sysname,switch,host(mgmt_v4_addr) as ip,host(mgmt_v6_addr) as ip2,community, DATE_TRUNC('second', now() - last_updated - poll_frequency) AS overdue FROM switches @@ -63,10 +63,16 @@ sub populate_switches or die "Couldn't get switch"; $dbh->commit; while (my $ref = $qswitch->fetchrow_hashref()) { + my $ip; + $ip = $ref->{'ip'}; + if (!defined($ip) or $ip eq "") { + $ip = 'udp6:[' . $ref->{'ip2'} . ']'; + } + print "Ip: $ip\n"; push @switches, { 'sysname' => $ref->{'sysname'}, 'id' => $ref->{'switch'}, - 'mgtip' => $ref->{'ip'}, + 'mgtip' => $ip, 'community' => $ref->{'community'} }; } |