]> git.sesse.net Git - nms/commitdiff
Poll for errors along with data in/out.
authorSteinar H. Gunderson <sesse@samfundet.no>
Sun, 2 Apr 2006 21:47:53 +0000 (21:47 +0000)
committerSteinar H. Gunderson <sesse@samfundet.no>
Sun, 2 Apr 2006 21:47:53 +0000 (21:47 +0000)
clients/snmpfetch.pl
sql/nms.sql

index 2798413fe3e9486389f1f3eb5275d5ee61f1f01d..bc64b60fb97cd737d56f546e305dc347eb2a48ec 100755 (executable)
@@ -49,7 +49,7 @@ my $qlock = $dbh->prepare("UPDATE switches SET locked='t', last_updated=now() WH
        or die "Couldn't prepare qlock";
 my $qunlock = $dbh->prepare("UPDATE switches SET locked='f', last_updated=now() WHERE switch=?")
        or die "Couldn't prepare qunlock";
-my $qpoll = $dbh->prepare("INSERT INTO polls (time, switch, port, bytes_in, bytes_out) VALUES (timeofday()::timestamp,?,?,?,?)")
+my $qpoll = $dbh->prepare("INSERT INTO polls (time, switch, port, bytes_in, bytes_out, errors_in, errors_out) VALUES (timeofday()::timestamp,?,?,?,?,?,?)")
        or die "Couldn't prepare qpoll";
 my $qtemppoll = $dbh->prepare("INSERT INTO temppoll (time, switch, temp) VALUES (timeofday()::timestamp,?::text::int,?::text::float)")
         or die "Couldn't prepare qtemppoll";
@@ -127,8 +127,10 @@ while (1) {
                for my $port (@ports) {
                        my $in = fetch_data($session, $port, 0, $switch->{'wide_counters'});
                        my $out = fetch_data($session, $port, 1, $switch->{'wide_counters'});
+                       my $ine = fetch_errors($session, $port, 0);
+                       my $oute = fetch_errors($session, $port, 1);
 
-                       $qpoll->execute($switch->{'switch'}, $port, $in, $out);
+                       $qpoll->execute($switch->{'switch'}, $port, $in, $out, $ine, $oute);
                }
                 my $conn = switch_connect($ip);
                 if (!defined($conn)) {
@@ -212,6 +214,18 @@ sub fetch_data {
 
        return fetch_snmp($session, $oid);
 }
+sub fetch_errors {
+       my ($session, $port, $out) = @_;
+       
+       my $oid;
+       if ($out) {
+               $oid = BER::encode_oid(1, 3, 6, 1, 2, 1, 2, 2, 1, 20, $port);     # interfaces.ifTable.ifEntry.ifOutErrors
+       } else {
+               $oid = BER::encode_oid(1, 3, 6, 1, 2, 1, 2, 2, 1, 14, $port);     # interfaces.ifTable.ifEntry.ifInErrors
+       }
+
+       return fetch_snmp($session, $oid);
+}
        
 sub fetch_snmp {
        my ($session, $oid) = @_;
index 12d8244df62e4be34d70aacf81769e0b4f49dc50..c1ae9ebd7b7f7735610299b30f9510e6b43558ee 100644 (file)
@@ -272,7 +272,9 @@ CREATE TABLE polls (
     switch integer NOT NULL,
     port integer NOT NULL,
     bytes_in bigint NOT NULL,
-    bytes_out bigint NOT NULL
+    bytes_out bigint NOT NULL,
+    errors_in bigint NOT NULL,
+    errors_out bigint NOT NULL
 );
 ALTER TABLE ONLY polls ALTER COLUMN "time" SET STATISTICS 100;