diff options
-rw-r--r-- | build/test/snmpd.conf | 1 | ||||
-rwxr-xr-x | collectors/snmpfetchng.pl | 12 |
2 files changed, 10 insertions, 3 deletions
diff --git a/build/test/snmpd.conf b/build/test/snmpd.conf index be5cb45..492add9 100644 --- a/build/test/snmpd.conf +++ b/build/test/snmpd.conf @@ -47,6 +47,7 @@ view systemonly included .1.3.6.1.2.1.25.1 # Full access from the local host rocommunity FullPuppTilNMS localhost +rocommunity FullPuppTilNMS # Default access to basic system info rocommunity public default -V systemonly # rocommunity6 is for IPv6 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'} }; } |