Code

Tests for --rate-multiplier option
authortonvoon <ton.voon@opsview.com>
Wed, 30 Jun 2010 07:56:05 +0000 (07:56 +0000)
committertonvoon <ton.voon@opsview.com>
Wed, 30 Jun 2010 07:56:05 +0000 (07:56 +0000)
plugins/check_snmp.c
plugins/tests/check_snmp.t

index b16428fe0b02e78651cc86d27629dcfd01e68dbd..f8cae9b6297606136fe2ccf00d182eb6339c3977 100644 (file)
@@ -798,7 +798,7 @@ process_arguments (int argc, char **argv)
                        calculate_rate = 1;
                        break;
                case L_RATE_MULTIPLIER:
                        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:
                                usage2(_("Rate multiplier must be a positive integer"),optarg);
                        break;
                case L_INVERT_SEARCH:
index a7a8d2cfc04a2bfe7a5f38ee02e4398cf93f4a13..0fa1691e14b71adc5cb93432abea7b221eb65080 100755 (executable)
@@ -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");
 
 
 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" );
 $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" );