Title: [opsview] [11538] Set sensitive_arguments in Uptime Poller.
Revision
11538
Author
pknight
Date
2013-02-20 09:52:23 +0000 (Wed, 20 Feb 2013)

Log Message

Set sensitive_arguments in Uptime Poller.
Added [real] host address argument.

Modified Paths

Modified: trunk/opsview-core/import/opspacks_source/snmp-mib-ii/config.json
===================================================================
--- trunk/opsview-core/import/opspacks_source/snmp-mib-ii/config.json	2013-02-19 22:52:59 UTC (rev 11537)
+++ trunk/opsview-core/import/opspacks_source/snmp-mib-ii/config.json	2013-02-20 09:52:23 UTC (rev 11538)
@@ -428,7 +428,7 @@
             "ref" : "/rest/config/plugin/check_snmp_uptime"
          },
          "retry_check_interval" : "1",
-         "sensitive_arguments" : "0",
+         "sensitive_arguments" : "1",
          "servicegroup" : {
             "name" : "Network - SNMP MIB-II",
          },

Modified: trunk/opsview-core/nagios-plugins/check_snmp_uptime
===================================================================
--- trunk/opsview-core/nagios-plugins/check_snmp_uptime	2013-02-19 22:52:59 UTC (rev 11537)
+++ trunk/opsview-core/nagios-plugins/check_snmp_uptime	2013-02-20 09:52:23 UTC (rev 11538)
@@ -49,6 +49,12 @@
     'default' => ''
 );
 
+$np->add_arg(
+    'spec' => 'hostaddress|A=s',
+    'help' => "-A, --hostaddress HOST ADDRESS\n   Actual host address to check",
+    'default' => ''
+);
+
 $np->getopts;
 
 my $oid_sysDescr =
@@ -59,6 +65,7 @@
 my $returnstring = "";
 my $prev_uptime  = 0;
 my $timeticks    = 0;
+my $days         = 0;
 
 # Cache file name
 my $hostname   = $np->opts->hostname;
@@ -76,15 +83,21 @@
 }
 
 if ( $np->opts->cascade ) {
-    if ( $prev_uptime > $timeticks ) {
+    if ( not $np->opts->hostaddress ) {
+        $returnstring = "Host address required";
+        $status       = 1;
+    }
+    elsif ( $prev_uptime > $timeticks ) {
         require Opsview::Externalcommand;
         my $cmd = Opsview::Externalcommand->new(
             command => 'PROCESS_SERVICE_CHECK_RESULT',
-            args    => join( ';', $hostname, 'Uptime', '1', 'Uptime reset' ),
+            args    => join(
+                ';', $np->opts->hostaddress, 'Uptime', '1', 'Uptime reset'
+            ),
         );
         $cmd->send_to_master;
-        $np->nagios_exit( OK, 'OK' );
     }
+    $np->nagios_exit( OK, "OK|days=$days" );
 }
 
 if ( $status == 0 ) {
@@ -140,7 +153,7 @@
     }
 
     # Convert to days
-    my $days = sprintf( "%.1f", $timeticks / 100 / 60 / 60 / 24 );
+    $days = sprintf( "%.1f", $timeticks / 100 / 60 / 60 / 24 );
 
     my $temp;
     $temp = "Uptime: $uptime|days=$days";

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

Reply via email to