diff options
author | Peter Bray <illumino@users.sourceforge.net> | 2005-07-25 01:47:15 +0000 |
---|---|---|
committer | Peter Bray <illumino@users.sourceforge.net> | 2005-07-25 01:47:15 +0000 |
commit | cdc06cc3e2c4670d3cd46b0a03adcf7e6958eff1 (patch) | |
tree | 62b074eaca618762fb03f94708ec3def50037697 /plugins | |
parent | 05853f47eb6e608de993cc59343c73b96b9b33e2 (diff) | |
download | monitoring-plugins-cdc06cc3e2c4670d3cd46b0a03adcf7e6958eff1.tar.gz |
[1185704] New Testing Infrastructure.
Complete rewrite of the original testing infrastructure and
all test cases (to use the new infrastructure)
See NPTest.pm and issue 1185704 for more details.
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1207 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/t/check_disk.t | 44 | ||||
-rw-r--r-- | plugins/t/check_dns.t | 44 | ||||
-rw-r--r-- | plugins/t/check_fping.t | 48 | ||||
-rw-r--r-- | plugins/t/check_ftp.t | 44 | ||||
-rw-r--r-- | plugins/t/check_hpjd.t | 50 | ||||
-rw-r--r-- | plugins/t/check_http.t | 36 | ||||
-rw-r--r-- | plugins/t/check_imap.t | 51 | ||||
-rw-r--r-- | plugins/t/check_load.t | 30 | ||||
-rw-r--r-- | plugins/t/check_mysql.t | 33 | ||||
-rw-r--r-- | plugins/t/check_ping.t | 47 | ||||
-rw-r--r-- | plugins/t/check_pop.t | 47 | ||||
-rw-r--r-- | plugins/t/check_procs.t | 53 | ||||
-rw-r--r-- | plugins/t/check_smtp.t | 43 | ||||
-rw-r--r-- | plugins/t/check_snmp.t | 91 | ||||
-rw-r--r-- | plugins/t/check_swap.t | 35 | ||||
-rw-r--r-- | plugins/t/check_tcp.t | 41 | ||||
-rw-r--r-- | plugins/t/check_time.t | 60 | ||||
-rw-r--r-- | plugins/t/check_udp.t | 37 | ||||
-rw-r--r-- | plugins/t/check_users.t | 31 | ||||
-rw-r--r-- | plugins/t/check_vsz.t | 28 |
20 files changed, 453 insertions, 440 deletions
diff --git a/plugins/t/check_disk.t b/plugins/t/check_disk.t index f1e436dc..f2427fbe 100644 --- a/plugins/t/check_disk.t +++ b/plugins/t/check_disk.t | |||
@@ -1,31 +1,33 @@ | |||
1 | #! /usr/bin/perl -w -I .. | ||
2 | # | ||
3 | # Disk Space Tests via check_disk | ||
4 | # | ||
5 | # $Id$ | ||
6 | # | ||
7 | |||
1 | use strict; | 8 | use strict; |
2 | use Test; | 9 | use Test; |
10 | use NPTest; | ||
11 | |||
3 | use vars qw($tests); | 12 | use vars qw($tests); |
13 | BEGIN {$tests = 10; plan tests => $tests} | ||
14 | |||
15 | my $successOutput = '/^DISK OK - /'; | ||
16 | my $failureOutput = '/^DISK CRITICAL - /'; | ||
17 | |||
18 | my $mountpoint_valid = getTestParameter( "mountpoint_valid", "NP_MOUNTPOINT_VALID", "/", | ||
19 | "The path to a valid mountpoint" ); | ||
4 | 20 | ||
5 | BEGIN {$tests = 6; plan tests => $tests} | 21 | my $mountpoint_invalid = getTestParameter( "mountpoint_invalid", "NP_MOUNTPOINT_INVALID", "/missing", |
22 | "The path to a invalid (non-existent) mountpoint" ); | ||
6 | 23 | ||
7 | my $null = ''; | ||
8 | my $cmd; | ||
9 | my $str; | ||
10 | my $t; | 24 | my $t; |
11 | 25 | ||
12 | $cmd = "./check_disk 100 100 /"; | 26 | $t += checkCmd( "./check_disk 100 100 ${mountpoint_valid}", 0, $successOutput ); |
13 | $str = `$cmd`; | 27 | $t += checkCmd( "./check_disk -w 0 -c 0 ${mountpoint_valid}", 0, $successOutput ); |
14 | $t += ok $?>>8,0; | 28 | $t += checkCmd( "./check_disk -w 1\% -c 1\% ${mountpoint_valid}", 0, $successOutput ); |
15 | print "Test was: $cmd\n" if ($?); | 29 | $t += checkCmd( "./check_disk 0 0 ${mountpoint_valid}", 2, $failureOutput ); |
16 | $t += ok $str, '/^(Disk ok - +[\.0-9]+|DISK OK - )/'; | 30 | $t += checkCmd( "./check_disk 100 100 ${mountpoint_invalid}", 2, '/not found/' ); |
17 | |||
18 | $cmd = "./check_disk -w 0 -c 0 /"; | ||
19 | $str = `$cmd`; | ||
20 | $t += ok $?>>8,0; | ||
21 | print "Test was: $cmd\n" if ($?); | ||
22 | $t += ok $str, '/^(Disk ok - +[\.0-9]+|DISK OK - )/'; | ||
23 | |||
24 | $cmd = "./check_disk 0 0 /"; | ||
25 | $str = `$cmd`; | ||
26 | $t += ok $?>>8,2; | ||
27 | print "Test was: $cmd\n" unless ($?); | ||
28 | $t += ok $str, '/^(Only +[\.0-9]+|DISK CRITICAL - )/'; | ||
29 | 31 | ||
30 | exit(0) if defined($Test::Harness::VERSION); | 32 | exit(0) if defined($Test::Harness::VERSION); |
31 | exit($tests - $t); | 33 | exit($tests - $t); |
diff --git a/plugins/t/check_dns.t b/plugins/t/check_dns.t index bee1d34b..fbaca794 100644 --- a/plugins/t/check_dns.t +++ b/plugins/t/check_dns.t | |||
@@ -1,28 +1,42 @@ | |||
1 | #! /usr/bin/perl -w | 1 | #! /usr/bin/perl -w -I .. |
2 | # | ||
3 | # Domain Name Server (DNS) Tests via check_dns | ||
4 | # | ||
5 | # $Id$ | ||
6 | # | ||
2 | 7 | ||
3 | use strict; | 8 | use strict; |
4 | use Cache; | ||
5 | use Test; | 9 | use Test; |
10 | use NPTest; | ||
11 | |||
6 | use vars qw($tests); | 12 | use vars qw($tests); |
13 | BEGIN {$tests = 6; plan tests => $tests} | ||
14 | |||
15 | my $successOutput = '/DNS OK: [\.0-9]+ seconds response time/'; | ||
7 | 16 | ||
8 | BEGIN {$tests = 3; plan tests => $tests} | 17 | my $hostname_valid = getTestParameter( "hostname_valid", "NP_HOSTNAME_VALID", "localhost", |
18 | "A valid (known to DNS) hostname" ); | ||
9 | 19 | ||
10 | #`nslookup localhost > /dev/null 2>&1` || exit(77); | 20 | my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost", |
21 | "An invalid (not known to DNS) hostname" ); | ||
22 | |||
23 | my $dns_server = getTestParameter( "dns_server", "NP_DNS_SERVER", undef, | ||
24 | "A non default (remote) DNS server" ); | ||
11 | 25 | ||
12 | my $null = ''; | ||
13 | my $cmd; | ||
14 | my $str; | ||
15 | my $t; | 26 | my $t; |
16 | 27 | ||
17 | $str = `./check_dns $Cache::dnshost -to 5`; | 28 | # |
18 | $t += ok $?>>8,0; | 29 | # Default DNS Server |
19 | print "Test was: $cmd\n" if ($?); | 30 | # |
20 | $t += ok $str, '/DNS OK: +[\.0-9]+ seconds response time, /'; | 31 | $t += checkCmd( "./check_dns -H $hostname_valid -t 5", 0, $successOutput ); |
32 | $t += checkCmd( "./check_dns -H $hostname_invalid -t 1", 2 ); | ||
21 | 33 | ||
22 | $cmd = "./check_dns $Cache::nullhost -to 1"; | 34 | # |
23 | $str = `$cmd`; | 35 | # Specified DNS Server |
24 | $t += ok $?>>8,2; | 36 | # |
25 | print "Test was: $cmd\n" unless ($?); | 37 | $t += checkCmd( "./check_dns -H $hostname_valid -s $dns_server -t 5", 0, $successOutput ); |
38 | $t += checkCmd( "./check_dns -H $hostname_invalid -s $dns_server -t 1", 2 ); | ||
26 | 39 | ||
27 | exit(0) if defined($Test::Harness::VERSION); | 40 | exit(0) if defined($Test::Harness::VERSION); |
28 | exit($tests - $t); | 41 | exit($tests - $t); |
42 | |||
diff --git a/plugins/t/check_fping.t b/plugins/t/check_fping.t index 629ee35f..c59d59e0 100644 --- a/plugins/t/check_fping.t +++ b/plugins/t/check_fping.t | |||
@@ -1,37 +1,43 @@ | |||
1 | #! /usr/bin/perl -w | 1 | #! /usr/bin/perl -w -I .. |
2 | # | ||
3 | # FPing Tests via check_fping | ||
4 | # | ||
2 | # $Id$ | 5 | # $Id$ |
6 | # | ||
3 | 7 | ||
4 | use strict; | 8 | use strict; |
5 | use Cache; | ||
6 | use Test; | 9 | use Test; |
10 | use NPTest; | ||
11 | |||
7 | use vars qw($tests); | 12 | use vars qw($tests); |
8 | 13 | ||
9 | BEGIN {$tests = 3; plan tests => $tests} | 14 | BEGIN {$tests = 4; plan tests => $tests} |
10 | 15 | ||
11 | exit(0) unless (-x "./check_fping"); | 16 | my $successOutput = '/^FPING OK - /'; |
17 | my $failureOutput = '/^FPING CRITICAL - /'; | ||
12 | 18 | ||
13 | #`fping 127.0.0.1 > /dev/null 2>&1` || exit(77); | 19 | my $host_responsive = getTestParameter( "host_responsive", "NP_HOST_RESPONSIVE", "localhost", |
20 | "The hostname of system responsive to network requests" ); | ||
14 | 21 | ||
15 | my $null = ''; | 22 | my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1", |
16 | my $cmd; | 23 | "The hostname of system not responsive to network requests" ); |
17 | my $str; | ||
18 | my $t; | ||
19 | my $stat; | ||
20 | 24 | ||
25 | my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost", | ||
26 | "An invalid (not known to DNS) hostname" ); | ||
21 | 27 | ||
22 | $cmd = "./check_fping 127.0.0.1"; | ||
23 | $str = `$cmd`; | ||
24 | $t += ok $?>>8,0; | ||
25 | print "Test was: $cmd\n" if ($?); | ||
26 | $t += ok $str, '/^FPING OK - 127.0.0.1/'; | ||
27 | 28 | ||
28 | $cmd = "./check_fping $Cache::nullhost"; | 29 | my $t; |
29 | $str = `$cmd`; | 30 | |
30 | if ($?>>8 == 1 or $?>>8 == 2) { | 31 | if ( -x "./check_fping" ) |
31 | $stat = 2; | 32 | { |
33 | $t += checkCmd( "./check_fping $host_responsive", 0, $successOutput ); | ||
34 | $t += checkCmd( "./check_fping $host_nonresponsive", [ 1, 2 ] ); | ||
35 | $t += checkCmd( "./check_fping $hostname_invalid", [ 1, 2 ] ); | ||
36 | } | ||
37 | else | ||
38 | { | ||
39 | $t += skipMissingCmd( "./check_fping", $tests ); | ||
32 | } | 40 | } |
33 | $t += ok $stat,2; | ||
34 | print "Test was: $cmd\n" if (($?>>8) < 1); | ||
35 | 41 | ||
36 | exit(0) if defined($Test::Harness::VERSION); | 42 | exit(0) if defined($Test::Harness::VERSION); |
37 | exit($tests - $t); | 43 | exit($tests - $t); |
diff --git a/plugins/t/check_ftp.t b/plugins/t/check_ftp.t index d9e9d9ca..47a73e13 100644 --- a/plugins/t/check_ftp.t +++ b/plugins/t/check_ftp.t | |||
@@ -1,32 +1,34 @@ | |||
1 | #! /usr/bin/perl -w | 1 | #! /usr/bin/perl -w -I .. |
2 | # | ||
3 | # File Transfer Protocol (FTP) Test via check_ftp | ||
4 | # | ||
5 | # $Id$ | ||
6 | # | ||
2 | 7 | ||
3 | #use strict; | 8 | use strict; |
4 | use Cache; | ||
5 | use Test; | 9 | use Test; |
10 | use NPTest; | ||
11 | |||
6 | use vars qw($tests); | 12 | use vars qw($tests); |
13 | BEGIN {$tests = 4; plan tests => $tests} | ||
7 | 14 | ||
8 | BEGIN {$tests = 3; plan tests => $tests} | 15 | my $host_tcp_ftp = getTestParameter( "host_tcp_ftp", "NP_HOST_TCP_FTP", "localhost", |
16 | "A host providing the FTP Service (an FTP server)"); | ||
9 | 17 | ||
10 | my $null = ''; | 18 | my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1", |
11 | my $cmd; | 19 | "The hostname of system not responsive to network requests" ); |
12 | my $str; | ||
13 | my $t; | ||
14 | 20 | ||
15 | $cmd = "./check_ftp $Cache::hostname -wt 300 -ct 600"; | 21 | my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost", |
16 | $str = `$cmd`; | 22 | "An invalid (not known to DNS) hostname" ); |
17 | $t += ok $?>>8,0; | ||
18 | print "Test was: $cmd\n" if ($?); | ||
19 | $t += ok $str, '/FTP OK -\s+[0-9]?\.?[0-9]+ second response time/'; | ||
20 | 23 | ||
21 | #$cmd = "./check_ftp $Cache::noserver -wt 0 -ct 0"; | 24 | my $successOutput = '/FTP OK -\s+[0-9]?\.?[0-9]+ second response time/'; |
22 | #$str = `$cmd`; | ||
23 | #$t += ok $?>>8,2; | ||
24 | #print "Test was: $cmd\n" unless ($?); | ||
25 | 25 | ||
26 | $cmd = "./check_ftp $Cache::nullhost -wt 0 -ct 0 -to 1"; | 26 | my $t; |
27 | $str = `$cmd`; | 27 | |
28 | $t += ok $?>>8,2; | 28 | $t += checkCmd( "./check_ftp $host_tcp_ftp -wt 300 -ct 600", 0, $successOutput ); |
29 | print "Test was: $cmd\n" unless ($?); | 29 | $t += checkCmd( "./check_ftp $host_nonresponsive -wt 0 -ct 0 -to 1", 2 ); |
30 | $t += checkCmd( "./check_ftp $hostname_invalid -wt 0 -ct 0", 2 ); | ||
30 | 31 | ||
31 | exit(0) if defined($Test::Harness::VERSION); | 32 | exit(0) if defined($Test::Harness::VERSION); |
32 | exit($tests - $t); | 33 | exit($tests - $t); |
34 | |||
diff --git a/plugins/t/check_hpjd.t b/plugins/t/check_hpjd.t index b4e198d2..b749c778 100644 --- a/plugins/t/check_hpjd.t +++ b/plugins/t/check_hpjd.t | |||
@@ -1,32 +1,42 @@ | |||
1 | #! /usr/bin/perl -w | 1 | #! /usr/bin/perl -w -I .. |
2 | # | ||
3 | # HP JetDirect Test via check_hpjd | ||
4 | # | ||
5 | # $Id$ | ||
6 | # | ||
2 | 7 | ||
3 | use strict; | 8 | use strict; |
4 | use Helper; | ||
5 | use Cache; | ||
6 | use Test; | 9 | use Test; |
10 | use NPTest; | ||
11 | |||
7 | use vars qw($tests); | 12 | use vars qw($tests); |
13 | BEGIN {$tests = 5; plan tests => $tests} | ||
8 | 14 | ||
9 | BEGIN {$tests = 4; plan tests => $tests} | 15 | my $successOutput = '/^Printer ok - /'; |
16 | my $failureOutput = '/Timeout: No [Rr]esponse from /'; | ||
10 | 17 | ||
11 | exit(0) unless (-x "./check_hpjd"); | 18 | my $host_tcp_hpjd = getTestParameter( "host_tcp_hpjd", "NP_HOST_TCP_HPJD", undef, |
19 | "A host (usually a printer) providing the HP-JetDirect Services" ); | ||
12 | 20 | ||
13 | my $null = ''; | 21 | my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1", |
14 | my $cmd; | 22 | "The hostname of system not responsive to network requests" ); |
15 | my $str; | ||
16 | my $t; | ||
17 | my $printer = get_option("hpjd_printer","HP Jet-Direct card address"); | ||
18 | 23 | ||
19 | $cmd = "./check_hpjd $printer"; | 24 | my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost", |
20 | $str = `$cmd`; | 25 | "An invalid (not known to DNS) hostname" ); |
21 | $t += ok $?>>8,0; | ||
22 | print "Test was: $cmd\n" if ($?); | ||
23 | $t += ok $str, '/^Printer ok - /'; | ||
24 | 26 | ||
25 | $cmd = "./check_hpjd $Cache::noserver"; | 27 | my $t; |
26 | $str = `$cmd`; | 28 | |
27 | $t += ok $?>>8,2; | 29 | if ( -x "./check_hpjd" ) |
28 | print "Test was: $cmd\n" unless ($?); | 30 | { |
29 | $t += ok $str, '/Timeout: No response from /'; | 31 | $t += checkCmd( "./check_hpjd $host_tcp_hpjd", 0, $successOutput ); |
32 | $t += checkCmd( "./check_hpjd $host_nonresponsive", 2, $failureOutput ); | ||
33 | $t += checkCmd( "./check_hpjd $hostname_invalid", 3 ); | ||
34 | } | ||
35 | else | ||
36 | { | ||
37 | $t += skipMissingCmd( "./check_hpjd", $tests ); | ||
38 | } | ||
30 | 39 | ||
31 | exit(0) if defined($Test::Harness::VERSION); | 40 | exit(0) if defined($Test::Harness::VERSION); |
32 | exit($tests - $t); | 41 | exit($tests - $t); |
42 | |||
diff --git a/plugins/t/check_http.t b/plugins/t/check_http.t index 5be549ad..56d939b3 100644 --- a/plugins/t/check_http.t +++ b/plugins/t/check_http.t | |||
@@ -1,22 +1,36 @@ | |||
1 | #! /usr/bin/perl -w | 1 | #! /usr/bin/perl -w -I .. |
2 | # | ||
3 | # HyperText Transfer Protocol (HTTP) Test via check_http | ||
4 | # | ||
5 | # $Id$ | ||
6 | # | ||
2 | 7 | ||
3 | use strict; | 8 | use strict; |
4 | use Cache; | ||
5 | use Test; | 9 | use Test; |
10 | use NPTest; | ||
11 | |||
6 | use vars qw($tests); | 12 | use vars qw($tests); |
13 | BEGIN {$tests = 4; plan tests => $tests} | ||
7 | 14 | ||
8 | BEGIN {$tests = 3; plan tests => $tests} | 15 | my $host_tcp_http = getTestParameter( "host_tcp_http", "NP_HOST_TCP_HTTP", "localhost", |
16 | "A host providing the HTTP Service (a web server)" ); | ||
9 | 17 | ||
10 | my $null = ''; | 18 | my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1", |
11 | my $str; | 19 | "The hostname of system not responsive to network requests" ); |
12 | my $t; | ||
13 | 20 | ||
14 | $str = `./check_http $Cache::httphost -wt 300 -ct 600`; | 21 | my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost", |
15 | $t += ok $?>>8,0; | 22 | "An invalid (not known to DNS) hostname" ); |
16 | $t += ok $str, '/(HTTP\s[o|O][k|K]\s)?\s?HTTP\/1.[01]\s[0-9]{3}\s(OK|Found)\s-\s+[0-9]+\sbytes\sin\s+([0-9]+|[0-9]+\.[0-9]+)\sseconds/'; | ||
17 | 23 | ||
18 | $str = `./check_http $Cache::nullhost -wt 1 -ct 2`; | 24 | my $successOutput = '/(HTTP\s[o|O][k|K]\s)?\s?HTTP\/1.[01]\s[0-9]{3}\s(OK|Found)\s-\s+[0-9]+\sbytes\sin\s+([0-9]+|[0-9]+\.[0-9]+)\sseconds/'; |
19 | $t += ok $?>>8,2; | 25 | |
26 | my %exceptions = ( 2 => "No Web Server present?" ); | ||
27 | |||
28 | my $t; | ||
29 | |||
30 | $t += checkCmd( "./check_http $host_tcp_http -wt 300 -ct 600", { 0 => 'continue', 2 => 'skip' }, $successOutput, %exceptions ); | ||
31 | $t += checkCmd( "./check_http $host_nonresponsive -wt 1 -ct 2", 2 ); | ||
32 | $t += checkCmd( "./check_http $hostname_invalid -wt 1 -ct 2", 2 ); | ||
20 | 33 | ||
21 | exit(0) if defined($Test::Harness::VERSION); | 34 | exit(0) if defined($Test::Harness::VERSION); |
22 | exit($tests - $t); | 35 | exit($tests - $t); |
36 | |||
diff --git a/plugins/t/check_imap.t b/plugins/t/check_imap.t index 47494e59..f86faa4c 100644 --- a/plugins/t/check_imap.t +++ b/plugins/t/check_imap.t | |||
@@ -1,34 +1,39 @@ | |||
1 | #! /usr/bin/perl -w | 1 | #! /usr/bin/perl -w -I .. |
2 | 2 | # | |
3 | #use strict; | 3 | # Internet Mail Access Protocol (IMAP) Server Tests via check_imap |
4 | use Cache; | 4 | # |
5 | # $Id$ | ||
6 | # | ||
7 | |||
8 | use strict; | ||
5 | use Test; | 9 | use Test; |
10 | use NPTest; | ||
11 | |||
6 | use vars qw($tests); | 12 | use vars qw($tests); |
13 | BEGIN {$tests = 5; plan tests => $tests} | ||
7 | 14 | ||
8 | BEGIN {$tests = 3; plan tests => $tests} | 15 | my $host_tcp_smtp = getTestParameter( "host_tcp_smtp", "NP_HOST_TCP_SMTP", "mailhost", |
16 | "A host providing an STMP Service (a mail server)"); | ||
9 | 17 | ||
10 | my $null = ''; | 18 | my $host_tcp_imap = getTestParameter( "host_tcp_imap", "NP_HOST_TCP_IMAP", $host_tcp_smtp, |
11 | my $cmd; | 19 | "A host providing an IMAP Service (a mail server)"); |
12 | my $str; | ||
13 | my $t; | ||
14 | 20 | ||
15 | $cmd = "./check_imap $Cache::mailhost"; | 21 | my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1", |
16 | $str = `$cmd`; | 22 | "The hostname of system not responsive to network requests" ); |
17 | $t += ok $?>>8,0; | ||
18 | print "Test was: $cmd\n" if ($?); | ||
19 | 23 | ||
20 | $cmd = "./check_imap -H $Cache::mailhost -p 143 -w 9 -c 9 -t 10 -e '* OK'"; | 24 | my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost", |
21 | $str = `$cmd`; | 25 | "An invalid (not known to DNS) hostname" ); |
22 | $t += ok $?>>8,0; | ||
23 | print "Test was: $cmd\n" if ($?); | ||
24 | 26 | ||
27 | my %exceptions = ( 2 => "No IMAP Server present?" ); | ||
28 | |||
29 | my $t; | ||
30 | |||
31 | $t += checkCmd( "./check_imap $host_tcp_imap", 0, undef, %exceptions ); | ||
32 | $t += checkCmd( "./check_imap -H $host_tcp_imap -p 143 -w 9 -c 9 -t 10 -e '* OK'", 0, undef, %exceptions ); | ||
33 | $t += checkCmd( "./check_imap $host_tcp_imap -p 143 -wt 9 -ct 9 -to 10 -e '* OK'", 0, undef, %exceptions ); | ||
34 | $t += checkCmd( "./check_imap $host_nonresponsive", 2 ); | ||
35 | $t += checkCmd( "./check_imap $hostname_invalid", 2 ); | ||
25 | 36 | ||
26 | # Reverse compatibility | ||
27 | $cmd = "./check_imap $Cache::mailhost -p 143 -wt 9 -ct 9 -to 10 -e '* OK'"; | ||
28 | $str = `$cmd`; | ||
29 | $t += ok $?>>8,0; | ||
30 | print "Test was: $cmd\n" if ($?); | ||
31 | 37 | ||
32 | exit(0) if defined($Test::Harness::VERSION); | 38 | exit(0) if defined($Test::Harness::VERSION); |
33 | exit($tests - $t); | 39 | exit($tests - $t); |
34 | |||
diff --git a/plugins/t/check_load.t b/plugins/t/check_load.t index 414e09d6..8f954dc4 100644 --- a/plugins/t/check_load.t +++ b/plugins/t/check_load.t | |||
@@ -1,27 +1,25 @@ | |||
1 | #! /usr/bin/perl -w | 1 | #! /usr/bin/perl -w -I .. |
2 | # | ||
3 | # Load Average Tests via check_load | ||
4 | # | ||
5 | # $Id$ | ||
6 | # | ||
2 | 7 | ||
3 | use strict; | 8 | use strict; |
4 | use Test; | 9 | use Test; |
5 | use vars qw($tests); | 10 | use NPTest; |
6 | 11 | ||
12 | use vars qw($tests); | ||
7 | BEGIN {$tests = 4; plan tests => $tests} | 13 | BEGIN {$tests = 4; plan tests => $tests} |
8 | 14 | ||
9 | my $null = ''; | 15 | my $successOutput = '/^OK - load average: [0-9]\.?[0-9]+, [0-9]\.?[0-9]+, [0-9]\.?[0-9]+/'; |
10 | my $cmd; | 16 | my $failureOutput = '/^CRITICAL - load average: [0-9]\.?[0-9]+, [0-9]\.?[0-9]+, [0-9]\.?[0-9]+/'; |
11 | my $str; | ||
12 | my $t; | ||
13 | 17 | ||
14 | $cmd = "./check_load -w 100,100,100 -c 100,100,100"; | 18 | my $t; |
15 | $str = `$cmd`; | ||
16 | $t += ok $?>>8,0; | ||
17 | print "Test was: $cmd\n" if ($?); | ||
18 | $t += ok $str, '/^OK - load average: [0-9]\.?[0-9]+, [0-9]\.?[0-9]+, [0-9]\.?[0-9]+/'; | ||
19 | 19 | ||
20 | $cmd = "./check_load -w 0,0,0 -c 0,0,0"; | 20 | $t += checkCmd( "./check_load -w 100,100,100 -c 100,100,100", 0, $successOutput ); |
21 | $str = `$cmd`; | 21 | $t += checkCmd( "./check_load -w 0,0,0 -c 0,0,0", 2, $failureOutput ); |
22 | $t += ok $?>>8,2; | ||
23 | print "Test was: $cmd\n" unless ($?); | ||
24 | $t += ok $str, '/^CRITICAL - load average: [0-9]\.?[0-9]+, [0-9]\.?[0-9]+, [0-9]\.?[0-9]+/'; | ||
25 | 22 | ||
26 | exit(0) if defined($Test::Harness::VERSION); | 23 | exit(0) if defined($Test::Harness::VERSION); |
27 | exit($tests - $t); | 24 | exit($tests - $t); |
25 | |||
diff --git a/plugins/t/check_mysql.t b/plugins/t/check_mysql.t index 0fae65fe..ad423595 100644 --- a/plugins/t/check_mysql.t +++ b/plugins/t/check_mysql.t | |||
@@ -1,26 +1,33 @@ | |||
1 | #! /usr/bin/perl -w | 1 | #! /usr/bin/perl -w -I .. |
2 | # | ||
3 | # MySQL Database Server Tests via check_mysql | ||
4 | # | ||
5 | # $Id$ | ||
6 | # | ||
2 | 7 | ||
3 | use strict; | 8 | use strict; |
4 | use Helper; | ||
5 | use Cache; | ||
6 | use Test; | 9 | use Test; |
10 | use NPTest; | ||
11 | |||
7 | use vars qw($tests); | 12 | use vars qw($tests); |
8 | 13 | ||
9 | BEGIN {$tests = 2; plan tests => $tests} | 14 | BEGIN {$tests = 2; plan tests => $tests} |
10 | 15 | ||
11 | exit(0) unless (-x "./check_mysql"); | ||
12 | |||
13 | my $null = ''; | ||
14 | my $cmd; | ||
15 | my $str; | ||
16 | my $t; | 16 | my $t; |
17 | 17 | ||
18 | my $mysqlserver = get_option("mysqlserver","host for MYSQL tests"); | 18 | my $failureOutput = '/Access denied for user: /'; |
19 | |||
20 | if ( -x "./check_mysql" ) | ||
21 | { | ||
22 | my $mysqlserver = getTestParameter( "mysql_server", "NP_MYSQL_SERVER", undef, | ||
23 | "A MySQL Server"); | ||
19 | 24 | ||
20 | $cmd = "./check_mysql -H $mysqlserver -P 3306"; | 25 | $t += checkCmd( "./check_mysql -H $mysqlserver -P 3306", 2, $failureOutput ); |
21 | $str = `$cmd`; | 26 | } |
22 | $t += ok $?>>8,2; | 27 | else |
23 | $t += ok $str, '/Access denied for user: /'; | 28 | { |
29 | $t += skipMissingCmd( "./check_mysql", $tests ); | ||
30 | } | ||
24 | 31 | ||
25 | exit(0) if defined($Test::Harness::VERSION); | 32 | exit(0) if defined($Test::Harness::VERSION); |
26 | exit($tests - $t); | 33 | exit($tests - $t); |
diff --git a/plugins/t/check_ping.t b/plugins/t/check_ping.t index 97bc660e..49c568a6 100644 --- a/plugins/t/check_ping.t +++ b/plugins/t/check_ping.t | |||
@@ -1,33 +1,36 @@ | |||
1 | #! /usr/bin/perl -w | 1 | #! /usr/bin/perl -w -I .. |
2 | # | ||
3 | # Ping Response Tests via check_ping | ||
4 | # | ||
5 | # $Id$ | ||
6 | # | ||
2 | 7 | ||
3 | use strict; | 8 | use strict; |
4 | use Cache; | ||
5 | use Test; | 9 | use Test; |
10 | use NPTest; | ||
11 | |||
6 | use vars qw($tests); | 12 | use vars qw($tests); |
7 | 13 | ||
8 | BEGIN {$tests = 5; plan tests => $tests} | 14 | BEGIN {$tests = 6; plan tests => $tests} |
15 | |||
16 | my $successOutput = '/PING (ok|OK) - Packet loss = +[0-9]{1,2}\%, +RTA = [\.0-9]+ ms/'; | ||
17 | my $failureOutput = '/Packet loss = +[0-9]{1,2}\%, +RTA = [\.0-9]+ ms/'; | ||
18 | |||
19 | my $host_responsive = getTestParameter( "host_responsive", "NP_HOST_RESPONSIVE", "localhost", | ||
20 | "The hostname of system responsive to network requests" ); | ||
21 | |||
22 | my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1", | ||
23 | "The hostname of system not responsive to network requests" ); | ||
24 | |||
25 | my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost", | ||
26 | "An invalid (not known to DNS) hostname" ); | ||
9 | 27 | ||
10 | my $null = ''; | ||
11 | my $cmd; | ||
12 | my $str; | ||
13 | my $t; | 28 | my $t; |
14 | 29 | ||
15 | $cmd = "./check_ping 127.0.0.1 100 100 1000 1000 -p 1"; | 30 | $t += checkCmd( "./check_ping $host_responsive 100 100 1000 1000 -p 1", 0, $successOutput ); |
16 | $str = `$cmd`; | 31 | $t += checkCmd( "./check_ping $host_responsive 0 0 0 0 -p 1", 2, $failureOutput ); |
17 | $t += ok $?>>8,0; | 32 | $t += checkCmd( "./check_ping $host_nonresponsive 0 0 0 0 -p 1 -to 1", 2 ); |
18 | print "Test was: $cmd\n" if ($?); | 33 | $t += checkCmd( "./check_ping $hostname_invalid 0 0 0 0 -p 1 -to 1", 3 ); |
19 | $t += ok $str, '/PING (ok|OK) - Packet loss = +[0-9]{1,2}\%, +RTA = [\.0-9]+ ms/'; | ||
20 | |||
21 | $cmd = "./check_ping 127.0.0.1 0 0 0 0 -p 1"; | ||
22 | $str = `$cmd`; | ||
23 | $t += ok $?>>8,2; | ||
24 | print "Test was: $cmd\n" unless ($?); | ||
25 | $t += ok $str, '/Packet loss = +[0-9]{1,2}\%, +RTA = [\.0-9]+ ms/'; | ||
26 | |||
27 | $cmd = "./check_ping $Cache::nullhost 0 0 0 0 -p 1 -to 1"; | ||
28 | $str = `$cmd`; | ||
29 | $t += ok $?>>8,2; | ||
30 | print "Test was: $cmd\n" unless ($?); | ||
31 | 34 | ||
32 | exit(0) if defined($Test::Harness::VERSION); | 35 | exit(0) if defined($Test::Harness::VERSION); |
33 | exit($tests - $t); | 36 | exit($tests - $t); |
diff --git a/plugins/t/check_pop.t b/plugins/t/check_pop.t index 60b5a4ef..e78f963e 100644 --- a/plugins/t/check_pop.t +++ b/plugins/t/check_pop.t | |||
@@ -1,31 +1,38 @@ | |||
1 | #! /usr/bin/perl -w | 1 | #! /usr/bin/perl -w -I .. |
2 | # | ||
3 | # Post Office Protocol (POP) Server Tests via check_pop | ||
4 | # | ||
5 | # $Id$ | ||
6 | # | ||
2 | 7 | ||
3 | #use strict; | 8 | use strict; |
4 | use Cache; | ||
5 | use Test; | 9 | use Test; |
10 | use NPTest; | ||
11 | |||
6 | use vars qw($tests); | 12 | use vars qw($tests); |
13 | BEGIN {$tests = 5; plan tests => $tests} | ||
7 | 14 | ||
8 | BEGIN {$tests = 3; plan tests => $tests} | 15 | my $host_tcp_smtp = getTestParameter( "host_tcp_smtp", "NP_HOST_TCP_SMTP", "mailhost", |
16 | "A host providing an STMP Service (a mail server)"); | ||
9 | 17 | ||
10 | my $null = ''; | 18 | my $host_tcp_pop = getTestParameter( "host_tcp_pop", "NP_HOST_TCP_POP", $host_tcp_smtp, |
11 | my $cmd; | 19 | "A host providing an POP Service (a mail server)"); |
12 | my $str; | 20 | |
13 | my $t; | 21 | my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1", |
22 | "The hostname of system not responsive to network requests" ); | ||
14 | 23 | ||
15 | $cmd = "./check_pop $Cache::mailhost"; | 24 | my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost", |
16 | $str = `$cmd`; | 25 | "An invalid (not known to DNS) hostname" ); |
17 | $t += ok $?>>8,0; | ||
18 | print "Test was: $cmd\n" if ($?); | ||
19 | 26 | ||
20 | $cmd = "./check_pop -H $Cache::mailhost -p 110 -w 9 -c 9 -t 10 -e '+OK'"; | 27 | my %exceptions = ( 2 => "No POP Server present?" ); |
21 | $str = `$cmd`; | 28 | |
22 | $t += ok $?>>8,0; | 29 | my $t; |
23 | print "Test was: $cmd\n" if ($?); | ||
24 | 30 | ||
25 | $cmd = "./check_pop $Cache::mailhost -p 110 -wt 9 -ct 9 -to 10 -e '+OK'"; | 31 | $t += checkCmd( "./check_pop $host_tcp_pop", 0, undef, %exceptions ); |
26 | $str = `$cmd`; | 32 | $t += checkCmd( "./check_pop -H $host_tcp_pop -p 110 -w 9 -c 9 -t 10 -e '+OK'", 0, undef, %exceptions ); |
27 | $t += ok $?>>8,0; | 33 | $t += checkCmd( "./check_pop $host_tcp_pop -p 110 -wt 9 -ct 9 -to 10 -e '+OK'", 0, undef, %exceptions ); |
28 | print "Test was: $cmd\n" if ($?); | 34 | $t += checkCmd( "./check_pop $host_nonresponsive", 2 ); |
35 | $t += checkCmd( "./check_pop $hostname_invalid", 2 ); | ||
29 | 36 | ||
30 | exit(0) if defined($Test::Harness::VERSION); | 37 | exit(0) if defined($Test::Harness::VERSION); |
31 | exit($tests - $t); | 38 | exit($tests - $t); |
diff --git a/plugins/t/check_procs.t b/plugins/t/check_procs.t index da49ac61..cb5f1224 100644 --- a/plugins/t/check_procs.t +++ b/plugins/t/check_procs.t | |||
@@ -1,51 +1,24 @@ | |||
1 | #! /usr/bin/perl -w | 1 | #! /usr/bin/perl -w -I .. |
2 | # | ||
3 | # Process Tests via check_procs | ||
4 | # | ||
5 | # $Id$ | ||
6 | # | ||
2 | 7 | ||
3 | use strict; | 8 | use strict; |
4 | use Cache; | ||
5 | use Test; | 9 | use Test; |
6 | use vars qw($tests); | 10 | use NPTest; |
7 | 11 | ||
12 | use vars qw($tests); | ||
8 | BEGIN {$tests = 10; plan tests => $tests} | 13 | BEGIN {$tests = 10; plan tests => $tests} |
9 | 14 | ||
10 | my $null = ''; | ||
11 | my $cmd; | ||
12 | my $str; | ||
13 | my $t; | 15 | my $t; |
14 | 16 | ||
15 | # Reverse Compatibility | 17 | $t += checkCmd( "./check_procs -w 100000 -c 100000", 0, '/^PROCS OK: [0-9]+ process(es)?$/' ); |
16 | $cmd = "./check_procs -w 100000 -c 100000"; | 18 | $t += checkCmd( "./check_procs -w 100000 -c 100000 -s Z", 0, '/^PROCS OK: [0-9]+ process(es)? with /' ); |
17 | $str = `$cmd`; | 19 | $t += checkCmd( "./check_procs -w 0 -c 10000000", 1, '/^PROCS WARNING: [0-9]+ process(es)?$/' ); |
18 | $t += ok $?>>8,0; | 20 | $t += checkCmd( "./check_procs -w 0 -c 0", 2, '/^PROCS CRITICAL: [0-9]+ process(es)?$/' ); |
19 | print "Test was: $cmd\n" if ($?); | 21 | $t += checkCmd( "./check_procs -w 0 -c 0 -s S", 2, '/^PROCS CRITICAL: [0-9]+ process(es)? with /' ); |
20 | $t += ok $str, '/^PROCS OK: [0-9]+ process(es)?$/'; | ||
21 | |||
22 | # Reverse Compatibility | ||
23 | $cmd = "./check_procs -w 100000 -c 100000 -s Z"; | ||
24 | $str = `$cmd`; | ||
25 | $t += ok $?>>8,0; | ||
26 | print "Test was: $cmd\n" if ($?); | ||
27 | $t += ok $str, '/^PROCS OK: [0-9]+ process(es)? with /'; | ||
28 | |||
29 | # Reverse Compatibility | ||
30 | $cmd = "./check_procs -w 0 -c 10000000"; | ||
31 | $str = `$cmd`; | ||
32 | $t += ok $?>>8,1; | ||
33 | print "Test was: $cmd\n" unless ($?); | ||
34 | $t += ok $str, '/^PROCS WARNING: [0-9]+ process(es)?$/'; | ||
35 | |||
36 | # Reverse Compatibility | ||
37 | $cmd = "./check_procs -w 0 -c 0"; | ||
38 | $str = `$cmd`; | ||
39 | $t += ok $?>>8,2; | ||
40 | print "Test was: $cmd\n" unless ($?); | ||
41 | $t += ok $str, '/^PROCS CRITICAL: [0-9]+ process(es)?$/'; | ||
42 | |||
43 | # Reverse Compatibility | ||
44 | $cmd = "./check_procs -w 0 -c 0 -s S"; | ||
45 | $str = `$cmd`; | ||
46 | $t += ok $?>>8,2; | ||
47 | print "Test was: $cmd\n" unless ($?); | ||
48 | $t += ok $str, '/^PROCS CRITICAL: [0-9]+ process(es)? with /'; | ||
49 | 22 | ||
50 | exit(0) if defined($Test::Harness::VERSION); | 23 | exit(0) if defined($Test::Harness::VERSION); |
51 | exit($tests - $t); | 24 | exit($tests - $t); |
diff --git a/plugins/t/check_smtp.t b/plugins/t/check_smtp.t index 2a82b877..3bf32ecf 100644 --- a/plugins/t/check_smtp.t +++ b/plugins/t/check_smtp.t | |||
@@ -1,31 +1,34 @@ | |||
1 | #! /usr/bin/perl -w | 1 | #! /usr/bin/perl -w -I .. |
2 | # | ||
3 | # Simple Mail Transfer Protocol (SMTP) Test via check_smtp | ||
4 | # | ||
5 | # $Id$ | ||
6 | # | ||
2 | 7 | ||
3 | #use strict; | 8 | use strict; |
4 | use Cache; | ||
5 | use Test; | 9 | use Test; |
10 | use NPTest; | ||
11 | |||
6 | use vars qw($tests); | 12 | use vars qw($tests); |
13 | BEGIN {$tests = 5; plan tests => $tests} | ||
7 | 14 | ||
8 | BEGIN {$tests = 3; plan tests => $tests} | 15 | my $host_tcp_smtp = getTestParameter( "host_tcp_smtp", "NP_HOST_TCP_SMTP", "mailhost", |
16 | "A host providing an STMP Service (a mail server)"); | ||
9 | 17 | ||
10 | my $null = ''; | 18 | my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1", |
11 | my $cmd; | 19 | "The hostname of system not responsive to network requests" ); |
12 | my $str; | ||
13 | my $t; | ||
14 | 20 | ||
15 | $cmd = "./check_smtp $Cache::mailhost"; | 21 | my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost", |
16 | $str = `$cmd`; | 22 | "An invalid (not known to DNS) hostname" ); |
17 | $t += ok $?>>8,0; | 23 | my %exceptions = ( 2 => "No SMTP Server present?" ); |
18 | print "Test was: $cmd\n" if ($?); | ||
19 | 24 | ||
20 | $cmd = "./check_smtp -H $Cache::mailhost -p 25 -t 1 -w 9 -c 9 -t 10 -e 220"; | 25 | my $t; |
21 | $str = `$cmd`; | ||
22 | $t += ok $?>>8,0; | ||
23 | print "Test was: $cmd\n" if ($?); | ||
24 | 26 | ||
25 | $cmd = "./check_smtp -H $Cache::mailhost -p 25 -wt 9 -ct 9 -to 10 -e 220"; | 27 | $t += checkCmd( "./check_smtp $host_tcp_smtp", 0, undef, %exceptions ); |
26 | $str = `$cmd`; | 28 | $t += checkCmd( "./check_smtp -H $host_tcp_smtp -p 25 -t 1 -w 9 -c 9 -t 10 -e 220", 0, undef, %exceptions ); |
27 | $t += ok $?>>8,0; | 29 | $t += checkCmd( "./check_smtp -H $host_tcp_smtp -p 25 -wt 9 -ct 9 -to 10 -e 220", 0, undef, %exceptions ); |
28 | print "Test was: $cmd\n" if ($?); | 30 | $t += checkCmd( "./check_smtp $host_nonresponsive", 2 ); |
31 | $t += checkCmd( "./check_smtp $hostname_invalid", 3 ); | ||
29 | 32 | ||
30 | exit(0) if defined($Test::Harness::VERSION); | 33 | exit(0) if defined($Test::Harness::VERSION); |
31 | exit($tests - $t); | 34 | exit($tests - $t); |
diff --git a/plugins/t/check_snmp.t b/plugins/t/check_snmp.t index 162b0b9b..b45b6c01 100644 --- a/plugins/t/check_snmp.t +++ b/plugins/t/check_snmp.t | |||
@@ -1,52 +1,57 @@ | |||
1 | #! /usr/bin/perl -w | 1 | #! /usr/bin/perl -w -I .. |
2 | # | ||
3 | # Simple Network Management Protocol (SNMP) Test via check_snmp | ||
4 | # | ||
5 | # $Id$ | ||
6 | # | ||
2 | 7 | ||
3 | use strict; | 8 | use strict; |
4 | use Helper; | ||
5 | use Cache; | ||
6 | use Test; | 9 | use Test; |
7 | use vars qw($tests); | 10 | use NPTest; |
8 | 11 | ||
9 | BEGIN {$tests = 8; plan tests => $tests} | 12 | use vars qw($tests); |
13 | BEGIN {$tests = 12; plan tests => $tests} | ||
10 | 14 | ||
11 | my $null = ''; | ||
12 | my $cmd; | ||
13 | my $str; | ||
14 | my $t; | 15 | my $t; |
15 | my $community=get_option("snmp_community","SNMP community name"); | 16 | |
16 | 17 | if ( -x "./check_snmp" ) | |
17 | exit(0) unless (-x "./check_snmp"); | 18 | { |
18 | 19 | my $host_snmp = getTestParameter( "host_snmp", "NP_HOST_SNMP", "localhost", | |
19 | $cmd = "./check_snmp -H 127.0.0.1 -C $community -o system.sysUpTime.0 -w 1: -c 1:"; | 20 | "A host providing an SNMP Service"); |
20 | $str = `$cmd`; | 21 | |
21 | $t += ok $?>>8,0; | 22 | my $snmp_community = getTestParameter( "snmp_community", "NP_SNMP_COMMUNITY", "public", |
22 | print "Test was: $cmd\n" if ($?); | 23 | "The SNMP Community string for SNMP Testing" ); |
23 | chomp $str; | 24 | |
24 | $t += ok $str, '/^SNMP OK - \d+/'; | 25 | my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1", |
25 | 26 | "The hostname of system not responsive to network requests" ); | |
26 | $cmd = "./check_snmp -H 127.0.0.1 -C $community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w 1:1 -c 1:1"; | 27 | |
27 | $str = `$cmd`; | 28 | my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost", |
28 | $t += ok $?>>8,0; | 29 | "An invalid (not known to DNS) hostname" ); |
29 | print "Test was: $cmd\n" if ($?); | 30 | |
30 | chomp $str; | 31 | my %exceptions = ( 3 => "No SNMP Server present?" ); |
31 | $t += ok $str, '/^SNMP OK - 1\s*$/'; | 32 | |
32 | 33 | ||
33 | $cmd = "./check_snmp -H 127.0.0.1 -C $community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w 0 -c 1:"; | 34 | $t += checkCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0 -w 1: -c 1:", |
34 | $str = `$cmd`; | 35 | { 0 => 'continue', 3 => 'skip' }, '/^SNMP OK - \d+/', %exceptions ); |
35 | $t += ok $?>>8,1; | 36 | |
36 | print "Test was: $cmd\n" unless ($?); | 37 | $t += checkCmd( "./check_snmp -H $host_snmp -C $snmp_community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w 1:1 -c 1:1", |
37 | chomp $str; | 38 | { 0 => 'continue', 3 => 'skip' }, '/^SNMP OK - 1\s*$/', %exceptions ); |
38 | $t += ok $str, '/^SNMP WARNING - \*1\*\s*$/'; | 39 | |
39 | 40 | $t += checkCmd( "./check_snmp -H $host_snmp -C $snmp_community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w 0 -c 1:", | |
40 | $cmd = "./check_snmp -H 127.0.0.1 -C $community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w :0 -c 0"; | 41 | { 1 => 'continue', 3 => 'skip' }, '/^SNMP WARNING - \*1\*\s*$/', %exceptions ); |
41 | $str = `$cmd`; | 42 | |
42 | $t += ok $?>>8,2; | 43 | $t += checkCmd( "./check_snmp -H $host_snmp -C $snmp_community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w :0 -c 0", |
43 | print "Test was: $cmd\n" unless ($?); | 44 | { 2 => 'continue', 3 => 'skip' }, '/^SNMP CRITICAL - \*1\*\s*$/', %exceptions ); |
44 | chomp $str; | 45 | |
45 | $t += ok $str, '/^SNMP CRITICAL - \*1\*\s*$/'; | 46 | $t += checkCmd( "./check_snmp -H $host_nonresponsive -C $snmp_community -o system.sysUpTime.0 -w 1: -c 1:", 3, '/SNMP problem - /' ); |
46 | 47 | ||
47 | #host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 = 1 | 48 | $t += checkCmd( "./check_snmp -H $hostname_invalid -C $snmp_community -o system.sysUpTime.0 -w 1: -c 1:", 3, '/SNMP problem - /' ); |
48 | #enterprises.ucdavis.memory.memAvailSwap.0 | 49 | |
49 | #./check_snmp 127.0.0.1 -C staff -o enterprises.ucdavis.diskTable.dskEntry.dskAvail.1,enterprises.ucdavis.diskTable.dskEntry.dskPercent.1 -w 100000: -c 50000: -l Space on root -u 'bytes free (','% used)' | 50 | } |
51 | else | ||
52 | { | ||
53 | $t += skipMissingCmd( "./check_snmp", $tests ); | ||
54 | } | ||
50 | 55 | ||
51 | exit(0) if defined($Test::Harness::VERSION); | 56 | exit(0) if defined($Test::Harness::VERSION); |
52 | exit($tests - $t); | 57 | exit($tests - $t); |
diff --git a/plugins/t/check_swap.t b/plugins/t/check_swap.t index 5b702f00..348010de 100644 --- a/plugins/t/check_swap.t +++ b/plugins/t/check_swap.t | |||
@@ -1,34 +1,25 @@ | |||
1 | #! /usr/bin/perl -w | 1 | #! /usr/bin/perl -w -I .. |
2 | # | ||
3 | # Swap Space Tests via check_swap | ||
4 | # | ||
5 | # $Id$ | ||
6 | # | ||
2 | 7 | ||
3 | use strict; | 8 | use strict; |
4 | use Cache; | ||
5 | use Test; | 9 | use Test; |
6 | use vars qw($tests); | 10 | use NPTest; |
7 | 11 | ||
12 | use vars qw($tests); | ||
8 | BEGIN {$tests = 6; plan tests => $tests} | 13 | BEGIN {$tests = 6; plan tests => $tests} |
9 | 14 | ||
10 | my $null = ''; | ||
11 | my $cmd; | ||
12 | my $str; | ||
13 | my $t; | 15 | my $t; |
14 | 16 | ||
15 | $cmd = "./check_swap 100 100"; | 17 | my $successOutput = '/^SWAP OK - [0-9]+\% free \([0-9]+ MB out of [0-9]+ MB\)/'; |
16 | $str = `$cmd`; | 18 | my $failureOutput = '/^SWAP CRITICAL - [0-9]+\% free \([0-9]+ MB out of [0-9]+ MB\)/'; |
17 | $t += ok $?>>8,0; | ||
18 | print "Test was: $cmd\n" if ($?); | ||
19 | $t += ok $str, '/^Swap ok - Swap used\: +[0-9]{1,2}\% \([0-9]+ bytes out of [0-9]+\)$/'; | ||
20 | |||
21 | $cmd = "./check_swap 0 0"; | ||
22 | $str = `$cmd`; | ||
23 | $t += ok $?>>8,2; | ||
24 | print "Test was: $cmd\n" unless ($?); | ||
25 | $t += ok $str, '/^CRITICAL - Swap used\: +[0-9]{1,2}\% \([0-9]+ bytes out of [0-9]+\)$/'; | ||
26 | 19 | ||
27 | $cmd = "./check_swap 100 100 1000000000 1000000000"; | 20 | $t += checkCmd( "./check_swap -w 1048576 -c 1048576", 0, $successOutput ); # 1MB free |
28 | $str = `$cmd`; | 21 | $t += checkCmd( "./check_swap -w 1\% -c 1\%", 0, $successOutput ); # 1% free |
29 | $t += ok $?>>8,2; | 22 | $t += checkCmd( "./check_swap -w 100\% -c 100\%", 2, $failureOutput ); # 100% free (always fails) |
30 | print "Test was: $cmd\n" unless ($?); | ||
31 | $t += ok $str, '/^CRITICAL - Swap used\: +[0-9]{1,2}\% \([0-9]+ bytes out of [0-9]+\)$/'; | ||
32 | 23 | ||
33 | exit(0) if defined($Test::Harness::VERSION); | 24 | exit(0) if defined($Test::Harness::VERSION); |
34 | exit($tests - $t); | 25 | exit($tests - $t); |
diff --git a/plugins/t/check_tcp.t b/plugins/t/check_tcp.t index 21c3b774..ffe559df 100644 --- a/plugins/t/check_tcp.t +++ b/plugins/t/check_tcp.t | |||
@@ -1,27 +1,34 @@ | |||
1 | #! /usr/bin/perl -w | 1 | #! /usr/bin/perl -w -I .. |
2 | # | ||
3 | # TCP Connection Based Tests via check_tcp | ||
4 | # | ||
5 | # $Id$ | ||
6 | # | ||
2 | 7 | ||
3 | #use strict; | 8 | use strict; |
4 | use Cache; | ||
5 | use Test; | 9 | use Test; |
10 | use NPTest; | ||
11 | |||
6 | use vars qw($tests); | 12 | use vars qw($tests); |
13 | BEGIN {$tests = 5; plan tests => $tests} | ||
7 | 14 | ||
8 | BEGIN {$tests = 3; plan tests => $tests} | 15 | my $host_tcp_http = getTestParameter( "host_tcp_http", "NP_HOST_TCP_HTTP", "localhost", |
16 | "A host providing the HTTP Service (a web server)" ); | ||
9 | 17 | ||
10 | my $null = ''; | 18 | my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1", |
11 | my $cmd; | 19 | "The hostname of system not responsive to network requests" ); |
12 | my $str; | 20 | |
13 | my $t; | 21 | my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost", |
22 | "An invalid (not known to DNS) hostname" ); | ||
14 | 23 | ||
15 | $cmd = "./check_tcp $Cache::hostname -p 80 -wt 300 -ct 600"; | 24 | my $successOutput = '/^TCP OK\s-\s+[0-9]?\.?[0-9]+ second response time on port [0-9]+/'; |
16 | $str = `$cmd`; | 25 | |
17 | $t += ok $?>>8,0; | 26 | my $t; |
18 | print "$cmd\n" if ($?); | ||
19 | $t += ok $str, '/^TCP OK\s-\s+[0-9]?\.?[0-9]+ second response time on port 80/'; | ||
20 | 27 | ||
21 | $cmd = "./check_tcp $Cache::nullhost -p 81 -wt 0 -ct 0 -to 1"; | 28 | $t += checkCmd( "./check_tcp $host_tcp_http -p 80 -wt 300 -ct 600", 0, $successOutput ); |
22 | $str = `$cmd`; | 29 | $t += checkCmd( "./check_tcp $host_tcp_http -p 81 -wt 0 -ct 0 -to 1", 2 ); # use invalid port for this test |
23 | $t += ok $?>>8,2; | 30 | $t += checkCmd( "./check_tcp $host_nonresponsive -p 80 -wt 0 -ct 0 -to 1", 2 ); |
24 | print "$cmd\n" unless ($?); | 31 | $t += checkCmd( "./check_tcp $hostname_invalid -p 80 -wt 0 -ct 0 -to 1", 2 ); |
25 | 32 | ||
26 | exit(0) if defined($Test::Harness::VERSION); | 33 | exit(0) if defined($Test::Harness::VERSION); |
27 | exit($tests - $t); | 34 | exit($tests - $t); |
diff --git a/plugins/t/check_time.t b/plugins/t/check_time.t index 4d8c5c2b..05878dc2 100644 --- a/plugins/t/check_time.t +++ b/plugins/t/check_time.t | |||
@@ -1,52 +1,40 @@ | |||
1 | #! /usr/bin/perl -w | 1 | #! /usr/bin/perl -w -I .. |
2 | # | ||
3 | # System Time Tests via check_time | ||
4 | # | ||
5 | # $Id$ | ||
6 | # | ||
2 | 7 | ||
3 | use strict; | 8 | use strict; |
4 | use Cache; | ||
5 | use Helper; | ||
6 | use Test; | 9 | use Test; |
10 | use NPTest; | ||
11 | |||
7 | use vars qw($tests); | 12 | use vars qw($tests); |
13 | BEGIN {$tests = 8; plan tests => $tests} | ||
8 | 14 | ||
9 | BEGIN {$tests = 6; plan tests => $tests} | 15 | my $host_udp_time = getTestParameter( "host_udp_time", "NP_HOST_UDP_TIME", "localhost", |
16 | "A host providing the UDP Time Service" ); | ||
10 | 17 | ||
11 | my $null = ''; | 18 | my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1", |
12 | my $cmd; | 19 | "The hostname of system not responsive to network requests" ); |
13 | my $str; | ||
14 | my $t; | ||
15 | my $udp_hostname=get_option("udp_hostname","UDP host name"); | ||
16 | 20 | ||
17 | # standard mode | 21 | my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost", |
22 | "An invalid (not known to DNS) hostname" ); | ||
18 | 23 | ||
19 | $cmd = "./check_time -H $udp_hostname -w 999999,59 -c 999999,59 -t 60"; | 24 | my $successOutput = '/^TIME OK - [0-9]+ second time difference/'; |
20 | $str = `$cmd`; | ||
21 | $t += ok $?>>8,0; | ||
22 | print "Test was: $cmd\n" if ($?); | ||
23 | $t += ok $str, '/^TIME OK - [0-9]+ second time difference$/'; | ||
24 | 25 | ||
25 | $cmd = "./check_time -H $udp_hostname -w 999999 -W 59 -c 999999 -C 59 -t 60"; | 26 | my $t; |
26 | $str = `$cmd`; | ||
27 | $t += ok $?>>8,0; | ||
28 | print "Test was: $cmd\n" if ($?); | ||
29 | $t += ok $str, '/^TIME OK - [0-9]+ second time difference$/'; | ||
30 | 27 | ||
31 | # reverse compatibility mode | 28 | # standard mode |
29 | $t += checkCmd( "./check_time -H $host_udp_time -w 999999,59 -c 999999,59 -t 60", 0, $successOutput ); | ||
30 | $t += checkCmd( "./check_time -H $host_udp_time -w 999999 -W 59 -c 999999 -C 59 -t 60", 0, $successOutput ); | ||
32 | 31 | ||
33 | $cmd = "./check_time $udp_hostname -wt 59 -ct 59 -cd 999999 -wd 999999 -to 60"; | 32 | # reverse compatibility mode |
34 | $str = `$cmd`; | 33 | $t += checkCmd( "./check_time $host_udp_time -wt 59 -ct 59 -cd 999999 -wd 999999 -to 60", 0, $successOutput ); |
35 | $t += ok $?>>8,0; | ||
36 | print "Test was: $cmd\n" if ($?); | ||
37 | $t += ok $str, '/^TIME OK - [0-9]+ second time difference$/'; | ||
38 | 34 | ||
39 | # failure mode | 35 | # failure mode |
40 | 36 | $t += checkCmd( "./check_time -H $host_nonresponsive -t 1", 2 ); | |
41 | #$cmd = "./check_time -H $Cache::nullhost -t 1"; | 37 | $t += checkCmd( "./check_time -H $hostname_invalid -t 1", 3 ); |
42 | #$str = `$cmd`; | ||
43 | #$t += ok $?>>8,255; | ||
44 | #print "Test was: $cmd\n" unless ($?); | ||
45 | |||
46 | #$cmd = "./check_time -H $Cache::noserver -t 1"; | ||
47 | #$str = `$cmd`; | ||
48 | #$t += ok $?>>8,255; | ||
49 | #print "$cmd\n" unless ($?); | ||
50 | 38 | ||
51 | exit(0) if defined($Test::Harness::VERSION); | 39 | exit(0) if defined($Test::Harness::VERSION); |
52 | exit($tests - $t); | 40 | exit($tests - $t); |
diff --git a/plugins/t/check_udp.t b/plugins/t/check_udp.t index abbf5e49..c80e08ad 100644 --- a/plugins/t/check_udp.t +++ b/plugins/t/check_udp.t | |||
@@ -1,24 +1,33 @@ | |||
1 | #! /usr/bin/perl -w | 1 | #! /usr/bin/perl -w -I .. |
2 | # | ||
3 | # UDP Connection Based Tests via check_udp | ||
4 | # | ||
5 | # $Id$ | ||
6 | # | ||
2 | 7 | ||
3 | #use strict; | 8 | use strict; |
4 | use Cache; | ||
5 | use Helper; | ||
6 | use Test; | 9 | use Test; |
10 | use NPTest; | ||
11 | |||
7 | use vars qw($tests); | 12 | use vars qw($tests); |
13 | BEGIN {$tests = 3; plan tests => $tests} #TODO# Update to 4 when the commented out test is fixed | ||
8 | 14 | ||
9 | BEGIN {$tests = 3; plan tests => $tests} | 15 | my $host_udp_time = getTestParameter( "host_udp_time", "NP_HOST_UDP_TIME", "localhost", |
16 | "A host providing the UDP Time Service" ); | ||
10 | 17 | ||
11 | my $null = ''; | 18 | my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1", |
12 | my $str; | 19 | "The hostname of system not responsive to network requests" ); |
13 | my $t; | 20 | |
14 | my $hostname=get_option("udp_hostname","UDP host name"); | 21 | my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost", |
22 | "An invalid (not known to DNS) hostname" ); | ||
15 | 23 | ||
16 | $str = `./check_udp $hostname -p 37 -wt 300 -ct 600`; | 24 | my $successOutput = '/^Connection accepted on port [0-9]+ - [0-9]+ second response time$/'; |
17 | $t += ok $?>>8,0; | 25 | |
18 | $t += ok $str, '/^Connection accepted on port 37 - [0-9]+ second response time$/'; | 26 | my $t; |
19 | 27 | ||
20 | $str = `./check_udp $Cache::nullhost -p 80 -wt 0 -ct 0 -to 1`; | 28 | $t += checkCmd( "./check_udp -H $host_udp_time -p 37 -wt 300 -ct 600", 0, $successOutput ); |
21 | $t += ok $?>>8,2; | 29 | $t += checkCmd( "./check_udp $host_nonresponsive -p 37 -wt 0 -ct 0 -to 1", 2 ); |
30 | #TODO# $t += checkCmd( "./check_udp $hostname_invalid -p 37 -wt 0 -ct 0 -to 1", 2 ); # Currently returns 0 (ie success) | ||
22 | 31 | ||
23 | exit(0) if defined($Test::Harness::VERSION); | 32 | exit(0) if defined($Test::Harness::VERSION); |
24 | exit($tests - $t); | 33 | exit($tests - $t); |
diff --git a/plugins/t/check_users.t b/plugins/t/check_users.t index 593f1737..4b313d30 100644 --- a/plugins/t/check_users.t +++ b/plugins/t/check_users.t | |||
@@ -1,28 +1,25 @@ | |||
1 | #! /usr/bin/perl -w | 1 | #! /usr/bin/perl -w -I .. |
2 | # | ||
3 | # Logged in Users Tests via check_users | ||
4 | # | ||
5 | # $Id$ | ||
6 | # | ||
2 | 7 | ||
3 | use strict; | 8 | use strict; |
4 | use Cache; | ||
5 | use Test; | 9 | use Test; |
6 | use vars qw($tests); | 10 | use NPTest; |
7 | 11 | ||
12 | use vars qw($tests); | ||
8 | BEGIN {$tests = 4; plan tests => $tests} | 13 | BEGIN {$tests = 4; plan tests => $tests} |
9 | 14 | ||
10 | my $null = ''; | 15 | my $successOutput = '/^USERS OK - [0-9]+ users currently logged in/'; |
11 | my $cmd; | 16 | my $failureOutput = '/^USERS CRITICAL - [0-9]+ users currently logged in/'; |
12 | my $str; | ||
13 | my $t; | ||
14 | 17 | ||
15 | $cmd = "./check_users 1000 1000"; | 18 | my $t; |
16 | $str = `$cmd`; | ||
17 | $t += ok $?>>8,0; | ||
18 | print "Test was: $cmd\n" if ($?); | ||
19 | $t += ok $str, '/^USERS OK - +[0-9]+ users currently logged in$/'; | ||
20 | 19 | ||
21 | $cmd = "./check_users 0 0"; | 20 | $t += checkCmd( "./check_users 1000 1000", 0, $successOutput ); |
22 | $str = `$cmd`; | 21 | $t += checkCmd( "./check_users 0 0", 2, $failureOutput ); |
23 | $t += ok $?>>8,2; | ||
24 | print "Test was: $cmd\n" unless ($?); | ||
25 | $t += ok $str, '/^USERS CRITICAL - [0-9]+ +users currently logged in$/'; | ||
26 | 22 | ||
27 | exit(0) if defined($Test::Harness::VERSION); | 23 | exit(0) if defined($Test::Harness::VERSION); |
28 | exit($tests - $t); | 24 | exit($tests - $t); |
25 | |||
diff --git a/plugins/t/check_vsz.t b/plugins/t/check_vsz.t deleted file mode 100644 index 95972619..00000000 --- a/plugins/t/check_vsz.t +++ /dev/null | |||
@@ -1,28 +0,0 @@ | |||
1 | #! /usr/bin/perl -w | ||
2 | |||
3 | use strict; | ||
4 | use Cache; | ||
5 | use Test; | ||
6 | use vars qw($tests); | ||
7 | |||
8 | BEGIN {$tests = 4; plan tests => $tests} | ||
9 | |||
10 | my $null = ''; | ||
11 | my $cmd; | ||
12 | my $str; | ||
13 | my $t; | ||
14 | |||
15 | $cmd = "./check_vsz 100000 1000000 init"; | ||
16 | $str = `$cmd`; | ||
17 | $t += ok $?>>8,0; | ||
18 | print "Test was: $cmd\n" if ($?); | ||
19 | $t += ok $str, '/^ok \(all VSZ\<[0-9]+\)/'; | ||
20 | |||
21 | $cmd = "./check_vsz 0 0"; | ||
22 | $str = `$cmd`; | ||
23 | $t += ok $?>>8,2; | ||
24 | print "Test was: $cmd\n" unless ($?); | ||
25 | $t += ok $str, '/^CRITICAL \(VSZ\>[0-9]+\)/'; | ||
26 | |||
27 | exit(0) if defined($Test::Harness::VERSION); | ||
28 | exit($tests - $t); | ||