diff options
author | Lorenz <12514511+RincewindsHat@users.noreply.github.com> | 2023-03-10 10:33:25 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-10 10:33:25 (GMT) |
commit | 5077120a251980b4fafed61b4aa8fa5730a85443 (patch) | |
tree | 8500b8f5dbe774b399cfdc79f5665ba88ef7f255 /plugins/t | |
parent | a3de84594104ac87a91e200d569fb57edacca928 (diff) | |
parent | 269718094177fb8a7e3d3005d1310495009fe8c4 (diff) | |
download | monitoring-plugins-5077120a251980b4fafed61b4aa8fa5730a85443.tar.gz |
Merge branch 'master' into master
Diffstat (limited to 'plugins/t')
-rw-r--r-- | plugins/t/NPTest.cache.travis | 54 | ||||
-rw-r--r-- | plugins/t/check_curl.t | 58 | ||||
-rw-r--r-- | plugins/t/check_disk.t | 7 | ||||
-rw-r--r-- | plugins/t/check_dns.t | 10 | ||||
-rw-r--r-- | plugins/t/check_fping.t | 32 | ||||
-rw-r--r-- | plugins/t/check_http.t | 12 | ||||
-rw-r--r-- | plugins/t/check_load.t | 15 | ||||
-rw-r--r-- | plugins/t/check_swap.t | 6 |
8 files changed, 80 insertions, 114 deletions
diff --git a/plugins/t/NPTest.cache.travis b/plugins/t/NPTest.cache.travis deleted file mode 100644 index 9b9f805..0000000 --- a/plugins/t/NPTest.cache.travis +++ /dev/null | |||
@@ -1,54 +0,0 @@ | |||
1 | { | ||
2 | 'NP_ALLOW_SUDO' => 'yes', | ||
3 | 'NP_DNS_SERVER' => '8.8.8.8', | ||
4 | 'NP_GOOD_NTP_SERVICE' => '', | ||
5 | 'NP_HOST_DHCP_RESPONSIVE' => '', | ||
6 | 'NP_HOST_HPJD_PORT_INVALID' => '161', | ||
7 | 'NP_HOST_HPJD_PORT_VALID' => '', | ||
8 | 'NP_HOSTNAME_INVALID_CIDR' => '130.133.8.39/30', | ||
9 | 'NP_HOSTNAME_INVALID' => 'nosuchhost', | ||
10 | 'NP_HOSTNAME_VALID_CIDR' => '130.133.8.41/30', | ||
11 | 'NP_HOSTNAME_VALID_IP' => '130.133.8.40', | ||
12 | 'NP_HOSTNAME_VALID' => 'monitoring-plugins.org', | ||
13 | 'NP_HOSTNAME_VALID_REVERSE' => 'orwell.monitoring-plugins.org.', | ||
14 | 'NP_HOST_NONRESPONSIVE' => '10.0.0.1', | ||
15 | 'NP_HOST_RESPONSIVE' => 'localhost', | ||
16 | 'NP_HOST_SMB' => '', | ||
17 | 'NP_HOST_SNMP' => '', | ||
18 | 'NP_HOST_TCP_FTP' => '', | ||
19 | 'NP_HOST_TCP_HPJD' => '', | ||
20 | 'NP_HOST_TCP_HTTP2' => 'test.monitoring-plugins.org', | ||
21 | 'NP_HOST_TCP_HTTP' => 'localhost', | ||
22 | 'NP_HOST_TCP_IMAP' => 'imap.web.de', | ||
23 | 'NP_HOST_TCP_JABBER' => 'jabber.org', | ||
24 | 'NP_HOST_TCP_LDAP' => 'localhost', | ||
25 | 'NP_HOST_TCP_POP' => 'pop.web.de', | ||
26 | 'NP_HOST_TCP_PROXY' => 'localhost', | ||
27 | 'NP_HOST_TCP_SMTP' => 'localhost', | ||
28 | 'NP_HOST_TCP_SMTP_NOTLS' => '', | ||
29 | 'NP_HOST_TCP_SMTP_TLS' => '', | ||
30 | 'NP_HOST_TLS_CERT' => 'localhost, | ||
31 | 'NP_HOST_TLS_HTTP' => 'localhost', | ||
32 | 'NP_HOST_UDP_TIME' => 'none', | ||
33 | 'NP_INTERNET_ACCESS' => 'yes', | ||
34 | 'NP_LDAP_BASE_DN' => 'cn=admin,dc=nodomain', | ||
35 | 'NP_MOUNTPOINT2_VALID' => '/media/ramdisk', | ||
36 | 'NP_MOUNTPOINT_VALID' => '/', | ||
37 | 'NP_MYSQL_LOGIN_DETAILS' => '-u root -d test', | ||
38 | 'NP_MYSQL_SERVER' => 'localhost', | ||
39 | 'NP_MYSQL_SOCKET' => '/var/run/mysqld/mysqld.sock', | ||
40 | 'NP_MYSQL_WITH_SLAVE' => '', | ||
41 | 'NP_MYSQL_WITH_SLAVE_LOGIN' => '', | ||
42 | 'NP_NO_NTP_SERVICE' => 'localhost', | ||
43 | 'NP_PORT_TCP_PROXY' => '3128', | ||
44 | 'NP_SMB_SHARE' => '', | ||
45 | 'NP_SMB_SHARE_DENY' => '', | ||
46 | 'NP_SMB_SHARE_SPC' => '', | ||
47 | 'NP_SMB_VALID_USER' => '', | ||
48 | 'NP_SMB_VALID_USER_PASS' => '', | ||
49 | 'NP_SNMP_COMMUNITY' => '', | ||
50 | 'NP_SNMP_USER' => '', | ||
51 | 'NP_SSH_CONFIGFILE' => '~/.ssh/config', | ||
52 | 'NP_SSH_HOST' => 'localhost', | ||
53 | 'NP_SSH_IDENTITY' => '~/.ssh/id_rsa' | ||
54 | } | ||
diff --git a/plugins/t/check_curl.t b/plugins/t/check_curl.t index 4bff538..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 => 57; | 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,32 +39,41 @@ 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 | cmp_ok( $res->output, 'eq', "HTTP CRITICAL - Invalid HTTP response received from host on port 80: cURL returned 28 - Timeout was reached", "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 |
57 | # Is also possible to get a socket timeout if DNS is not responding fast enough | 74 | # Is also possible to get a socket timeout if DNS is not responding fast enough |
58 | # cURL gives us consistent strings from it's own 'lib/strerror.c' | 75 | # cURL gives us consistent strings from it's own 'lib/strerror.c' |
59 | like( $res->output, "/cURL returned 6 - Couldn't resolve host name/", "Output OK"); | 76 | like( $res->output, "/cURL returned 6 - Could not resolve host:/", "Output OK"); |
60 | 77 | ||
61 | # host header checks | 78 | # host header checks |
62 | $res = NPTest->testCmd("./$plugin -v -H $host_tcp_http"); | 79 | $res = NPTest->testCmd("./$plugin -v -H $host_tcp_http"); |
@@ -84,7 +101,7 @@ like( $res->output, '/^Host: testhost:8001\s*$/ms', "Host Header OK" ); | |||
84 | like( $res->output, '/CURLOPT_URL: http:\/\/'.$host_tcp_http.':80\//ms', "Url OK" ); | 101 | like( $res->output, '/CURLOPT_URL: http:\/\/'.$host_tcp_http.':80\//ms', "Url OK" ); |
85 | 102 | ||
86 | SKIP: { | 103 | SKIP: { |
87 | skip "No internet access", 3 if $internet_access eq "no"; | 104 | skip "No internet access", 4 if $internet_access eq "no"; |
88 | 105 | ||
89 | $res = NPTest->testCmd("./$plugin -v -H $host_tls_http -S"); | 106 | $res = NPTest->testCmd("./$plugin -v -H $host_tls_http -S"); |
90 | like( $res->output, '/^Host: '.$host_tls_http.'\s*$/ms', "Host Header OK" ); | 107 | like( $res->output, '/^Host: '.$host_tls_http.'\s*$/ms', "Host Header OK" ); |
@@ -94,6 +111,9 @@ SKIP: { | |||
94 | 111 | ||
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" ); |
114 | |||
115 | $res = NPTest->testCmd("./$plugin -v -H $host_tls_http -D -S -p 443"); | ||
116 | like( $res->output, '/(^Host: '.$host_tls_http.'\s*$)|(cURL returned 60)/ms', "Host Header OK" ); | ||
97 | }; | 117 | }; |
98 | 118 | ||
99 | SKIP: { | 119 | SKIP: { |
@@ -117,7 +137,7 @@ SKIP: { | |||
117 | cmp_ok( $res->return_code, "==", 0, "And also when not found"); | 137 | cmp_ok( $res->return_code, "==", 0, "And also when not found"); |
118 | } | 138 | } |
119 | SKIP: { | 139 | SKIP: { |
120 | skip "No internet access", 16 if $internet_access eq "no"; | 140 | skip "No internet access", 28 if $internet_access eq "no"; |
121 | 141 | ||
122 | $res = NPTest->testCmd( | 142 | $res = NPTest->testCmd( |
123 | "./$plugin --ssl $host_tls_http" | 143 | "./$plugin --ssl $host_tls_http" |
@@ -185,13 +205,7 @@ SKIP: { | |||
185 | like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' ); | 205 | like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' ); |
186 | 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' ); |
187 | 207 | ||
188 | $res = NPTest->testCmd( | 208 | $res = NPTest->testCmd( "./$plugin -H www.mozilla.com -u /firefox -f curl" ); |
189 | "./$plugin --ssl -H www.e-paycobalt.com" | ||
190 | ); | ||
191 | cmp_ok( $res->return_code, "==", 0, "Can read https for www.e-paycobalt.com (uses AES certificate)" ); | ||
192 | |||
193 | |||
194 | $res = NPTest->testCmd( "./$plugin -H www.mozilla.com -u /firefox -f follow" ); | ||
195 | is( $res->return_code, 0, "Redirection based on location is okay"); | 209 | is( $res->return_code, 0, "Redirection based on location is okay"); |
196 | 210 | ||
197 | $res = NPTest->testCmd( "./$plugin -H www.mozilla.com --extended-perfdata" ); | 211 | $res = NPTest->testCmd( "./$plugin -H www.mozilla.com --extended-perfdata" ); |
diff --git a/plugins/t/check_disk.t b/plugins/t/check_disk.t index fdd8769..ec527e7 100644 --- a/plugins/t/check_disk.t +++ b/plugins/t/check_disk.t | |||
@@ -88,8 +88,9 @@ $result = NPTest->testCmd( | |||
88 | ); | 88 | ); |
89 | $_ = $result->perf_output; | 89 | $_ = $result->perf_output; |
90 | my ($warn_absth_data, $crit_absth_data, $total_absth_data) = (m/=.[^;]*;(\d+);(\d+);\d+;(\d+)/); | 90 | my ($warn_absth_data, $crit_absth_data, $total_absth_data) = (m/=.[^;]*;(\d+);(\d+);\d+;(\d+)/); |
91 | is ($warn_absth_data, $total_absth_data - 20, "Wrong warning in perf data using absolute thresholds"); | 91 | # default unit is MiB, but perfdata is always bytes |
92 | is ($crit_absth_data, $total_absth_data - 10, "Wrong critical in perf data using absolute thresholds"); | 92 | is ($warn_absth_data, $total_absth_data - (20 * (2 ** 20)), "Wrong warning in perf data using absolute thresholds"); |
93 | is ($crit_absth_data, $total_absth_data - (10 * (2 ** 20)), "Wrong critical in perf data using absolute thresholds"); | ||
93 | 94 | ||
94 | # Then check percent thresholds. | 95 | # Then check percent thresholds. |
95 | $result = NPTest->testCmd( | 96 | $result = NPTest->testCmd( |
@@ -119,7 +120,7 @@ like ( $result->only_output, qr/$more_free/, "Have disk name in text"); | |||
119 | $result = NPTest->testCmd( "./check_disk -w 1 -c 1 -p $more_free -p $less_free" ); | 120 | $result = NPTest->testCmd( "./check_disk -w 1 -c 1 -p $more_free -p $less_free" ); |
120 | cmp_ok( $result->return_code, '==', 0, "At least 1 MB available on $more_free and $less_free"); | 121 | cmp_ok( $result->return_code, '==', 0, "At least 1 MB available on $more_free and $less_free"); |
121 | $_ = $result->output; | 122 | $_ = $result->output; |
122 | my ($free_mb_on_mp1, $free_mb_on_mp2) = (m/(\d+) MB .* (\d+) MB /g); | 123 | my ($free_mb_on_mp1, $free_mb_on_mp2) = (m/(\d+)MiB .* (\d+)MiB /g); |
123 | my $free_mb_on_all = $free_mb_on_mp1 + $free_mb_on_mp2; | 124 | my $free_mb_on_all = $free_mb_on_mp1 + $free_mb_on_mp2; |
124 | 125 | ||
125 | 126 | ||
diff --git a/plugins/t/check_dns.t b/plugins/t/check_dns.t index cdfbe60..afb2062 100644 --- a/plugins/t/check_dns.t +++ b/plugins/t/check_dns.t | |||
@@ -10,7 +10,7 @@ use NPTest; | |||
10 | 10 | ||
11 | plan skip_all => "check_dns not compiled" unless (-x "check_dns"); | 11 | plan skip_all => "check_dns not compiled" unless (-x "check_dns"); |
12 | 12 | ||
13 | plan tests => 19; | 13 | plan tests => 23; |
14 | 14 | ||
15 | my $successOutput = '/DNS OK: [\.0-9]+ seconds? response time/'; | 15 | my $successOutput = '/DNS OK: [\.0-9]+ seconds? response time/'; |
16 | 16 | ||
@@ -105,3 +105,11 @@ cmp_ok( $res->return_code, '==', 0, "Got expected address"); | |||
105 | $res = NPTest->testCmd("./check_dns -H $hostname_valid -a $hostname_invalid_cidr -t 5"); | 105 | $res = NPTest->testCmd("./check_dns -H $hostname_valid -a $hostname_invalid_cidr -t 5"); |
106 | cmp_ok( $res->return_code, '==', 2, "Got wrong address"); | 106 | cmp_ok( $res->return_code, '==', 2, "Got wrong address"); |
107 | like ( $res->output, "/^DNS CRITICAL.*expected '$hostname_invalid_cidr' but got '$hostname_valid_ip'".'$/', "Output OK"); | 107 | like ( $res->output, "/^DNS CRITICAL.*expected '$hostname_invalid_cidr' but got '$hostname_valid_ip'".'$/', "Output OK"); |
108 | |||
109 | $res = NPTest->testCmd("./check_dns -H $hostname_valid -n"); | ||
110 | cmp_ok( $res->return_code, '==', 2, "Found $hostname_valid"); | ||
111 | like ( $res->output, "/^DNS CRITICAL.*Domain '$hostname_valid' was found by the server:/", "Output OK"); | ||
112 | |||
113 | $res = NPTest->testCmd("./check_dns -H $hostname_invalid -n"); | ||
114 | cmp_ok( $res->return_code, '==', 0, "Did not find $hostname_invalid"); | ||
115 | like ( $res->output, $successOutput, "Output OK" ); | ||
diff --git a/plugins/t/check_fping.t b/plugins/t/check_fping.t index 342b0a7..67b357b 100644 --- a/plugins/t/check_fping.t +++ b/plugins/t/check_fping.t | |||
@@ -5,34 +5,30 @@ | |||
5 | # | 5 | # |
6 | 6 | ||
7 | use strict; | 7 | use strict; |
8 | use Test; | 8 | use Test::More; |
9 | use NPTest; | 9 | use NPTest; |
10 | 10 | ||
11 | use vars qw($tests); | ||
12 | |||
13 | BEGIN {$tests = 4; plan tests => $tests} | ||
14 | |||
15 | my $successOutput = '/^FPING OK - /'; | ||
16 | my $failureOutput = '/^FPING CRITICAL - /'; | ||
17 | |||
18 | my $host_responsive = getTestParameter("NP_HOST_RESPONSIVE", "The hostname of system responsive to network requests", "localhost"); | 11 | my $host_responsive = getTestParameter("NP_HOST_RESPONSIVE", "The hostname of system responsive to network requests", "localhost"); |
19 | my $host_nonresponsive = getTestParameter("NP_HOST_NONRESPONSIVE", "The hostname of system not responsive to network requests", "10.0.0.1"); | 12 | my $host_nonresponsive = getTestParameter("NP_HOST_NONRESPONSIVE", "The hostname of system not responsive to network requests", "10.0.0.1"); |
20 | my $hostname_invalid = getTestParameter("NP_HOSTNAME_INVALID", "An invalid (not known to DNS) hostname", "nosuchhost"); | 13 | my $hostname_invalid = getTestParameter("NP_HOSTNAME_INVALID", "An invalid (not known to DNS) hostname", "nosuchhost"); |
21 | 14 | ||
22 | my $t; | 15 | my $res; |
23 | 16 | ||
24 | my $fping = qx(which fping 2> /dev/null); | 17 | my $fping = qx(which fping 2> /dev/null); |
25 | chomp($fping); | 18 | chomp($fping); |
26 | if( ! -x "./check_fping") { | 19 | if( ! -x "./check_fping") { |
27 | $t += skipMissingCmd( "./check_fping", $tests ); | 20 | plan skip_all => "check_fping not found, skipping tests"; |
28 | } | 21 | } |
29 | elsif ( $> != 0 && (!$fping || ! -u $fping)) { | 22 | elsif ( !$fping || !-x $fping ) { |
30 | $t += skipMsg( "./check_fping", $tests ); | 23 | plan skip_all => "fping not found or cannot be executed, skipping tests"; |
31 | } else { | 24 | } else { |
32 | $t += checkCmd( "./check_fping $host_responsive", 0, $successOutput ); | 25 | plan tests => 3; |
33 | $t += checkCmd( "./check_fping $host_nonresponsive", [ 1, 2 ] ); | 26 | $res = NPTest->testCmd( "./check_fping $host_responsive" ); |
34 | $t += checkCmd( "./check_fping $hostname_invalid", [ 1, 2 ] ); | 27 | cmp_ok( $res->return_code, '==', 0, "Responsive host returns OK"); |
35 | } | 28 | |
29 | $res = NPTest->testCmd( "./check_fping $host_nonresponsive" ); | ||
30 | cmp_ok( $res->return_code, '==', 2, "Non-Responsive host returns Critical"); | ||
36 | 31 | ||
37 | exit(0) if defined($Test::Harness::VERSION); | 32 | $res = NPTest->testCmd( "./check_fping $hostname_invalid" ); |
38 | exit($tests - $t); | 33 | cmp_ok( $res->return_code, '==', 3, "Invalid host returns Unknown"); |
34 | } | ||
diff --git a/plugins/t/check_http.t b/plugins/t/check_http.t index e92681e..1ca52f6 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", 16 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" |
@@ -135,7 +135,7 @@ SKIP: { | |||
135 | 135 | ||
136 | # run some certificate checks with faketime | 136 | # run some certificate checks with faketime |
137 | SKIP: { | 137 | SKIP: { |
138 | skip "No faketime binary found", 12 if !$faketime; | 138 | skip "No faketime binary found", 7 if !$faketime; |
139 | $res = NPTest->testCmd("LC_TIME=C TZ=UTC ./$plugin -C 1 $host_tls_http"); | 139 | $res = NPTest->testCmd("LC_TIME=C TZ=UTC ./$plugin -C 1 $host_tls_http"); |
140 | like($res->output, qr/OK - Certificate '$host_tls_cert' will expire on/, "Catch cert output"); | 140 | like($res->output, qr/OK - Certificate '$host_tls_cert' will expire on/, "Catch cert output"); |
141 | is( $res->return_code, 0, "Catch cert output exit code" ); | 141 | is( $res->return_code, 0, "Catch cert output exit code" ); |
@@ -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 | ||
diff --git a/plugins/t/check_load.t b/plugins/t/check_load.t index 55f6f75..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 = "/^OK - load average: $loadValue, $loadValue, $loadValue/"; | 14 | my $successOutput = "/^LOAD OK - total load average: $loadValue, $loadValue, $loadValue/"; |
15 | my $failureOutput = "/^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_swap.t b/plugins/t/check_swap.t index e44adc9..de9e0f0 100644 --- a/plugins/t/check_swap.t +++ b/plugins/t/check_swap.t | |||
@@ -8,9 +8,9 @@ use strict; | |||
8 | use Test::More tests => 8; | 8 | use Test::More tests => 8; |
9 | use NPTest; | 9 | use NPTest; |
10 | 10 | ||
11 | my $successOutput = '/^SWAP OK - [0-9]+\% free \([0-9]+ MB out of [0-9]+ MB\)/'; | 11 | my $successOutput = '/^SWAP OK - [0-9]+\% free \([0-9]+MB out of [0-9]+MB\)/'; |
12 | my $failureOutput = '/^SWAP CRITICAL - [0-9]+\% free \([0-9]+ MB out of [0-9]+ MB\)/'; | 12 | my $failureOutput = '/^SWAP CRITICAL - [0-9]+\% free \([0-9]+MB out of [0-9]+MB\)/'; |
13 | my $warnOutput = '/^SWAP WARNING - [0-9]+\% free \([0-9]+ MB out of [0-9]+ MB\)/'; | 13 | my $warnOutput = '/^SWAP WARNING - [0-9]+\% free \([0-9]+MB out of [0-9]+MB\)/'; |
14 | 14 | ||
15 | my $result; | 15 | my $result; |
16 | 16 | ||