diff options
Diffstat (limited to 'plugins/t')
-rw-r--r-- | plugins/t/NPTest.cache.travis | 54 | ||||
-rw-r--r-- | plugins/t/check_disk.t | 4 | ||||
-rw-r--r-- | plugins/t/check_dns.t | 5 | ||||
-rw-r--r-- | plugins/t/check_fping.t | 14 | ||||
-rw-r--r-- | plugins/t/check_http.t | 24 | ||||
-rw-r--r-- | plugins/t/check_mysql.t | 32 | ||||
-rw-r--r-- | plugins/t/check_ntp.t | 10 | ||||
-rw-r--r-- | plugins/t/check_procs.t | 7 | ||||
-rw-r--r-- | plugins/t/check_snmp.t | 13 | ||||
-rw-r--r-- | plugins/t/check_tcp.t | 18 | ||||
-rw-r--r-- | plugins/t/check_udp.t | 2 | ||||
-rw-r--r-- | plugins/t/negate.t | 2 |
12 files changed, 132 insertions, 53 deletions
diff --git a/plugins/t/NPTest.cache.travis b/plugins/t/NPTest.cache.travis new file mode 100644 index 00000000..c1007deb --- /dev/null +++ b/plugins/t/NPTest.cache.travis | |||
@@ -0,0 +1,54 @@ | |||
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_TCP_HTTP' => 'localhost', | ||
18 | 'NP_HOST_TCP_HTTP2' => 'labs.consol.de', | ||
19 | 'NP_HOST_TCP_IMAP' => 'imap.web.de', | ||
20 | 'NP_HOST_TCP_POP' => 'pop.web.de', | ||
21 | 'NP_HOST_TCP_SMTP' => 'localhost', | ||
22 | 'NP_HOST_TCP_SMTP_NOTLS' => '', | ||
23 | 'NP_HOST_TCP_SMTP_TLS' => '', | ||
24 | 'NP_INTERNET_ACCESS' => 'yes', | ||
25 | 'NP_MOUNTPOINT2_VALID' => '', | ||
26 | 'NP_MOUNTPOINT_VALID' => '/', | ||
27 | 'NP_MYSQL_SERVER' => 'localhost', | ||
28 | 'NP_HOST_UDP_TIME' => 'localhost', | ||
29 | 'NP_MYSQL_SOCKET' => '/var/run/mysqld/mysqld.sock', | ||
30 | 'NP_MYSQL_WITH_SLAVE' => '', | ||
31 | 'NP_MYSQL_WITH_SLAVE_LOGIN' => '', | ||
32 | 'NP_NO_NTP_SERVICE' => 'localhost', | ||
33 | 'NP_SMB_SHARE' => '', | ||
34 | 'NP_SMB_SHARE_DENY' => '', | ||
35 | 'NP_SMB_SHARE_SPC' => '', | ||
36 | 'NP_SMB_VALID_USER' => '', | ||
37 | 'NP_SMB_VALID_USER_PASS' => '', | ||
38 | 'NP_SNMP_COMMUNITY' => '', | ||
39 | 'NP_SSH_CONFIGFILE' => '~/.ssh/config', | ||
40 | 'NP_SSH_HOST' => 'localhost', | ||
41 | 'NP_SSH_IDENTITY' => '~/.ssh/id_dsa', | ||
42 | 'NP_HOST_TCP_JABBER' => 'jabber.org', | ||
43 | 'host_nonresponsive' => '10.0.0.1', | ||
44 | 'host_responsive' => 'localhost', | ||
45 | 'host_snmp' => '', | ||
46 | 'host_tcp_ftp' => '', | ||
47 | 'host_tcp_http' => 'localhost', | ||
48 | 'host_tcp_imap' => 'imap.nierlein.de', | ||
49 | 'host_tcp_smtp' => 'localhost', | ||
50 | 'hostname_invalid' => 'nosuchhost', | ||
51 | 'snmp_community' => '', | ||
52 | 'user_snmp' => '', | ||
53 | 'host_udp_time' => 'none', | ||
54 | } | ||
diff --git a/plugins/t/check_disk.t b/plugins/t/check_disk.t index 39b4ca9f..7e0f74b7 100644 --- a/plugins/t/check_disk.t +++ b/plugins/t/check_disk.t | |||
@@ -4,7 +4,7 @@ | |||
4 | # | 4 | # |
5 | # | 5 | # |
6 | 6 | ||
7 | # TODO: Add in tests for perf data. Need to beef up Nagios::Plugin::Performance to cater for max, min, etc | 7 | # TODO: Add in tests for perf data. Need to beef up Monitoring::Plugin::Performance to cater for max, min, etc |
8 | 8 | ||
9 | use strict; | 9 | use strict; |
10 | use Test::More; | 10 | use Test::More; |
@@ -37,7 +37,7 @@ cmp_ok( $c, '==', 2, "Got two mountpoints in output"); | |||
37 | 37 | ||
38 | 38 | ||
39 | # Get perf data | 39 | # Get perf data |
40 | # Should use Nagios::Plugin | 40 | # Should use Monitoring::Plugin |
41 | my @perf_data = sort(split(/ /, $result->perf_output)); | 41 | my @perf_data = sort(split(/ /, $result->perf_output)); |
42 | 42 | ||
43 | 43 | ||
diff --git a/plugins/t/check_dns.t b/plugins/t/check_dns.t index 64aaf0ce..4ff553f7 100644 --- a/plugins/t/check_dns.t +++ b/plugins/t/check_dns.t | |||
@@ -10,14 +10,14 @@ 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 => 13; | 13 | plan tests => 14; |
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 | "nagios.com" | 20 | "monitoring-plugins.org" |
21 | ); | 21 | ); |
22 | 22 | ||
23 | my $hostname_valid_ip = getTestParameter( | 23 | my $hostname_valid_ip = getTestParameter( |
@@ -54,6 +54,7 @@ cmp_ok( $res->return_code, '==', 2, "Critical threshold passed"); | |||
54 | 54 | ||
55 | $res = NPTest->testCmd("./check_dns -H $hostname_valid -t 5 -w 0 -c 5"); | 55 | $res = NPTest->testCmd("./check_dns -H $hostname_valid -t 5 -w 0 -c 5"); |
56 | cmp_ok( $res->return_code, '==', 1, "Warning threshold passed"); | 56 | cmp_ok( $res->return_code, '==', 1, "Warning threshold passed"); |
57 | like( $res->output, "/\|time=[\d\.]+s;0.0*;5\.0*;0\.0*/", "Output performance data OK" ); | ||
57 | 58 | ||
58 | $res = NPTest->testCmd("./check_dns -H $hostname_invalid -t 1"); | 59 | $res = NPTest->testCmd("./check_dns -H $hostname_invalid -t 1"); |
59 | cmp_ok( $res->return_code, '==', 2, "Invalid $hostname_invalid"); | 60 | cmp_ok( $res->return_code, '==', 2, "Invalid $hostname_invalid"); |
diff --git a/plugins/t/check_fping.t b/plugins/t/check_fping.t index 45a9be8a..08692e46 100644 --- a/plugins/t/check_fping.t +++ b/plugins/t/check_fping.t | |||
@@ -27,16 +27,18 @@ my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_IN | |||
27 | 27 | ||
28 | my $t; | 28 | my $t; |
29 | 29 | ||
30 | if ( -x "./check_fping" ) | 30 | my $fping = qx(which fping 2> /dev/null); |
31 | { | 31 | chomp($fping); |
32 | if( ! -x "./check_fping") { | ||
33 | $t += skipMissingCmd( "./check_fping", $tests ); | ||
34 | } | ||
35 | elsif ( $> != 0 && (!$fping || ! -u $fping)) { | ||
36 | $t += skipMsg( "./check_fping", $tests ); | ||
37 | } else { | ||
32 | $t += checkCmd( "./check_fping $host_responsive", 0, $successOutput ); | 38 | $t += checkCmd( "./check_fping $host_responsive", 0, $successOutput ); |
33 | $t += checkCmd( "./check_fping $host_nonresponsive", [ 1, 2 ] ); | 39 | $t += checkCmd( "./check_fping $host_nonresponsive", [ 1, 2 ] ); |
34 | $t += checkCmd( "./check_fping $hostname_invalid", [ 1, 2 ] ); | 40 | $t += checkCmd( "./check_fping $hostname_invalid", [ 1, 2 ] ); |
35 | } | 41 | } |
36 | else | ||
37 | { | ||
38 | $t += skipMissingCmd( "./check_fping", $tests ); | ||
39 | } | ||
40 | 42 | ||
41 | exit(0) if defined($Test::Harness::VERSION); | 43 | exit(0) if defined($Test::Harness::VERSION); |
42 | exit($tests - $t); | 44 | exit($tests - $t); |
diff --git a/plugins/t/check_http.t b/plugins/t/check_http.t index 29086737..2539a289 100644 --- a/plugins/t/check_http.t +++ b/plugins/t/check_http.t | |||
@@ -31,8 +31,8 @@ my $internet_access = getTestParameter( "NP_INTERNET_ACCESS", | |||
31 | "yes"); | 31 | "yes"); |
32 | 32 | ||
33 | my $host_tcp_http2 = getTestParameter( "NP_HOST_TCP_HTTP2", | 33 | my $host_tcp_http2 = getTestParameter( "NP_HOST_TCP_HTTP2", |
34 | "A host providing an index page containing the string 'nagios'", | 34 | "A host providing an index page containing the string 'monitoring'", |
35 | "nagios.org" ); | 35 | "test.monitoring-plugins.org" ); |
36 | 36 | ||
37 | 37 | ||
38 | $res = NPTest->testCmd( | 38 | $res = NPTest->testCmd( |
@@ -62,27 +62,27 @@ cmp_ok( $res->return_code, '==', 2, "Webserver $hostname_invalid not valid" ); | |||
62 | like( $res->output, "/Unable to open TCP socket|Socket timeout after/", "Output OK"); | 62 | like( $res->output, "/Unable to open TCP socket|Socket timeout after/", "Output OK"); |
63 | 63 | ||
64 | SKIP: { | 64 | SKIP: { |
65 | skip "No host serving nagios in index file", 7 unless $host_tcp_http2; | 65 | skip "No host serving monitoring in index file", 7 unless $host_tcp_http2; |
66 | 66 | ||
67 | $res = NPTest->testCmd( "./check_http -H $host_tcp_http2 -r 'nagios'" ); | 67 | $res = NPTest->testCmd( "./check_http -H $host_tcp_http2 -r 'monitoring'" ); |
68 | cmp_ok( $res->return_code, "==", 0, "Got a reference to 'nagios'"); | 68 | cmp_ok( $res->return_code, "==", 0, "Got a reference to 'monitoring'"); |
69 | 69 | ||
70 | $res = NPTest->testCmd( "./check_http -H $host_tcp_http2 -r 'nAGiOs'" ); | 70 | $res = NPTest->testCmd( "./check_http -H $host_tcp_http2 -r 'mONiTORing'" ); |
71 | cmp_ok( $res->return_code, "==", 2, "Not got 'nAGiOs'"); | 71 | cmp_ok( $res->return_code, "==", 2, "Not got 'mONiTORing'"); |
72 | like ( $res->output, "/pattern not found/", "Error message says 'pattern not found'"); | 72 | like ( $res->output, "/pattern not found/", "Error message says 'pattern not found'"); |
73 | 73 | ||
74 | $res = NPTest->testCmd( "./check_http -H $host_tcp_http2 -R 'nAGiOs'" ); | 74 | $res = NPTest->testCmd( "./check_http -H $host_tcp_http2 -R 'mONiTORing'" ); |
75 | cmp_ok( $res->return_code, "==", 0, "But case insensitive doesn't mind 'nAGiOs'"); | 75 | cmp_ok( $res->return_code, "==", 0, "But case insensitive doesn't mind 'mONiTORing'"); |
76 | 76 | ||
77 | $res = NPTest->testCmd( "./check_http -H $host_tcp_http2 -r 'nagios' --invert-regex" ); | 77 | $res = NPTest->testCmd( "./check_http -H $host_tcp_http2 -r 'monitoring' --invert-regex" ); |
78 | cmp_ok( $res->return_code, "==", 2, "Invert results work when found"); | 78 | cmp_ok( $res->return_code, "==", 2, "Invert results work when found"); |
79 | like ( $res->output, "/pattern found/", "Error message says 'pattern found'"); | 79 | like ( $res->output, "/pattern found/", "Error message says 'pattern found'"); |
80 | 80 | ||
81 | $res = NPTest->testCmd( "./check_http -H $host_tcp_http2 -r 'nAGiOs' --invert-regex" ); | 81 | $res = NPTest->testCmd( "./check_http -H $host_tcp_http2 -r 'mONiTORing' --invert-regex" ); |
82 | cmp_ok( $res->return_code, "==", 0, "And also when not found"); | 82 | cmp_ok( $res->return_code, "==", 0, "And also when not found"); |
83 | } | 83 | } |
84 | SKIP: { | 84 | SKIP: { |
85 | skip "No internet access", 11 if $internet_access eq "no"; | 85 | skip "No internet access", 16 if $internet_access eq "no"; |
86 | 86 | ||
87 | $res = NPTest->testCmd( | 87 | $res = NPTest->testCmd( |
88 | "./check_http --ssl www.verisign.com" | 88 | "./check_http --ssl www.verisign.com" |
diff --git a/plugins/t/check_mysql.t b/plugins/t/check_mysql.t index d9716458..28cd4cd0 100644 --- a/plugins/t/check_mysql.t +++ b/plugins/t/check_mysql.t | |||
@@ -21,27 +21,29 @@ 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( |
25 | "NP_MYSQL_SERVER", | 25 | "NP_MYSQL_SERVER", |
26 | "A MySQL Server hostname or IP with no slaves setup" | 26 | "A MySQL Server hostname or IP with no slaves setup" |
27 | ); | 27 | ); |
28 | my $mysqlsocket = getTestParameter( | 28 | my $mysqlsocket = getTestParameter( |
29 | "NP_MYSQL_SOCKET", | 29 | "NP_MYSQL_SOCKET", |
30 | "A MySQL Server socket with no slaves setup" | 30 | "Full path to a MySQL Server socket with no slaves setup" |
31 | ); | 31 | ); |
32 | my $mysql_login_details = getTestParameter( | 32 | my $mysql_login_details = getTestParameter( |
33 | "MYSQL_LOGIN_DETAILS", | 33 | "MYSQL_LOGIN_DETAILS", |
34 | "Command line parameters to specify login access", | 34 | "Command line parameters to specify login access (requires " . |
35 | "-u user -ppw -d db", | 35 | "REPLICATION CLIENT privleges)", |
36 | "-u test -ptest", | ||
36 | ); | 37 | ); |
37 | my $with_slave = getTestParameter( | 38 | my $with_slave = getTestParameter( |
38 | "NP_MYSQL_WITH_SLAVE", | 39 | "NP_MYSQL_WITH_SLAVE", |
39 | "MySQL server with slaves setup" | 40 | "MySQL server with slaves setup" |
40 | ); | 41 | ); |
41 | my $with_slave_login = getTestParameter( | 42 | my $with_slave_login = getTestParameter( |
42 | "NP_MYSQL_WITH_SLAVE_LOGIN", | 43 | "NP_MYSQL_WITH_SLAVE_LOGIN", |
43 | "Login details for server with slave", | 44 | "Login details for server with slave (requires REPLICATION CLIENT " . |
44 | "-uroot -ppw" | 45 | "privleges)", |
46 | $mysql_login_details || "-u test -ptest" | ||
45 | ); | 47 | ); |
46 | 48 | ||
47 | my $result; | 49 | my $result; |
diff --git a/plugins/t/check_ntp.t b/plugins/t/check_ntp.t index 3eee6e17..74d890fa 100644 --- a/plugins/t/check_ntp.t +++ b/plugins/t/check_ntp.t | |||
@@ -23,12 +23,12 @@ my $no_ntp_service = getTestParameter( "NP_NO_NTP_SERVICE", | |||
23 | "A host NOT providing the NTP service", | 23 | "A host NOT providing the NTP service", |
24 | "localhost" ); | 24 | "localhost" ); |
25 | 25 | ||
26 | my $host_nonresponsive = getTestParameter( "NP_HOST_NONRESPONSIVE", | 26 | my $host_nonresponsive = getTestParameter( "NP_HOST_NONRESPONSIVE", |
27 | "The hostname of system not responsive to network requests", | 27 | "The hostname of system not responsive to network requests", |
28 | "10.0.0.1" ); | 28 | "10.0.0.1" ); |
29 | 29 | ||
30 | my $hostname_invalid = getTestParameter( "NP_HOSTNAME_INVALID", | 30 | my $hostname_invalid = getTestParameter( "NP_HOSTNAME_INVALID", |
31 | "An invalid (not known to DNS) hostname", | 31 | "An invalid (not known to DNS) hostname", |
32 | "nosuchhost"); | 32 | "nosuchhost"); |
33 | 33 | ||
34 | my $ntp_okmatch1 = '/^NTP\sOK:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs/'; | 34 | my $ntp_okmatch1 = '/^NTP\sOK:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs/'; |
@@ -43,7 +43,7 @@ my $ntp_nosuchhost = '/^check_ntp.*: Invalid hostname/address - ' . $hostname_in | |||
43 | 43 | ||
44 | foreach my $plugin (@PLUGINS1) { | 44 | foreach my $plugin (@PLUGINS1) { |
45 | SKIP: { | 45 | SKIP: { |
46 | skip "No NTP server defined", 1 unless $ntp_service; | 46 | skip "No NTP server defined", 6 unless $ntp_service; |
47 | $res = NPTest->testCmd( | 47 | $res = NPTest->testCmd( |
48 | "./$plugin -H $ntp_service -w 1000 -c 2000" | 48 | "./$plugin -H $ntp_service -w 1000 -c 2000" |
49 | ); | 49 | ); |
@@ -88,7 +88,7 @@ foreach my $plugin (@PLUGINS1) { | |||
88 | 88 | ||
89 | foreach my $plugin (@PLUGINS2) { | 89 | foreach my $plugin (@PLUGINS2) { |
90 | SKIP: { | 90 | SKIP: { |
91 | skip "No NTP server defined", 1 unless $ntp_service; | 91 | skip "No NTP server defined", 6 unless $ntp_service; |
92 | $res = NPTest->testCmd( | 92 | $res = NPTest->testCmd( |
93 | "./$plugin -H $ntp_service -w 1000 -c 2000 -W 20 -C 21 -j 100000 -k 200000 -m 1: -n 0:" | 93 | "./$plugin -H $ntp_service -w 1000 -c 2000 -W 20 -C 21 -j 100000 -k 200000 -m 1: -n 0:" |
94 | ); | 94 | ); |
diff --git a/plugins/t/check_procs.t b/plugins/t/check_procs.t index 1dea5643..ca4acdd7 100644 --- a/plugins/t/check_procs.t +++ b/plugins/t/check_procs.t | |||
@@ -13,7 +13,7 @@ my $t; | |||
13 | if (`uname -s` eq "SunOS\n" && ! -x "/usr/local/nagios/libexec/pst3") { | 13 | if (`uname -s` eq "SunOS\n" && ! -x "/usr/local/nagios/libexec/pst3") { |
14 | plan skip_all => "Ignoring tests on solaris because of pst3"; | 14 | plan skip_all => "Ignoring tests on solaris because of pst3"; |
15 | } else { | 15 | } else { |
16 | plan tests => 12; | 16 | plan tests => 14; |
17 | } | 17 | } |
18 | 18 | ||
19 | my $result; | 19 | my $result; |
@@ -26,6 +26,11 @@ $result = NPTest->testCmd( "./check_procs -w 100000 -c 100000 -s Z" ); | |||
26 | is( $result->return_code, 0, "Checking less than 100000 zombie processes" ); | 26 | is( $result->return_code, 0, "Checking less than 100000 zombie processes" ); |
27 | like( $result->output, '/^PROCS OK: [0-9]+ process(es)? with /', "Output correct" ); | 27 | like( $result->output, '/^PROCS OK: [0-9]+ process(es)? with /', "Output correct" ); |
28 | 28 | ||
29 | if(fork() == 0) { exec("sleep 7"); } # fork a test process | ||
30 | $result = NPTest->testCmd( "./check_procs -a 'sleep 7'" ); | ||
31 | is( $result->return_code, 0, "Parent process is ignored" ); | ||
32 | like( $result->output, '/^PROCS OK: 1 process?/', "Output correct" ); | ||
33 | |||
29 | $result = NPTest->testCmd( "./check_procs -w 0 -c 100000" ); | 34 | $result = NPTest->testCmd( "./check_procs -w 0 -c 100000" ); |
30 | is( $result->return_code, 1, "Checking warning if processes > 0" ); | 35 | is( $result->return_code, 1, "Checking warning if processes > 0" ); |
31 | like( $result->output, '/^PROCS WARNING: [0-9]+ process(es)? | procs=[0-9]+;0;100000;0;$/', "Output correct" ); | 36 | like( $result->output, '/^PROCS WARNING: [0-9]+ process(es)? | procs=[0-9]+;0;100000;0;$/', "Output correct" ); |
diff --git a/plugins/t/check_snmp.t b/plugins/t/check_snmp.t index 6de5f299..2d6c44a7 100644 --- a/plugins/t/check_snmp.t +++ b/plugins/t/check_snmp.t | |||
@@ -10,7 +10,7 @@ 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 => 60; | 13 | plan tests => 61; |
14 | } | 14 | } |
15 | 15 | ||
16 | my $res; | 16 | my $res; |
@@ -26,6 +26,7 @@ my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRES | |||
26 | 26 | ||
27 | my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost", | 27 | my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost", |
28 | "An invalid (not known to DNS) hostname" ); | 28 | "An invalid (not known to DNS) hostname" ); |
29 | my $user_snmp = getTestParameter( "user_snmp", "NP_SNMP_USER", "auth_md5", "An SNMP user"); | ||
29 | 30 | ||
30 | $res = NPTest->testCmd( "./check_snmp -t 1" ); | 31 | $res = NPTest->testCmd( "./check_snmp -t 1" ); |
31 | is( $res->return_code, 3, "No host name" ); | 32 | is( $res->return_code, 3, "No host name" ); |
@@ -35,7 +36,7 @@ $res = NPTest->testCmd( "./check_snmp -H fakehostname" ); | |||
35 | is( $res->return_code, 3, "No OIDs specified" ); | 36 | is( $res->return_code, 3, "No OIDs specified" ); |
36 | is( $res->output, "No OIDs specified" ); | 37 | is( $res->output, "No OIDs specified" ); |
37 | 38 | ||
38 | $res = NPTest->testCmd( "./check_snmp -H fakehost -o oids -P 3 --seclevel=rubbish" ); | 39 | $res = NPTest->testCmd( "./check_snmp -H fakehost -o oids -P 3 -U not_a_user --seclevel=rubbish" ); |
39 | is( $res->return_code, 3, "Invalid seclevel" ); | 40 | is( $res->return_code, 3, "Invalid seclevel" ); |
40 | like( $res->output, "/check_snmp: Invalid seclevel - rubbish/" ); | 41 | like( $res->output, "/check_snmp: Invalid seclevel - rubbish/" ); |
41 | 42 | ||
@@ -44,7 +45,7 @@ is( $res->return_code, 3, "Invalid protocol" ); | |||
44 | like( $res->output, "/check_snmp: Invalid SNMP version - 3c/" ); | 45 | like( $res->output, "/check_snmp: Invalid SNMP version - 3c/" ); |
45 | 46 | ||
46 | SKIP: { | 47 | SKIP: { |
47 | skip "no snmp host defined", 38 if ( ! $host_snmp ); | 48 | skip "no snmp host defined", 48 if ( ! $host_snmp ); |
48 | 49 | ||
49 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0 -w 1: -c 1:"); | 50 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0 -w 1: -c 1:"); |
50 | cmp_ok( $res->return_code, '==', 0, "Exit OK when querying uptime" ); | 51 | cmp_ok( $res->return_code, '==', 0, "Exit OK when querying uptime" ); |
@@ -154,6 +155,12 @@ SKIP: { | |||
154 | 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"); | 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"); |
155 | } | 156 | } |
156 | 157 | ||
158 | SKIP: { | ||
159 | skip "no SNMP user defined", 1 if ( ! $user_snmp ); | ||
160 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp -o HOST-RESOURCES-MIB::hrSystemUptime.0 -P 3 -U $user_snmp -L noAuthNoPriv"); | ||
161 | like( $res->output, '/^SNMP OK - Timeticks:\s\(\d+\)\s+(?:\d+ days?,\s+)?\d+:\d+:\d+\.\d+\s.*$/', "noAuthNoPriv security level works properly" ); | ||
162 | } | ||
163 | |||
157 | # These checks need a complete command line. An invalid community is used so | 164 | # These checks need a complete command line. An invalid community is used so |
158 | # the tests can run on hosts w/o snmp host/community in NPTest.cache. Execution will fail anyway | 165 | # the tests can run on hosts w/o snmp host/community in NPTest.cache. Execution will fail anyway |
159 | SKIP: { | 166 | SKIP: { |
diff --git a/plugins/t/check_tcp.t b/plugins/t/check_tcp.t index abb16aec..f996685d 100644 --- a/plugins/t/check_tcp.t +++ b/plugins/t/check_tcp.t | |||
@@ -12,7 +12,6 @@ BEGIN { | |||
12 | use NPTest; | 12 | use NPTest; |
13 | $has_ipv6 = NPTest::has_ipv6(); | 13 | $has_ipv6 = NPTest::has_ipv6(); |
14 | $tests = $has_ipv6 ? 14 : 11; | 14 | $tests = $has_ipv6 ? 14 : 11; |
15 | plan tests => $tests; | ||
16 | } | 15 | } |
17 | 16 | ||
18 | 17 | ||
@@ -25,20 +24,29 @@ my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRES | |||
25 | my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost", | 24 | my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost", |
26 | "An invalid (not known to DNS) hostname" ); | 25 | "An invalid (not known to DNS) hostname" ); |
27 | 26 | ||
27 | my $internet_access = getTestParameter( "NP_INTERNET_ACCESS", | ||
28 | "Is this system directly connected to the internet?", | ||
29 | "yes"); | ||
30 | |||
28 | my $successOutput = '/^TCP OK\s-\s+[0-9]?\.?[0-9]+ second response time on port [0-9]+/'; | 31 | my $successOutput = '/^TCP OK\s-\s+[0-9]?\.?[0-9]+ second response time on port [0-9]+/'; |
29 | 32 | ||
30 | my $failedExpect = '/^TCP WARNING\s-\sUnexpected response from host/socket on port [0-9]+/'; | 33 | my $failedExpect = '/^TCP WARNING\s-\sUnexpected response from host/socket on port [0-9]+/'; |
31 | 34 | ||
32 | my $t; | 35 | my $t; |
33 | 36 | ||
37 | $tests = $tests - 4 if $internet_access eq "no"; | ||
38 | plan tests => $tests; | ||
39 | |||
34 | $t += checkCmd( "./check_tcp $host_tcp_http -p 80 -wt 300 -ct 600", 0, $successOutput ); | 40 | $t += checkCmd( "./check_tcp $host_tcp_http -p 80 -wt 300 -ct 600", 0, $successOutput ); |
35 | $t += checkCmd( "./check_tcp $host_tcp_http -p 81 -wt 0 -ct 0 -to 1", 2 ); # use invalid port for this test | 41 | $t += checkCmd( "./check_tcp $host_tcp_http -p 81 -wt 0 -ct 0 -to 1", 2 ); # use invalid port for this test |
36 | $t += checkCmd( "./check_tcp $host_nonresponsive -p 80 -wt 0 -ct 0 -to 1", 2 ); | 42 | $t += checkCmd( "./check_tcp $host_nonresponsive -p 80 -wt 0 -ct 0 -to 1", 2 ); |
37 | $t += checkCmd( "./check_tcp $hostname_invalid -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 ); |
38 | $t += checkCmd( "./check_tcp -S -D 1 -H www.verisign.com -p 443", 0 ); | 44 | if($internet_access ne "no") { |
39 | $t += checkCmd( "./check_tcp -S -D 9000,1 -H www.verisign.com -p 443", 1 ); | 45 | $t += checkCmd( "./check_tcp -S -D 1 -H www.verisign.com -p 443", 0 ); |
40 | $t += checkCmd( "./check_tcp -S -D 9000 -H www.verisign.com -p 443", 1 ); | 46 | $t += checkCmd( "./check_tcp -S -D 9000,1 -H www.verisign.com -p 443", 1 ); |
41 | $t += checkCmd( "./check_tcp -S -D 9000,8999 -H www.verisign.com -p 443", 2 ); | 47 | $t += checkCmd( "./check_tcp -S -D 9000 -H www.verisign.com -p 443", 1 ); |
48 | $t += checkCmd( "./check_tcp -S -D 9000,8999 -H www.verisign.com -p 443", 2 ); | ||
49 | } | ||
42 | 50 | ||
43 | # Need the \r\n to make it more standards compliant with web servers. Need the various quotes | 51 | # Need the \r\n to make it more standards compliant with web servers. Need the various quotes |
44 | # so that perl doesn't interpret the \r\n and is passed onto command line correctly | 52 | # so that perl doesn't interpret the \r\n and is passed onto command line correctly |
diff --git a/plugins/t/check_udp.t b/plugins/t/check_udp.t index 619cadfb..1f6fee70 100644 --- a/plugins/t/check_udp.t +++ b/plugins/t/check_udp.t | |||
@@ -62,7 +62,7 @@ SKIP: { | |||
62 | cmp_ok( $res->return_code, '==', '2', "Hung waiting for response"); | 62 | cmp_ok( $res->return_code, '==', '2', "Hung waiting for response"); |
63 | like ( $res->output, '/Socket timeout after 5 seconds/', "Timeout message"); | 63 | like ( $res->output, '/Socket timeout after 5 seconds/', "Timeout message"); |
64 | like ( $duration, '/^[56]$/', "Timeout after 5 (possibly 6) seconds"); | 64 | like ( $duration, '/^[56]$/', "Timeout after 5 (possibly 6) seconds"); |
65 | my $read_nc = <NC>; | 65 | my $read_nc = <NC> || ''; |
66 | close NC; | 66 | close NC; |
67 | cmp_ok( $read_nc, 'eq', "foofoo", "Data received correctly" ); | 67 | cmp_ok( $read_nc, 'eq', "foofoo", "Data received correctly" ); |
68 | } | 68 | } |
diff --git a/plugins/t/negate.t b/plugins/t/negate.t index 0afe3ae6..f18acc39 100644 --- a/plugins/t/negate.t +++ b/plugins/t/negate.t | |||
@@ -78,7 +78,7 @@ foreach my $current_state (keys(%state)) { | |||
78 | } | 78 | } |
79 | } | 79 | } |
80 | 80 | ||
81 | # Same as aboce with substitute | 81 | # Same as above with substitute |
82 | foreach my $current_state (keys(%state)) { | 82 | foreach my $current_state (keys(%state)) { |
83 | foreach my $new_state (keys(%state)) { | 83 | foreach my $new_state (keys(%state)) { |
84 | $res = NPTest->testCmd( "./negate -s --$current_state=$new_state ./check_dummy ".$state{$current_state}." 'Fake $new_state'" ); | 84 | $res = NPTest->testCmd( "./negate -s --$current_state=$new_state ./check_dummy ".$state{$current_state}." 'Fake $new_state'" ); |