aboutsummaryrefslogtreecommitdiffstats
path: root/collectors/snmpfetchng.pl
diff options
context:
space:
mode:
authorKristian Lyngstol <kristian@bohemians.org>2016-05-23 02:10:59 +0200
committerKristian Lyngstol <kristian@bohemians.org>2016-05-23 02:10:59 +0200
commita86b49735ef3029f46f4c2b7f5c309d4562b2cce (patch)
treeba610df02f97f9132cbfb221ada5a4865cd8f80a /collectors/snmpfetchng.pl
parentf264fba8cddc51bf16f7797fcf447350fa6e55d0 (diff)
snmpfetcher: use IPv6 if available.
Also fixes snmpd.conf config to expose it...
Diffstat (limited to 'collectors/snmpfetchng.pl')
-rwxr-xr-xcollectors/snmpfetchng.pl12
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'}
};
}