diff options
Diffstat (limited to 'plugins/t')
-rw-r--r-- | plugins/t/NPTest.cache.travis | 56 | ||||
-rw-r--r-- | plugins/t/check_apt.t | 18 | ||||
-rw-r--r-- | plugins/t/check_by_ssh.t | 14 | ||||
-rw-r--r-- | plugins/t/check_curl.t | 201 | ||||
-rw-r--r-- | plugins/t/check_disk.t | 15 | ||||
-rw-r--r-- | plugins/t/check_dns.t | 34 | ||||
-rw-r--r-- | plugins/t/check_fping.t | 44 | ||||
-rw-r--r-- | plugins/t/check_ftp.t | 11 | ||||
-rw-r--r-- | plugins/t/check_http.t | 158 | ||||
-rw-r--r-- | plugins/t/check_imap.t | 15 | ||||
-rw-r--r-- | plugins/t/check_jabber.t | 20 | ||||
-rw-r--r-- | plugins/t/check_ldap.t | 71 | ||||
-rw-r--r-- | plugins/t/check_load.t | 4 | ||||
-rw-r--r-- | plugins/t/check_mysql.t | 29 | ||||
-rw-r--r-- | plugins/t/check_mysql_query.t | 11 | ||||
-rw-r--r-- | plugins/t/check_snmp.t | 28 | ||||
-rw-r--r-- | plugins/t/check_ssh.t | 14 | ||||
-rw-r--r-- | plugins/t/check_swap.t | 6 | ||||
-rw-r--r-- | plugins/t/check_tcp.t | 25 | ||||
-rw-r--r-- | plugins/t/check_time.t | 11 | ||||
-rw-r--r-- | plugins/t/check_udp.t | 6 | ||||
-rw-r--r-- | plugins/t/check_users.t | 4 |
22 files changed, 515 insertions, 280 deletions
diff --git a/plugins/t/NPTest.cache.travis b/plugins/t/NPTest.cache.travis deleted file mode 100644 index 4ebfb90..0000000 --- a/plugins/t/NPTest.cache.travis +++ /dev/null | |||
@@ -1,56 +0,0 @@ | |||
1 | { | ||
2 | 'MYSQL_LOGIN_DETAILS' => '-u root -d test', | ||
3 | 'NP_ALLOW_SUDO' => 'yes', | ||
4 | 'NP_DNS_SERVER' => '8.8.8.8', | ||
5 | 'NP_GOOD_NTP_SERVICE' => '', | ||
6 | 'NP_HOSTNAME_INVALID' => 'nosuchhost', | ||
7 | 'NP_HOSTNAME_VALID' => 'monitoringplugins.org', | ||
8 | 'NP_HOSTNAME_VALID_IP' => '130.133.8.40', | ||
9 | 'NP_HOSTNAME_VALID_REVERSE' => 'orwell.monitoring-plugins.org.', | ||
10 | 'NP_HOST_DHCP_RESPONSIVE' => '', | ||
11 | 'NP_HOST_NONRESPONSIVE' => '10.0.0.1', | ||
12 | 'NP_HOST_RESPONSIVE' => 'localhost', | ||
13 | 'NP_HOST_SMB' => '', | ||
14 | 'NP_HOST_SNMP' => '', | ||
15 | 'NP_HOST_TCP_FTP' => '', | ||
16 | 'NP_HOST_TCP_HPJD' => '', | ||
17 | 'NP_HOST_HPJD_PORT_INVALID' => '161', | ||
18 | 'NP_HOST_HPJD_PORT_VALID' => '', | ||
19 | 'NP_HOST_TCP_HTTP' => 'localhost', | ||
20 | 'NP_HOST_TCP_HTTP2' => 'labs.consol.de', | ||
21 | 'NP_HOST_TCP_IMAP' => 'imap.web.de', | ||
22 | 'NP_HOST_TCP_POP' => 'pop.web.de', | ||
23 | 'NP_HOST_TCP_SMTP' => 'localhost', | ||
24 | 'NP_HOST_TCP_SMTP_NOTLS' => '', | ||
25 | 'NP_HOST_TCP_SMTP_TLS' => '', | ||
26 | 'NP_INTERNET_ACCESS' => 'yes', | ||
27 | 'NP_MOUNTPOINT2_VALID' => '', | ||
28 | 'NP_MOUNTPOINT_VALID' => '/', | ||
29 | 'NP_MYSQL_SERVER' => 'localhost', | ||
30 | 'NP_HOST_UDP_TIME' => 'localhost', | ||
31 | 'NP_MYSQL_SOCKET' => '/var/run/mysqld/mysqld.sock', | ||
32 | 'NP_MYSQL_WITH_SLAVE' => '', | ||
33 | 'NP_MYSQL_WITH_SLAVE_LOGIN' => '', | ||
34 | 'NP_NO_NTP_SERVICE' => 'localhost', | ||
35 | 'NP_SMB_SHARE' => '', | ||
36 | 'NP_SMB_SHARE_DENY' => '', | ||
37 | 'NP_SMB_SHARE_SPC' => '', | ||
38 | 'NP_SMB_VALID_USER' => '', | ||
39 | 'NP_SMB_VALID_USER_PASS' => '', | ||
40 | 'NP_SNMP_COMMUNITY' => '', | ||
41 | 'NP_SSH_CONFIGFILE' => '~/.ssh/config', | ||
42 | 'NP_SSH_HOST' => 'localhost', | ||
43 | 'NP_SSH_IDENTITY' => '~/.ssh/id_dsa', | ||
44 | 'NP_HOST_TCP_JABBER' => 'jabber.org', | ||
45 | 'host_nonresponsive' => '10.0.0.1', | ||
46 | 'host_responsive' => 'localhost', | ||
47 | 'host_snmp' => '', | ||
48 | 'host_tcp_ftp' => '', | ||
49 | 'host_tcp_http' => 'localhost', | ||
50 | 'host_tcp_imap' => 'imap.nierlein.de', | ||
51 | 'host_tcp_smtp' => 'localhost', | ||
52 | 'hostname_invalid' => 'nosuchhost', | ||
53 | 'snmp_community' => '', | ||
54 | 'user_snmp' => '', | ||
55 | 'host_udp_time' => 'none', | ||
56 | } | ||
diff --git a/plugins/t/check_apt.t b/plugins/t/check_apt.t index 9ba0ff8..430eb53 100644 --- a/plugins/t/check_apt.t +++ b/plugins/t/check_apt.t | |||
@@ -23,7 +23,7 @@ sub make_result_regexp { | |||
23 | } | 23 | } |
24 | 24 | ||
25 | if (-x "./check_apt") { | 25 | if (-x "./check_apt") { |
26 | plan tests => 28; | 26 | plan tests => 36; |
27 | } else { | 27 | } else { |
28 | plan skip_all => "No check_apt compiled"; | 28 | plan skip_all => "No check_apt compiled"; |
29 | } | 29 | } |
@@ -40,10 +40,18 @@ $result = NPTest->testCmd( sprintf($testfile_command, "", "debian2") ); | |||
40 | is( $result->return_code, 1, "Debian apt output, warning" ); | 40 | is( $result->return_code, 1, "Debian apt output, warning" ); |
41 | like( $result->output, make_result_regexp(13, 0), "Output correct" ); | 41 | like( $result->output, make_result_regexp(13, 0), "Output correct" ); |
42 | 42 | ||
43 | $result = NPTest->testCmd( sprintf($testfile_command, "-o", "debian2") ); | ||
44 | is( $result->return_code, 0, "Debian apt output, no critical" ); | ||
45 | like( $result->output, make_result_regexp(13, 0), "Output correct" ); | ||
46 | |||
43 | $result = NPTest->testCmd( sprintf($testfile_command, "", "debian3") ); | 47 | $result = NPTest->testCmd( sprintf($testfile_command, "", "debian3") ); |
44 | is( $result->return_code, 2, "Debian apt output, some critical" ); | 48 | is( $result->return_code, 2, "Debian apt output, some critical" ); |
45 | like( $result->output, make_result_regexp(19, 4), "Output correct" ); | 49 | like( $result->output, make_result_regexp(19, 4), "Output correct" ); |
46 | 50 | ||
51 | $result = NPTest->testCmd( sprintf($testfile_command, "-o", "debian3") ); | ||
52 | is( $result->return_code, 2, "Debian apt output, some critical" ); | ||
53 | like( $result->output, make_result_regexp(19, 4), "Output correct" ); | ||
54 | |||
47 | $result = NPTest->testCmd( sprintf($testfile_command, "-c '^[^\\(]*\\(.* (Debian-Security:|Ubuntu:[^/]*/[^-]*-security)'", "debian3") ); | 55 | $result = NPTest->testCmd( sprintf($testfile_command, "-c '^[^\\(]*\\(.* (Debian-Security:|Ubuntu:[^/]*/[^-]*-security)'", "debian3") ); |
48 | is( $result->return_code, 2, "Debian apt output - should have same result when default security regexp specified via -c" ); | 56 | is( $result->return_code, 2, "Debian apt output - should have same result when default security regexp specified via -c" ); |
49 | like( $result->output, make_result_regexp(19, 4), "Output correct" ); | 57 | like( $result->output, make_result_regexp(19, 4), "Output correct" ); |
@@ -52,6 +60,10 @@ $result = NPTest->testCmd( sprintf($testfile_command, "-i libc6", "debian3") ); | |||
52 | is( $result->return_code, 1, "Debian apt output, filter for libc6" ); | 60 | is( $result->return_code, 1, "Debian apt output, filter for libc6" ); |
53 | like( $result->output, make_result_regexp(3, 0), "Output correct" ); | 61 | like( $result->output, make_result_regexp(3, 0), "Output correct" ); |
54 | 62 | ||
63 | $result = NPTest->testCmd( sprintf($testfile_command, "-i libc6", "debian3") ); | ||
64 | is( $result->return_code, 1, "Debian apt output, filter for libc6, not critical" ); | ||
65 | like( $result->output, make_result_regexp(3, 0), "Output correct" ); | ||
66 | |||
55 | $result = NPTest->testCmd( sprintf($testfile_command, "-i libc6 -i xen", "debian3") ); | 67 | $result = NPTest->testCmd( sprintf($testfile_command, "-i libc6 -i xen", "debian3") ); |
56 | is( $result->return_code, 2, "Debian apt output, filter for libc6 and xen" ); | 68 | is( $result->return_code, 2, "Debian apt output, filter for libc6 and xen" ); |
57 | like( $result->output, make_result_regexp(9, 4), "Output correct" ); | 69 | like( $result->output, make_result_regexp(9, 4), "Output correct" ); |
@@ -64,6 +76,10 @@ $result = NPTest->testCmd( sprintf($testfile_command, "-e libc6", "debian3") ); | |||
64 | is( $result->return_code, 2, "Debian apt output, filter out libc6" ); | 76 | is( $result->return_code, 2, "Debian apt output, filter out libc6" ); |
65 | like( $result->output, make_result_regexp(16, 4), "Output correct" ); | 77 | like( $result->output, make_result_regexp(16, 4), "Output correct" ); |
66 | 78 | ||
79 | $result = NPTest->testCmd( sprintf($testfile_command, "-e libc6 -o", "debian3") ); | ||
80 | is( $result->return_code, 2, "Debian apt output, filter out libc6, critical" ); | ||
81 | like( $result->output, make_result_regexp(16, 4), "Output correct" ); | ||
82 | |||
67 | $result = NPTest->testCmd( sprintf($testfile_command, "-e libc6 -e xen", "debian3") ); | 83 | $result = NPTest->testCmd( sprintf($testfile_command, "-e libc6 -e xen", "debian3") ); |
68 | is( $result->return_code, 1, "Debian apt output, filter out libc6 and xen" ); | 84 | is( $result->return_code, 1, "Debian apt output, filter out libc6 and xen" ); |
69 | like( $result->output, make_result_regexp(10, 0), "Output correct" ); | 85 | like( $result->output, make_result_regexp(10, 0), "Output correct" ); |
diff --git a/plugins/t/check_by_ssh.t b/plugins/t/check_by_ssh.t index 4797390..1d2939e 100644 --- a/plugins/t/check_by_ssh.t +++ b/plugins/t/check_by_ssh.t | |||
@@ -9,17 +9,9 @@ use Test::More; | |||
9 | use NPTest; | 9 | use NPTest; |
10 | 10 | ||
11 | # Required parameters | 11 | # Required parameters |
12 | my $ssh_service = getTestParameter( "NP_SSH_HOST", | 12 | my $ssh_service = getTestParameter("NP_SSH_HOST", "A host providing SSH service", "localhost"); |
13 | "A host providing SSH service", | 13 | my $ssh_key = getTestParameter("NP_SSH_IDENTITY", "A key allowing access to NP_SSH_HOST", "~/.ssh/id_dsa"); |
14 | "localhost"); | 14 | my $ssh_conf = getTestParameter( "NP_SSH_CONFIGFILE", "A config file with ssh settings", "~/.ssh/config"); |
15 | |||
16 | my $ssh_key = getTestParameter( "NP_SSH_IDENTITY", | ||
17 | "A key allowing access to NP_SSH_HOST", | ||
18 | "~/.ssh/id_dsa"); | ||
19 | |||
20 | my $ssh_conf = getTestParameter( "NP_SSH_CONFIGFILE", | ||
21 | "A config file with ssh settings", | ||
22 | "~/.ssh/config"); | ||
23 | 15 | ||
24 | 16 | ||
25 | plan skip_all => "SSH_HOST and SSH_IDENTITY must be defined" unless ($ssh_service && $ssh_key); | 17 | plan skip_all => "SSH_HOST and SSH_IDENTITY must be defined" unless ($ssh_service && $ssh_key); |
diff --git a/plugins/t/check_curl.t b/plugins/t/check_curl.t new file mode 100644 index 0000000..ada6a04 --- /dev/null +++ b/plugins/t/check_curl.t | |||
@@ -0,0 +1,201 @@ | |||
1 | #! /usr/bin/perl -w -I .. | ||
2 | # | ||
3 | # HyperText Transfer Protocol (HTTP) Test via check_http | ||
4 | # | ||
5 | # | ||
6 | |||
7 | use strict; | ||
8 | use Test::More; | ||
9 | use POSIX qw/mktime strftime/; | ||
10 | use NPTest; | ||
11 | |||
12 | plan tests => 58; | ||
13 | |||
14 | my $successOutput = '/OK.*HTTP.*second/'; | ||
15 | |||
16 | my $res; | ||
17 | my $plugin = 'check_http'; | ||
18 | $plugin = 'check_curl' if $0 =~ m/check_curl/mx; | ||
19 | |||
20 | my $host_tcp_http = getTestParameter("NP_HOST_TCP_HTTP", "A host providing the HTTP Service (a web server)", "localhost"); | ||
21 | 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"); | ||
23 | my $host_nonresponsive = getTestParameter("NP_HOST_NONRESPONSIVE", "The hostname of system not responsive to network requests", "10.0.0.1"); | ||
24 | my $hostname_invalid = getTestParameter("NP_HOSTNAME_INVALID", "An invalid (not known to DNS) hostname", "nosuchhost"); | ||
25 | my $internet_access = getTestParameter("NP_INTERNET_ACCESS", "Is this system directly connected to the internet?", "yes"); | ||
26 | my $host_tcp_http2 = getTestParameter("NP_HOST_TCP_HTTP2", "A host providing an index page containing the string 'monitoring'", "test.monitoring-plugins.org"); | ||
27 | my $host_tcp_proxy = getTestParameter("NP_HOST_TCP_PROXY", "A host providing a HTTP proxy with CONNECT support", "localhost"); | ||
28 | my $port_tcp_proxy = getTestParameter("NP_PORT_TCP_PROXY", "Port of the proxy with HTTP and CONNECT support", "3128"); | ||
29 | |||
30 | my $faketime = -x '/usr/bin/faketime' ? 1 : 0; | ||
31 | |||
32 | |||
33 | $res = NPTest->testCmd( | ||
34 | "./$plugin $host_tcp_http -wt 300 -ct 600" | ||
35 | ); | ||
36 | cmp_ok( $res->return_code, '==', 0, "Webserver $host_tcp_http responded" ); | ||
37 | like( $res->output, $successOutput, "Output OK" ); | ||
38 | |||
39 | $res = NPTest->testCmd( | ||
40 | "./$plugin $host_tcp_http -wt 300 -ct 600 -v -v -v -k 'bob:there' -k 'carl:frown'" | ||
41 | ); | ||
42 | like( $res->output, '/bob:there\r\ncarl:frown\r\n/', "Got headers with multiple -k options" ); | ||
43 | |||
44 | $res = NPTest->testCmd( | ||
45 | "./$plugin $host_nonresponsive -wt 1 -ct 2 -t 3" | ||
46 | ); | ||
47 | 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?!) | ||
49 | like( $res->output, "/HTTP CRITICAL - Invalid HTTP response received from host on port 80: cURL returned 28 - Connection timed out after/", "Output OK"); | ||
50 | |||
51 | $res = NPTest->testCmd( | ||
52 | "./$plugin $hostname_invalid -wt 1 -ct 2" | ||
53 | ); | ||
54 | 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. | ||
56 | # 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 | ||
58 | # cURL gives us consistent strings from it's own 'lib/strerror.c' | ||
59 | like( $res->output, "/cURL returned 6 - Could not resolve host:/", "Output OK"); | ||
60 | |||
61 | # host header checks | ||
62 | $res = NPTest->testCmd("./$plugin -v -H $host_tcp_http"); | ||
63 | like( $res->output, '/^Host: '.$host_tcp_http.'\s*$/ms', "Host Header OK" ); | ||
64 | like( $res->output, '/CURLOPT_URL: http:\/\/'.$host_tcp_http.':80\//ms', "Url OK" ); | ||
65 | |||
66 | $res = NPTest->testCmd("./$plugin -v -H $host_tcp_http -p 80"); | ||
67 | like( $res->output, '/^Host: '.$host_tcp_http.'\s*$/ms', "Host Header OK" ); | ||
68 | like( $res->output, '/CURLOPT_URL: http:\/\/'.$host_tcp_http.':80\//ms', "Url OK" ); | ||
69 | |||
70 | $res = NPTest->testCmd("./$plugin -v -H $host_tcp_http:8080 -p 80"); | ||
71 | like( $res->output, '/^Host: '.$host_tcp_http.':8080\s*$/ms', "Host Header OK" ); | ||
72 | like( $res->output, '/CURLOPT_URL: http:\/\/'.$host_tcp_http.':80\//ms', "Url OK" ); | ||
73 | |||
74 | $res = NPTest->testCmd("./$plugin -v -H $host_tcp_http:8080 -p 80"); | ||
75 | like( $res->output, '/^Host: '.$host_tcp_http.':8080\s*$/ms', "Host Header OK" ); | ||
76 | like( $res->output, '/CURLOPT_URL: http:\/\/'.$host_tcp_http.':80\//ms', "Url OK" ); | ||
77 | |||
78 | $res = NPTest->testCmd("./$plugin -v -H $host_tcp_http:8080 -p 80 -k 'Host: testhost:8001'"); | ||
79 | like( $res->output, '/^Host: testhost:8001\s*$/ms', "Host Header OK" ); | ||
80 | like( $res->output, '/CURLOPT_URL: http:\/\/'.$host_tcp_http.':80\//ms', "Url OK" ); | ||
81 | |||
82 | $res = NPTest->testCmd("./$plugin -v -I $host_tcp_http -p 80 -k 'Host: testhost:8001'"); | ||
83 | 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" ); | ||
85 | |||
86 | SKIP: { | ||
87 | skip "No internet access", 4 if $internet_access eq "no"; | ||
88 | |||
89 | $res = NPTest->testCmd("./$plugin -v -H $host_tls_http -S"); | ||
90 | like( $res->output, '/^Host: '.$host_tls_http.'\s*$/ms', "Host Header OK" ); | ||
91 | |||
92 | $res = NPTest->testCmd("./$plugin -v -H $host_tls_http:8080 -S -p 443"); | ||
93 | like( $res->output, '/^Host: '.$host_tls_http.':8080\s*$/ms', "Host Header OK" ); | ||
94 | |||
95 | $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" ); | ||
97 | |||
98 | $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" ); | ||
100 | }; | ||
101 | |||
102 | SKIP: { | ||
103 | skip "No host serving monitoring in index file", 7 unless $host_tcp_http2; | ||
104 | |||
105 | $res = NPTest->testCmd( "./$plugin -H $host_tcp_http2 -r 'monitoring'" ); | ||
106 | cmp_ok( $res->return_code, "==", 0, "Got a reference to 'monitoring'"); | ||
107 | |||
108 | $res = NPTest->testCmd( "./$plugin -H $host_tcp_http2 -r 'mONiTORing'" ); | ||
109 | cmp_ok( $res->return_code, "==", 2, "Not got 'mONiTORing'"); | ||
110 | like ( $res->output, "/pattern not found/", "Error message says 'pattern not found'"); | ||
111 | |||
112 | $res = NPTest->testCmd( "./$plugin -H $host_tcp_http2 -R 'mONiTORing'" ); | ||
113 | cmp_ok( $res->return_code, "==", 0, "But case insensitive doesn't mind 'mONiTORing'"); | ||
114 | |||
115 | $res = NPTest->testCmd( "./$plugin -H $host_tcp_http2 -r 'monitoring' --invert-regex" ); | ||
116 | cmp_ok( $res->return_code, "==", 2, "Invert results work when found"); | ||
117 | like ( $res->output, "/pattern found/", "Error message says 'pattern found'"); | ||
118 | |||
119 | $res = NPTest->testCmd( "./$plugin -H $host_tcp_http2 -r 'mONiTORing' --invert-regex" ); | ||
120 | cmp_ok( $res->return_code, "==", 0, "And also when not found"); | ||
121 | } | ||
122 | SKIP: { | ||
123 | skip "No internet access", 28 if $internet_access eq "no"; | ||
124 | |||
125 | $res = NPTest->testCmd( | ||
126 | "./$plugin --ssl $host_tls_http" | ||
127 | ); | ||
128 | cmp_ok( $res->return_code, '==', 0, "Can read https for $host_tls_http" ); | ||
129 | |||
130 | $res = NPTest->testCmd( "./$plugin -C 1 --ssl $host_tls_http" ); | ||
131 | cmp_ok( $res->return_code, '==', 0, "Checking certificate for $host_tls_http"); | ||
132 | like ( $res->output, "/Certificate '$host_tls_cert' will expire on/", "Output OK" ); | ||
133 | my $saved_cert_output = $res->output; | ||
134 | |||
135 | $res = NPTest->testCmd( "./$plugin -C 8000,1 --ssl $host_tls_http" ); | ||
136 | cmp_ok( $res->return_code, '==', 1, "Checking certificate for $host_tls_http"); | ||
137 | like ( $res->output, qr/WARNING - Certificate '$host_tls_cert' expires in \d+ day/, "Output Warning" ); | ||
138 | |||
139 | $res = NPTest->testCmd( "./$plugin $host_tls_http -C 1" ); | ||
140 | is( $res->return_code, 0, "Old syntax for cert checking okay" ); | ||
141 | is( $res->output, $saved_cert_output, "Same output as new syntax" ); | ||
142 | |||
143 | $res = NPTest->testCmd( "./$plugin -H $host_tls_http -C 1" ); | ||
144 | is( $res->return_code, 0, "Updated syntax for cert checking okay" ); | ||
145 | is( $res->output, $saved_cert_output, "Same output as new syntax" ); | ||
146 | |||
147 | $res = NPTest->testCmd( "./$plugin -C 1 $host_tls_http" ); | ||
148 | cmp_ok( $res->output, 'eq', $saved_cert_output, "--ssl option automatically added"); | ||
149 | |||
150 | $res = NPTest->testCmd( "./$plugin $host_tls_http -C 1" ); | ||
151 | cmp_ok( $res->output, 'eq', $saved_cert_output, "Old syntax for cert checking still works"); | ||
152 | |||
153 | # run some certificate checks with faketime | ||
154 | SKIP: { | ||
155 | skip "No faketime binary found", 12 if !$faketime; | ||
156 | $res = NPTest->testCmd("LC_TIME=C TZ=UTC ./$plugin -C 1 $host_tls_http"); | ||
157 | like($res->output, qr/OK - Certificate '$host_tls_cert' will expire on/, "Catch cert output"); | ||
158 | is( $res->return_code, 0, "Catch cert output exit code" ); | ||
159 | my($mon,$day,$hour,$min,$sec,$year) = ($res->output =~ /(\w+)\s+(\d+)\s+(\d+):(\d+):(\d+)\s+(\d+)/); | ||
160 | if(!defined $year) { | ||
161 | die("parsing date failed from: ".$res->output); | ||
162 | } | ||
163 | my $months = {'Jan' => 0, 'Feb' => 1, 'Mar' => 2, 'Apr' => 3, 'May' => 4, 'Jun' => 5, 'Jul' => 6, 'Aug' => 7, 'Sep' => 8, 'Oct' => 9, 'Nov' => 10, 'Dec' => 11}; | ||
164 | my $ts = mktime($sec, $min, $hour, $day, $months->{$mon}, $year-1900); | ||
165 | my $time = strftime("%Y-%m-%d %H:%M:%S", localtime($ts)); | ||
166 | $res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts))."' ./$plugin -C 1 $host_tls_http"); | ||
167 | like($res->output, qr/CRITICAL - Certificate '$host_tls_cert' just expired/, "Output on expire date"); | ||
168 | is( $res->return_code, 2, "Output on expire date" ); | ||
169 | |||
170 | $res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts-1))."' ./$plugin -C 1 $host_tls_http"); | ||
171 | like($res->output, qr/CRITICAL - Certificate '$host_tls_cert' expires in 0 minutes/, "cert expires in 1 second output"); | ||
172 | is( $res->return_code, 2, "cert expires in 1 second exit code" ); | ||
173 | |||
174 | $res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts-120))."' ./$plugin -C 1 $host_tls_http"); | ||
175 | like($res->output, qr/CRITICAL - Certificate '$host_tls_cert' expires in 2 minutes/, "cert expires in 2 minutes output"); | ||
176 | is( $res->return_code, 2, "cert expires in 2 minutes exit code" ); | ||
177 | |||
178 | $res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts-7200))."' ./$plugin -C 1 $host_tls_http"); | ||
179 | like($res->output, qr/CRITICAL - Certificate '$host_tls_cert' expires in 2 hours/, "cert expires in 2 hours output"); | ||
180 | is( $res->return_code, 2, "cert expires in 2 hours exit code" ); | ||
181 | |||
182 | $res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts+1))."' ./$plugin -C 1 $host_tls_http"); | ||
183 | like($res->output, qr/CRITICAL - Certificate '$host_tls_cert' expired on/, "Certificate expired output"); | ||
184 | is( $res->return_code, 2, "Certificate expired exit code" ); | ||
185 | }; | ||
186 | |||
187 | $res = NPTest->testCmd( "./$plugin --ssl $host_tls_http -E" ); | ||
188 | like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' ); | ||
189 | like ( $res->output, '/time_ssl=[\d\.]+/', 'Extended Performance Data SSL Output OK' ); | ||
190 | |||
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" ); | ||
197 | is( $res->return_code, 0, "Redirection based on location is okay"); | ||
198 | |||
199 | $res = NPTest->testCmd( "./$plugin -H www.mozilla.com --extended-perfdata" ); | ||
200 | like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' ); | ||
201 | } | ||
diff --git a/plugins/t/check_disk.t b/plugins/t/check_disk.t index 7e0f74b..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 | ||
@@ -248,11 +249,11 @@ $result = NPTest->testCmd( "./check_disk -w 100% -c 100% ".${mountpoint_valid} ) | |||
248 | cmp_ok( $result->return_code, "==", 2, "100% empty" ); | 249 | cmp_ok( $result->return_code, "==", 2, "100% empty" ); |
249 | like( $result->output, $failureOutput, "Right output" ); | 250 | like( $result->output, $failureOutput, "Right output" ); |
250 | 251 | ||
251 | $result = NPTest->testCmd( "./check_disk -w 100000 -c 100000 $mountpoint_valid" ); | 252 | $result = NPTest->testCmd( "./check_disk -w 100000000 -c 100000000 $mountpoint_valid" ); |
252 | cmp_ok( $result->return_code, '==', 2, "Check for 100GB free" ); | 253 | cmp_ok( $result->return_code, '==', 2, "Check for 100TB free" ); |
253 | 254 | ||
254 | $result = NPTest->testCmd( "./check_disk -w 100 -c 100 -u GB ".${mountpoint_valid} ); # 100 GB empty | 255 | $result = NPTest->testCmd( "./check_disk -w 100 -c 100 -u TB ".${mountpoint_valid} ); # 100 TB empty |
255 | cmp_ok( $result->return_code, "==", 2, "100 GB empty" ); | 256 | cmp_ok( $result->return_code, "==", 2, "100 TB empty" ); |
256 | 257 | ||
257 | 258 | ||
258 | # Checking old syntax of check_disk warn crit [fs], with warn/crit at USED% thresholds | 259 | # Checking old syntax of check_disk warn crit [fs], with warn/crit at USED% thresholds |
diff --git a/plugins/t/check_dns.t b/plugins/t/check_dns.t index 035e768..afb2062 100644 --- a/plugins/t/check_dns.t +++ b/plugins/t/check_dns.t | |||
@@ -10,26 +10,38 @@ 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 => 16; | 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 | ||
17 | my $hostname_valid = getTestParameter( | 17 | my $hostname_valid = getTestParameter( |
18 | "NP_HOSTNAME_VALID", | 18 | "NP_HOSTNAME_VALID", |
19 | "A valid (known to DNS) hostname", | 19 | "A valid (known to DNS) hostname", |
20 | "monitoring-plugins.org" | 20 | "monitoring-plugins.org", |
21 | ); | 21 | ); |
22 | 22 | ||
23 | my $hostname_valid_ip = getTestParameter( | 23 | my $hostname_valid_ip = getTestParameter( |
24 | "NP_HOSTNAME_VALID_IP", | 24 | "NP_HOSTNAME_VALID_IP", |
25 | "The IP address of the valid hostname $hostname_valid", | 25 | "The IP address of the valid hostname $hostname_valid", |
26 | "66.118.156.50", | 26 | "130.133.8.40", |
27 | ); | ||
28 | |||
29 | my $hostname_valid_cidr = getTestParameter( | ||
30 | "NP_HOSTNAME_VALID_CIDR", | ||
31 | "An valid CIDR range containing $hostname_valid_ip", | ||
32 | "130.133.8.41/30", | ||
33 | ); | ||
34 | |||
35 | my $hostname_invalid_cidr = getTestParameter( | ||
36 | "NP_HOSTNAME_INVALID_CIDR", | ||
37 | "An (valid) CIDR range NOT containing $hostname_valid_ip", | ||
38 | "130.133.8.39/30", | ||
27 | ); | 39 | ); |
28 | 40 | ||
29 | my $hostname_valid_reverse = getTestParameter( | 41 | my $hostname_valid_reverse = getTestParameter( |
30 | "NP_HOSTNAME_VALID_REVERSE", | 42 | "NP_HOSTNAME_VALID_REVERSE", |
31 | "The hostname of $hostname_valid_ip", | 43 | "The hostname of $hostname_valid_ip", |
32 | "66-118-156-50.static.sagonet.net.", | 44 | "orwell.monitoring-plugins.org.", |
33 | ); | 45 | ); |
34 | 46 | ||
35 | my $hostname_invalid = getTestParameter( | 47 | my $hostname_invalid = getTestParameter( |
@@ -87,3 +99,17 @@ $res = NPTest->testCmd("./check_dns -H $hostname_valid_ip -a $hostname_valid_rev | |||
87 | cmp_ok( $res->return_code, '==', 0, "Got expected fqdn"); | 99 | cmp_ok( $res->return_code, '==', 0, "Got expected fqdn"); |
88 | like ( $res->output, $successOutput, "Output OK"); | 100 | like ( $res->output, $successOutput, "Output OK"); |
89 | 101 | ||
102 | $res = NPTest->testCmd("./check_dns -H $hostname_valid -a $hostname_valid_cidr -t 5"); | ||
103 | cmp_ok( $res->return_code, '==', 0, "Got expected address"); | ||
104 | |||
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"); | ||
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 08692e4..67b357b 100644 --- a/plugins/t/check_fping.t +++ b/plugins/t/check_fping.t | |||
@@ -5,40 +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); | 11 | my $host_responsive = getTestParameter("NP_HOST_RESPONSIVE", "The hostname of system responsive to network requests", "localhost"); |
12 | my $host_nonresponsive = getTestParameter("NP_HOST_NONRESPONSIVE", "The hostname of system not responsive to network requests", "10.0.0.1"); | ||
13 | my $hostname_invalid = getTestParameter("NP_HOSTNAME_INVALID", "An invalid (not known to DNS) hostname", "nosuchhost"); | ||
12 | 14 | ||
13 | BEGIN {$tests = 4; plan tests => $tests} | 15 | my $res; |
14 | |||
15 | my $successOutput = '/^FPING OK - /'; | ||
16 | my $failureOutput = '/^FPING CRITICAL - /'; | ||
17 | |||
18 | my $host_responsive = getTestParameter( "host_responsive", "NP_HOST_RESPONSIVE", "localhost", | ||
19 | "The hostname of system responsive to network requests" ); | ||
20 | |||
21 | my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1", | ||
22 | "The hostname of system not responsive to network requests" ); | ||
23 | |||
24 | my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost", | ||
25 | "An invalid (not known to DNS) hostname" ); | ||
26 | |||
27 | |||
28 | my $t; | ||
29 | 16 | ||
30 | my $fping = qx(which fping 2> /dev/null); | 17 | my $fping = qx(which fping 2> /dev/null); |
31 | chomp($fping); | 18 | chomp($fping); |
32 | if( ! -x "./check_fping") { | 19 | if( ! -x "./check_fping") { |
33 | $t += skipMissingCmd( "./check_fping", $tests ); | 20 | plan skip_all => "check_fping not found, skipping tests"; |
34 | } | 21 | } |
35 | elsif ( $> != 0 && (!$fping || ! -u $fping)) { | 22 | elsif ( !$fping || !-x $fping ) { |
36 | $t += skipMsg( "./check_fping", $tests ); | 23 | plan skip_all => "fping not found or cannot be executed, skipping tests"; |
37 | } else { | 24 | } else { |
38 | $t += checkCmd( "./check_fping $host_responsive", 0, $successOutput ); | 25 | plan tests => 3; |
39 | $t += checkCmd( "./check_fping $host_nonresponsive", [ 1, 2 ] ); | 26 | $res = NPTest->testCmd( "./check_fping $host_responsive" ); |
40 | $t += checkCmd( "./check_fping $hostname_invalid", [ 1, 2 ] ); | 27 | cmp_ok( $res->return_code, '==', 0, "Responsive host returns OK"); |
41 | } | ||
42 | 28 | ||
43 | exit(0) if defined($Test::Harness::VERSION); | 29 | $res = NPTest->testCmd( "./check_fping $host_nonresponsive" ); |
44 | exit($tests - $t); | 30 | cmp_ok( $res->return_code, '==', 2, "Non-Responsive host returns Critical"); |
31 | |||
32 | $res = NPTest->testCmd( "./check_fping $hostname_invalid" ); | ||
33 | cmp_ok( $res->return_code, '==', 3, "Invalid host returns Unknown"); | ||
34 | } | ||
diff --git a/plugins/t/check_ftp.t b/plugins/t/check_ftp.t index de6831b..93a7d7c 100644 --- a/plugins/t/check_ftp.t +++ b/plugins/t/check_ftp.t | |||
@@ -11,14 +11,9 @@ use NPTest; | |||
11 | use vars qw($tests); | 11 | use vars qw($tests); |
12 | BEGIN {$tests = 4; plan tests => $tests} | 12 | BEGIN {$tests = 4; plan tests => $tests} |
13 | 13 | ||
14 | my $host_tcp_ftp = getTestParameter( "host_tcp_ftp", "NP_HOST_TCP_FTP", "localhost", | 14 | my $host_tcp_ftp = getTestParameter("NP_HOST_TCP_FTP", "A host providing the FTP Service (an FTP server)", "localhost"); |
15 | "A host providing the FTP Service (an FTP server)"); | 15 | my $host_nonresponsive = getTestParameter("NP_HOST_NONRESPONSIVE", "The hostname of system not responsive to network requests", "10.0.0.1"); |
16 | 16 | my $hostname_invalid = getTestParameter("NP_HOSTNAME_INVALID", "An invalid (not known to DNS) hostname", "nosuchhost"); | |
17 | my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1", | ||
18 | "The hostname of system not responsive to network requests" ); | ||
19 | |||
20 | my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost", | ||
21 | "An invalid (not known to DNS) hostname" ); | ||
22 | 17 | ||
23 | my $successOutput = '/FTP OK -\s+[0-9]?\.?[0-9]+ second response time/'; | 18 | my $successOutput = '/FTP OK -\s+[0-9]?\.?[0-9]+ second response time/'; |
24 | 19 | ||
diff --git a/plugins/t/check_http.t b/plugins/t/check_http.t index 2539a28..c137f7b 100644 --- a/plugins/t/check_http.t +++ b/plugins/t/check_http.t | |||
@@ -6,54 +6,49 @@ | |||
6 | 6 | ||
7 | use strict; | 7 | use strict; |
8 | use Test::More; | 8 | use Test::More; |
9 | use POSIX qw/mktime strftime/; | ||
9 | use NPTest; | 10 | use NPTest; |
10 | 11 | ||
11 | plan tests => 30; | 12 | plan tests => 50; |
12 | 13 | ||
13 | my $successOutput = '/OK.*HTTP.*second/'; | 14 | my $successOutput = '/OK.*HTTP.*second/'; |
14 | 15 | ||
15 | my $res; | 16 | my $res; |
17 | my $plugin = 'check_http'; | ||
18 | $plugin = 'check_curl' if $0 =~ m/check_curl/mx; | ||
16 | 19 | ||
17 | my $host_tcp_http = getTestParameter( "NP_HOST_TCP_HTTP", | 20 | my $host_tcp_http = getTestParameter("NP_HOST_TCP_HTTP", "A host providing the HTTP Service (a web server)", "localhost"); |
18 | "A host providing the HTTP Service (a web server)", | 21 | my $host_tls_http = getTestParameter("NP_HOST_TLS_HTTP", "A host providing the HTTPS Service (a tls web server)", "localhost"); |
19 | "localhost" ); | 22 | 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"); | ||
24 | my $hostname_invalid = getTestParameter("NP_HOSTNAME_INVALID", "An invalid (not known to DNS) hostname", "nosuchhost"); | ||
25 | my $internet_access = getTestParameter("NP_INTERNET_ACCESS", "Is this system directly connected to the internet?", "yes"); | ||
26 | my $host_tcp_http2 = getTestParameter("NP_HOST_TCP_HTTP2", "A host providing an index page containing the string 'monitoring'", "test.monitoring-plugins.org"); | ||
27 | my $host_tcp_proxy = getTestParameter("NP_HOST_TCP_PROXY", "A host providing a HTTP proxy with CONNECT support", "localhost"); | ||
28 | my $port_tcp_proxy = getTestParameter("NP_PORT_TCP_PROXY", "Port of the proxy with HTTP and CONNECT support", "3128"); | ||
20 | 29 | ||
21 | my $host_nonresponsive = getTestParameter( "NP_HOST_NONRESPONSIVE", | 30 | my $faketime = -x '/usr/bin/faketime' ? 1 : 0; |
22 | "The hostname of system not responsive to network requests", | ||
23 | "10.0.0.1" ); | ||
24 | |||
25 | my $hostname_invalid = getTestParameter( "NP_HOSTNAME_INVALID", | ||
26 | "An invalid (not known to DNS) hostname", | ||
27 | "nosuchhost"); | ||
28 | |||
29 | my $internet_access = getTestParameter( "NP_INTERNET_ACCESS", | ||
30 | "Is this system directly connected to the internet?", | ||
31 | "yes"); | ||
32 | |||
33 | my $host_tcp_http2 = getTestParameter( "NP_HOST_TCP_HTTP2", | ||
34 | "A host providing an index page containing the string 'monitoring'", | ||
35 | "test.monitoring-plugins.org" ); | ||
36 | 31 | ||
37 | 32 | ||
38 | $res = NPTest->testCmd( | 33 | $res = NPTest->testCmd( |
39 | "./check_http $host_tcp_http -wt 300 -ct 600" | 34 | "./$plugin $host_tcp_http -wt 300 -ct 600" |
40 | ); | 35 | ); |
41 | cmp_ok( $res->return_code, '==', 0, "Webserver $host_tcp_http responded" ); | 36 | cmp_ok( $res->return_code, '==', 0, "Webserver $host_tcp_http responded" ); |
42 | like( $res->output, $successOutput, "Output OK" ); | 37 | like( $res->output, $successOutput, "Output OK" ); |
43 | 38 | ||
44 | $res = NPTest->testCmd( | 39 | $res = NPTest->testCmd( |
45 | "./check_http $host_tcp_http -wt 300 -ct 600 -v -v -v -k 'bob:there' -k 'carl:frown'" | 40 | "./$plugin $host_tcp_http -wt 300 -ct 600 -v -v -v -k 'bob:there' -k 'carl:frown'" |
46 | ); | 41 | ); |
47 | like( $res->output, '/bob:there\r\ncarl:frown\r\n/', "Got headers with multiple -k options" ); | 42 | like( $res->output, '/bob:there\r\ncarl:frown\r\n/', "Got headers with multiple -k options" ); |
48 | 43 | ||
49 | $res = NPTest->testCmd( | 44 | $res = NPTest->testCmd( |
50 | "./check_http $host_nonresponsive -wt 1 -ct 2" | 45 | "./$plugin $host_nonresponsive -wt 1 -ct 2 -t 3" |
51 | ); | 46 | ); |
52 | cmp_ok( $res->return_code, '==', 2, "Webserver $host_nonresponsive not responding" ); | 47 | cmp_ok( $res->return_code, '==', 2, "Webserver $host_nonresponsive not responding" ); |
53 | cmp_ok( $res->output, 'eq', "CRITICAL - Socket timeout after 10 seconds", "Output OK"); | 48 | cmp_ok( $res->output, 'eq', "CRITICAL - Socket timeout after 3 seconds", "Output OK"); |
54 | 49 | ||
55 | $res = NPTest->testCmd( | 50 | $res = NPTest->testCmd( |
56 | "./check_http $hostname_invalid -wt 1 -ct 2" | 51 | "./$plugin $hostname_invalid -wt 1 -ct 2" |
57 | ); | 52 | ); |
58 | cmp_ok( $res->return_code, '==', 2, "Webserver $hostname_invalid not valid" ); | 53 | cmp_ok( $res->return_code, '==', 2, "Webserver $hostname_invalid not valid" ); |
59 | # The first part of the message comes from the OS catalogue, so cannot check this. | 54 | # The first part of the message comes from the OS catalogue, so cannot check this. |
@@ -61,70 +56,141 @@ cmp_ok( $res->return_code, '==', 2, "Webserver $hostname_invalid not valid" ); | |||
61 | # Is also possible to get a socket timeout if DNS is not responding fast enough | 56 | # Is also possible to get a socket timeout if DNS is not responding fast enough |
62 | like( $res->output, "/Unable to open TCP socket|Socket timeout after/", "Output OK"); | 57 | like( $res->output, "/Unable to open TCP socket|Socket timeout after/", "Output OK"); |
63 | 58 | ||
59 | # host header checks | ||
60 | $res = NPTest->testCmd("./$plugin -v -H $host_tcp_http"); | ||
61 | like( $res->output, '/^Host: '.$host_tcp_http.'\s*$/ms', "Host Header OK" ); | ||
62 | |||
63 | $res = NPTest->testCmd("./$plugin -v -H $host_tcp_http -p 80"); | ||
64 | like( $res->output, '/^Host: '.$host_tcp_http.'\s*$/ms', "Host Header OK" ); | ||
65 | |||
66 | $res = NPTest->testCmd("./$plugin -v -H $host_tcp_http:8080 -p 80"); | ||
67 | like( $res->output, '/^Host: '.$host_tcp_http.':8080\s*$/ms', "Host Header OK" ); | ||
68 | |||
69 | $res = NPTest->testCmd("./$plugin -v -H $host_tcp_http:8080 -p 80"); | ||
70 | like( $res->output, '/^Host: '.$host_tcp_http.':8080\s*$/ms', "Host Header OK" ); | ||
71 | |||
72 | SKIP: { | ||
73 | skip "No internet access", 3 if $internet_access eq "no"; | ||
74 | |||
75 | $res = NPTest->testCmd("./$plugin -v -H $host_tls_http -S"); | ||
76 | like( $res->output, '/^Host: '.$host_tls_http.'\s*$/ms', "Host Header OK" ); | ||
77 | |||
78 | $res = NPTest->testCmd("./$plugin -v -H $host_tls_http:8080 -S -p 443"); | ||
79 | like( $res->output, '/^Host: '.$host_tls_http.':8080\s*$/ms', "Host Header OK" ); | ||
80 | |||
81 | $res = NPTest->testCmd("./$plugin -v -H $host_tls_http:443 -S -p 443"); | ||
82 | like( $res->output, '/^Host: '.$host_tls_http.'\s*$/ms', "Host Header OK" ); | ||
83 | }; | ||
84 | |||
64 | SKIP: { | 85 | SKIP: { |
65 | skip "No host serving monitoring in index file", 7 unless $host_tcp_http2; | 86 | skip "No host serving monitoring in index file", 7 unless $host_tcp_http2; |
66 | 87 | ||
67 | $res = NPTest->testCmd( "./check_http -H $host_tcp_http2 -r 'monitoring'" ); | 88 | $res = NPTest->testCmd( "./$plugin -H $host_tcp_http2 -r 'monitoring'" ); |
68 | cmp_ok( $res->return_code, "==", 0, "Got a reference to 'monitoring'"); | 89 | cmp_ok( $res->return_code, "==", 0, "Got a reference to 'monitoring'"); |
69 | 90 | ||
70 | $res = NPTest->testCmd( "./check_http -H $host_tcp_http2 -r 'mONiTORing'" ); | 91 | $res = NPTest->testCmd( "./$plugin -H $host_tcp_http2 -r 'mONiTORing'" ); |
71 | cmp_ok( $res->return_code, "==", 2, "Not got 'mONiTORing'"); | 92 | cmp_ok( $res->return_code, "==", 2, "Not got 'mONiTORing'"); |
72 | like ( $res->output, "/pattern not found/", "Error message says 'pattern not found'"); | 93 | like ( $res->output, "/pattern not found/", "Error message says 'pattern not found'"); |
73 | 94 | ||
74 | $res = NPTest->testCmd( "./check_http -H $host_tcp_http2 -R 'mONiTORing'" ); | 95 | $res = NPTest->testCmd( "./$plugin -H $host_tcp_http2 -R 'mONiTORing'" ); |
75 | cmp_ok( $res->return_code, "==", 0, "But case insensitive doesn't mind 'mONiTORing'"); | 96 | cmp_ok( $res->return_code, "==", 0, "But case insensitive doesn't mind 'mONiTORing'"); |
76 | 97 | ||
77 | $res = NPTest->testCmd( "./check_http -H $host_tcp_http2 -r 'monitoring' --invert-regex" ); | 98 | $res = NPTest->testCmd( "./$plugin -H $host_tcp_http2 -r 'monitoring' --invert-regex" ); |
78 | cmp_ok( $res->return_code, "==", 2, "Invert results work when found"); | 99 | cmp_ok( $res->return_code, "==", 2, "Invert results work when found"); |
79 | like ( $res->output, "/pattern found/", "Error message says 'pattern found'"); | 100 | like ( $res->output, "/pattern found/", "Error message says 'pattern found'"); |
80 | 101 | ||
81 | $res = NPTest->testCmd( "./check_http -H $host_tcp_http2 -r 'mONiTORing' --invert-regex" ); | 102 | $res = NPTest->testCmd( "./$plugin -H $host_tcp_http2 -r 'mONiTORing' --invert-regex" ); |
82 | cmp_ok( $res->return_code, "==", 0, "And also when not found"); | 103 | cmp_ok( $res->return_code, "==", 0, "And also when not found"); |
83 | } | 104 | } |
84 | SKIP: { | 105 | SKIP: { |
85 | skip "No internet access", 16 if $internet_access eq "no"; | 106 | skip "No internet access", 23 if $internet_access eq "no"; |
86 | 107 | ||
87 | $res = NPTest->testCmd( | 108 | $res = NPTest->testCmd( |
88 | "./check_http --ssl www.verisign.com" | 109 | "./$plugin --ssl $host_tls_http" |
89 | ); | 110 | ); |
90 | cmp_ok( $res->return_code, '==', 0, "Can read https for www.verisign.com" ); | 111 | cmp_ok( $res->return_code, '==', 0, "Can read https for $host_tls_http" ); |
91 | 112 | ||
92 | $res = NPTest->testCmd( "./check_http -C 1 --ssl www.verisign.com" ); | 113 | $res = NPTest->testCmd( "./$plugin -C 1 --ssl $host_tls_http" ); |
93 | cmp_ok( $res->return_code, '==', 0, "Checking certificate for www.verisign.com"); | 114 | cmp_ok( $res->return_code, '==', 0, "Checking certificate for $host_tls_http"); |
94 | like ( $res->output, "/Certificate 'www.verisign.com' will expire on/", "Output OK" ); | 115 | like ( $res->output, "/Certificate '$host_tls_cert' will expire on/", "Output OK" ); |
95 | my $saved_cert_output = $res->output; | 116 | my $saved_cert_output = $res->output; |
96 | 117 | ||
97 | $res = NPTest->testCmd( "./check_http -C 8000,1 --ssl www.verisign.com" ); | 118 | $res = NPTest->testCmd( "./$plugin -C 8000,1 --ssl $host_tls_http" ); |
98 | cmp_ok( $res->return_code, '==', 1, "Checking certificate for www.verisign.com"); | 119 | cmp_ok( $res->return_code, '==', 1, "Checking certificate for $host_tls_http"); |
99 | like ( $res->output, qr/WARNING - Certificate 'www.verisign.com' expires in \d+ day/, "Output Warning" ); | 120 | like ( $res->output, qr/WARNING - Certificate '$host_tls_cert' expires in \d+ day/, "Output Warning" ); |
100 | 121 | ||
101 | $res = NPTest->testCmd( "./check_http www.verisign.com -C 1" ); | 122 | $res = NPTest->testCmd( "./$plugin $host_tls_http -C 1" ); |
102 | is( $res->return_code, 0, "Old syntax for cert checking okay" ); | 123 | is( $res->return_code, 0, "Old syntax for cert checking okay" ); |
103 | is( $res->output, $saved_cert_output, "Same output as new syntax" ); | 124 | is( $res->output, $saved_cert_output, "Same output as new syntax" ); |
104 | 125 | ||
105 | $res = NPTest->testCmd( "./check_http -H www.verisign.com -C 1" ); | 126 | $res = NPTest->testCmd( "./$plugin -H $host_tls_http -C 1" ); |
106 | is( $res->return_code, 0, "Updated syntax for cert checking okay" ); | 127 | is( $res->return_code, 0, "Updated syntax for cert checking okay" ); |
107 | is( $res->output, $saved_cert_output, "Same output as new syntax" ); | 128 | is( $res->output, $saved_cert_output, "Same output as new syntax" ); |
108 | 129 | ||
109 | $res = NPTest->testCmd( "./check_http -C 1 www.verisign.com" ); | 130 | $res = NPTest->testCmd( "./$plugin -C 1 $host_tls_http" ); |
110 | cmp_ok( $res->output, 'eq', $saved_cert_output, "--ssl option automatically added"); | 131 | cmp_ok( $res->output, 'eq', $saved_cert_output, "--ssl option automatically added"); |
111 | 132 | ||
112 | $res = NPTest->testCmd( "./check_http www.verisign.com -C 1" ); | 133 | $res = NPTest->testCmd( "./$plugin $host_tls_http -C 1" ); |
113 | cmp_ok( $res->output, 'eq', $saved_cert_output, "Old syntax for cert checking still works"); | 134 | cmp_ok( $res->output, 'eq', $saved_cert_output, "Old syntax for cert checking still works"); |
114 | 135 | ||
115 | $res = NPTest->testCmd( "./check_http --ssl www.verisign.com -E" ); | 136 | # run some certificate checks with faketime |
137 | SKIP: { | ||
138 | skip "No faketime binary found", 7 if !$faketime; | ||
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"); | ||
141 | is( $res->return_code, 0, "Catch cert output exit code" ); | ||
142 | my($mon,$day,$hour,$min,$sec,$year) = ($res->output =~ /(\w+)\s+(\d+)\s+(\d+):(\d+):(\d+)\s+(\d+)/); | ||
143 | if(!defined $year) { | ||
144 | die("parsing date failed from: ".$res->output); | ||
145 | } | ||
146 | my $months = {'Jan' => 0, 'Feb' => 1, 'Mar' => 2, 'Apr' => 3, 'May' => 4, 'Jun' => 5, 'Jul' => 6, 'Aug' => 7, 'Sep' => 8, 'Oct' => 9, 'Nov' => 10, 'Dec' => 11}; | ||
147 | my $ts = mktime($sec, $min, $hour, $day, $months->{$mon}, $year-1900); | ||
148 | my $time = strftime("%Y-%m-%d %H:%M:%S", localtime($ts)); | ||
149 | $res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts))."' ./$plugin -C 1 $host_tls_http"); | ||
150 | like($res->output, qr/CRITICAL - Certificate '$host_tls_cert' just expired/, "Output on expire date"); | ||
151 | |||
152 | $res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts-1))."' ./$plugin -C 1 $host_tls_http"); | ||
153 | like($res->output, qr/CRITICAL - Certificate '$host_tls_cert' expires in 0 minutes/, "cert expires in 1 second output"); | ||
154 | |||
155 | $res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts-120))."' ./$plugin -C 1 $host_tls_http"); | ||
156 | like($res->output, qr/CRITICAL - Certificate '$host_tls_cert' expires in 2 minutes/, "cert expires in 2 minutes output"); | ||
157 | |||
158 | $res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts-7200))."' ./$plugin -C 1 $host_tls_http"); | ||
159 | like($res->output, qr/CRITICAL - Certificate '$host_tls_cert' expires in 2 hours/, "cert expires in 2 hours output"); | ||
160 | |||
161 | $res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts+1))."' ./$plugin -C 1 $host_tls_http"); | ||
162 | like($res->output, qr/CRITICAL - Certificate '$host_tls_cert' expired on/, "Certificate expired output"); | ||
163 | }; | ||
164 | |||
165 | $res = NPTest->testCmd( "./$plugin --ssl $host_tls_http -E" ); | ||
116 | like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' ); | 166 | like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' ); |
117 | 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' ); |
118 | 168 | ||
119 | $res = NPTest->testCmd( | 169 | $res = NPTest->testCmd( |
120 | "./check_http --ssl www.e-paycobalt.com" | 170 | "./$plugin --ssl -H www.e-paycobalt.com" |
121 | ); | 171 | ); |
122 | cmp_ok( $res->return_code, "==", 0, "Can read https for www.e-paycobalt.com (uses AES certificate)" ); | 172 | cmp_ok( $res->return_code, "==", 0, "Can read https for www.e-paycobalt.com (uses AES certificate)" ); |
123 | 173 | ||
124 | 174 | ||
125 | $res = NPTest->testCmd( "./check_http -H www.mozilla.com -u /firefox -f follow" ); | 175 | $res = NPTest->testCmd( "./$plugin -H www.mozilla.com -u /firefox -f follow" ); |
126 | is( $res->return_code, 0, "Redirection based on location is okay"); | 176 | is( $res->return_code, 0, "Redirection based on location is okay"); |
127 | 177 | ||
128 | $res = NPTest->testCmd( "./check_http -H www.mozilla.com --extended-perfdata" ); | 178 | $res = NPTest->testCmd( "./$plugin -H www.mozilla.com --extended-perfdata" ); |
129 | like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' ); | 179 | like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' ); |
130 | } | 180 | } |
181 | |||
182 | SKIP: { | ||
183 | skip "No internet access or proxy configured", 6 if $internet_access eq "no" or ! $host_tcp_proxy; | ||
184 | |||
185 | $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"); | ||
187 | like($res->output, qr/OK: Status line output matched/, "Proxy HTTP Output is sufficent"); | ||
188 | |||
189 | $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"); | ||
191 | like($res->output, qr/HTTP OK:/, "Proxy HTTP CONNECT output sufficent"); | ||
192 | |||
193 | $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"); | ||
195 | like($res->output, qr/HTTP OK:/, "Proxy HTTP CONNECT output sufficent"); | ||
196 | } | ||
diff --git a/plugins/t/check_imap.t b/plugins/t/check_imap.t index 9c6eae1..7c74e56 100644 --- a/plugins/t/check_imap.t +++ b/plugins/t/check_imap.t | |||
@@ -8,17 +8,10 @@ use strict; | |||
8 | use Test::More tests => 7; | 8 | use Test::More tests => 7; |
9 | use NPTest; | 9 | use NPTest; |
10 | 10 | ||
11 | my $host_tcp_smtp = getTestParameter( "host_tcp_smtp", "NP_HOST_TCP_SMTP", "mailhost", | 11 | my $host_tcp_smtp = getTestParameter("NP_HOST_TCP_SMTP", "A host providing an STMP Service (a mail server)", "mailhost"); |
12 | "A host providing an STMP Service (a mail server)"); | 12 | my $host_tcp_imap = getTestParameter("NP_HOST_TCP_IMAP", "A host providing an IMAP Service (a mail server)", $host_tcp_smtp); |
13 | 13 | my $host_nonresponsive = getTestParameter("NP_HOST_NONRESPONSIVE", "The hostname of system not responsive to network requests", "10.0.0.1"); | |
14 | my $host_tcp_imap = getTestParameter( "host_tcp_imap", "NP_HOST_TCP_IMAP", $host_tcp_smtp, | 14 | my $hostname_invalid = getTestParameter("NP_HOSTNAME_INVALID", "An invalid (not known to DNS) hostname", "nosuchhost"); |
15 | "A host providing an IMAP Service (a mail server)"); | ||
16 | |||
17 | my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1", | ||
18 | "The hostname of system not responsive to network requests" ); | ||
19 | |||
20 | my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost", | ||
21 | "An invalid (not known to DNS) hostname" ); | ||
22 | 15 | ||
23 | my $t; | 16 | my $t; |
24 | 17 | ||
diff --git a/plugins/t/check_jabber.t b/plugins/t/check_jabber.t index 7a708d5..fcdae17 100644 --- a/plugins/t/check_jabber.t +++ b/plugins/t/check_jabber.t | |||
@@ -10,23 +10,9 @@ use NPTest; | |||
10 | 10 | ||
11 | plan tests => 10; | 11 | plan tests => 10; |
12 | 12 | ||
13 | my $host_tcp_jabber = getTestParameter( | 13 | my $host_tcp_jabber = getTestParameter("NP_HOST_TCP_JABBER", "A host providing the Jabber Service", "jabber.de"); |
14 | "NP_HOST_TCP_JABBER", | 14 | my $host_nonresponsive = getTestParameter("NP_HOST_NONRESPONSIVE", "The hostname of system not responsive to network requests", "10.0.0.1"); |
15 | "A host providing the Jabber Service", | 15 | my $hostname_invalid = getTestParameter("NP_HOSTNAME_INVALID", "An invalid (not known to DNS) hostname", "nosuchhost"); |
16 | "jabber.org" | ||
17 | ); | ||
18 | |||
19 | my $host_nonresponsive = getTestParameter( | ||
20 | "NP_HOST_NONRESPONSIVE", | ||
21 | "The hostname of system not responsive to network requests", | ||
22 | "10.0.0.1", | ||
23 | ); | ||
24 | |||
25 | my $hostname_invalid = getTestParameter( | ||
26 | "NP_HOSTNAME_INVALID", | ||
27 | "An invalid (not known to DNS) hostname", | ||
28 | "nosuchhost", | ||
29 | ); | ||
30 | 16 | ||
31 | 17 | ||
32 | my $jabberOK = '/JABBER OK\s-\s\d+\.\d+\ssecond response time on '.$host_tcp_jabber.' port 5222/'; | 18 | my $jabberOK = '/JABBER OK\s-\s\d+\.\d+\ssecond response time on '.$host_tcp_jabber.' port 5222/'; |
diff --git a/plugins/t/check_ldap.t b/plugins/t/check_ldap.t new file mode 100644 index 0000000..b8a4a76 --- /dev/null +++ b/plugins/t/check_ldap.t | |||
@@ -0,0 +1,71 @@ | |||
1 | #!/usr/bin/env perl -I .. | ||
2 | # | ||
3 | # Lightweight Directory Access Protocol (LDAP) Test via check_ldap | ||
4 | # | ||
5 | # | ||
6 | |||
7 | use strict; | ||
8 | use warnings; | ||
9 | use Test::More; | ||
10 | use NPTest; | ||
11 | |||
12 | my $host_tcp_ldap = getTestParameter("NP_HOST_TCP_LDAP", "A host providing the LDAP Service", "localhost"); | ||
13 | my $ldap_base_dn = getTestParameter("NP_LDAP_BASE_DN", "A base dn for the LDAP Service", "cn=admin"); | ||
14 | my $host_nonresponsive = getTestParameter("NP_HOST_NONRESPONSIVE", "The hostname of system not responsive to network requests", "10.0.0.1"); | ||
15 | my $hostname_invalid = getTestParameter("NP_HOSTNAME_INVALID", "An invalid (not known to DNS) hostname", "nosuchhost"); | ||
16 | |||
17 | my($result, $cmd); | ||
18 | my $command = './check_ldap'; | ||
19 | |||
20 | plan tests => 16; | ||
21 | |||
22 | SKIP: { | ||
23 | skip "NP_HOST_NONRESPONSIVE not set", 2 if ! $host_nonresponsive; | ||
24 | |||
25 | $result = NPTest->testCmd("$command -H $host_nonresponsive -b ou=blah -t 2 -w 1 -c 1"); | ||
26 | is( $result->return_code, 2, "$command -H $host_nonresponsive -b ou=blah -t 5 -w 2 -c 3" ); | ||
27 | is( $result->output, 'CRITICAL - Socket timeout after 2 seconds', "output ok" ); | ||
28 | }; | ||
29 | |||
30 | SKIP: { | ||
31 | skip "NP_HOSTNAME_INVALID not set", 2 if ! $hostname_invalid; | ||
32 | |||
33 | $result = NPTest->testCmd("$command -H $hostname_invalid -b ou=blah -t 5"); | ||
34 | is( $result->return_code, 2, "$command -H $hostname_invalid -b ou=blah -t 5" ); | ||
35 | is( $result->output, 'Could not bind to the LDAP server', "output ok" ); | ||
36 | }; | ||
37 | |||
38 | SKIP: { | ||
39 | skip "NP_HOST_TCP_LDAP not set", 12 if ! $host_tcp_ldap; | ||
40 | skip "NP_LDAP_BASE_DN not set", 12 if ! $ldap_base_dn; | ||
41 | |||
42 | $cmd = "$command -H $host_tcp_ldap -b $ldap_base_dn -t 5 -w 2 -c 3 -3"; | ||
43 | $result = NPTest->testCmd($cmd); | ||
44 | is( $result->return_code, 0, $cmd ); | ||
45 | like( $result->output, '/^LDAP OK - \d+.\d+ seconds response time\|time=\d+\.\d+s;2\.0+;3\.0+;0\.0+$/', "output ok" ); | ||
46 | |||
47 | $cmd = "$command -H $host_tcp_ldap -b $ldap_base_dn -t 5 -w 2 -c 3 -3 -W 10000000 -C 10000001"; | ||
48 | $result = NPTest->testCmd($cmd); | ||
49 | is( $result->return_code, 0, $cmd ); | ||
50 | like( $result->output, '/^LDAP OK - found \d+ entries in \d+\.\d+ seconds\|time=\d\.\d+s;2\.0+;3\.0+;0\.0+ entries=\d+\.0+;10000000;10000001;0\.0+$/', "output ok" ); | ||
51 | |||
52 | $cmd = "$command -H $host_tcp_ldap -b $ldap_base_dn -t 5 -w 2 -c 3 -3 -W 10000000: -C 10000001:"; | ||
53 | $result = NPTest->testCmd($cmd); | ||
54 | is( $result->return_code, 2, $cmd ); | ||
55 | like( $result->output, '/^LDAP CRITICAL - found \d+ entries in \d+\.\d+ seconds\|time=\d\.\d+s;2\.0+;3\.0+;0\.0+ entries=\d+\.0+;10000000:;10000001:;0\.0+$/', "output ok" ); | ||
56 | |||
57 | $cmd = "$command -H $host_tcp_ldap -b $ldap_base_dn -t 5 -w 2 -c 3 -3 -W 0 -C 0"; | ||
58 | $result = NPTest->testCmd($cmd); | ||
59 | is( $result->return_code, 2, $cmd ); | ||
60 | like( $result->output, '/^LDAP CRITICAL - found \d+ entries in \d+\.\d+ seconds\|time=\d\.\d+s;2\.0+;3\.0+;0\.0+ entries=\d+\.0+;0;0;0\.0+$/', "output ok" ); | ||
61 | |||
62 | $cmd = "$command -H $host_tcp_ldap -b $ldap_base_dn -t 5 -w 2 -c 3 -3 -W 10000000: -C 10000001"; | ||
63 | $result = NPTest->testCmd($cmd); | ||
64 | is( $result->return_code, 1, $cmd ); | ||
65 | like( $result->output, '/^LDAP WARNING - found \d+ entries in \d+\.\d+ seconds\|time=\d\.\d+s;2\.0+;3\.0+;0\.0+ entries=\d+\.0+;10000000:;10000001;0\.0+$/', "output ok" ); | ||
66 | |||
67 | $cmd = "$command -H $host_tcp_ldap -b $ldap_base_dn -t 5 -w 2 -c 3 -3 -C 10000001"; | ||
68 | $result = NPTest->testCmd($cmd); | ||
69 | is( $result->return_code, 0, $cmd ); | ||
70 | like( $result->output, '/^LDAP OK - found \d+ entries in \d+\.\d+ seconds\|time=\d\.\d+s;2\.0+;3\.0+;0\.0+ entries=\d+\.0+;;10000001;0\.0+$/', "output ok" ); | ||
71 | }; | ||
diff --git a/plugins/t/check_load.t b/plugins/t/check_load.t index 55f6f75..60837ef 100644 --- a/plugins/t/check_load.t +++ b/plugins/t/check_load.t | |||
@@ -11,8 +11,8 @@ 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 - load average: $loadValue, $loadValue, $loadValue/"; |
15 | my $failureOutput = "/^CRITICAL - load average: $loadValue, $loadValue, $loadValue/"; | 15 | my $failureOutput = "/^LOAD CRITICAL - load average: $loadValue, $loadValue, $loadValue/"; |
16 | 16 | ||
17 | plan tests => 11; | 17 | plan tests => 11; |
18 | 18 | ||
diff --git a/plugins/t/check_mysql.t b/plugins/t/check_mysql.t index 28cd4cd..e426bf5 100644 --- a/plugins/t/check_mysql.t +++ b/plugins/t/check_mysql.t | |||
@@ -21,30 +21,11 @@ plan skip_all => "check_mysql not compiled" unless (-x "check_mysql"); | |||
21 | plan tests => 15; | 21 | plan tests => 15; |
22 | 22 | ||
23 | my $bad_login_output = '/Access denied for user /'; | 23 | my $bad_login_output = '/Access denied for user /'; |
24 | my $mysqlserver = getTestParameter( | 24 | my $mysqlserver = getTestParameter("NP_MYSQL_SERVER", "A MySQL Server hostname or IP with no slaves setup"); |
25 | "NP_MYSQL_SERVER", | 25 | my $mysqlsocket = getTestParameter("NP_MYSQL_SOCKET", "Full path to a MySQL Server socket with no slaves setup"); |
26 | "A MySQL Server hostname or IP 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"); |
27 | ); | 27 | my $with_slave = getTestParameter("NP_MYSQL_WITH_SLAVE", "MySQL server with slaves setup"); |
28 | my $mysqlsocket = getTestParameter( | 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"); |
29 | "NP_MYSQL_SOCKET", | ||
30 | "Full path to a MySQL Server socket with no slaves setup" | ||
31 | ); | ||
32 | my $mysql_login_details = getTestParameter( | ||
33 | "MYSQL_LOGIN_DETAILS", | ||
34 | "Command line parameters to specify login access (requires " . | ||
35 | "REPLICATION CLIENT privleges)", | ||
36 | "-u test -ptest", | ||
37 | ); | ||
38 | my $with_slave = getTestParameter( | ||
39 | "NP_MYSQL_WITH_SLAVE", | ||
40 | "MySQL server with slaves setup" | ||
41 | ); | ||
42 | my $with_slave_login = getTestParameter( | ||
43 | "NP_MYSQL_WITH_SLAVE_LOGIN", | ||
44 | "Login details for server with slave (requires REPLICATION CLIENT " . | ||
45 | "privleges)", | ||
46 | $mysql_login_details || "-u test -ptest" | ||
47 | ); | ||
48 | 29 | ||
49 | my $result; | 30 | my $result; |
50 | 31 | ||
diff --git a/plugins/t/check_mysql_query.t b/plugins/t/check_mysql_query.t index 407af88..96899ac 100644 --- a/plugins/t/check_mysql_query.t +++ b/plugins/t/check_mysql_query.t | |||
@@ -17,15 +17,8 @@ use vars qw($tests); | |||
17 | 17 | ||
18 | plan skip_all => "check_mysql_query not compiled" unless (-x "check_mysql_query"); | 18 | plan skip_all => "check_mysql_query not compiled" unless (-x "check_mysql_query"); |
19 | 19 | ||
20 | my $mysqlserver = getTestParameter( | 20 | my $mysqlserver = getTestParameter("NP_MYSQL_SERVER", "A MySQL Server with no slaves setup"); |
21 | "NP_MYSQL_SERVER", | 21 | my $mysql_login_details = getTestParameter("NP_MYSQL_LOGIN_DETAILS", "Command line parameters to specify login access", "-u user -ppw -d db"); |
22 | "A MySQL Server with no slaves setup" | ||
23 | ); | ||
24 | my $mysql_login_details = getTestParameter( | ||
25 | "MYSQL_LOGIN_DETAILS", | ||
26 | "Command line parameters to specify login access", | ||
27 | "-u user -ppw -d db", | ||
28 | ); | ||
29 | my $result; | 22 | my $result; |
30 | 23 | ||
31 | if (! $mysqlserver) { | 24 | if (! $mysqlserver) { |
diff --git a/plugins/t/check_snmp.t b/plugins/t/check_snmp.t index 2d6c44a..f2f218f 100644 --- a/plugins/t/check_snmp.t +++ b/plugins/t/check_snmp.t | |||
@@ -10,23 +10,17 @@ use NPTest; | |||
10 | 10 | ||
11 | BEGIN { | 11 | BEGIN { |
12 | plan skip_all => 'check_snmp is not compiled' unless -x "./check_snmp"; | 12 | plan skip_all => 'check_snmp is not compiled' unless -x "./check_snmp"; |
13 | plan tests => 61; | 13 | plan tests => 63; |
14 | } | 14 | } |
15 | 15 | ||
16 | my $res; | 16 | my $res; |
17 | 17 | ||
18 | my $host_snmp = getTestParameter( "host_snmp", "NP_HOST_SNMP", "localhost", | 18 | my $host_snmp = getTestParameter("NP_HOST_SNMP", "A host providing an SNMP Service", "localhost"); |
19 | "A host providing an SNMP Service"); | 19 | my $snmp_community = getTestParameter("NP_SNMP_COMMUNITY", "The SNMP Community string for SNMP Testing (assumes snmp v1)", "public"); |
20 | my $host_nonresponsive = getTestParameter("NP_HOST_NONRESPONSIVE", "The hostname of system not responsive to network requests", "10.0.0.1"); | ||
21 | my $hostname_invalid = getTestParameter("NP_HOSTNAME_INVALID", "An invalid (not known to DNS) hostname", "nosuchhost"); | ||
22 | my $user_snmp = getTestParameter("NP_SNMP_USER", "An SNMP user", "auth_md5"); | ||
20 | 23 | ||
21 | my $snmp_community = getTestParameter( "snmp_community", "NP_SNMP_COMMUNITY", "public", | ||
22 | "The SNMP Community string for SNMP Testing (assumes snmp v1)" ); | ||
23 | |||
24 | my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1", | ||
25 | "The hostname of system not responsive to network requests" ); | ||
26 | |||
27 | my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost", | ||
28 | "An invalid (not known to DNS) hostname" ); | ||
29 | my $user_snmp = getTestParameter( "user_snmp", "NP_SNMP_USER", "auth_md5", "An SNMP user"); | ||
30 | 24 | ||
31 | $res = NPTest->testCmd( "./check_snmp -t 1" ); | 25 | $res = NPTest->testCmd( "./check_snmp -t 1" ); |
32 | is( $res->return_code, 3, "No host name" ); | 26 | is( $res->return_code, 3, "No host name" ); |
@@ -45,7 +39,7 @@ is( $res->return_code, 3, "Invalid protocol" ); | |||
45 | like( $res->output, "/check_snmp: Invalid SNMP version - 3c/" ); | 39 | like( $res->output, "/check_snmp: Invalid SNMP version - 3c/" ); |
46 | 40 | ||
47 | SKIP: { | 41 | SKIP: { |
48 | skip "no snmp host defined", 48 if ( ! $host_snmp ); | 42 | skip "no snmp host defined", 50 if ( ! $host_snmp ); |
49 | 43 | ||
50 | $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 -C $snmp_community -o system.sysUpTime.0 -w 1: -c 1:"); |
51 | cmp_ok( $res->return_code, '==', 0, "Exit OK when querying uptime" ); | 45 | cmp_ok( $res->return_code, '==', 0, "Exit OK when querying uptime" ); |
@@ -153,6 +147,10 @@ SKIP: { | |||
153 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0"); | 147 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0"); |
154 | cmp_ok( $res->return_code, '==', 0, "Timetick used as a string"); | 148 | cmp_ok( $res->return_code, '==', 0, "Timetick used as a string"); |
155 | 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 | |||
151 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o HOST-RESOURCES-MIB::hrSWRunName.1"); | ||
152 | cmp_ok( $res->return_code, '==', 0, "snmp response without datatype"); | ||
153 | like( $res->output, '/^SNMP OK - "(systemd|init)" \| $/', "snmp response without datatype" ); | ||
156 | } | 154 | } |
157 | 155 | ||
158 | SKIP: { | 156 | SKIP: { |
@@ -166,8 +164,8 @@ SKIP: { | |||
166 | SKIP: { | 164 | SKIP: { |
167 | skip "no non responsive host defined", 2 if ( ! $host_nonresponsive ); | 165 | skip "no non responsive host defined", 2 if ( ! $host_nonresponsive ); |
168 | $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 -C np_foobar -o system.sysUpTime.0 -w 1: -c 1:"); |
169 | cmp_ok( $res->return_code, '==', 3, "Exit UNKNOWN with non responsive host" ); | 167 | cmp_ok( $res->return_code, '==', 2, "Exit CRITICAL with non responsive host" ); |
170 | like($res->output, '/External command error: Timeout: No Response from /', "String matches timeout problem"); | 168 | like($res->output, '/Plugin timed out while executing system call/', "String matches timeout problem"); |
171 | } | 169 | } |
172 | 170 | ||
173 | SKIP: { | 171 | SKIP: { |
diff --git a/plugins/t/check_ssh.t b/plugins/t/check_ssh.t index 8008349..a5cd23c 100644 --- a/plugins/t/check_ssh.t +++ b/plugins/t/check_ssh.t | |||
@@ -9,17 +9,9 @@ use Test::More; | |||
9 | use NPTest; | 9 | use NPTest; |
10 | 10 | ||
11 | # Required parameters | 11 | # Required parameters |
12 | my $ssh_host = getTestParameter("NP_SSH_HOST", | 12 | my $ssh_host = getTestParameter("NP_SSH_HOST", "A host providing SSH service", "localhost"); |
13 | "A host providing SSH service", | 13 | my $host_nonresponsive = getTestParameter("NP_HOST_NONRESPONSIVE", "The hostname of system not responsive to network requests", "10.0.0.1" ); |
14 | "localhost"); | 14 | my $hostname_invalid = getTestParameter("NP_HOSTNAME_INVALID", "An invalid (not known to DNS) hostname", "nosuchhost" ); |
15 | |||
16 | my $host_nonresponsive = getTestParameter("NP_HOST_NONRESPONSIVE", | ||
17 | "The hostname of system not responsive to network requests", | ||
18 | "10.0.0.1" ); | ||
19 | |||
20 | my $hostname_invalid = getTestParameter("NP_HOSTNAME_INVALID", | ||
21 | "An invalid (not known to DNS) hostname", | ||
22 | "nosuchhost" ); | ||
23 | 15 | ||
24 | 16 | ||
25 | plan skip_all => "SSH_HOST must be defined" unless $ssh_host; | 17 | plan skip_all => "SSH_HOST must be defined" unless $ssh_host; |
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 | ||
diff --git a/plugins/t/check_tcp.t b/plugins/t/check_tcp.t index f996685..cb4de53 100644 --- a/plugins/t/check_tcp.t +++ b/plugins/t/check_tcp.t | |||
@@ -15,18 +15,11 @@ BEGIN { | |||
15 | } | 15 | } |
16 | 16 | ||
17 | 17 | ||
18 | my $host_tcp_http = getTestParameter( "host_tcp_http", "NP_HOST_TCP_HTTP", "localhost", | 18 | my $host_tcp_http = getTestParameter("NP_HOST_TCP_HTTP", "A host providing the HTTP Service (a web server)", "localhost"); |
19 | "A host providing the HTTP Service (a web server)" ); | 19 | my $host_tls_http = getTestParameter("NP_HOST_TLS_HTTP", "A host providing the HTTPS Service (a tls web server)", "localhost"); |
20 | 20 | my $host_nonresponsive = getTestParameter("NP_HOST_NONRESPONSIVE", "The hostname of system not responsive to network requests", "10.0.0.1"); | |
21 | my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1", | 21 | my $hostname_invalid = getTestParameter("NP_HOSTNAME_INVALID", "An invalid (not known to DNS) hostname", "nosuchhost"); |
22 | "The hostname of system not responsive to network requests" ); | 22 | my $internet_access = getTestParameter("NP_INTERNET_ACCESS", "Is this system directly connected to the internet?", "yes"); |
23 | |||
24 | my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost", | ||
25 | "An invalid (not known to DNS) hostname" ); | ||
26 | |||
27 | my $internet_access = getTestParameter( "NP_INTERNET_ACCESS", | ||
28 | "Is this system directly connected to the internet?", | ||
29 | "yes"); | ||
30 | 23 | ||
31 | my $successOutput = '/^TCP OK\s-\s+[0-9]?\.?[0-9]+ second response time on port [0-9]+/'; | 24 | my $successOutput = '/^TCP OK\s-\s+[0-9]?\.?[0-9]+ second response time on port [0-9]+/'; |
32 | 25 | ||
@@ -42,10 +35,10 @@ $t += checkCmd( "./check_tcp $host_tcp_http -p 81 -wt 0 -ct 0 -to 1", 2 | |||
42 | $t += checkCmd( "./check_tcp $host_nonresponsive -p 80 -wt 0 -ct 0 -to 1", 2 ); | 35 | $t += checkCmd( "./check_tcp $host_nonresponsive -p 80 -wt 0 -ct 0 -to 1", 2 ); |
43 | $t += checkCmd( "./check_tcp $hostname_invalid -p 80 -wt 0 -ct 0 -to 1", 2 ); | 36 | $t += checkCmd( "./check_tcp $hostname_invalid -p 80 -wt 0 -ct 0 -to 1", 2 ); |
44 | if($internet_access ne "no") { | 37 | if($internet_access ne "no") { |
45 | $t += checkCmd( "./check_tcp -S -D 1 -H www.verisign.com -p 443", 0 ); | 38 | $t += checkCmd( "./check_tcp -S -D 1 -H $host_tls_http -p 443", 0 ); |
46 | $t += checkCmd( "./check_tcp -S -D 9000,1 -H www.verisign.com -p 443", 1 ); | 39 | $t += checkCmd( "./check_tcp -S -D 9000,1 -H $host_tls_http -p 443", 1 ); |
47 | $t += checkCmd( "./check_tcp -S -D 9000 -H www.verisign.com -p 443", 1 ); | 40 | $t += checkCmd( "./check_tcp -S -D 9000 -H $host_tls_http -p 443", 1 ); |
48 | $t += checkCmd( "./check_tcp -S -D 9000,8999 -H www.verisign.com -p 443", 2 ); | 41 | $t += checkCmd( "./check_tcp -S -D 9000,8999 -H $host_tls_http -p 443", 2 ); |
49 | } | 42 | } |
50 | 43 | ||
51 | # Need the \r\n to make it more standards compliant with web servers. Need the various quotes | 44 | # Need the \r\n to make it more standards compliant with web servers. Need the various quotes |
diff --git a/plugins/t/check_time.t b/plugins/t/check_time.t index 961f56e..92c2f89 100644 --- a/plugins/t/check_time.t +++ b/plugins/t/check_time.t | |||
@@ -11,14 +11,9 @@ use NPTest; | |||
11 | use vars qw($tests); | 11 | use vars qw($tests); |
12 | BEGIN {$tests = 8; plan tests => $tests} | 12 | BEGIN {$tests = 8; plan tests => $tests} |
13 | 13 | ||
14 | my $host_udp_time = getTestParameter( "host_udp_time", "NP_HOST_UDP_TIME", "localhost", | 14 | my $host_udp_time = getTestParameter("NP_HOST_UDP_TIME", "A host providing the UDP Time Service", "localhost"); |
15 | "A host providing the UDP Time Service" ); | 15 | my $host_nonresponsive = getTestParameter("NP_HOST_NONRESPONSIVE", "The hostname of system not responsive to network requests", "10.0.0.1"); |
16 | 16 | my $hostname_invalid = getTestParameter("NP_HOSTNAME_INVALID", "An invalid (not known to DNS) hostname", "nosuchhost"); | |
17 | my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1", | ||
18 | "The hostname of system not responsive to network requests" ); | ||
19 | |||
20 | my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost", | ||
21 | "An invalid (not known to DNS) hostname" ); | ||
22 | 17 | ||
23 | my $successOutput = '/^TIME OK - [0-9]+ second time difference/'; | 18 | my $successOutput = '/^TIME OK - [0-9]+ second time difference/'; |
24 | 19 | ||
diff --git a/plugins/t/check_udp.t b/plugins/t/check_udp.t index 1f6fee7..6c47d09 100644 --- a/plugins/t/check_udp.t +++ b/plugins/t/check_udp.t | |||
@@ -34,12 +34,12 @@ my $nc; | |||
34 | if(system("which nc.traditional >/dev/null 2>&1") == 0) { | 34 | if(system("which nc.traditional >/dev/null 2>&1") == 0) { |
35 | $nc = 'nc.traditional -w 3 -l -u -p 3333'; | 35 | $nc = 'nc.traditional -w 3 -l -u -p 3333'; |
36 | } | 36 | } |
37 | elsif(system("which netcat >/dev/null 2>&1") == 0) { | ||
38 | $nc = 'netcat -w 3 -l -u -p 3333'; | ||
39 | } | ||
40 | elsif(system("which nc >/dev/null 2>&1") == 0) { | 37 | elsif(system("which nc >/dev/null 2>&1") == 0) { |
41 | $nc = 'nc -w 3 -l -u -4 localhost 3333'; | 38 | $nc = 'nc -w 3 -l -u -4 localhost 3333'; |
42 | } | 39 | } |
40 | elsif(system("which netcat >/dev/null 2>&1") == 0) { | ||
41 | $nc = 'netcat -w 3 -l -u -p 3333'; | ||
42 | } | ||
43 | 43 | ||
44 | SKIP: { | 44 | SKIP: { |
45 | skip "solaris netcat does not listen to udp", 6 if $^O eq 'solaris'; | 45 | skip "solaris netcat does not listen to udp", 6 if $^O eq 'solaris'; |
diff --git a/plugins/t/check_users.t b/plugins/t/check_users.t index 39044bb..088f3b5 100644 --- a/plugins/t/check_users.t +++ b/plugins/t/check_users.t | |||
@@ -13,7 +13,7 @@ use Test; | |||
13 | use NPTest; | 13 | use NPTest; |
14 | 14 | ||
15 | use vars qw($tests); | 15 | use vars qw($tests); |
16 | BEGIN {$tests = 4; plan tests => $tests} | 16 | BEGIN {$tests = 8; plan tests => $tests} |
17 | 17 | ||
18 | my $successOutput = '/^USERS OK - [0-9]+ users currently logged in/'; | 18 | my $successOutput = '/^USERS OK - [0-9]+ users currently logged in/'; |
19 | my $failureOutput = '/^USERS CRITICAL - [0-9]+ users currently logged in/'; | 19 | my $failureOutput = '/^USERS CRITICAL - [0-9]+ users currently logged in/'; |
@@ -22,6 +22,8 @@ my $t; | |||
22 | 22 | ||
23 | $t += checkCmd( "./check_users 1000 1000", 0, $successOutput ); | 23 | $t += checkCmd( "./check_users 1000 1000", 0, $successOutput ); |
24 | $t += checkCmd( "./check_users 0 0", 2, $failureOutput ); | 24 | $t += checkCmd( "./check_users 0 0", 2, $failureOutput ); |
25 | $t += checkCmd( "./check_users -w 0:1000 -c 0:1000", 0, $successOutput ); | ||
26 | $t += checkCmd( "./check_users -w 0:0 -c 0:0", 2, $failureOutput ); | ||
25 | 27 | ||
26 | exit(0) if defined($Test::Harness::VERSION); | 28 | exit(0) if defined($Test::Harness::VERSION); |
27 | exit($tests - $t); | 29 | exit($tests - $t); |