[nagiosplug] Tests for --rate-multiplier option
Ton Voon
tonvoon at users.sourceforge.net
Wed Jun 30 10:15:28 CEST 2010
Module: nagiosplug
Branch: master
Commit: 752dbc20b2bfbeb2b7d253b67fa6eda3adefb8c6
Author: tonvoon <ton.voon at opsview.com>
Date: Wed Jun 30 07:56:05 2010 +0000
URL: http://nagiosplug.git.sf.net/git/gitweb.cgi?p=nagiosplug/nagiosplug;a=commit;h=752dbc2
Tests for --rate-multiplier option
---
plugins/check_snmp.c | 2 +-
plugins/tests/check_snmp.t | 13 +++++++++++++
2 files changed, 14 insertions(+), 1 deletions(-)
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c
index b16428f..f8cae9b 100644
--- a/plugins/check_snmp.c
+++ b/plugins/check_snmp.c
@@ -798,7 +798,7 @@ process_arguments (int argc, char **argv)
calculate_rate = 1;
break;
case L_RATE_MULTIPLIER:
- if(!is_integer(optarg)||(rate_multiplier=atoi(optarg)<=0))
+ if(!is_integer(optarg)||((rate_multiplier=atoi(optarg))<=0))
usage2(_("Rate multiplier must be a positive integer"),optarg);
break;
case L_INVERT_SEARCH:
diff --git a/plugins/tests/check_snmp.t b/plugins/tests/check_snmp.t
index a7a8d2c..0fa1691 100755
--- a/plugins/tests/check_snmp.t
+++ b/plugins/tests/check_snmp.t
@@ -141,6 +141,19 @@ is($res->return_code, 0, "OK as no thresholds" );
is($res->output, "SNMP RATE OK - inoctets 333 | inoctets-rate=333 ", "Check rate decreases due to longer interval");
+
+$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 --rate -l inoctets_per_minute --rate-multiplier=60" );
+is($res->return_code, 0, "OK for first call" );
+is($res->output, "No previous data to calculate rate - assume okay" );
+
+# Need to sleep, otherwise duration=0
+sleep 1;
+
+$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 --rate -l inoctets_per_minute --rate-multiplier=60" );
+is($res->return_code, 0, "OK as no thresholds" );
+is($res->output, "SNMP RATE OK - inoctets_per_minute 11.1 | inoctets_per_minute-rate=11.1 ", "Checking multiplier");
+
+
$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.11 -s '\"stringtests\"'" );
is($res->return_code, 0, "OK as string matches" );
is($res->output, 'SNMP OK - "stringtests" | ', "Good string match" );
More information about the Commits
mailing list