diff options
Diffstat (limited to 'plugins/tests')
-rwxr-xr-x | plugins/tests/check_http.t | 29 | ||||
-rwxr-xr-x[-rw-r--r--] | plugins/tests/check_procs.t | 85 | ||||
-rwxr-xr-x | plugins/tests/check_snmp.t | 36 | ||||
-rw-r--r-- | plugins/tests/check_snmp_agent.pl | 14 | ||||
-rw-r--r-- | plugins/tests/var/ps_axwo.debian | 4 |
5 files changed, 102 insertions, 66 deletions
diff --git a/plugins/tests/check_http.t b/plugins/tests/check_http.t index c3085e13..225b449f 100755 --- a/plugins/tests/check_http.t +++ b/plugins/tests/check_http.t | |||
@@ -7,7 +7,7 @@ | |||
7 | # Country Name (2 letter code) [AU]:UK | 7 | # Country Name (2 letter code) [AU]:UK |
8 | # State or Province Name (full name) [Some-State]:Derbyshire | 8 | # State or Province Name (full name) [Some-State]:Derbyshire |
9 | # Locality Name (eg, city) []:Belper | 9 | # Locality Name (eg, city) []:Belper |
10 | # Organization Name (eg, company) [Internet Widgits Pty Ltd]:Nagios Plugins | 10 | # Organization Name (eg, company) [Internet Widgits Pty Ltd]:Monitoring Plugins |
11 | # Organizational Unit Name (eg, section) []: | 11 | # Organizational Unit Name (eg, section) []: |
12 | # Common Name (eg, YOUR name) []:Ton Voon | 12 | # Common Name (eg, YOUR name) []:Ton Voon |
13 | # Email Address []:tonvoon@mac.com | 13 | # Email Address []:tonvoon@mac.com |
@@ -20,8 +20,9 @@ use FindBin qw($Bin); | |||
20 | my $common_tests = 70; | 20 | my $common_tests = 70; |
21 | my $ssl_only_tests = 8; | 21 | my $ssl_only_tests = 8; |
22 | # Check that all dependent modules are available | 22 | # Check that all dependent modules are available |
23 | eval "use HTTP::Daemon 6.01;"; | ||
24 | plan skip_all => 'HTTP::Daemon >= 6.01 required' if $@; | ||
23 | eval { | 25 | eval { |
24 | require HTTP::Daemon; | ||
25 | require HTTP::Status; | 26 | require HTTP::Status; |
26 | require HTTP::Response; | 27 | require HTTP::Response; |
27 | }; | 28 | }; |
@@ -392,27 +393,21 @@ sub run_common_tests { | |||
392 | skip "This doesn't seems to work all the time", 1 unless ($ENV{HTTP_EXTERNAL}); | 393 | skip "This doesn't seems to work all the time", 1 unless ($ENV{HTTP_EXTERNAL}); |
393 | $cmd = "$command -f follow -u /redir_external -t 5"; | 394 | $cmd = "$command -f follow -u /redir_external -t 5"; |
394 | eval { | 395 | eval { |
395 | local $SIG{ALRM} = sub { die "alarm\n" }; | 396 | $result = NPTest->testCmd( $cmd, 2 ); |
396 | alarm(2); | 397 | }; |
397 | $result = NPTest->testCmd( $cmd ); | 398 | like( $@, "/timeout in command: $cmd/", $cmd ); |
398 | alarm(0); }; | ||
399 | is( $@, "alarm\n", $cmd ); | ||
400 | } | 399 | } |
401 | 400 | ||
402 | $cmd = "$command -u /timeout -t 5"; | 401 | $cmd = "$command -u /timeout -t 5"; |
403 | eval { | 402 | eval { |
404 | local $SIG{ALRM} = sub { die "alarm\n" }; | 403 | $result = NPTest->testCmd( $cmd, 2 ); |
405 | alarm(2); | 404 | }; |
406 | $result = NPTest->testCmd( $cmd ); | 405 | like( $@, "/timeout in command: $cmd/", $cmd ); |
407 | alarm(0); }; | ||
408 | is( $@, "alarm\n", $cmd ); | ||
409 | 406 | ||
410 | $cmd = "$command -f follow -u /redir_timeout -t 2"; | 407 | $cmd = "$command -f follow -u /redir_timeout -t 2"; |
411 | eval { | 408 | eval { |
412 | local $SIG{ALRM} = sub { die "alarm\n" }; | 409 | $result = NPTest->testCmd( $cmd, 5 ); |
413 | alarm(5); | 410 | }; |
414 | $result = NPTest->testCmd( $cmd ); | 411 | is( $@, "", $cmd ); |
415 | alarm(0); }; | ||
416 | isnt( $@, "alarm\n", $cmd ); | ||
417 | 412 | ||
418 | } | 413 | } |
diff --git a/plugins/tests/check_procs.t b/plugins/tests/check_procs.t index d71c83a2..54d43d9b 100644..100755 --- a/plugins/tests/check_procs.t +++ b/plugins/tests/check_procs.t | |||
@@ -18,59 +18,68 @@ my $command = "./check_procs --input-file=tests/var/ps-axwo.darwin"; | |||
18 | 18 | ||
19 | $result = NPTest->testCmd( "$command" ); | 19 | $result = NPTest->testCmd( "$command" ); |
20 | is( $result->return_code, 0, "Run with no options" ); | 20 | is( $result->return_code, 0, "Run with no options" ); |
21 | like( $result->output, '/^PROCS OK: 95 processes$/', "Output correct" ); | 21 | is( $result->output, "PROCS OK: 95 processes | procs=95;;;0;", "Output correct" ); |
22 | 22 | ||
23 | $result = NPTest->testCmd( "$command -w 5" ); | 23 | $result = NPTest->testCmd( "$command -w 5" ); |
24 | is( $result->return_code, 1, "Checking > 5 processes" ); | 24 | is( $result->return_code, 1, "Checking > 5 processes" ); |
25 | like( $result->output, '/^PROCS WARNING: 95 processes$/', "Output correct" ); | 25 | is( $result->output, "PROCS WARNING: 95 processes | procs=95;5;;0;", "Output correct" ); |
26 | 26 | ||
27 | $result = NPTest->testCmd( "$command -w 4 -c 44" ); | 27 | $result = NPTest->testCmd( "$command -w 4 -c 44" ); |
28 | is( $result->return_code, 2, "Checking critical" ); | 28 | is( $result->return_code, 2, "Checking critical" ); |
29 | like( $result->output, '/^PROCS CRITICAL: 95 processes$/', "Output correct" ); | 29 | is( $result->output, "PROCS CRITICAL: 95 processes | procs=95;4;44;0;", "Output correct" ); |
30 | 30 | ||
31 | $result = NPTest->testCmd( "$command -w 100 -c 200" ); | 31 | $result = NPTest->testCmd( "$command -w 100 -c 200" ); |
32 | is( $result->return_code, 0, "Checking no threshold breeched" ); | 32 | is( $result->return_code, 0, "Checking no threshold breeched" ); |
33 | like( $result->output, '/^PROCS OK: 95 processes$/', "Output correct" ); | 33 | is( $result->output, "PROCS OK: 95 processes | procs=95;100;200;0;", "Output correct" ); |
34 | 34 | ||
35 | $result = NPTest->testCmd( "$command -C launchd -c 5" ); | 35 | $result = NPTest->testCmd( "$command -C launchd -c 5" ); |
36 | is( $result->return_code, 2, "Checking processes filtered by command name" ); | 36 | is( $result->return_code, 2, "Checking processes filtered by command name" ); |
37 | like( $result->output, '/^PROCS CRITICAL: 6 processes with command name \'launchd\'$/', "Output correct" ); | 37 | is( $result->output, "PROCS CRITICAL: 6 processes with command name 'launchd' | procs=6;;5;0;", "Output correct" ); |
38 | 38 | ||
39 | $result = NPTest->testCmd( "$command -u 501 -w 39 -c 41" ); | 39 | SKIP: { |
40 | is( $result->return_code, 1, "Checking processes filtered by userid" ); | 40 | skip 'user with uid 501 required', 4 unless getpwuid(501); |
41 | like( $result->output, '/^PROCS WARNING: 40 processes with UID = 501 (.*)$/', "Output correct" ); | ||
42 | 41 | ||
43 | $result = NPTest->testCmd( "$command -C launchd -u 501" ); | 42 | $result = NPTest->testCmd( "$command -u 501 -w 39 -c 41" ); |
44 | is( $result->return_code, 0, "Checking processes filtered by command name and userid" ); | 43 | is( $result->return_code, 1, "Checking processes filtered by userid" ); |
45 | like( $result->output, '/^PROCS OK: 1 process with command name \'launchd\', UID = 501 (.*)$/', "Output correct" ); | 44 | like( $result->output, '/^PROCS WARNING: 40 processes with UID = 501 (.*)$/', "Output correct" ); |
46 | 45 | ||
47 | $result = NPTest->testCmd( "$command -u -2 -w 2:2" ); | 46 | $result = NPTest->testCmd( "$command -C launchd -u 501" ); |
48 | is( $result->return_code, 1, "Checking processes with userid=-2" ); | 47 | is( $result->return_code, 0, "Checking processes filtered by command name and userid" ); |
49 | like( $result->output, '/^PROCS WARNING: 3 processes with UID = -2 \(nobody\)$/', "Output correct" ); | 48 | like( $result->output, '/^PROCS OK: 1 process with command name \'launchd\', UID = 501 (.*)$/', "Output correct" ); |
49 | } | ||
50 | |||
51 | SKIP: { | ||
52 | skip 'user with uid -2 required', 8 unless getpwuid(-2); | ||
53 | skip 'uid -2 must have name "nobody"', 8 unless getpwuid(-2) eq 'nobody'; | ||
50 | 54 | ||
51 | $result = NPTest->testCmd( "$command -u -2 -w 3:3" ); | 55 | $result = NPTest->testCmd( "$command -u -2 -w 2:2" ); |
52 | is( $result->return_code, 0, "Checking processes with userid=-2 past threshold" ); | 56 | is( $result->return_code, 1, "Checking processes with userid=-2" ); |
53 | like( $result->output, '/^PROCS OK: 3 processes with UID = -2 \(nobody\)$/', "Output correct" ); | 57 | like( $result->output, '/^PROCS WARNING: 3 processes with UID = -2 \(nobody\)$/', "Output correct" ); |
54 | 58 | ||
55 | $result = NPTest->testCmd( "$command -u -2 -a usb" ); | 59 | $result = NPTest->testCmd( "$command -u -2 -w 3:3" ); |
56 | is( $result->return_code, 0, "Checking processes with userid=-2 and usb in arguments" ); | 60 | is( $result->return_code, 0, "Checking processes with userid=-2 past threshold" ); |
57 | like( $result->output, '/^PROCS OK: 1 process with UID = -2 \(nobody\), args \'usb\'/', "Output correct" ); | 61 | like( $result->output, '/^PROCS OK: 3 processes with UID = -2 \(nobody\)$/', "Output correct" ); |
58 | 62 | ||
59 | $result = NPTest->testCmd( "$command -u -2 -a UsB" ); | 63 | $result = NPTest->testCmd( "$command -u -2 -a usb" ); |
60 | is( $result->return_code, 0, "Checking case sensitivity of args" ); | 64 | is( $result->return_code, 0, "Checking processes with userid=-2 and usb in arguments" ); |
61 | like( $result->output, '/^PROCS OK: 0 processes with UID = -2 \(nobody\), args \'UsB\'/', "Output correct" ); | 65 | like( $result->output, '/^PROCS OK: 1 process with UID = -2 \(nobody\), args \'usb\'/', "Output correct" ); |
66 | |||
67 | $result = NPTest->testCmd( "$command -u -2 -a UsB" ); | ||
68 | is( $result->return_code, 0, "Checking case sensitivity of args" ); | ||
69 | like( $result->output, '/^PROCS OK: 0 processes with UID = -2 \(nobody\), args \'UsB\'/', "Output correct" ); | ||
70 | }; | ||
62 | 71 | ||
63 | $result = NPTest->testCmd( "$command --ereg-argument-array='mdworker.*501'" ); | 72 | $result = NPTest->testCmd( "$command --ereg-argument-array='mdworker.*501'" ); |
64 | is( $result->return_code, 0, "Checking regexp search of arguments" ); | 73 | is( $result->return_code, 0, "Checking regexp search of arguments" ); |
65 | is( $result->output, "PROCS OK: 1 process with regex args 'mdworker.*501'", "Output correct" ); | 74 | is( $result->output, "PROCS OK: 1 process with regex args 'mdworker.*501' | procs=1;;;0;", "Output correct" ); |
66 | 75 | ||
67 | $result = NPTest->testCmd( "$command --vsz 1000000" ); | 76 | $result = NPTest->testCmd( "$command --vsz 1000000" ); |
68 | is( $result->return_code, 0, "Checking filter by VSZ" ); | 77 | is( $result->return_code, 0, "Checking filter by VSZ" ); |
69 | like( $result->output, '/^PROCS OK: 24 processes with VSZ >= 1000000$/', "Output correct" ); | 78 | is( $result->output, 'PROCS OK: 24 processes with VSZ >= 1000000 | procs=24;;;0;', "Output correct" ); |
70 | 79 | ||
71 | $result = NPTest->testCmd( "$command --rss 100000" ); | 80 | $result = NPTest->testCmd( "$command --rss 100000" ); |
72 | is( $result->return_code, 0, "Checking filter by RSS" ); | 81 | is( $result->return_code, 0, "Checking filter by RSS" ); |
73 | like( $result->output, '/^PROCS OK: 3 processes with RSS >= 100000$/', "Output correct" ); | 82 | is( $result->output, 'PROCS OK: 3 processes with RSS >= 100000 | procs=3;;;0;', "Output correct" ); |
74 | 83 | ||
75 | $result = NPTest->testCmd( "$command -s S" ); | 84 | $result = NPTest->testCmd( "$command -s S" ); |
76 | is( $result->return_code, 0, "Checking filter for sleeping processes" ); | 85 | is( $result->return_code, 0, "Checking filter for sleeping processes" ); |
@@ -86,34 +95,38 @@ like( $result->output, '/^PROCS CRITICAL: 39 processes with PPID = 1/', "Output | |||
86 | 95 | ||
87 | $result = NPTest->testCmd( "$command -P 0.71" ); | 96 | $result = NPTest->testCmd( "$command -P 0.71" ); |
88 | is( $result->return_code, 0, "Checking filter for percentage cpu > 0.71" ); | 97 | is( $result->return_code, 0, "Checking filter for percentage cpu > 0.71" ); |
89 | is( $result->output, 'PROCS OK: 7 processes with PCPU >= 0.71', "Output correct" ); | 98 | is( $result->output, 'PROCS OK: 7 processes with PCPU >= 0.71 | procs=7;;;0;', "Output correct" ); |
90 | 99 | ||
91 | $result = NPTest->testCmd( "$command -P 0.70" ); | 100 | $result = NPTest->testCmd( "$command -P 0.70" ); |
92 | is( $result->return_code, 0, "Checking filter for percentage cpu > 0.70" ); | 101 | is( $result->return_code, 0, "Checking filter for percentage cpu > 0.70" ); |
93 | is( $result->output, 'PROCS OK: 8 processes with PCPU >= 0.70', "Output correct" ); | 102 | is( $result->output, 'PROCS OK: 8 processes with PCPU >= 0.70 | procs=8;;;0;', "Output correct" ); |
94 | 103 | ||
95 | $result = NPTest->testCmd( "$command --metric=CPU -w 8" ); | 104 | $result = NPTest->testCmd( "$command --metric=CPU -w 8" ); |
96 | is( $result->return_code, 1, "Checking against metric of CPU > 8" ); | 105 | is( $result->return_code, 1, "Checking against metric of CPU > 8" ); |
97 | is( $result->output, 'CPU WARNING: 1 warn out of 95 processes', "Output correct" ); | 106 | is( $result->output, 'CPU WARNING: 1 warn out of 95 processes | procs=95;;;0; procs_warn=1;;;0; procs_crit=0;;;0;', "Output correct" ); |
98 | 107 | ||
99 | # TODO: Because of a conversion to int, if CPU is 1.45%, will not alert, but 2.01% will. | 108 | # TODO: Because of a conversion to int, if CPU is 1.45%, will not alert, but 2.01% will. |
100 | $result = NPTest->testCmd( "$command --metric=CPU -w 1 -u 501 -v" ); | 109 | SKIP: { |
101 | is( $result->return_code, 1, "Checking against metric of CPU > 1 with uid=501 - TODO" ); | 110 | skip 'user with uid 501 required', 2 unless getpwuid(501); |
102 | is( $result->output, 'CPU WARNING: 2 warn out of 40 processes with UID = 501 (tonvoon) [Skype, PubSubAgent]', "Output correct" ); | 111 | |
112 | $result = NPTest->testCmd( "$command --metric=CPU -w 1 -u 501 -v" ); | ||
113 | is( $result->return_code, 1, "Checking against metric of CPU > 1 with uid=501 - TODO" ); | ||
114 | is( $result->output, 'CPU WARNING: 2 warn out of 40 processes with UID = 501 (tonvoon) [Skype, PubSubAgent]', "Output correct" ); | ||
115 | }; | ||
103 | 116 | ||
104 | $result = NPTest->testCmd( "$command --metric=VSZ -w 1200000 -v" ); | 117 | $result = NPTest->testCmd( "$command --metric=VSZ -w 1200000 -v" ); |
105 | is( $result->return_code, 1, "Checking against VSZ > 1.2GB" ); | 118 | is( $result->return_code, 1, "Checking against VSZ > 1.2GB" ); |
106 | is( $result->output, 'VSZ WARNING: 4 warn out of 95 processes [WindowServer, Safari, Mail, Skype]', "Output correct" ); | 119 | is( $result->output, 'VSZ WARNING: 4 warn out of 95 processes [WindowServer, Safari, Mail, Skype] | procs=95;;;0; procs_warn=4;;;0; procs_crit=0;;;0;', "Output correct" ); |
107 | 120 | ||
108 | $result = NPTest->testCmd( "$command --metric=VSZ -w 1200000 -v" ); | 121 | $result = NPTest->testCmd( "$command --metric=VSZ -w 1200000 -v" ); |
109 | is( $result->return_code, 1, "Checking against VSZ > 1.2GB" ); | 122 | is( $result->return_code, 1, "Checking against VSZ > 1.2GB" ); |
110 | is( $result->output, 'VSZ WARNING: 4 warn out of 95 processes [WindowServer, Safari, Mail, Skype]', "Output correct" ); | 123 | is( $result->output, 'VSZ WARNING: 4 warn out of 95 processes [WindowServer, Safari, Mail, Skype] | procs=95;;;0; procs_warn=4;;;0; procs_crit=0;;;0;', "Output correct" ); |
111 | 124 | ||
112 | $result = NPTest->testCmd( "$command --metric=RSS -c 70000 -v" ); | 125 | $result = NPTest->testCmd( "$command --metric=RSS -c 70000 -v" ); |
113 | is( $result->return_code, 2, "Checking against RSS > 70MB" ); | 126 | is( $result->return_code, 2, "Checking against RSS > 70MB" ); |
114 | is( $result->output, 'RSS CRITICAL: 5 crit, 0 warn out of 95 processes [WindowServer, SystemUIServer, Safari, Mail, Safari]', "Output correct" ); | 127 | is( $result->output, 'RSS CRITICAL: 5 crit, 0 warn out of 95 processes [WindowServer, SystemUIServer, Safari, Mail, Safari] | procs=95;;;0; procs_warn=0;;;0; procs_crit=5;;;0;', "Output correct" ); |
115 | 128 | ||
116 | $result = NPTest->testCmd( "$command --ereg-argument-array='(nosuchname|nosuch2name)'" ); | 129 | $result = NPTest->testCmd( "$command --ereg-argument-array='(nosuchname|nosuch2name)'" ); |
117 | is( $result->return_code, 0, "Checking no pipe symbol in output" ); | 130 | is( $result->return_code, 0, "Checking no pipe symbol in output" ); |
118 | is( $result->output, "PROCS OK: 0 processes with regex args '(nosuchname,nosuch2name)'", "Output correct" ); | 131 | is( $result->output, "PROCS OK: 0 processes with regex args '(nosuchname,nosuch2name)' | procs=0;;;0;", "Output correct" ); |
119 | 132 | ||
diff --git a/plugins/tests/check_snmp.t b/plugins/tests/check_snmp.t index 1ef0b209..aace9bcc 100755 --- a/plugins/tests/check_snmp.t +++ b/plugins/tests/check_snmp.t | |||
@@ -8,7 +8,7 @@ use Test::More; | |||
8 | use NPTest; | 8 | use NPTest; |
9 | use FindBin qw($Bin); | 9 | use FindBin qw($Bin); |
10 | 10 | ||
11 | my $tests = 53; | 11 | my $tests = 67; |
12 | # Check that all dependent modules are available | 12 | # Check that all dependent modules are available |
13 | eval { | 13 | eval { |
14 | require NetSNMP::OID; | 14 | require NetSNMP::OID; |
@@ -59,7 +59,7 @@ if ($ARGV[0] && $ARGV[0] eq "-d") { | |||
59 | } | 59 | } |
60 | 60 | ||
61 | # We should merge that with $ENV{'NPTEST_CACHE'}, use one dir for all test data | 61 | # We should merge that with $ENV{'NPTEST_CACHE'}, use one dir for all test data |
62 | $ENV{'NAGIOS_PLUGIN_STATE_DIRECTORY'} ||= "/var/tmp"; | 62 | $ENV{'MP_STATE_PATH'} ||= "/var/tmp"; |
63 | 63 | ||
64 | my $res; | 64 | my $res; |
65 | 65 | ||
@@ -79,7 +79,7 @@ Copyright (c) 1986-2004 by cisco Systems, Inc. | |||
79 | $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.0 -o sysContact.0 -o .1.3.6.1.4.1.8072.3.2.67.1"); | 79 | $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.0 -o sysContact.0 -o .1.3.6.1.4.1.8072.3.2.67.1"); |
80 | cmp_ok( $res->return_code, '==', 0, "Exit OK when querying multi-line OIDs" ); | 80 | cmp_ok( $res->return_code, '==', 0, "Exit OK when querying multi-line OIDs" ); |
81 | like($res->output, '/^SNMP OK - /', "String contains SNMP OK"); | 81 | like($res->output, '/^SNMP OK - /', "String contains SNMP OK"); |
82 | like($res->output, '/'.quotemeta('SNMP OK - Cisco Internetwork Operating System Software Alice Kisco Outernetwork Oserating Gystem Totware | | 82 | like($res->output, '/'.quotemeta('SNMP OK - Cisco Internetwork Operating System Software ').'"?Alice"?'.quotemeta(' Kisco Outernetwork Oserating Gystem Totware | |
83 | .1.3.6.1.4.1.8072.3.2.67.0: | 83 | .1.3.6.1.4.1.8072.3.2.67.0: |
84 | "Cisco Internetwork Operating System Software | 84 | "Cisco Internetwork Operating System Software |
85 | IOS (tm) Catalyst 4000 \"L3\" Switch Software (cat4000-I9K91S-M), Version | 85 | IOS (tm) Catalyst 4000 \"L3\" Switch Software (cat4000-I9K91S-M), Version |
@@ -109,7 +109,7 @@ like($res->output, '/'.quotemeta('SNMP OK - And now have fun with with this: \"C | |||
109 | "And now have fun with with this: \"C:\\\\\" | 109 | "And now have fun with with this: \"C:\\\\\" |
110 | because we\'re not done yet!"').'/m', "Attempt to confuse parser No.3"); | 110 | because we\'re not done yet!"').'/m', "Attempt to confuse parser No.3"); |
111 | 111 | ||
112 | system("rm -f ".$ENV{'NAGIOS_PLUGIN_STATE_DIRECTORY'}."/check_snmp/*"); | 112 | system("rm -f ".$ENV{'MP_STATE_PATH'}."/check_snmp/*"); |
113 | $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 -w 600" ); | 113 | $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 -w 600" ); |
114 | is($res->return_code, 0, "Returns OK"); | 114 | is($res->return_code, 0, "Returns OK"); |
115 | is($res->output, "No previous data to calculate rate - assume okay"); | 115 | is($res->output, "No previous data to calculate rate - assume okay"); |
@@ -214,3 +214,31 @@ $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1 | |||
214 | is($res->return_code, 0, "String check should check whole string, not a parsed number" ); | 214 | is($res->return_code, 0, "String check should check whole string, not a parsed number" ); |
215 | is($res->output, 'SNMP OK - "CUSTOM CHECK OK: foo is 12345" | ', "String check witn numbers returns whole string"); | 215 | is($res->output, 'SNMP OK - "CUSTOM CHECK OK: foo is 12345" | ', "String check witn numbers returns whole string"); |
216 | 216 | ||
217 | $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.16 -w -2: -c -3:" ); | ||
218 | is($res->return_code, 0, "Negative integer check OK" ); | ||
219 | is($res->output, 'SNMP OK - -2 | iso.3.6.1.4.1.8072.3.2.67.16=-2 ', "Negative integer check OK output" ); | ||
220 | |||
221 | $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.16 -w -2: -c -3:" ); | ||
222 | is($res->return_code, 1, "Negative integer check WARNING" ); | ||
223 | is($res->output, 'SNMP WARNING - *-3* | iso.3.6.1.4.1.8072.3.2.67.16=-3 ', "Negative integer check WARNING output" ); | ||
224 | |||
225 | $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.16 -w -2: -c -3:" ); | ||
226 | is($res->return_code, 2, "Negative integer check CRITICAL" ); | ||
227 | is($res->output, 'SNMP CRITICAL - *-4* | iso.3.6.1.4.1.8072.3.2.67.16=-4 ', "Negative integer check CRITICAL output" ); | ||
228 | |||
229 | $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.17 -w -3: -c -6:" ); | ||
230 | is($res->return_code, 1, "Negative integer as string, WARNING" ); | ||
231 | is($res->output, 'SNMP WARNING - *-4* | iso.3.6.1.4.1.8072.3.2.67.17=-4 ', "Negative integer as string, WARNING output" ); | ||
232 | |||
233 | $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.17 -w -2: -c -3:" ); | ||
234 | is($res->return_code, 2, "Negative integer as string, CRITICAL" ); | ||
235 | is($res->output, 'SNMP CRITICAL - *-4* | iso.3.6.1.4.1.8072.3.2.67.17=-4 ', "Negative integer as string, CRITICAL output" ); | ||
236 | |||
237 | $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.18 -c ~:-6.5" ); | ||
238 | is($res->return_code, 0, "Negative float OK" ); | ||
239 | is($res->output, 'SNMP OK - -6.6 | iso.3.6.1.4.1.8072.3.2.67.18=-6.6 ', "Negative float OK output" ); | ||
240 | |||
241 | $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.18 -w ~:-6.65 -c ~:-6.55" ); | ||
242 | is($res->return_code, 1, "Negative float WARNING" ); | ||
243 | is($res->output, 'SNMP WARNING - *-6.6* | iso.3.6.1.4.1.8072.3.2.67.18=-6.6 ', "Negative float WARNING output" ); | ||
244 | |||
diff --git a/plugins/tests/check_snmp_agent.pl b/plugins/tests/check_snmp_agent.pl index 8cacd527..0e41d575 100644 --- a/plugins/tests/check_snmp_agent.pl +++ b/plugins/tests/check_snmp_agent.pl | |||
@@ -7,7 +7,7 @@ | |||
7 | use NetSNMP::OID qw(:all); | 7 | use NetSNMP::OID qw(:all); |
8 | use NetSNMP::agent; | 8 | use NetSNMP::agent; |
9 | use NetSNMP::ASN qw(ASN_OCTET_STR ASN_COUNTER ASN_COUNTER64 ASN_INTEGER ASN_INTEGER64 ASN_UNSIGNED ASN_UNSIGNED64); | 9 | use NetSNMP::ASN qw(ASN_OCTET_STR ASN_COUNTER ASN_COUNTER64 ASN_INTEGER ASN_INTEGER64 ASN_UNSIGNED ASN_UNSIGNED64); |
10 | #use Math::Int64 qw(uint64); # Skip that module whie we don't need it | 10 | #use Math::Int64 qw(uint64); # Skip that module while we don't need it |
11 | sub uint64 { return $_ } | 11 | sub uint64 { return $_ } |
12 | 12 | ||
13 | if (!$agent) { | 13 | if (!$agent) { |
@@ -16,8 +16,6 @@ if (!$agent) { | |||
16 | } | 16 | } |
17 | 17 | ||
18 | my $baseoid = '.1.3.6.1.4.1.8072.3.2.67'; | 18 | my $baseoid = '.1.3.6.1.4.1.8072.3.2.67'; |
19 | # Next are arrays of indexes (Type, initial value and increments) | ||
20 | # Undef miltipliers are randomized | ||
21 | my $multiline = 'Cisco Internetwork Operating System Software | 19 | my $multiline = 'Cisco Internetwork Operating System Software |
22 | IOS (tm) Catalyst 4000 "L3" Switch Software (cat4000-I9K91S-M), Version | 20 | IOS (tm) Catalyst 4000 "L3" Switch Software (cat4000-I9K91S-M), Version |
23 | 12.2(20)EWA, RELEASE SOFTWARE (fc1) | 21 | 12.2(20)EWA, RELEASE SOFTWARE (fc1) |
@@ -33,10 +31,12 @@ ends with with this: C:\\'; | |||
33 | my $multilin5 = 'And now have fun with with this: "C:\\" | 31 | my $multilin5 = 'And now have fun with with this: "C:\\" |
34 | because we\'re not done yet!'; | 32 | because we\'re not done yet!'; |
35 | 33 | ||
36 | # 0..15 <---- please update comment when adding/removing fields | 34 | # Next are arrays of indexes (Type, initial value and increments) |
37 | my @fields = (ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_UNSIGNED, ASN_UNSIGNED, ASN_COUNTER, ASN_COUNTER64, ASN_UNSIGNED, ASN_COUNTER, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR ); | 35 | # 0..16 <---- please update comment when adding/removing fields |
38 | my @values = ($multiline, $multilin2, $multilin3, $multilin4, $multilin5, 4294965296, 1000, 4294965296, uint64("18446744073709351616"), int(rand(2**32)), 64000, "stringtests", "3.5", "87.4startswithnumberbutshouldbestring", '555"I said"', 'CUSTOM CHECK OK: foo is 12345' ); | 36 | my @fields = (ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_UNSIGNED, ASN_UNSIGNED, ASN_COUNTER, ASN_COUNTER64, ASN_UNSIGNED, ASN_COUNTER, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_INTEGER, ASN_OCTET_STR, ASN_OCTET_STR ); |
39 | my @incrts = (undef, undef, undef, undef, undef, 1000, -500, 1000, 100000, undef, 666, undef, undef, undef, undef, undef ); | 37 | my @values = ($multiline, $multilin2, $multilin3, $multilin4, $multilin5, 4294965296, 1000, 4294965296, uint64("18446744073709351616"), int(rand(2**32)), 64000, "stringtests", "3.5", "87.4startswithnumberbutshouldbestring", '555"I said"', 'CUSTOM CHECK OK: foo is 12345', -2, '-4', '-6.6' ); |
38 | # undef increments are randomized | ||
39 | my @incrts = (undef, undef, undef, undef, undef, 1000, -500, 1000, 100000, undef, 666, undef, undef, undef, undef, undef, -1, undef, undef ); | ||
40 | 40 | ||
41 | # Number of elements in our OID | 41 | # Number of elements in our OID |
42 | my $oidelts; | 42 | my $oidelts; |
diff --git a/plugins/tests/var/ps_axwo.debian b/plugins/tests/var/ps_axwo.debian index 0d7d7bce..37a2d35e 100644 --- a/plugins/tests/var/ps_axwo.debian +++ b/plugins/tests/var/ps_axwo.debian | |||
@@ -31,7 +31,7 @@ S 0 6907 1 2308 892 0.0 mysqld_safe /bin/sh /usr/bin/mysqld_ | |||
31 | S 103 6944 6907 123220 27724 0.0 mysqld /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-locking --port=3306 --socket=/var/run/mysqld/mysqld.sock | 31 | S 103 6944 6907 123220 27724 0.0 mysqld /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-locking --port=3306 --socket=/var/run/mysqld/mysqld.sock |
32 | S 0 6945 6907 1488 420 0.0 logger logger -p daemon.err -t mysqld_safe -i -t mysqld | 32 | S 0 6945 6907 1488 420 0.0 logger logger -p daemon.err -t mysqld_safe -i -t mysqld |
33 | S 1001 17778 1 6436 1588 0.0 snmpd /usr/sbin/snmpd -u nagios -Lsd -Lf /dev/null -p/var/run/snmpd.pid | 33 | S 1001 17778 1 6436 1588 0.0 snmpd /usr/sbin/snmpd -u nagios -Lsd -Lf /dev/null -p/var/run/snmpd.pid |
34 | Ss 0 17789 1 9496 5556 0.0 snmptrapd /usr/sbin/snmptrapd -t -m ALL -M /usr/share/snmp/mibs:/usr/local/nagios/snmp/load -p /var/run/snmptrapd.pid | 34 | Ss 0 17789 1 9496 5556 0.0 snmptrapd /usr/sbin/snmptrapd -t -m ALL -M /usr/share/snmp/mibs:/usr/local/monitoring/snmp/load -p /var/run/snmptrapd.pid |
35 | Ss 0 847 2319 14452 1752 0.0 sshd sshd: tonvoon [priv] | 35 | Ss 0 847 2319 14452 1752 0.0 sshd sshd: tonvoon [priv] |
36 | S 1000 857 847 14616 1832 0.0 sshd sshd: tonvoon@pts/3 | 36 | S 1000 857 847 14616 1832 0.0 sshd sshd: tonvoon@pts/3 |
37 | Ss 1000 860 857 2984 1620 0.0 bash -bash | 37 | Ss 1000 860 857 2984 1620 0.0 bash -bash |
@@ -79,6 +79,6 @@ Ss 1001 23783 1 3220 764 0.0 ndo2db /usr/local/nagios/bin/nd | |||
79 | Ss 1001 23784 1 6428 4948 0.0 import_ndologsd import_ndologsd | 79 | Ss 1001 23784 1 6428 4948 0.0 import_ndologsd import_ndologsd |
80 | S+ 1001 9803 18955 4132 1936 0.0 ssh ssh altinity@cube02.lei.altinity | 80 | S+ 1001 9803 18955 4132 1936 0.0 ssh ssh altinity@cube02.lei.altinity |
81 | S 1001 22505 22324 20256 1616 0.0 nagios ../../bin/nagios -d /usr/local/nagios/etc/nagios.cfg | 81 | S 1001 22505 22324 20256 1616 0.0 nagios ../../bin/nagios -d /usr/local/nagios/etc/nagios.cfg |
82 | S 1001 22506 22505 1676 608 0.0 check_ping /usr/local/nagios/libexec/check_ping -H 192.168.10.23 -w 3000.0,80% -c 5000.0,100% -p 1 | 82 | S 1001 22506 22505 1676 608 0.0 check_ping /usr/local/libexec/check_ping -H 192.168.10.23 -w 3000.0,80% -c 5000.0,100% -p 1 |
83 | S 1001 22507 22506 1660 492 0.0 ping /bin/ping -n -U -w 10 -c 1 192.168.10.23 | 83 | S 1001 22507 22506 1660 492 0.0 ping /bin/ping -n -U -w 10 -c 1 192.168.10.23 |
84 | R+ 1001 22508 23370 2308 680 0.0 ps ps axwo stat uid pid ppid vsz rss pcpu comm args | 84 | R+ 1001 22508 23370 2308 680 0.0 ps ps axwo stat uid pid ppid vsz rss pcpu comm args |