diff options
Diffstat (limited to 'plugins/t')
-rw-r--r-- | plugins/t/NPTest.cache.travis | 54 | ||||
-rw-r--r-- | plugins/t/check_curl.t | 7 | ||||
-rw-r--r-- | plugins/t/check_fping.t | 32 | ||||
-rw-r--r-- | plugins/t/check_http.t | 4 |
4 files changed, 19 insertions, 78 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 a4f1dfb..45ee533 100644 --- a/plugins/t/check_curl.t +++ b/plugins/t/check_curl.t | |||
@@ -84,7 +84,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" ); | 84 | like( $res->output, '/CURLOPT_URL: http:\/\/'.$host_tcp_http.':80\//ms', "Url OK" ); |
85 | 85 | ||
86 | SKIP: { | 86 | SKIP: { |
87 | skip "No internet access", 3 if $internet_access eq "no"; | 87 | skip "No internet access", 4 if $internet_access eq "no"; |
88 | 88 | ||
89 | $res = NPTest->testCmd("./$plugin -v -H $host_tls_http -S"); | 89 | $res = NPTest->testCmd("./$plugin -v -H $host_tls_http -S"); |
90 | like( $res->output, '/^Host: '.$host_tls_http.'\s*$/ms', "Host Header OK" ); | 90 | like( $res->output, '/^Host: '.$host_tls_http.'\s*$/ms', "Host Header OK" ); |
@@ -120,7 +120,7 @@ SKIP: { | |||
120 | cmp_ok( $res->return_code, "==", 0, "And also when not found"); | 120 | cmp_ok( $res->return_code, "==", 0, "And also when not found"); |
121 | } | 121 | } |
122 | SKIP: { | 122 | SKIP: { |
123 | skip "No internet access", 16 if $internet_access eq "no"; | 123 | skip "No internet access", 28 if $internet_access eq "no"; |
124 | 124 | ||
125 | $res = NPTest->testCmd( | 125 | $res = NPTest->testCmd( |
126 | "./$plugin --ssl $host_tls_http" | 126 | "./$plugin --ssl $host_tls_http" |
@@ -193,8 +193,7 @@ SKIP: { | |||
193 | ); | 193 | ); |
194 | cmp_ok( $res->return_code, "==", 0, "Can read https for www.e-paycobalt.com (uses AES certificate)" ); | 194 | cmp_ok( $res->return_code, "==", 0, "Can read https for www.e-paycobalt.com (uses AES certificate)" ); |
195 | 195 | ||
196 | 196 | $res = NPTest->testCmd( "./$plugin -H www.mozilla.com -u /firefox -f curl" ); | |
197 | $res = NPTest->testCmd( "./$plugin -H www.mozilla.com -u /firefox -f follow" ); | ||
198 | is( $res->return_code, 0, "Redirection based on location is okay"); | 197 | is( $res->return_code, 0, "Redirection based on location is okay"); |
199 | 198 | ||
200 | $res = NPTest->testCmd( "./$plugin -H www.mozilla.com --extended-perfdata" ); | 199 | $res = NPTest->testCmd( "./$plugin -H www.mozilla.com --extended-perfdata" ); |
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..c137f7b 100644 --- a/plugins/t/check_http.t +++ b/plugins/t/check_http.t | |||
@@ -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", 23 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" ); |