aboutsummaryrefslogtreecommitdiffstats
path: root/clients/snmpfetch.pl
diff options
context:
space:
mode:
Diffstat (limited to 'clients/snmpfetch.pl')
-rwxr-xr-xclients/snmpfetch.pl15
1 files changed, 10 insertions, 5 deletions
diff --git a/clients/snmpfetch.pl b/clients/snmpfetch.pl
index 1b43395..6eb9eb5 100755
--- a/clients/snmpfetch.pl
+++ b/clients/snmpfetch.pl
@@ -50,7 +50,7 @@ our $qlock = $dbh->prepare("UPDATE switches SET locked='t', last_updated=now() W
or die "Couldn't prepare qlock";
our $qunlock = $dbh->prepare("UPDATE switches SET locked='f', last_updated=now() WHERE switch=?")
or die "Couldn't prepare qunlock";
-our $qpoll = $dbh->prepare("INSERT INTO polls (time, switch, port, bytes_in, bytes_out, errors_in, errors_out, official_port,operstatus) VALUES (timeofday()::timestamp,?,?,?,?,?,?,true,?)")
+our $qpoll = $dbh->prepare("INSERT INTO polls (time, switch, port, bytes_in, bytes_out, errors_in, errors_out, official_port,operstatus,ifdescr) VALUES (timeofday()::timestamp,?,?,?,?,?,?,true,?,?)")
or die "Couldn't prepare qpoll";
poll_loop(@ARGV);
@@ -148,6 +148,7 @@ sub poll_loop {
push @vars, ["ifOutOctets", $port];
push @vars, ["ifInErrors", $port];
push @vars, ["ifOutErrors", $port];
+ push @vars, ["ifDescr", $port];
push @vars, ["ifOperStatus", $port];
my $varlist = SNMP::VarList->new(@vars);
$session->get($varlist, [ \&callback, $switch_status, $port ]);
@@ -189,7 +190,8 @@ sub callback {
my ($switch, $port, $vars) = @_;
my ($in, $out, $ine, $oute) = (undef, undef, undef, undef);
- my $operstatus = "false";
+ my $operstatus = 2;
+ my $ifdescr = undef;
for my $var (@$vars) {
if ($port != $var->[1]) {
@@ -205,6 +207,8 @@ sub callback {
$oute = $var->[2];
} elsif ($var->[0] eq 'ifOperStatus') {
$operstatus = $var->[2];
+ } elsif ($var->[0] eq 'ifDescr') {
+ $ifdescr = $var->[2];
} else {
die "Response for unknown OID $var->[0].$var->[1]";
}
@@ -216,18 +220,19 @@ sub callback {
warn $switch->{'sysname'}.":$port: failed reading in";
}
$ok = 0;
- warn "no in";
}
if (!defined($out) || $out !~ /^\d+$/) {
if (defined($oute)) {
warn $switch->{'sysname'}.":$port: failed reading in";
}
$ok = 0;
- warn "no out";
+ }
+ if (!defined($ifdescr)) {
+ $ok = 0;
}
if ($ok) {
- $qpoll->execute($switch->{'switch'}, $port, $in, $out, $ine, $oute,$operstatus) || die "%s:%s: %s\n", $switch->{'switch'}, $port, $in;
+ $qpoll->execute($switch->{'switch'}, $port, $in, $out, $ine, $oute,$operstatus,$ifdescr) || die "%s:%s: %s\n", $switch->{'switch'}, $port, $in;
$dbh->commit;
} else {
warn $switch->{'sysname'} . " failed to OK.";