diff options
Diffstat (limited to 'plugins/t')
-rw-r--r-- | plugins/t/check_by_ssh.t | 18 | ||||
-rw-r--r-- | plugins/t/check_curl.t | 46 | ||||
-rw-r--r-- | plugins/t/check_disk.t | 39 | ||||
-rw-r--r-- | plugins/t/check_http.t | 16 | ||||
-rw-r--r-- | plugins/t/check_load.t | 15 | ||||
-rw-r--r-- | plugins/t/check_mysql.t | 6 | ||||
-rw-r--r-- | plugins/t/check_mysql_query.t | 2 | ||||
-rw-r--r-- | plugins/t/check_nagios.t | 2 | ||||
-rw-r--r-- | plugins/t/check_smtp.t | 40 | ||||
-rw-r--r-- | plugins/t/check_snmp.t | 68 | ||||
-rw-r--r-- | plugins/t/negate.t | 2 |
11 files changed, 155 insertions, 99 deletions
diff --git a/plugins/t/check_by_ssh.t b/plugins/t/check_by_ssh.t index 1d2939e..b6479f1 100644 --- a/plugins/t/check_by_ssh.t +++ b/plugins/t/check_by_ssh.t | |||
@@ -19,19 +19,19 @@ plan skip_all => "SSH_HOST and SSH_IDENTITY must be defined" unless ($ssh_servic | |||
19 | plan tests => 42; | 19 | plan tests => 42; |
20 | 20 | ||
21 | # Some random check strings/response | 21 | # Some random check strings/response |
22 | my @responce = ('OK: Everything is fine', | 22 | my @response = ('OK: Everything is fine', |
23 | 'WARNING: Hey, pick me, pick me', | 23 | 'WARNING: Hey, pick me, pick me', |
24 | 'CRITICAL: Shit happens', | 24 | 'CRITICAL: Shit happens', |
25 | 'UNKNOWN: What can I do for ya', | 25 | 'UNKNOWN: What can I do for ya', |
26 | 'WOOPS: What did I smoke', | 26 | 'WOOPS: What did I smoke', |
27 | ); | 27 | ); |
28 | my @responce_re; | 28 | my @response_re; |
29 | my @check; | 29 | my @check; |
30 | for (@responce) { | 30 | for (@response) { |
31 | push(@check, "echo $_"); | 31 | push(@check, "echo $_"); |
32 | my $re_str = $_; | 32 | my $re_str = $_; |
33 | $re_str =~ s{(.)} { "\Q$1" }ge; | 33 | $re_str =~ s{(.)} { "\Q$1" }ge; |
34 | push(@responce_re, $re_str); | 34 | push(@response_re, $re_str); |
35 | } | 35 | } |
36 | 36 | ||
37 | my $result; | 37 | my $result; |
@@ -47,7 +47,7 @@ for (my $i=0; $i<4; $i++) { | |||
47 | "./check_by_ssh -i $ssh_key -H $ssh_service -C '$check[$i]; exit $i'" | 47 | "./check_by_ssh -i $ssh_key -H $ssh_service -C '$check[$i]; exit $i'" |
48 | ); | 48 | ); |
49 | cmp_ok($result->return_code, '==', $i, "Exit with return code $i"); | 49 | cmp_ok($result->return_code, '==', $i, "Exit with return code $i"); |
50 | is($result->output, $responce[$i], "Status text is correct for check $i"); | 50 | is($result->output, $response[$i], "Status text is correct for check $i"); |
51 | } | 51 | } |
52 | 52 | ||
53 | $result = NPTest->testCmd( | 53 | $result = NPTest->testCmd( |
@@ -84,7 +84,7 @@ $result = NPTest->testCmd( | |||
84 | "./check_by_ssh -i $ssh_key -H $ssh_service -C '$check[4]; exit 8'" | 84 | "./check_by_ssh -i $ssh_key -H $ssh_service -C '$check[4]; exit 8'" |
85 | ); | 85 | ); |
86 | cmp_ok($result->return_code, '==', 8, "Exit with return code 8 (out of bounds)"); | 86 | cmp_ok($result->return_code, '==', 8, "Exit with return code 8 (out of bounds)"); |
87 | is($result->output, $responce[4], "Return proper status text even with unknown status codes"); | 87 | is($result->output, $response[4], "Return proper status text even with unknown status codes"); |
88 | 88 | ||
89 | $result = NPTest->testCmd( | 89 | $result = NPTest->testCmd( |
90 | "./check_by_ssh -i $ssh_key -H $ssh_service -F $ssh_conf -C 'exit 0'" | 90 | "./check_by_ssh -i $ssh_key -H $ssh_service -F $ssh_conf -C 'exit 0'" |
@@ -108,7 +108,7 @@ my %linemap = ( | |||
108 | foreach my $line (0, 2, 4, 6) { | 108 | foreach my $line (0, 2, 4, 6) { |
109 | my $code = $linemap{$line}; | 109 | my $code = $linemap{$line}; |
110 | my $statline = $line+1; | 110 | my $statline = $line+1; |
111 | is($lines[$line], "$responce[$code]", "multiple checks status text is correct for line $line"); | 111 | is($lines[$line], "$response[$code]", "multiple checks status text is correct for line $line"); |
112 | is($lines[$statline], "STATUS CODE: $code", "multiple check status code is correct for line $line"); | 112 | is($lines[$statline], "STATUS CODE: $code", "multiple check status code is correct for line $line"); |
113 | } | 113 | } |
114 | 114 | ||
@@ -124,7 +124,7 @@ close(PASV) or die("Unable to close '/tmp/check_by_ssh.$$': $!"); | |||
124 | cmp_ok(scalar(@pasv), '==', 1, 'One passive result for one check performed'); | 124 | cmp_ok(scalar(@pasv), '==', 1, 'One passive result for one check performed'); |
125 | for (0) { | 125 | for (0) { |
126 | if ($pasv[$_]) { | 126 | if ($pasv[$_]) { |
127 | like($pasv[$_], '/^\[\d+\] PROCESS_SERVICE_CHECK_RESULT;flint;serv;2;' . $responce_re[2] . '$/', 'proper result for passive check'); | 127 | like($pasv[$_], '/^\[\d+\] PROCESS_SERVICE_CHECK_RESULT;flint;serv;2;' . $response_re[2] . '$/', 'proper result for passive check'); |
128 | } else { | 128 | } else { |
129 | fail('proper result for passive check'); | 129 | fail('proper result for passive check'); |
130 | } | 130 | } |
@@ -144,7 +144,7 @@ for (0, 1, 2, 3, 4) { | |||
144 | if ($pasv[$_]) { | 144 | if ($pasv[$_]) { |
145 | my $ret = $_; | 145 | my $ret = $_; |
146 | $ret = 9 if ($_ == 4); | 146 | $ret = 9 if ($_ == 4); |
147 | like($pasv[$_], '/^\[\d+\] PROCESS_SERVICE_CHECK_RESULT;flint;c' . $_ . ';' . $ret . ';' . $responce_re[$_] . '$/', "proper result for passive check $_"); | 147 | like($pasv[$_], '/^\[\d+\] PROCESS_SERVICE_CHECK_RESULT;flint;c' . $_ . ';' . $ret . ';' . $response_re[$_] . '$/', "proper result for passive check $_"); |
148 | } else { | 148 | } else { |
149 | fail("proper result for passive check $_"); | 149 | fail("proper result for passive check $_"); |
150 | } | 150 | } |
diff --git a/plugins/t/check_curl.t b/plugins/t/check_curl.t index 45ee533..eae98cc 100644 --- a/plugins/t/check_curl.t +++ b/plugins/t/check_curl.t | |||
@@ -1,15 +1,22 @@ | |||
1 | #! /usr/bin/perl -w -I .. | 1 | #! /usr/bin/perl -w -I .. |
2 | # | 2 | # |
3 | # HyperText Transfer Protocol (HTTP) Test via check_http | 3 | # HyperText Transfer Protocol (HTTP) Test via check_curl |
4 | # | 4 | # |
5 | # | 5 | # |
6 | 6 | ||
7 | use strict; | 7 | use strict; |
8 | use Test::More; | 8 | use Test::More; |
9 | use POSIX qw/mktime strftime/; | 9 | use POSIX qw/mktime strftime/; |
10 | use NPTest; | ||
11 | 10 | ||
12 | plan tests => 58; | 11 | use vars qw($tests $has_ipv6); |
12 | |||
13 | BEGIN { | ||
14 | use NPTest; | ||
15 | $has_ipv6 = NPTest::has_ipv6(); | ||
16 | $tests = $has_ipv6 ? 59 : 57; | ||
17 | plan tests => $tests; | ||
18 | } | ||
19 | |||
13 | 20 | ||
14 | my $successOutput = '/OK.*HTTP.*second/'; | 21 | my $successOutput = '/OK.*HTTP.*second/'; |
15 | 22 | ||
@@ -18,6 +25,7 @@ my $plugin = 'check_http'; | |||
18 | $plugin = 'check_curl' if $0 =~ m/check_curl/mx; | 25 | $plugin = 'check_curl' if $0 =~ m/check_curl/mx; |
19 | 26 | ||
20 | my $host_tcp_http = getTestParameter("NP_HOST_TCP_HTTP", "A host providing the HTTP Service (a web server)", "localhost"); | 27 | my $host_tcp_http = getTestParameter("NP_HOST_TCP_HTTP", "A host providing the HTTP Service (a web server)", "localhost"); |
28 | my $host_tcp_http_ipv6 = getTestParameter("NP_HOST_TCP_HTTP_IPV6", "An IPv6 address providing a HTTP Service (a web server)", "::1"); | ||
21 | my $host_tls_http = getTestParameter("NP_HOST_TLS_HTTP", "A host providing the HTTPS Service (a tls web server)", "localhost"); | 29 | my $host_tls_http = getTestParameter("NP_HOST_TLS_HTTP", "A host providing the HTTPS Service (a tls web server)", "localhost"); |
22 | my $host_tls_cert = getTestParameter("NP_HOST_TLS_CERT", "the common name of the certificate.", "localhost"); | 30 | my $host_tls_cert = getTestParameter("NP_HOST_TLS_CERT", "the common name of the certificate.", "localhost"); |
23 | my $host_nonresponsive = getTestParameter("NP_HOST_NONRESPONSIVE", "The hostname of system not responsive to network requests", "10.0.0.1"); | 31 | my $host_nonresponsive = getTestParameter("NP_HOST_NONRESPONSIVE", "The hostname of system not responsive to network requests", "10.0.0.1"); |
@@ -31,26 +39,35 @@ my $faketime = -x '/usr/bin/faketime' ? 1 : 0; | |||
31 | 39 | ||
32 | 40 | ||
33 | $res = NPTest->testCmd( | 41 | $res = NPTest->testCmd( |
34 | "./$plugin $host_tcp_http -wt 300 -ct 600" | 42 | "./$plugin $host_tcp_http -wt 300 -ct 600" |
35 | ); | 43 | ); |
36 | cmp_ok( $res->return_code, '==', 0, "Webserver $host_tcp_http responded" ); | 44 | cmp_ok( $res->return_code, '==', 0, "Webserver $host_tcp_http responded" ); |
37 | like( $res->output, $successOutput, "Output OK" ); | 45 | like( $res->output, $successOutput, "Output OK" ); |
38 | 46 | ||
47 | if ($has_ipv6) { | ||
48 | # Test for IPv6 formatting | ||
49 | $res = NPTest->testCmd( | ||
50 | "./$plugin -I $host_tcp_http_ipv6 -wt 300 -ct 600" | ||
51 | ); | ||
52 | cmp_ok( $res->return_code, '==', 0, "IPv6 URL formatting is working" ); | ||
53 | like( $res->output, $successOutput, "Output OK" ); | ||
54 | } | ||
55 | |||
39 | $res = NPTest->testCmd( | 56 | $res = NPTest->testCmd( |
40 | "./$plugin $host_tcp_http -wt 300 -ct 600 -v -v -v -k 'bob:there' -k 'carl:frown'" | 57 | "./$plugin $host_tcp_http -wt 300 -ct 600 -v -v -v -k 'bob:there' -k 'carl:frown'" |
41 | ); | 58 | ); |
42 | like( $res->output, '/bob:there\r\ncarl:frown\r\n/', "Got headers with multiple -k options" ); | 59 | like( $res->output, '/bob:there\r\ncarl:frown\r\n/', "Got headers with multiple -k options" ); |
43 | 60 | ||
44 | $res = NPTest->testCmd( | 61 | $res = NPTest->testCmd( |
45 | "./$plugin $host_nonresponsive -wt 1 -ct 2 -t 3" | 62 | "./$plugin $host_nonresponsive -wt 1 -ct 2 -t 3" |
46 | ); | 63 | ); |
47 | cmp_ok( $res->return_code, '==', 2, "Webserver $host_nonresponsive not responding" ); | 64 | cmp_ok( $res->return_code, '==', 2, "Webserver $host_nonresponsive not responding" ); |
48 | # was CRITICAL only, but both check_curl and check_http print HTTP CRITICAL (puzzle?!) | 65 | # was CRITICAL only, but both check_curl and check_http print HTTP CRITICAL (puzzle?!) |
49 | like( $res->output, "/HTTP CRITICAL - Invalid HTTP response received from host on port 80: cURL returned 28 - Connection timed out after/", "Output OK"); | 66 | like( $res->output, "/HTTP CRITICAL - Invalid HTTP response received from host on port 80: cURL returned 28 - Connection timed out after/", "Output OK"); |
50 | 67 | ||
51 | $res = NPTest->testCmd( | 68 | $res = NPTest->testCmd( |
52 | "./$plugin $hostname_invalid -wt 1 -ct 2" | 69 | "./$plugin $hostname_invalid -wt 1 -ct 2" |
53 | ); | 70 | ); |
54 | cmp_ok( $res->return_code, '==', 2, "Webserver $hostname_invalid not valid" ); | 71 | cmp_ok( $res->return_code, '==', 2, "Webserver $hostname_invalid not valid" ); |
55 | # The first part of the message comes from the OS catalogue, so cannot check this. | 72 | # The first part of the message comes from the OS catalogue, so cannot check this. |
56 | # On Debian, it is Name or service not known, on Darwin, it is No address associated with nodename | 73 | # On Debian, it is Name or service not known, on Darwin, it is No address associated with nodename |
@@ -95,7 +112,7 @@ SKIP: { | |||
95 | $res = NPTest->testCmd("./$plugin -v -H $host_tls_http:443 -S -p 443"); | 112 | $res = NPTest->testCmd("./$plugin -v -H $host_tls_http:443 -S -p 443"); |
96 | like( $res->output, '/^Host: '.$host_tls_http.'\s*$/ms', "Host Header OK" ); | 113 | like( $res->output, '/^Host: '.$host_tls_http.'\s*$/ms', "Host Header OK" ); |
97 | 114 | ||
98 | $res = NPTest->testCmd("./$plugin -v -H $host_tls_http -D -p 443"); | 115 | $res = NPTest->testCmd("./$plugin -v -H $host_tls_http -D -S -p 443"); |
99 | like( $res->output, '/(^Host: '.$host_tls_http.'\s*$)|(cURL returned 60)/ms', "Host Header OK" ); | 116 | like( $res->output, '/(^Host: '.$host_tls_http.'\s*$)|(cURL returned 60)/ms', "Host Header OK" ); |
100 | }; | 117 | }; |
101 | 118 | ||
@@ -188,11 +205,6 @@ SKIP: { | |||
188 | like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' ); | 205 | like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' ); |
189 | like ( $res->output, '/time_ssl=[\d\.]+/', 'Extended Performance Data SSL Output OK' ); | 206 | like ( $res->output, '/time_ssl=[\d\.]+/', 'Extended Performance Data SSL Output OK' ); |
190 | 207 | ||
191 | $res = NPTest->testCmd( | ||
192 | "./$plugin --ssl -H www.e-paycobalt.com" | ||
193 | ); | ||
194 | cmp_ok( $res->return_code, "==", 0, "Can read https for www.e-paycobalt.com (uses AES certificate)" ); | ||
195 | |||
196 | $res = NPTest->testCmd( "./$plugin -H www.mozilla.com -u /firefox -f curl" ); | 208 | $res = NPTest->testCmd( "./$plugin -H www.mozilla.com -u /firefox -f curl" ); |
197 | is( $res->return_code, 0, "Redirection based on location is okay"); | 209 | is( $res->return_code, 0, "Redirection based on location is okay"); |
198 | 210 | ||
diff --git a/plugins/t/check_disk.t b/plugins/t/check_disk.t index ec527e7..ca035ce 100644 --- a/plugins/t/check_disk.t +++ b/plugins/t/check_disk.t | |||
@@ -23,7 +23,7 @@ my $mountpoint2_valid = getTestParameter( "NP_MOUNTPOINT2_VALID", "Path to anoth | |||
23 | if ($mountpoint_valid eq "" or $mountpoint2_valid eq "") { | 23 | if ($mountpoint_valid eq "" or $mountpoint2_valid eq "") { |
24 | plan skip_all => "Need 2 mountpoints to test"; | 24 | plan skip_all => "Need 2 mountpoints to test"; |
25 | } else { | 25 | } else { |
26 | plan tests => 78; | 26 | plan tests => 88; |
27 | } | 27 | } |
28 | 28 | ||
29 | $result = NPTest->testCmd( | 29 | $result = NPTest->testCmd( |
@@ -326,19 +326,19 @@ cmp_ok( $result->return_code, '==', 0, "grouping: exit ok if the sum of free meg | |||
326 | $result = NPTest->testCmd( "./check_disk -w ". ($free_mb_on_all - 1) ." -c ". ($free_mb_on_all - 1) ." -p $mountpoint_valid -g group -p $mountpoint2_valid" ); | 326 | $result = NPTest->testCmd( "./check_disk -w ". ($free_mb_on_all - 1) ." -c ". ($free_mb_on_all - 1) ." -p $mountpoint_valid -g group -p $mountpoint2_valid" ); |
327 | cmp_ok( $result->return_code, '==', 3, "Invalid options: -p must come after groupname"); | 327 | cmp_ok( $result->return_code, '==', 3, "Invalid options: -p must come after groupname"); |
328 | 328 | ||
329 | # regex: exit unknown if given regex is not compileable | 329 | # regex: exit unknown if given regex is not compilable |
330 | $result = NPTest->testCmd( "./check_disk -w 1 -c 1 -r '('" ); | 330 | $result = NPTest->testCmd( "./check_disk -w 1 -c 1 -r '('" ); |
331 | cmp_ok( $result->return_code, '==', 3, "Exit UNKNOWN if regex is not compileable"); | 331 | cmp_ok( $result->return_code, '==', 3, "Exit UNKNOWN if regex is not compilable"); |
332 | 332 | ||
333 | # ignore: exit unknown, if all pathes are deselected using -i | 333 | # ignore: exit unknown, if all paths are deselected using -i |
334 | $result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p $mountpoint_valid -p $mountpoint2_valid -i '$mountpoint_valid' -i '$mountpoint2_valid'" ); | 334 | $result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p $mountpoint_valid -p $mountpoint2_valid -i '$mountpoint_valid' -i '$mountpoint2_valid'" ); |
335 | cmp_ok( $result->return_code, '==', 3, "ignore-ereg: Unknown if all fs are ignored (case sensitive)"); | 335 | cmp_ok( $result->return_code, '==', 3, "ignore-ereg: Unknown if all fs are ignored (case sensitive)"); |
336 | 336 | ||
337 | # ignore: exit unknown, if all pathes are deselected using -I | 337 | # ignore: exit unknown, if all paths are deselected using -I |
338 | $result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p $mountpoint_valid -p $mountpoint2_valid -I '".uc($mountpoint_valid)."' -I '".uc($mountpoint2_valid)."'" ); | 338 | $result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p $mountpoint_valid -p $mountpoint2_valid -I '".uc($mountpoint_valid)."' -I '".uc($mountpoint2_valid)."'" ); |
339 | cmp_ok( $result->return_code, '==', 3, "ignore-ereg: Unknown if all fs are ignored (case insensitive)"); | 339 | cmp_ok( $result->return_code, '==', 3, "ignore-ereg: Unknown if all fs are ignored (case insensitive)"); |
340 | 340 | ||
341 | # ignore: exit unknown, if all pathes are deselected using -i | 341 | # ignore: exit unknown, if all paths are deselected using -i |
342 | $result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p $mountpoint_valid -p $mountpoint2_valid -i '.*'" ); | 342 | $result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p $mountpoint_valid -p $mountpoint2_valid -i '.*'" ); |
343 | cmp_ok( $result->return_code, '==', 3, "ignore-ereg: Unknown if all fs are ignored using -i '.*'"); | 343 | cmp_ok( $result->return_code, '==', 3, "ignore-ereg: Unknown if all fs are ignored using -i '.*'"); |
344 | 344 | ||
@@ -347,7 +347,32 @@ $result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p $mountpoint_valid -p $mo | |||
347 | like( $result->output, qr/$mountpoint_valid/, "output data does have $mountpoint_valid in it"); | 347 | like( $result->output, qr/$mountpoint_valid/, "output data does have $mountpoint_valid in it"); |
348 | unlike( $result->output, qr/$mountpoint2_valid/, "output data does not have $mountpoint2_valid in it"); | 348 | unlike( $result->output, qr/$mountpoint2_valid/, "output data does not have $mountpoint2_valid in it"); |
349 | 349 | ||
350 | # ignore: test if all pathes are listed when ignore regex doesn't match | 350 | # ignore: test if all paths are listed when ignore regex doesn't match |
351 | $result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p $mountpoint_valid -p $mountpoint2_valid -i '^barbazJodsf\$'"); | 351 | $result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p $mountpoint_valid -p $mountpoint2_valid -i '^barbazJodsf\$'"); |
352 | like( $result->output, qr/$mountpoint_valid/, "ignore: output data does have $mountpoint_valid when regex doesn't match"); | 352 | like( $result->output, qr/$mountpoint_valid/, "ignore: output data does have $mountpoint_valid when regex doesn't match"); |
353 | like( $result->output, qr/$mountpoint2_valid/,"ignore: output data does have $mountpoint2_valid when regex doesn't match"); | 353 | like( $result->output, qr/$mountpoint2_valid/,"ignore: output data does have $mountpoint2_valid when regex doesn't match"); |
354 | |||
355 | # ignore-missing: exit okay, when fs is not accessible | ||
356 | $result = NPTest->testCmd( "./check_disk --ignore-missing -w 0% -c 0% -p /bob"); | ||
357 | cmp_ok( $result->return_code, '==', 0, "ignore-missing: return okay for not existing filesystem /bob"); | ||
358 | like( $result->output, '/^DISK OK - No disks were found for provided parameters; - ignored paths: /bob;.*$/', 'Output OK'); | ||
359 | |||
360 | # ignore-missing: exit okay, when regex does not match | ||
361 | $result = NPTest->testCmd( "./check_disk --ignore-missing -w 0% -c 0% -r /bob"); | ||
362 | cmp_ok( $result->return_code, '==', 0, "ignore-missing: return okay for regular expression not matching"); | ||
363 | like( $result->output, '/^DISK OK - No disks were found for provided parameters;.*$/', 'Output OK'); | ||
364 | |||
365 | # ignore-missing: exit okay, when fs with exact match (-E) is not found | ||
366 | $result = NPTest->testCmd( "./check_disk --ignore-missing -w 0% -c 0% -E -p /etc"); | ||
367 | cmp_ok( $result->return_code, '==', 0, "ignore-missing: return okay when exact match does not find fs"); | ||
368 | like( $result->output, '/^DISK OK - No disks were found for provided parameters; - ignored paths: /etc;.*$/', 'Output OK'); | ||
369 | |||
370 | # ignore-missing: exit okay, when checking one existing fs and one non-existing fs (regex) | ||
371 | $result = NPTest->testCmd( "./check_disk --ignore-missing -w 0% -c 0% -r '/bob' -r '^/\$'"); | ||
372 | cmp_ok( $result->return_code, '==', 0, "ignore-missing: return okay for regular expression not matching"); | ||
373 | like( $result->output, '/^DISK OK - free space: \/ .*$/', 'Output OK'); | ||
374 | |||
375 | # ignore-missing: exit okay, when checking one existing fs and one non-existing fs (path) | ||
376 | $result = NPTest->testCmd( "./check_disk --ignore-missing -w 0% -c 0% -p '/bob' -p '/'"); | ||
377 | cmp_ok( $result->return_code, '==', 0, "ignore-missing: return okay for regular expression not matching"); | ||
378 | like( $result->output, '/^DISK OK - free space: / .*; - ignored paths: /bob;.*$/', 'Output OK'); \ No newline at end of file | ||
diff --git a/plugins/t/check_http.t b/plugins/t/check_http.t index c137f7b..1f2fbdf 100644 --- a/plugins/t/check_http.t +++ b/plugins/t/check_http.t | |||
@@ -9,7 +9,7 @@ use Test::More; | |||
9 | use POSIX qw/mktime strftime/; | 9 | use POSIX qw/mktime strftime/; |
10 | use NPTest; | 10 | use NPTest; |
11 | 11 | ||
12 | plan tests => 50; | 12 | plan tests => 49; |
13 | 13 | ||
14 | my $successOutput = '/OK.*HTTP.*second/'; | 14 | my $successOutput = '/OK.*HTTP.*second/'; |
15 | 15 | ||
@@ -103,7 +103,7 @@ SKIP: { | |||
103 | cmp_ok( $res->return_code, "==", 0, "And also when not found"); | 103 | cmp_ok( $res->return_code, "==", 0, "And also when not found"); |
104 | } | 104 | } |
105 | SKIP: { | 105 | SKIP: { |
106 | skip "No internet access", 23 if $internet_access eq "no"; | 106 | skip "No internet access", 22 if $internet_access eq "no"; |
107 | 107 | ||
108 | $res = NPTest->testCmd( | 108 | $res = NPTest->testCmd( |
109 | "./$plugin --ssl $host_tls_http" | 109 | "./$plugin --ssl $host_tls_http" |
@@ -166,12 +166,6 @@ SKIP: { | |||
166 | like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' ); | 166 | like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' ); |
167 | like ( $res->output, '/time_ssl=[\d\.]+/', 'Extended Performance Data SSL Output OK' ); | 167 | like ( $res->output, '/time_ssl=[\d\.]+/', 'Extended Performance Data SSL Output OK' ); |
168 | 168 | ||
169 | $res = NPTest->testCmd( | ||
170 | "./$plugin --ssl -H www.e-paycobalt.com" | ||
171 | ); | ||
172 | cmp_ok( $res->return_code, "==", 0, "Can read https for www.e-paycobalt.com (uses AES certificate)" ); | ||
173 | |||
174 | |||
175 | $res = NPTest->testCmd( "./$plugin -H www.mozilla.com -u /firefox -f follow" ); | 169 | $res = NPTest->testCmd( "./$plugin -H www.mozilla.com -u /firefox -f follow" ); |
176 | is( $res->return_code, 0, "Redirection based on location is okay"); | 170 | is( $res->return_code, 0, "Redirection based on location is okay"); |
177 | 171 | ||
@@ -184,13 +178,13 @@ SKIP: { | |||
184 | 178 | ||
185 | $res = NPTest->testCmd( "./$plugin -I $host_tcp_proxy -p $port_tcp_proxy -u http://$host_tcp_http -e 200,301,302"); | 179 | $res = NPTest->testCmd( "./$plugin -I $host_tcp_proxy -p $port_tcp_proxy -u http://$host_tcp_http -e 200,301,302"); |
186 | is( $res->return_code, 0, "Proxy HTTP works"); | 180 | is( $res->return_code, 0, "Proxy HTTP works"); |
187 | like($res->output, qr/OK: Status line output matched/, "Proxy HTTP Output is sufficent"); | 181 | like($res->output, qr/OK: Status line output matched/, "Proxy HTTP Output is sufficient"); |
188 | 182 | ||
189 | $res = NPTest->testCmd( "./$plugin -I $host_tcp_proxy -p $port_tcp_proxy -H $host_tls_http -S -j CONNECT"); | 183 | $res = NPTest->testCmd( "./$plugin -I $host_tcp_proxy -p $port_tcp_proxy -H $host_tls_http -S -j CONNECT"); |
190 | is( $res->return_code, 0, "Proxy HTTP CONNECT works"); | 184 | is( $res->return_code, 0, "Proxy HTTP CONNECT works"); |
191 | like($res->output, qr/HTTP OK:/, "Proxy HTTP CONNECT output sufficent"); | 185 | like($res->output, qr/HTTP OK:/, "Proxy HTTP CONNECT output sufficient"); |
192 | 186 | ||
193 | $res = NPTest->testCmd( "./$plugin -I $host_tcp_proxy -p $port_tcp_proxy -H $host_tls_http -S -j CONNECT:HEAD"); | 187 | $res = NPTest->testCmd( "./$plugin -I $host_tcp_proxy -p $port_tcp_proxy -H $host_tls_http -S -j CONNECT:HEAD"); |
194 | is( $res->return_code, 0, "Proxy HTTP CONNECT works with override method"); | 188 | is( $res->return_code, 0, "Proxy HTTP CONNECT works with override method"); |
195 | like($res->output, qr/HTTP OK:/, "Proxy HTTP CONNECT output sufficent"); | 189 | like($res->output, qr/HTTP OK:/, "Proxy HTTP CONNECT output sufficient"); |
196 | } | 190 | } |
diff --git a/plugins/t/check_load.t b/plugins/t/check_load.t index 60837ef..bba8947 100644 --- a/plugins/t/check_load.t +++ b/plugins/t/check_load.t | |||
@@ -11,10 +11,12 @@ use NPTest; | |||
11 | my $res; | 11 | my $res; |
12 | 12 | ||
13 | my $loadValue = "[0-9]+\.?[0-9]+"; | 13 | my $loadValue = "[0-9]+\.?[0-9]+"; |
14 | my $successOutput = "/^LOAD OK - load average: $loadValue, $loadValue, $loadValue/"; | 14 | my $successOutput = "/^LOAD OK - total load average: $loadValue, $loadValue, $loadValue/"; |
15 | my $failureOutput = "/^LOAD CRITICAL - load average: $loadValue, $loadValue, $loadValue/"; | 15 | my $successScaledOutput = "/^LOAD OK - scaled load average: $loadValue, $loadValue, $loadValue - total load average: $loadValue, $loadValue, $loadValue/"; |
16 | my $failureOutput = "/^LOAD CRITICAL - total load average: $loadValue, $loadValue, $loadValue/"; | ||
17 | my $failurScaledOutput = "/^LOAD CRITICAL - scaled load average: $loadValue, $loadValue, $loadValue - total load average: $loadValue, $loadValue, $loadValue/"; | ||
16 | 18 | ||
17 | plan tests => 11; | 19 | plan tests => 13; |
18 | 20 | ||
19 | $res = NPTest->testCmd( "./check_load -w 100,100,100 -c 100,100,100" ); | 21 | $res = NPTest->testCmd( "./check_load -w 100,100,100 -c 100,100,100" ); |
20 | cmp_ok( $res->return_code, 'eq', 0, "load not over 100"); | 22 | cmp_ok( $res->return_code, 'eq', 0, "load not over 100"); |
@@ -26,7 +28,7 @@ like( $res->output, $failureOutput, "Output OK"); | |||
26 | 28 | ||
27 | $res = NPTest->testCmd( "./check_load -r -w 0,0,0 -c 0,0,0" ); | 29 | $res = NPTest->testCmd( "./check_load -r -w 0,0,0 -c 0,0,0" ); |
28 | cmp_ok( $res->return_code, 'eq', 2, "Load over 0 with per cpu division"); | 30 | cmp_ok( $res->return_code, 'eq', 2, "Load over 0 with per cpu division"); |
29 | like( $res->output, $failureOutput, "Output OK"); | 31 | like( $res->output, $failurScaledOutput, "Output OK"); |
30 | 32 | ||
31 | $res = NPTest->testCmd( "./check_load -w 100 -c 100,110" ); | 33 | $res = NPTest->testCmd( "./check_load -w 100 -c 100,110" ); |
32 | cmp_ok( $res->return_code, 'eq', 0, "Plugin can handle non-triplet-arguments"); | 34 | cmp_ok( $res->return_code, 'eq', 0, "Plugin can handle non-triplet-arguments"); |
@@ -34,3 +36,8 @@ like( $res->output, $successOutput, "Output OK"); | |||
34 | like( $res->perf_output, "/load1=$loadValue;100.000;100.000/", "Test handling of non triplet thresholds (load1)"); | 36 | like( $res->perf_output, "/load1=$loadValue;100.000;100.000/", "Test handling of non triplet thresholds (load1)"); |
35 | like( $res->perf_output, "/load5=$loadValue;100.000;110.000/", "Test handling of non triplet thresholds (load5)"); | 37 | like( $res->perf_output, "/load5=$loadValue;100.000;110.000/", "Test handling of non triplet thresholds (load5)"); |
36 | like( $res->perf_output, "/load15=$loadValue;100.000;110.000/", "Test handling of non triplet thresholds (load15)"); | 38 | like( $res->perf_output, "/load15=$loadValue;100.000;110.000/", "Test handling of non triplet thresholds (load15)"); |
39 | |||
40 | |||
41 | $res = NPTest->testCmd( "./check_load -w 100,100,100 -c 100,100,100 -r" ); | ||
42 | cmp_ok( $res->return_code, 'eq', 0, "load not over 100"); | ||
43 | like( $res->output, $successScaledOutput, "Output OK"); | ||
diff --git a/plugins/t/check_mysql.t b/plugins/t/check_mysql.t index e426bf5..baf3acc 100644 --- a/plugins/t/check_mysql.t +++ b/plugins/t/check_mysql.t | |||
@@ -5,7 +5,7 @@ | |||
5 | # | 5 | # |
6 | # | 6 | # |
7 | # These are the database permissions required for this test: | 7 | # These are the database permissions required for this test: |
8 | # GRANT SELECT ON $db.* TO $user@$host INDENTIFIED BY '$password'; | 8 | # GRANT SELECT ON $db.* TO $user@$host IDENTIFIED BY '$password'; |
9 | # GRANT SUPER, REPLICATION CLIENT ON *.* TO $user@$host; | 9 | # GRANT SUPER, REPLICATION CLIENT ON *.* TO $user@$host; |
10 | # Check with: | 10 | # Check with: |
11 | # mysql -u$user -p$password -h$host $db | 11 | # mysql -u$user -p$password -h$host $db |
@@ -23,9 +23,9 @@ plan tests => 15; | |||
23 | my $bad_login_output = '/Access denied for user /'; | 23 | my $bad_login_output = '/Access denied for user /'; |
24 | my $mysqlserver = getTestParameter("NP_MYSQL_SERVER", "A MySQL Server hostname or IP with no slaves setup"); | 24 | my $mysqlserver = getTestParameter("NP_MYSQL_SERVER", "A MySQL Server hostname or IP with no slaves setup"); |
25 | my $mysqlsocket = getTestParameter("NP_MYSQL_SOCKET", "Full path to a MySQL Server socket with no slaves setup"); | 25 | my $mysqlsocket = getTestParameter("NP_MYSQL_SOCKET", "Full path to a MySQL Server socket with no slaves setup"); |
26 | my $mysql_login_details = getTestParameter("NP_MYSQL_LOGIN_DETAILS", "Command line parameters to specify login access (requires REPLICATION CLIENT privleges)", "-u test -ptest"); | 26 | my $mysql_login_details = getTestParameter("NP_MYSQL_LOGIN_DETAILS", "Command line parameters to specify login access (requires REPLICATION CLIENT privileges)", "-u test -ptest"); |
27 | my $with_slave = getTestParameter("NP_MYSQL_WITH_SLAVE", "MySQL server with slaves setup"); | 27 | my $with_slave = getTestParameter("NP_MYSQL_WITH_SLAVE", "MySQL server with slaves setup"); |
28 | my $with_slave_login = getTestParameter("NP_MYSQL_WITH_SLAVE_LOGIN", "Login details for server with slave (requires REPLICATION CLIENT privleges)", $mysql_login_details || "-u test -ptest"); | 28 | my $with_slave_login = getTestParameter("NP_MYSQL_WITH_SLAVE_LOGIN", "Login details for server with slave (requires REPLICATION CLIENT privileges)", $mysql_login_details || "-u test -ptest"); |
29 | 29 | ||
30 | my $result; | 30 | my $result; |
31 | 31 | ||
diff --git a/plugins/t/check_mysql_query.t b/plugins/t/check_mysql_query.t index 96899ac..c30245b 100644 --- a/plugins/t/check_mysql_query.t +++ b/plugins/t/check_mysql_query.t | |||
@@ -31,7 +31,7 @@ $result = NPTest->testCmd("./check_mysql_query -q 'SELECT 1+1' -H $mysqlserver $ | |||
31 | cmp_ok( $result->return_code, '==', 0, "Can run query"); | 31 | cmp_ok( $result->return_code, '==', 0, "Can run query"); |
32 | 32 | ||
33 | $result = NPTest->testCmd("./check_mysql_query -H $mysqlserver $mysql_login_details"); | 33 | $result = NPTest->testCmd("./check_mysql_query -H $mysqlserver $mysql_login_details"); |
34 | cmp_ok( $result->return_code, '==', 3, "Missing query parmeter"); | 34 | cmp_ok( $result->return_code, '==', 3, "Missing query parameter"); |
35 | like( $result->output, "/Must specify a SQL query to run/", "Missing query error message"); | 35 | like( $result->output, "/Must specify a SQL query to run/", "Missing query error message"); |
36 | 36 | ||
37 | $result = NPTest->testCmd("./check_mysql_query -q 'SELECT 1+1' -H $mysqlserver -u dummy -d mysql"); | 37 | $result = NPTest->testCmd("./check_mysql_query -q 'SELECT 1+1' -H $mysqlserver -u dummy -d mysql"); |
diff --git a/plugins/t/check_nagios.t b/plugins/t/check_nagios.t index 81fc24d..f38f5e9 100644 --- a/plugins/t/check_nagios.t +++ b/plugins/t/check_nagios.t | |||
@@ -36,7 +36,7 @@ cmp_ok( $result->return_code, '==', 1, "Log over 5 minutes old" ); | |||
36 | like ( $result->output, $warningOutput, "Output for warning correct" ); | 36 | like ( $result->output, $warningOutput, "Output for warning correct" ); |
37 | 37 | ||
38 | my $now = time; | 38 | my $now = time; |
39 | # This substitution is dependant on the testcase | 39 | # This substitution is dependent on the testcase |
40 | system( "perl -pe 's/1133537544/$now/' $nagios1 > $nagios1.tmp" ) == 0 or die "Problem with munging $nagios1"; | 40 | system( "perl -pe 's/1133537544/$now/' $nagios1 > $nagios1.tmp" ) == 0 or die "Problem with munging $nagios1"; |
41 | 41 | ||
42 | $result = NPTest->testCmd( | 42 | $result = NPTest->testCmd( |
diff --git a/plugins/t/check_smtp.t b/plugins/t/check_smtp.t index aa6dae4..1a1ebe3 100644 --- a/plugins/t/check_smtp.t +++ b/plugins/t/check_smtp.t | |||
@@ -8,12 +8,14 @@ use strict; | |||
8 | use Test::More; | 8 | use Test::More; |
9 | use NPTest; | 9 | use NPTest; |
10 | 10 | ||
11 | my $host_tcp_smtp = getTestParameter( "NP_HOST_TCP_SMTP", | 11 | my $host_tcp_smtp = getTestParameter( "NP_HOST_TCP_SMTP", |
12 | "A host providing an SMTP Service (a mail server)", "mailhost"); | 12 | "A host providing an SMTP Service (a mail server)", "mailhost"); |
13 | my $host_tcp_smtp_tls = getTestParameter( "NP_HOST_TCP_SMTP_TLS", | 13 | my $host_tcp_smtp_starttls = getTestParameter( "NP_HOST_TCP_SMTP_STARTTLS", |
14 | "A host providing SMTP with STARTTLS", $host_tcp_smtp); | ||
15 | my $host_tcp_smtp_nostarttls = getTestParameter( "NP_HOST_TCP_SMTP_NOSTARTTLS", | ||
16 | "A host providing SMTP without STARTTLS", ""); | ||
17 | my $host_tcp_smtp_tls = getTestParameter( "NP_HOST_TCP_SMTP_TLS", | ||
14 | "A host providing SMTP with TLS", $host_tcp_smtp); | 18 | "A host providing SMTP with TLS", $host_tcp_smtp); |
15 | my $host_tcp_smtp_notls = getTestParameter( "NP_HOST_TCP_SMTP_NOTLS", | ||
16 | "A host providing SMTP without TLS", ""); | ||
17 | 19 | ||
18 | my $host_nonresponsive = getTestParameter( "NP_HOST_NONRESPONSIVE", | 20 | my $host_nonresponsive = getTestParameter( "NP_HOST_NONRESPONSIVE", |
19 | "The hostname of system not responsive to network requests", "10.0.0.1" ); | 21 | "The hostname of system not responsive to network requests", "10.0.0.1" ); |
@@ -22,7 +24,7 @@ my $hostname_invalid = getTestParameter( "NP_HOSTNAME_INVALID", | |||
22 | "An invalid (not known to DNS) hostname", "nosuchhost" ); | 24 | "An invalid (not known to DNS) hostname", "nosuchhost" ); |
23 | my $res; | 25 | my $res; |
24 | 26 | ||
25 | plan tests => 10; | 27 | plan tests => 16; |
26 | 28 | ||
27 | SKIP: { | 29 | SKIP: { |
28 | skip "No SMTP server defined", 4 unless $host_tcp_smtp; | 30 | skip "No SMTP server defined", 4 unless $host_tcp_smtp; |
@@ -42,22 +44,38 @@ SKIP: { | |||
42 | local $TODO = "Output is over two lines"; | 44 | local $TODO = "Output is over two lines"; |
43 | like ( $res->output, qr/^SMTP WARNING/, "Correct error message" ); | 45 | like ( $res->output, qr/^SMTP WARNING/, "Correct error message" ); |
44 | } | 46 | } |
47 | |||
48 | $res = NPTest->testCmd( "./check_smtp -H $host_tcp_smtp --ssl -p 25" ); | ||
49 | is ($res->return_code, 2, "Check rc of connecting to $host_tcp_smtp with TLS on standard SMTP port" ); | ||
50 | like ($res->output, qr/^CRITICAL - Cannot make SSL connection\./, "Check output of connecting to $host_tcp_smtp with TLS on standard SMTP port"); | ||
45 | } | 51 | } |
46 | 52 | ||
47 | SKIP: { | 53 | SKIP: { |
48 | skip "No SMTP server with TLS defined", 1 unless $host_tcp_smtp_tls; | 54 | skip "No SMTP server with STARTTLS defined", 1 unless $host_tcp_smtp_starttls; |
49 | # SSL connection for TLS | 55 | # SSL connection for STARTTLS |
50 | $res = NPTest->testCmd( "./check_smtp -H $host_tcp_smtp_tls -p 25 -S" ); | 56 | $res = NPTest->testCmd( "./check_smtp -H $host_tcp_smtp_starttls -p 25 -S" ); |
51 | is ($res->return_code, 0, "OK, with STARTTLS" ); | 57 | is ($res->return_code, 0, "OK, with STARTTLS" ); |
52 | } | 58 | } |
53 | 59 | ||
54 | SKIP: { | 60 | SKIP: { |
55 | skip "No SMTP server without TLS defined", 2 unless $host_tcp_smtp_notls; | 61 | skip "No SMTP server without STARTTLS defined", 2 unless $host_tcp_smtp_nostarttls; |
56 | $res = NPTest->testCmd( "./check_smtp -H $host_tcp_smtp_notls -p 25 -S" ); | 62 | $res = NPTest->testCmd( "./check_smtp -H $host_tcp_smtp_nostarttls -p 25 -S" ); |
57 | is ($res->return_code, 1, "OK, got warning from server without TLS"); | 63 | is ($res->return_code, 1, "OK, got warning from server without STARTTLS"); |
58 | is ($res->output, "WARNING - TLS not supported by server", "Right error message" ); | 64 | is ($res->output, "WARNING - TLS not supported by server", "Right error message" ); |
59 | } | 65 | } |
60 | 66 | ||
67 | SKIP: { | ||
68 | skip "No SMTP server with TLS defined", 1 unless $host_tcp_smtp_tls; | ||
69 | $res = NPTest->testCmd( "./check_smtp -H $host_tcp_smtp_tls --ssl" ); | ||
70 | is ($res->return_code, 0, "Check rc of connecting to $host_tcp_smtp_tls with TLS" ); | ||
71 | like ($res->output, qr/^SMTP OK - /, "Check output of connecting to $host_tcp_smtp_tls with TLS" ); | ||
72 | |||
73 | my $unused_port = 4465; | ||
74 | $res = NPTest->testCmd( "./check_smtp -H $host_tcp_smtp_tls -p $unused_port --ssl" ); | ||
75 | is ($res->return_code, 2, "Check rc of connecting to $host_tcp_smtp_tls with TLS on unused port $unused_port" ); | ||
76 | like ($res->output, qr/^connect to address $host_tcp_smtp_tls and port $unused_port: Connection refused/, "Check output of connecting to $host_tcp_smtp_tls with TLS on unused port $unused_port"); | ||
77 | } | ||
78 | |||
61 | $res = NPTest->testCmd( "./check_smtp $host_nonresponsive" ); | 79 | $res = NPTest->testCmd( "./check_smtp $host_nonresponsive" ); |
62 | is ($res->return_code, 2, "CRITICAL - host non responding" ); | 80 | is ($res->return_code, 2, "CRITICAL - host non responding" ); |
63 | 81 | ||
diff --git a/plugins/t/check_snmp.t b/plugins/t/check_snmp.t index f2f218f..576cc50 100644 --- a/plugins/t/check_snmp.t +++ b/plugins/t/check_snmp.t | |||
@@ -26,22 +26,22 @@ $res = NPTest->testCmd( "./check_snmp -t 1" ); | |||
26 | is( $res->return_code, 3, "No host name" ); | 26 | is( $res->return_code, 3, "No host name" ); |
27 | is( $res->output, "No host specified" ); | 27 | is( $res->output, "No host specified" ); |
28 | 28 | ||
29 | $res = NPTest->testCmd( "./check_snmp -H fakehostname" ); | 29 | $res = NPTest->testCmd( "./check_snmp -H fakehostname --ignore-mib-parsing-errors" ); |
30 | is( $res->return_code, 3, "No OIDs specified" ); | 30 | is( $res->return_code, 3, "No OIDs specified" ); |
31 | is( $res->output, "No OIDs specified" ); | 31 | is( $res->output, "No OIDs specified" ); |
32 | 32 | ||
33 | $res = NPTest->testCmd( "./check_snmp -H fakehost -o oids -P 3 -U not_a_user --seclevel=rubbish" ); | 33 | $res = NPTest->testCmd( "./check_snmp -H fakehost --ignore-mib-parsing-errors -o oids -P 3 -U not_a_user --seclevel=rubbish" ); |
34 | is( $res->return_code, 3, "Invalid seclevel" ); | 34 | is( $res->return_code, 3, "Invalid seclevel" ); |
35 | like( $res->output, "/check_snmp: Invalid seclevel - rubbish/" ); | 35 | like( $res->output, "/check_snmp: Invalid seclevel - rubbish/" ); |
36 | 36 | ||
37 | $res = NPTest->testCmd( "./check_snmp -H fakehost -o oids -P 3c" ); | 37 | $res = NPTest->testCmd( "./check_snmp -H fakehost --ignore-mib-parsing-errors -o oids -P 3c" ); |
38 | is( $res->return_code, 3, "Invalid protocol" ); | 38 | is( $res->return_code, 3, "Invalid protocol" ); |
39 | like( $res->output, "/check_snmp: Invalid SNMP version - 3c/" ); | 39 | like( $res->output, "/check_snmp: Invalid SNMP version - 3c/" ); |
40 | 40 | ||
41 | SKIP: { | 41 | SKIP: { |
42 | skip "no snmp host defined", 50 if ( ! $host_snmp ); | 42 | skip "no snmp host defined", 50 if ( ! $host_snmp ); |
43 | 43 | ||
44 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0 -w 1: -c 1:"); | 44 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o system.sysUpTime.0 -w 1: -c 1:"); |
45 | cmp_ok( $res->return_code, '==', 0, "Exit OK when querying uptime" ); | 45 | cmp_ok( $res->return_code, '==', 0, "Exit OK when querying uptime" ); |
46 | like($res->output, '/^SNMP OK - (\d+)/', "String contains SNMP OK"); | 46 | like($res->output, '/^SNMP OK - (\d+)/', "String contains SNMP OK"); |
47 | $res->output =~ /^SNMP OK - (\d+)/; | 47 | $res->output =~ /^SNMP OK - (\d+)/; |
@@ -51,111 +51,111 @@ SKIP: { | |||
51 | 51 | ||
52 | 52 | ||
53 | # some more threshold tests | 53 | # some more threshold tests |
54 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0 -c 1"); | 54 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o system.sysUpTime.0 -c 1"); |
55 | cmp_ok( $res->return_code, '==', 2, "Threshold test -c 1" ); | 55 | cmp_ok( $res->return_code, '==', 2, "Threshold test -c 1" ); |
56 | 56 | ||
57 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0 -c 1:"); | 57 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o system.sysUpTime.0 -c 1:"); |
58 | cmp_ok( $res->return_code, '==', 0, "Threshold test -c 1:" ); | 58 | cmp_ok( $res->return_code, '==', 0, "Threshold test -c 1:" ); |
59 | 59 | ||
60 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0 -c ~:1"); | 60 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o system.sysUpTime.0 -c ~:1"); |
61 | cmp_ok( $res->return_code, '==', 2, "Threshold test -c ~:1" ); | 61 | cmp_ok( $res->return_code, '==', 2, "Threshold test -c ~:1" ); |
62 | 62 | ||
63 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0 -c 1:10"); | 63 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o system.sysUpTime.0 -c 1:10"); |
64 | cmp_ok( $res->return_code, '==', 2, "Threshold test -c 1:10" ); | 64 | cmp_ok( $res->return_code, '==', 2, "Threshold test -c 1:10" ); |
65 | 65 | ||
66 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0 -c \@1:10"); | 66 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o system.sysUpTime.0 -c \@1:10"); |
67 | cmp_ok( $res->return_code, '==', 0, "Threshold test -c \@1:10" ); | 67 | cmp_ok( $res->return_code, '==', 0, "Threshold test -c \@1:10" ); |
68 | 68 | ||
69 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0 -c 10:1"); | 69 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o system.sysUpTime.0 -c 10:1"); |
70 | cmp_ok( $res->return_code, '==', 0, "Threshold test -c 10:1" ); | 70 | cmp_ok( $res->return_code, '==', 0, "Threshold test -c 10:1" ); |
71 | 71 | ||
72 | 72 | ||
73 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o .1.3.6.1.2.1.1.3.0 -w 1: -c 1:"); | 73 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o .1.3.6.1.2.1.1.3.0 -w 1: -c 1:"); |
74 | cmp_ok( $res->return_code, '==', 0, "Test with numeric OID (no mibs loaded)" ); | 74 | cmp_ok( $res->return_code, '==', 0, "Test with numeric OID (no mibs loaded)" ); |
75 | like($res->output, '/^SNMP OK - \d+/', "String contains SNMP OK"); | 75 | like($res->output, '/^SNMP OK - \d+/', "String contains SNMP OK"); |
76 | 76 | ||
77 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysDescr.0"); | 77 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o system.sysDescr.0"); |
78 | cmp_ok( $res->return_code, '==', 0, "Exit OK when querying sysDescr" ); | 78 | cmp_ok( $res->return_code, '==', 0, "Exit OK when querying sysDescr" ); |
79 | unlike($res->perf_output, '/sysDescr/', "Perfdata doesn't contain string values"); | 79 | unlike($res->perf_output, '/sysDescr/', "Perfdata doesn't contain string values"); |
80 | 80 | ||
81 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysDescr.0,system.sysDescr.0"); | 81 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o system.sysDescr.0,system.sysDescr.0"); |
82 | cmp_ok( $res->return_code, '==', 0, "Exit OK when querying two string OIDs, comma-separated" ); | 82 | cmp_ok( $res->return_code, '==', 0, "Exit OK when querying two string OIDs, comma-separated" ); |
83 | like($res->output, '/^SNMP OK - /', "String contains SNMP OK"); | 83 | like($res->output, '/^SNMP OK - /', "String contains SNMP OK"); |
84 | 84 | ||
85 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysDescr.0 -o system.sysDescr.0"); | 85 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o system.sysDescr.0 -o system.sysDescr.0"); |
86 | cmp_ok( $res->return_code, '==', 0, "Exit OK when querying two string OIDs, repeated option" ); | 86 | cmp_ok( $res->return_code, '==', 0, "Exit OK when querying two string OIDs, repeated option" ); |
87 | like($res->output, '/^SNMP OK - /', "String contains SNMP OK"); | 87 | like($res->output, '/^SNMP OK - /', "String contains SNMP OK"); |
88 | 88 | ||
89 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w 1:1 -c 1:1"); | 89 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w 1:1 -c 1:1"); |
90 | cmp_ok( $res->return_code, '==', 0, "Exit OK when querying hrSWRunIndex.1" ); | 90 | cmp_ok( $res->return_code, '==', 0, "Exit OK when querying hrSWRunIndex.1" ); |
91 | like($res->output, '/^SNMP OK - 1\s.*$/', "String fits SNMP OK and output format"); | 91 | like($res->output, '/^SNMP OK - 1\s.*$/', "String fits SNMP OK and output format"); |
92 | 92 | ||
93 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w 0 -c 1:"); | 93 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w 0 -c 1:"); |
94 | cmp_ok( $res->return_code, '==', 1, "Exit WARNING when querying hrSWRunIndex.1 and warn-th doesn't apply " ); | 94 | cmp_ok( $res->return_code, '==', 1, "Exit WARNING when querying hrSWRunIndex.1 and warn-th doesn't apply " ); |
95 | like($res->output, '/^SNMP WARNING - \*1\*\s.*$/', "String matches SNMP WARNING and output format"); | 95 | like($res->output, '/^SNMP WARNING - \*1\*\s.*$/', "String matches SNMP WARNING and output format"); |
96 | 96 | ||
97 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w :0 -c 0"); | 97 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w :0 -c 0"); |
98 | cmp_ok( $res->return_code, '==', 2, "Exit CRITICAL when querying hrSWRunIndex.1 and crit-th doesn't apply" ); | 98 | cmp_ok( $res->return_code, '==', 2, "Exit CRITICAL when querying hrSWRunIndex.1 and crit-th doesn't apply" ); |
99 | like($res->output, '/^SNMP CRITICAL - \*1\*\s.*$/', "String matches SNMP CRITICAL and output format"); | 99 | like($res->output, '/^SNMP CRITICAL - \*1\*\s.*$/', "String matches SNMP CRITICAL and output format"); |
100 | 100 | ||
101 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o ifIndex.2,ifIndex.1 -w 1:2 -c 1:2"); | 101 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o ifIndex.2,ifIndex.1 -w 1:2 -c 1:2"); |
102 | cmp_ok( $res->return_code, '==', 0, "Checking two OIDs at once" ); | 102 | cmp_ok( $res->return_code, '==', 0, "Checking two OIDs at once" ); |
103 | like($res->output, "/^SNMP OK - 2 1/", "Got two values back" ); | 103 | like($res->output, "/^SNMP OK - 2 1/", "Got two values back" ); |
104 | like( $res->perf_output, "/ifIndex.2=2/", "Got 1st perf data" ); | 104 | like( $res->perf_output, "/ifIndex.2=2/", "Got 1st perf data" ); |
105 | like( $res->perf_output, "/ifIndex.1=1/", "Got 2nd perf data" ); | 105 | like( $res->perf_output, "/ifIndex.1=1/", "Got 2nd perf data" ); |
106 | 106 | ||
107 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o ifIndex.2,ifIndex.1 -w 1:2,1:2 -c 2:2,2:2"); | 107 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o ifIndex.2,ifIndex.1 -w 1:2,1:2 -c 2:2,2:2"); |
108 | cmp_ok( $res->return_code, '==', 2, "Checking critical threshold is passed if any one value crosses" ); | 108 | cmp_ok( $res->return_code, '==', 2, "Checking critical threshold is passed if any one value crosses" ); |
109 | like($res->output, "/^SNMP CRITICAL - 2 *1*/", "Got two values back" ); | 109 | like($res->output, "/^SNMP CRITICAL - 2 *1*/", "Got two values back" ); |
110 | like( $res->perf_output, "/ifIndex.2=2/", "Got 1st perf data" ); | 110 | like( $res->perf_output, "/ifIndex.2=2/", "Got 1st perf data" ); |
111 | like( $res->perf_output, "/ifIndex.1=1/", "Got 2nd perf data" ); | 111 | like( $res->perf_output, "/ifIndex.1=1/", "Got 2nd perf data" ); |
112 | 112 | ||
113 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o host.hrStorage.hrMemorySize.0,host.hrSystem.hrSystemProcesses.0 -w 1:,1: -c 1:,1:"); | 113 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o host.hrStorage.hrMemorySize.0,host.hrSystem.hrSystemProcesses.0 -w 1:,1: -c 1:,1:"); |
114 | cmp_ok( $res->return_code, '==', 0, "Exit OK when querying hrMemorySize and hrSystemProcesses"); | 114 | cmp_ok( $res->return_code, '==', 0, "Exit OK when querying hrMemorySize and hrSystemProcesses"); |
115 | like($res->output, '/^SNMP OK - \d+ \d+/', "String contains hrMemorySize and hrSystemProcesses"); | 115 | like($res->output, '/^SNMP OK - \d+ \d+/', "String contains hrMemorySize and hrSystemProcesses"); |
116 | 116 | ||
117 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w \@:0 -c \@0"); | 117 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w \@:0 -c \@0"); |
118 | cmp_ok( $res->return_code, '==', 0, "Exit OK with inside-range thresholds"); | 118 | cmp_ok( $res->return_code, '==', 0, "Exit OK with inside-range thresholds"); |
119 | like($res->output, '/^SNMP OK - 1\s.*$/', "String matches SNMP OK and output format"); | 119 | like($res->output, '/^SNMP OK - 1\s.*$/', "String matches SNMP OK and output format"); |
120 | 120 | ||
121 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o enterprises.ucdavis.laTable.laEntry.laLoad.3"); | 121 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o enterprises.ucdavis.laTable.laEntry.laLoad.3"); |
122 | $res->output =~ m/^SNMP OK - (\d+\.\d{2})\s.*$/; | 122 | $res->output =~ m/^SNMP OK - (\d+\.\d{2})\s.*$/; |
123 | my $lower = $1 - 0.05; | 123 | my $lower = $1 - 0.05; |
124 | my $higher = $1 + 0.05; | 124 | my $higher = $1 + 0.05; |
125 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o enterprises.ucdavis.laTable.laEntry.laLoad.3 -w $lower -c $higher"); | 125 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o enterprises.ucdavis.laTable.laEntry.laLoad.3 -w $lower -c $higher"); |
126 | cmp_ok( $res->return_code, '==', 1, "Exit WARNING with fractionnal arguments"); | 126 | cmp_ok( $res->return_code, '==', 1, "Exit WARNING with fractionnal arguments"); |
127 | 127 | ||
128 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0,host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w ,:0 -c ,:2"); | 128 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o system.sysUpTime.0,host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w ,:0 -c ,:2"); |
129 | cmp_ok( $res->return_code, '==', 1, "Exit WARNING on 2nd threshold"); | 129 | cmp_ok( $res->return_code, '==', 1, "Exit WARNING on 2nd threshold"); |
130 | like($res->output, '/^SNMP WARNING - Timeticks:\s\(\d+\)\s+(?:\d+ days?,\s+)?\d+:\d+:\d+\.\d+\s+\*1\*\s.*$/', "First OID returned as string, 2nd checked for thresholds"); | 130 | like($res->output, '/^SNMP WARNING - Timeticks:\s\(\d+\)\s+(?:\d+ days?,\s+)?\d+:\d+:\d+\.\d+\s+\*1\*\s.*$/', "First OID returned as string, 2nd checked for thresholds"); |
131 | 131 | ||
132 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w '' -c ''"); | 132 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w '' -c ''"); |
133 | cmp_ok( $res->return_code, '==', 0, "Empty thresholds doesn't crash"); | 133 | cmp_ok( $res->return_code, '==', 0, "Empty thresholds doesn't crash"); |
134 | 134 | ||
135 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o host.hrStorage.hrMemorySize.0,host.hrSystem.hrSystemProcesses.0 -w ,,1 -c ,,2"); | 135 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o host.hrStorage.hrMemorySize.0,host.hrSystem.hrSystemProcesses.0 -w ,,1 -c ,,2"); |
136 | cmp_ok( $res->return_code, '==', 0, "Skipping first two thresholds on 2 OID check"); | 136 | cmp_ok( $res->return_code, '==', 0, "Skipping first two thresholds on 2 OID check"); |
137 | like($res->output, '/^SNMP OK - \d+ \w+ \d+\s.*$/', "Skipping first two thresholds, result printed rather than parsed"); | 137 | like($res->output, '/^SNMP OK - \d+ \w+ \d+\s.*$/', "Skipping first two thresholds, result printed rather than parsed"); |
138 | 138 | ||
139 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o host.hrStorage.hrMemorySize.0,host.hrSystem.hrSystemProcesses.0 -w ,, -c ,,"); | 139 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o host.hrStorage.hrMemorySize.0,host.hrSystem.hrSystemProcesses.0 -w ,, -c ,,"); |
140 | cmp_ok( $res->return_code, '==', 0, "Skipping all thresholds"); | 140 | cmp_ok( $res->return_code, '==', 0, "Skipping all thresholds"); |
141 | like($res->output, '/^SNMP OK - \d+ \w+ \d+\s.*$/', "Skipping all thresholds, result printed rather than parsed"); | 141 | like($res->output, '/^SNMP OK - \d+ \w+ \d+\s.*$/', "Skipping all thresholds, result printed rather than parsed"); |
142 | 142 | ||
143 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0 -c 1000000000000: -u '1/100 sec'"); | 143 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o system.sysUpTime.0 -c 1000000000000: -u '1/100 sec'"); |
144 | cmp_ok( $res->return_code, '==', 2, "Timetick used as a threshold"); | 144 | cmp_ok( $res->return_code, '==', 2, "Timetick used as a threshold"); |
145 | like($res->output, '/^SNMP CRITICAL - \*\d+\* 1\/100 sec.*$/', "Timetick used as a threshold, parsed as numeric"); | 145 | like($res->output, '/^SNMP CRITICAL - \*\d+\* 1\/100 sec.*$/', "Timetick used as a threshold, parsed as numeric"); |
146 | 146 | ||
147 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0"); | 147 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o system.sysUpTime.0"); |
148 | cmp_ok( $res->return_code, '==', 0, "Timetick used as a string"); | 148 | cmp_ok( $res->return_code, '==', 0, "Timetick used as a string"); |
149 | like($res->output, '/^SNMP OK - Timeticks:\s\(\d+\)\s+(?:\d+ days?,\s+)?\d+:\d+:\d+\.\d+\s.*$/', "Timetick used as a string, result printed rather than parsed"); | 149 | like($res->output, '/^SNMP OK - Timeticks:\s\(\d+\)\s+(?:\d+ days?,\s+)?\d+:\d+:\d+\.\d+\s.*$/', "Timetick used as a string, result printed rather than parsed"); |
150 | 150 | ||
151 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o HOST-RESOURCES-MIB::hrSWRunName.1"); | 151 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o HOST-RESOURCES-MIB::hrSWRunName.1"); |
152 | cmp_ok( $res->return_code, '==', 0, "snmp response without datatype"); | 152 | cmp_ok( $res->return_code, '==', 0, "snmp response without datatype"); |
153 | like( $res->output, '/^SNMP OK - "(systemd|init)" \| $/', "snmp response without datatype" ); | 153 | like( $res->output, '/^SNMP OK - "(systemd|init)" \| $/', "snmp response without datatype" ); |
154 | } | 154 | } |
155 | 155 | ||
156 | SKIP: { | 156 | SKIP: { |
157 | skip "no SNMP user defined", 1 if ( ! $user_snmp ); | 157 | skip "no SNMP user defined", 1 if ( ! $user_snmp ); |
158 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp -o HOST-RESOURCES-MIB::hrSystemUptime.0 -P 3 -U $user_snmp -L noAuthNoPriv"); | 158 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -o HOST-RESOURCES-MIB::hrSystemUptime.0 -P 3 -U $user_snmp -L noAuthNoPriv"); |
159 | like( $res->output, '/^SNMP OK - Timeticks:\s\(\d+\)\s+(?:\d+ days?,\s+)?\d+:\d+:\d+\.\d+\s.*$/', "noAuthNoPriv security level works properly" ); | 159 | like( $res->output, '/^SNMP OK - Timeticks:\s\(\d+\)\s+(?:\d+ days?,\s+)?\d+:\d+:\d+\.\d+\s.*$/', "noAuthNoPriv security level works properly" ); |
160 | } | 160 | } |
161 | 161 | ||
@@ -163,14 +163,14 @@ SKIP: { | |||
163 | # the tests can run on hosts w/o snmp host/community in NPTest.cache. Execution will fail anyway | 163 | # the tests can run on hosts w/o snmp host/community in NPTest.cache. Execution will fail anyway |
164 | SKIP: { | 164 | SKIP: { |
165 | skip "no non responsive host defined", 2 if ( ! $host_nonresponsive ); | 165 | skip "no non responsive host defined", 2 if ( ! $host_nonresponsive ); |
166 | $res = NPTest->testCmd( "./check_snmp -H $host_nonresponsive -C np_foobar -o system.sysUpTime.0 -w 1: -c 1:"); | 166 | $res = NPTest->testCmd( "./check_snmp -H $host_nonresponsive --ignore-mib-parsing-errors -C np_foobar -o system.sysUpTime.0 -w 1: -c 1:"); |
167 | cmp_ok( $res->return_code, '==', 2, "Exit CRITICAL with non responsive host" ); | 167 | cmp_ok( $res->return_code, '==', 2, "Exit CRITICAL with non responsive host" ); |
168 | like($res->output, '/Plugin timed out while executing system call/', "String matches timeout problem"); | 168 | like($res->output, '/Plugin timed out while executing system call/', "String matches timeout problem"); |
169 | } | 169 | } |
170 | 170 | ||
171 | SKIP: { | 171 | SKIP: { |
172 | skip "no non invalid host defined", 2 if ( ! $hostname_invalid ); | 172 | skip "no non invalid host defined", 2 if ( ! $hostname_invalid ); |
173 | $res = NPTest->testCmd( "./check_snmp -H $hostname_invalid -C np_foobar -o system.sysUpTime.0 -w 1: -c 1:"); | 173 | $res = NPTest->testCmd( "./check_snmp -H $hostname_invalid --ignore-mib-parsing-errors -C np_foobar -o system.sysUpTime.0 -w 1: -c 1:"); |
174 | cmp_ok( $res->return_code, '==', 3, "Exit UNKNOWN with non responsive host" ); | 174 | cmp_ok( $res->return_code, '==', 3, "Exit UNKNOWN with non responsive host" ); |
175 | like($res->output, '/External command error: .*(nosuchhost|Name or service not known|Unknown host)/', "String matches invalid host"); | 175 | like($res->output, '/External command error: .*(nosuchhost|Name or service not known|Unknown host).*/s', "String matches invalid host"); |
176 | } | 176 | } |
diff --git a/plugins/t/negate.t b/plugins/t/negate.t index d96a109..5ec1c84 100644 --- a/plugins/t/negate.t +++ b/plugins/t/negate.t | |||
@@ -84,7 +84,7 @@ foreach my $current_state (keys(%state)) { | |||
84 | foreach my $new_state (keys(%state)) { | 84 | foreach my $new_state (keys(%state)) { |
85 | $res = NPTest->testCmd( "./negate -s --$current_state=$new_state ./check_dummy ".$state{$current_state}." 'Fake $new_state'" ); | 85 | $res = NPTest->testCmd( "./negate -s --$current_state=$new_state ./check_dummy ".$state{$current_state}." 'Fake $new_state'" ); |
86 | is( $res->return_code, $state{$new_state}, "Got fake $new_state (with substitute)" ); | 86 | is( $res->return_code, $state{$new_state}, "Got fake $new_state (with substitute)" ); |
87 | is( $res->output, uc($new_state).": Fake $new_state", "Substitued fake $new_state output"); | 87 | is( $res->output, uc($new_state).": Fake $new_state", "Substituted fake $new_state output"); |
88 | } | 88 | } |
89 | } | 89 | } |
90 | 90 | ||