Title: [opsview] [11510] Allow tracing of individual hostnames in check_snmp_interfaces_cascade
- Revision
- 11510
- Author
- tvoon
- Date
- 2013-02-18 15:17:44 +0000 (Mon, 18 Feb 2013)
Log Message
Allow tracing of individual hostnames in check_snmp_interfaces_cascade
Modified Paths
Modified: trunk/CHANGES
===================================================================
--- trunk/CHANGES 2013-02-18 14:27:38 UTC (rev 11509)
+++ trunk/CHANGES 2013-02-18 15:17:44 UTC (rev 11510)
@@ -4,6 +4,7 @@
FEATURES:
PLATFORMS:
ENHANCEMENTS:
+ Allow tracing of individual hosts in check_snmp_interfaces_cascade
NOTICES:
FIXES:
Fixed incorrect SNMP version definition and timeout values
Modified: trunk/opsview-core/nagios-plugins/check_snmp_interfaces_cascade
===================================================================
--- trunk/opsview-core/nagios-plugins/check_snmp_interfaces_cascade 2013-02-18 14:27:38 UTC (rev 11509)
+++ trunk/opsview-core/nagios-plugins/check_snmp_interfaces_cascade 2013-02-18 15:17:44 UTC (rev 11510)
@@ -63,6 +63,15 @@
my $interfaces = {};
+# Hard code hostnames that you want to trace
+my $trace_host = 0;
+my @trace_interface_values;
+my $trace_hostnames = {
+
+ # If you want to add a hostname, as defined in Nagios, for tracing all results, enter here
+ #hostname => 1,
+};
+
# Where to put the .db file
my $db_home = "/usr/local/nagios/var/plugins/$script";
@@ -323,6 +332,10 @@
$nagios_hostname = $hostname;
}
+if ( $trace_hostnames->{$nagios_hostname} ) {
+ $trace_host = 1;
+}
+
#############################################
# Collect data from device for all interfaces
#############################################
@@ -781,6 +794,11 @@
#return 0;
}
+ if ($trace_host) {
+ push @trace_interface_values, $intdata->{octetsIn},
+ $intdata->{octetsOut};
+ }
+
my $max_state = 0;
my $extra_message = "";
my $speed_is_zero = 0;
@@ -1225,7 +1243,27 @@
}
open DUMPFILE, ">>", $dumpfile;
- print DUMPFILE $debug_data;
+ print DUMPFILE "Start: $start_time ("
+ . ( scalar localtime $start_time ) . ")\n"
+ . $debug_data;
close DUMPFILE;
}
+if (@trace_interface_values) {
+ my $dumpfile = "$db_home/$nagios_hostname.trace";
+
+ # Rotate files first. Last one drops out
+ my $max_file_size = 1000000;
+ if ( ( -e $dumpfile ) && ( -s $dumpfile ) > $max_file_size ) {
+ ( -e "$dumpfile.2" ) && move( "$dumpfile.2", "$dumpfile.3" );
+ ( -e "$dumpfile.1" ) && move( "$dumpfile.1", "$dumpfile.2" );
+ move( $dumpfile, "$dumpfile.1" );
+ }
+
+ open DUMPFILE, ">>", $dumpfile;
+ print DUMPFILE join( ":",
+ $start_time, ( map { $_->bstr() . "" } @trace_interface_values ) ),
+ '\n';
+ close DUMPFILE;
+}
+
$np->nagios_exit( $rc, $message );
_______________________________________________
Opsview-checkins mailing list
Opsview-checkins@lists.opsview.org
http://lists.opsview.org/lists/listinfo/opsview-checkins