Title: [opsview] [9957] Fixed issue where interfaces inheriting default threshold values did not
Revision
9957
Author
tvoon
Date
2012-09-05 17:15:41 +0100 (Wed, 05 Sep 2012)

Log Message

Fixed issue where interfaces inheriting default threshold values did not
have the threshold set correctly, when using check_snmp_interfaces_cascade

Modified Paths

Modified: trunk/CHANGES
===================================================================
--- trunk/CHANGES	2012-09-05 16:01:15 UTC (rev 9956)
+++ trunk/CHANGES	2012-09-05 16:15:41 UTC (rev 9957)
@@ -11,6 +11,8 @@
     FIXES:
     Fixed possible issues when removing Debian packages
     Fixed opsview_sync_ldap where apostrophes in a user's name
+    Fixed issue where interfaces inheriting default threshold values did not
+      have the threshold set correctly, when using check_snmp_interfaces_cascade
 
 3.201208XX 9th August 2012
     FEATURES:

Modified: trunk/opsview-core/bin/nagconfgen.pl
===================================================================
--- trunk/opsview-core/bin/nagconfgen.pl	2012-09-05 16:01:15 UTC (rev 9956)
+++ trunk/opsview-core/bin/nagconfgen.pl	2012-09-05 16:15:41 UTC (rev 9957)
@@ -348,6 +348,9 @@
           tidy_ifdescr_level snmp_max_msg_size ip snmp_extended_throughput_data
         );
 
+        my $default_thresholds =
+          $host->snmpinterfaces( { interfacename => "" } )->first;
+
         foreach my $int (@interfaces) {
             next unless $int->active;
 
@@ -362,6 +365,21 @@
 
             my $shortname = $int->shortinterfacename;
 
+            # As this is repeated for throughput, errors and discards,
+            # we have a common function here
+            my $set_threshold_inherited = sub {
+                foreach my $t (@_) {
+                    my $value = $int->$t;
+                    if ( defined $value && $value eq "" ) {
+                        $value = $default_thresholds->$t;
+                    }
+                    if ( !defined $value ) {
+                        $value = "";
+                    }
+                    $intdata->{$t} = $value;
+                }
+            };
+
             # Only include data when the service has been setup
             # TODO: This uses hardcoded service names at the moment. Maybe a lookup based on cascaded
             # servicechecks is a future improvement
@@ -370,24 +388,27 @@
                 ->{"Interface: $shortname"} )
             {
                 $intdata->{throughput} = 1;
-                map { $intdata->{$_} = $int->$_ }
-                  qw( throughput_warning throughput_critical );
+                $set_threshold_inherited->(
+                    qw(throughput_warning throughput_critical )
+                );
             }
             if (
                 exists $host_services_lookup->{ $host->name }
                 ->{"Errors: $shortname"} )
             {
                 $intdata->{errors} = 1;
-                map { $intdata->{$_} = $int->$_ }
-                  qw( errors_warning errors_critical );
+                $set_threshold_inherited->(
+                    qw(errors_warning errors_critical )
+                );
             }
             if (
                 exists $host_services_lookup->{ $host->name }
                 ->{"Discards: $shortname"} )
             {
                 $intdata->{discards} = 1;
-                map { $intdata->{$_} = $int->$_ }
-                  qw( discards_warning discards_critical );
+                $set_threshold_inherited->(
+                    qw(discards_warning discards_critical)
+                );
             }
         }
 

Modified: trunk/opsview-core/t/var/configs/Master Monitoring Server/plugins/check_snmp_interfaces_cascade/cisco4.json
===================================================================
--- trunk/opsview-core/t/var/configs/Master Monitoring Server/plugins/check_snmp_interfaces_cascade/cisco4.json	2012-09-05 16:01:15 UTC (rev 9956)
+++ trunk/opsview-core/t/var/configs/Master Monitoring Server/plugins/check_snmp_interfaces_cascade/cisco4.json	2012-09-05 16:15:41 UTC (rev 9957)
@@ -17,11 +17,11 @@
       "Ethernet0":{
          "1":{
             "discards":1,
-            "discards_critical":"",
+            "discards_critical":"7",
             "discards_warning":"4",
             "errors":1,
             "errors_critical":"10",
-            "errors_warning":"",
+            "errors_warning":"5",
             "indexid":"1",
             "shortinterfacename":"Ethernet0-01",
             "throughput":1,
@@ -30,7 +30,7 @@
          },
          "12":{
             "discards":1,
-            "discards_critical":"",
+            "discards_critical":"7",
             "discards_warning":"2",
             "errors":1,
             "errors_critical":"11",
@@ -43,11 +43,11 @@
          },
          "20":{
             "discards":1,
-            "discards_critical":null,
+            "discards_critical":"",
             "discards_warning":"",
             "errors":1,
             "errors_critical":"13",
-            "errors_warning":"",
+            "errors_warning":"5",
             "indexid":"20",
             "shortinterfacename":"Ethernet0-20",
             "throughput":1,
@@ -58,11 +58,11 @@
       "EthernetWithAVeryLongAndSillyNameForPeopleToDiscussAboutUntilARipeOldAgeOf75AndAHalf0":{
          "6":{
             "discards":1,
-            "discards_critical":"",
+            "discards_critical":"7",
             "discards_warning":"1",
             "errors":1,
             "errors_critical":"",
-            "errors_warning":"",
+            "errors_warning":"5",
             "indexid":"6",
             "shortinterfacename":"EthernetWithAVeryLongAndSillyNameForPeopleToDiscu 2",
             "throughput":1,

Modified: trunk/opsview-core/t/var/configs/dbic_trace
===================================================================
--- trunk/opsview-core/t/var/configs/dbic_trace	2012-09-05 16:01:15 UTC (rev 9956)
+++ trunk/opsview-core/t/var/configs/dbic_trace	2012-09-05 16:15:41 UTC (rev 9957)
@@ -481,8 +481,11 @@
 SELECT me.id, me.name, me.ip, me.alias, me.notification_interval, me.hostgroup, me.check_period, me.check_interval, me.retry_check_interval, me.check_attempts, me.icon, me.enable_snmp, me.snmp_community, me.notification_options, me.notification_period, me.check_command, me.http_admin_url, me.http_admin_port, me.monitored_by, me.uncommitted, me.other_addresses, me.snmp_version, me.snmp_port, me.snmpv3_username, me.snmpv3_authprotocol, me.snmpv3_authpassword, me.snmpv3_privprotocol, me.snmpv3_privpassword, me.snmptrap_tracing, me.use_rancid, me.rancid_vendor, me.rancid_username, me.rancid_password, me.rancid_connection_type, me.rancid_autoenable, me.use_nmis, me.nmis_node_type, me.flap_detection_enabled, me.use_mrtg, me.tidy_ifdescr_level, me.snmp_max_msg_size, me.snmp_extended_throughput_data FROM opsview.hosts me WHERE ( me.id = ? ) ORDER BY name ASC: '1'
 SELECT me.id, me.name, me.ip, me.alias, me.notification_interval, me.hostgroup, me.check_period, me.check_interval, me.retry_check_interval, me.check_attempts, me.icon, me.enable_snmp, me.snmp_community, me.notification_options, me.notification_period, me.check_command, me.http_admin_url, me.http_admin_port, me.monitored_by, me.uncommitted, me.other_addresses, me.snmp_version, me.snmp_port, me.snmpv3_username, me.snmpv3_authprotocol, me.snmpv3_authpassword, me.snmpv3_privprotocol, me.snmpv3_privpassword, me.snmptrap_tracing, me.use_rancid, me.rancid_vendor, me.rancid_username, me.rancid_password, me.rancid_connection_type, me.rancid_autoenable, me.use_nmis, me.nmis_node_type, me.flap_detection_enabled, me.use_mrtg, me.tidy_ifdescr_level, me.snmp_max_msg_size, me.snmp_extended_throughput_data FROM opsview.hosts me WHERE ( me.monitored_by = ? ) ORDER BY name ASC: '1'
 SELECT me.id, me.hostid, me.interfacename, me.active, me.throughput_warning, me.throughput_critical, me.errors_warning, me.errors_critical, me.discards_warning, me.discards_critical, me.shortinterfacename, me.indexid FROM opsview.hostsnmpinterfaces me WHERE ( ( active = ? AND me.hostid = ? ) ) ORDER BY interfacename: '1', '11'
+SELECT me.id, me.hostid, me.interfacename, me.active, me.throughput_warning, me.throughput_critical, me.errors_warning, me.errors_critical, me.discards_warning, me.discards_critical, me.shortinterfacename, me.indexid FROM opsview.hostsnmpinterfaces me WHERE ( ( interfacename = ? AND me.hostid = ? ) ) ORDER BY interfacename: '', '11'
 SELECT me.id, me.hostid, me.interfacename, me.active, me.throughput_warning, me.throughput_critical, me.errors_warning, me.errors_critical, me.discards_warning, me.discards_critical, me.shortinterfacename, me.indexid FROM opsview.hostsnmpinterfaces me WHERE ( ( active = ? AND me.hostid = ? ) ) ORDER BY interfacename: '1', '3'
+SELECT me.id, me.hostid, me.interfacename, me.active, me.throughput_warning, me.throughput_critical, me.errors_warning, me.errors_critical, me.discards_warning, me.discards_critical, me.shortinterfacename, me.indexid FROM opsview.hostsnmpinterfaces me WHERE ( ( interfacename = ? AND me.hostid = ? ) ) ORDER BY interfacename: '', '3'
 SELECT me.id, me.hostid, me.interfacename, me.active, me.throughput_warning, me.throughput_critical, me.errors_warning, me.errors_critical, me.discards_warning, me.discards_critical, me.shortinterfacename, me.indexid FROM opsview.hostsnmpinterfaces me WHERE ( ( active = ? AND me.hostid = ? ) ) ORDER BY interfacename: '1', '13'
+SELECT me.id, me.hostid, me.interfacename, me.active, me.throughput_warning, me.throughput_critical, me.errors_warning, me.errors_critical, me.discards_warning, me.discards_critical, me.shortinterfacename, me.indexid FROM opsview.hostsnmpinterfaces me WHERE ( ( interfacename = ? AND me.hostid = ? ) ) ORDER BY interfacename: '', '13'
 SELECT COUNT( * ) FROM opsview.hosts me WHERE ( me.monitored_by = ? ): '2'
 SELECT COUNT( * ) FROM opsview.hosts me WHERE ( me.monitored_by = ? ): '3'
 SELECT COUNT( * ) FROM opsview.hosts me WHERE ( me.monitored_by = ? ): '4'

_______________________________________________
Opsview-checkins mailing list
[email protected]
http://lists.opsview.org/lists/listinfo/opsview-checkins

Reply via email to