Title: [opsview] [12009] Fixed check_snmp_ifstatus plugin
Revision
12009
Author
dferguson
Date
2013-04-09 12:32:17 +0100 (Tue, 09 Apr 2013)

Log Message

Fixed check_snmp_ifstatus plugin

This is to cope with gaps in nodes when polling SNMP interfaces, as seen on customer site.

Original problem is due to the SNMP device not returning entries for all lines, i.e.

.1.3.6.1.2.1.2.2.1.1.1 = INTEGER: 1
.1.3.6.1.2.1.2.2.1.1.3 = INTEGER: 3
.1.3.6.1.2.1.2.2.1.2.1 = STRING: lo
.1.3.6.1.2.1.2.2.1.2.3 = STRING: eth0

note the missing ....1.x.2 on both lines

Modified Paths

Modified: trunk/CHANGES
===================================================================
--- trunk/CHANGES	2013-04-09 11:20:21 UTC (rev 12008)
+++ trunk/CHANGES	2013-04-09 11:32:17 UTC (rev 12009)
@@ -26,6 +26,7 @@
     Fixed semicolons in command definitions not being interpreted as comments
     Fixed ~ as needing to be executed by shell
     Fixed Debian nagios-nrpe-server package not being a conflict
+    Fixed check_snmp_ifstatus plugin to cope with gaps in nodes when polling SNMP interfaces
 
 3.20130304
     ENHANCEMENTS:

Modified: trunk/opsview-core/nagios-plugins/check_snmp_ifstatus
===================================================================
--- trunk/opsview-core/nagios-plugins/check_snmp_ifstatus	2013-04-09 11:20:21 UTC (rev 12008)
+++ trunk/opsview-core/nagios-plugins/check_snmp_ifstatus	2013-04-09 11:32:17 UTC (rev 12009)
@@ -152,22 +152,16 @@
         }
     }
 
-    my $index = 1;
-    while ( $index <= $number_of_interfaces ) {
-        $oid_temp = $oid_ifdescr . $index;
-        if ( !defined( $s->get_request($oid_temp) ) ) {
+    ( my $stripped_ifdescr = $oid_ifdescr ) =~ s/\.$//;
+
+    my $table = $s->get_table( -baseoid => $stripped_ifdescr );
+    foreach my $oid ( keys %$table ) {
+        my $temp_interface_descr = $table->{$oid};
+        if ( lc($temp_interface_descr) eq lc($target_interface) ) {
+            ( $target_interface_index = $oid ) =~ s/.*\.//;
         }
-        else {
-            foreach ( $s->var_bind_names() ) {
-                $temp_interface_descr = $s->var_bind_list()->{$_};
-            }
-            if ( lc($temp_interface_descr) eq lc($target_interface) ) {
-                $target_interface_index = $index;
-            }
-        }
-        $index++;
     }
-    if ( $target_interface_index == 0 ) {
+    if ( !$target_interface_index ) {
         return 1;
     }
     else {

_______________________________________________
Opsview-checkins mailing list
Opsview-checkins@lists.opsview.org
http://lists.opsview.org/lists/listinfo/opsview-checkins

Reply via email to