summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/check_snmp.c2
-rwxr-xr-xplugins/tests/check_snmp.t13
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)
798 calculate_rate = 1; 798 calculate_rate = 1;
799 break; 799 break;
800 case L_RATE_MULTIPLIER: 800 case L_RATE_MULTIPLIER:
801 if(!is_integer(optarg)||(rate_multiplier=atoi(optarg)<=0)) 801 if(!is_integer(optarg)||((rate_multiplier=atoi(optarg))<=0))
802 usage2(_("Rate multiplier must be a positive integer"),optarg); 802 usage2(_("Rate multiplier must be a positive integer"),optarg);
803 break; 803 break;
804 case L_INVERT_SEARCH: 804 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" );
141is($res->output, "SNMP RATE OK - inoctets 333 | inoctets-rate=333 ", "Check rate decreases due to longer interval"); 141is($res->output, "SNMP RATE OK - inoctets 333 | inoctets-rate=333 ", "Check rate decreases due to longer interval");
142 142
143 143
144
145$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" );
146is($res->return_code, 0, "OK for first call" );
147is($res->output, "No previous data to calculate rate - assume okay" );
148
149# Need to sleep, otherwise duration=0
150sleep 1;
151
152$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" );
153is($res->return_code, 0, "OK as no thresholds" );
154is($res->output, "SNMP RATE OK - inoctets_per_minute 11.1 | inoctets_per_minute-rate=11.1 ", "Checking multiplier");
155
156
144$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\"'" ); 157$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\"'" );
145is($res->return_code, 0, "OK as string matches" ); 158is($res->return_code, 0, "OK as string matches" );
146is($res->output, 'SNMP OK - "stringtests" | ', "Good string match" ); 159is($res->output, 'SNMP OK - "stringtests" | ', "Good string match" );