summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorPeter Bray <illumino@users.sourceforge.net>2005-07-25 01:47:15 +0000
committerPeter Bray <illumino@users.sourceforge.net>2005-07-25 01:47:15 +0000
commitcdc06cc3e2c4670d3cd46b0a03adcf7e6958eff1 (patch)
tree62b074eaca618762fb03f94708ec3def50037697 /plugins
parent05853f47eb6e608de993cc59343c73b96b9b33e2 (diff)
downloadmonitoring-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.t44
-rw-r--r--plugins/t/check_dns.t44
-rw-r--r--plugins/t/check_fping.t48
-rw-r--r--plugins/t/check_ftp.t44
-rw-r--r--plugins/t/check_hpjd.t50
-rw-r--r--plugins/t/check_http.t36
-rw-r--r--plugins/t/check_imap.t51
-rw-r--r--plugins/t/check_load.t30
-rw-r--r--plugins/t/check_mysql.t33
-rw-r--r--plugins/t/check_ping.t47
-rw-r--r--plugins/t/check_pop.t47
-rw-r--r--plugins/t/check_procs.t53
-rw-r--r--plugins/t/check_smtp.t43
-rw-r--r--plugins/t/check_snmp.t91
-rw-r--r--plugins/t/check_swap.t35
-rw-r--r--plugins/t/check_tcp.t41
-rw-r--r--plugins/t/check_time.t60
-rw-r--r--plugins/t/check_udp.t37
-rw-r--r--plugins/t/check_users.t31
-rw-r--r--plugins/t/check_vsz.t28
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
1use strict; 8use strict;
2use Test; 9use Test;
10use NPTest;
11
3use vars qw($tests); 12use vars qw($tests);
13BEGIN {$tests = 10; plan tests => $tests}
14
15my $successOutput = '/^DISK OK - /';
16my $failureOutput = '/^DISK CRITICAL - /';
17
18my $mountpoint_valid = getTestParameter( "mountpoint_valid", "NP_MOUNTPOINT_VALID", "/",
19 "The path to a valid mountpoint" );
4 20
5BEGIN {$tests = 6; plan tests => $tests} 21my $mountpoint_invalid = getTestParameter( "mountpoint_invalid", "NP_MOUNTPOINT_INVALID", "/missing",
22 "The path to a invalid (non-existent) mountpoint" );
6 23
7my $null = '';
8my $cmd;
9my $str;
10my $t; 24my $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 );
15print "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;
21print "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;
27print "Test was: $cmd\n" unless ($?);
28$t += ok $str, '/^(Only +[\.0-9]+|DISK CRITICAL - )/';
29 31
30exit(0) if defined($Test::Harness::VERSION); 32exit(0) if defined($Test::Harness::VERSION);
31exit($tests - $t); 33exit($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
3use strict; 8use strict;
4use Cache;
5use Test; 9use Test;
10use NPTest;
11
6use vars qw($tests); 12use vars qw($tests);
13BEGIN {$tests = 6; plan tests => $tests}
14
15my $successOutput = '/DNS OK: [\.0-9]+ seconds response time/';
7 16
8BEGIN {$tests = 3; plan tests => $tests} 17my $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); 20my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost",
21 "An invalid (not known to DNS) hostname" );
22
23my $dns_server = getTestParameter( "dns_server", "NP_DNS_SERVER", undef,
24 "A non default (remote) DNS server" );
11 25
12my $null = '';
13my $cmd;
14my $str;
15my $t; 26my $t;
16 27
17$str = `./check_dns $Cache::dnshost -to 5`; 28#
18$t += ok $?>>8,0; 29# Default DNS Server
19print "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#
25print "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
27exit(0) if defined($Test::Harness::VERSION); 40exit(0) if defined($Test::Harness::VERSION);
28exit($tests - $t); 41exit($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
4use strict; 8use strict;
5use Cache;
6use Test; 9use Test;
10use NPTest;
11
7use vars qw($tests); 12use vars qw($tests);
8 13
9BEGIN {$tests = 3; plan tests => $tests} 14BEGIN {$tests = 4; plan tests => $tests}
10 15
11exit(0) unless (-x "./check_fping"); 16my $successOutput = '/^FPING OK - /';
17my $failureOutput = '/^FPING CRITICAL - /';
12 18
13#`fping 127.0.0.1 > /dev/null 2>&1` || exit(77); 19my $host_responsive = getTestParameter( "host_responsive", "NP_HOST_RESPONSIVE", "localhost",
20 "The hostname of system responsive to network requests" );
14 21
15my $null = ''; 22my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1",
16my $cmd; 23 "The hostname of system not responsive to network requests" );
17my $str;
18my $t;
19my $stat;
20 24
25my $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;
25print "Test was: $cmd\n" if ($?);
26$t += ok $str, '/^FPING OK - 127.0.0.1/';
27 28
28$cmd = "./check_fping $Cache::nullhost"; 29my $t;
29$str = `$cmd`; 30
30if ($?>>8 == 1 or $?>>8 == 2) { 31if ( -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}
37else
38{
39 $t += skipMissingCmd( "./check_fping", $tests );
32} 40}
33$t += ok $stat,2;
34print "Test was: $cmd\n" if (($?>>8) < 1);
35 41
36exit(0) if defined($Test::Harness::VERSION); 42exit(0) if defined($Test::Harness::VERSION);
37exit($tests - $t); 43exit($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; 8use strict;
4use Cache;
5use Test; 9use Test;
10use NPTest;
11
6use vars qw($tests); 12use vars qw($tests);
13BEGIN {$tests = 4; plan tests => $tests}
7 14
8BEGIN {$tests = 3; plan tests => $tests} 15my $host_tcp_ftp = getTestParameter( "host_tcp_ftp", "NP_HOST_TCP_FTP", "localhost",
16 "A host providing the FTP Service (an FTP server)");
9 17
10my $null = ''; 18my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1",
11my $cmd; 19 "The hostname of system not responsive to network requests" );
12my $str;
13my $t;
14 20
15$cmd = "./check_ftp $Cache::hostname -wt 300 -ct 600"; 21my $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;
18print "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"; 24my $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"; 26my $t;
27$str = `$cmd`; 27
28$t += ok $?>>8,2; 28$t += checkCmd( "./check_ftp $host_tcp_ftp -wt 300 -ct 600", 0, $successOutput );
29print "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
31exit(0) if defined($Test::Harness::VERSION); 32exit(0) if defined($Test::Harness::VERSION);
32exit($tests - $t); 33exit($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
3use strict; 8use strict;
4use Helper;
5use Cache;
6use Test; 9use Test;
10use NPTest;
11
7use vars qw($tests); 12use vars qw($tests);
13BEGIN {$tests = 5; plan tests => $tests}
8 14
9BEGIN {$tests = 4; plan tests => $tests} 15my $successOutput = '/^Printer ok - /';
16my $failureOutput = '/Timeout: No [Rr]esponse from /';
10 17
11exit(0) unless (-x "./check_hpjd"); 18my $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
13my $null = ''; 21my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1",
14my $cmd; 22 "The hostname of system not responsive to network requests" );
15my $str;
16my $t;
17my $printer = get_option("hpjd_printer","HP Jet-Direct card address");
18 23
19$cmd = "./check_hpjd $printer"; 24my $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;
22print "Test was: $cmd\n" if ($?);
23$t += ok $str, '/^Printer ok - /';
24 26
25$cmd = "./check_hpjd $Cache::noserver"; 27my $t;
26$str = `$cmd`; 28
27$t += ok $?>>8,2; 29if ( -x "./check_hpjd" )
28print "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}
35else
36{
37 $t += skipMissingCmd( "./check_hpjd", $tests );
38}
30 39
31exit(0) if defined($Test::Harness::VERSION); 40exit(0) if defined($Test::Harness::VERSION);
32exit($tests - $t); 41exit($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
3use strict; 8use strict;
4use Cache;
5use Test; 9use Test;
10use NPTest;
11
6use vars qw($tests); 12use vars qw($tests);
13BEGIN {$tests = 4; plan tests => $tests}
7 14
8BEGIN {$tests = 3; plan tests => $tests} 15my $host_tcp_http = getTestParameter( "host_tcp_http", "NP_HOST_TCP_HTTP", "localhost",
16 "A host providing the HTTP Service (a web server)" );
9 17
10my $null = ''; 18my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1",
11my $str; 19 "The hostname of system not responsive to network requests" );
12my $t;
13 20
14$str = `./check_http $Cache::httphost -wt 300 -ct 600`; 21my $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`; 24my $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
26my %exceptions = ( 2 => "No Web Server present?" );
27
28my $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
21exit(0) if defined($Test::Harness::VERSION); 34exit(0) if defined($Test::Harness::VERSION);
22exit($tests - $t); 35exit($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
4use Cache; 4#
5# $Id$
6#
7
8use strict;
5use Test; 9use Test;
10use NPTest;
11
6use vars qw($tests); 12use vars qw($tests);
13BEGIN {$tests = 5; plan tests => $tests}
7 14
8BEGIN {$tests = 3; plan tests => $tests} 15my $host_tcp_smtp = getTestParameter( "host_tcp_smtp", "NP_HOST_TCP_SMTP", "mailhost",
16 "A host providing an STMP Service (a mail server)");
9 17
10my $null = ''; 18my $host_tcp_imap = getTestParameter( "host_tcp_imap", "NP_HOST_TCP_IMAP", $host_tcp_smtp,
11my $cmd; 19 "A host providing an IMAP Service (a mail server)");
12my $str;
13my $t;
14 20
15$cmd = "./check_imap $Cache::mailhost"; 21my $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;
18print "Test was: $cmd\n" if ($?);
19 23
20$cmd = "./check_imap -H $Cache::mailhost -p 143 -w 9 -c 9 -t 10 -e '* OK'"; 24my $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;
23print "Test was: $cmd\n" if ($?);
24 26
27my %exceptions = ( 2 => "No IMAP Server present?" );
28
29my $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;
30print "Test was: $cmd\n" if ($?);
31 37
32exit(0) if defined($Test::Harness::VERSION); 38exit(0) if defined($Test::Harness::VERSION);
33exit($tests - $t); 39exit($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
3use strict; 8use strict;
4use Test; 9use Test;
5use vars qw($tests); 10use NPTest;
6 11
12use vars qw($tests);
7BEGIN {$tests = 4; plan tests => $tests} 13BEGIN {$tests = 4; plan tests => $tests}
8 14
9my $null = ''; 15my $successOutput = '/^OK - load average: [0-9]\.?[0-9]+, [0-9]\.?[0-9]+, [0-9]\.?[0-9]+/';
10my $cmd; 16my $failureOutput = '/^CRITICAL - load average: [0-9]\.?[0-9]+, [0-9]\.?[0-9]+, [0-9]\.?[0-9]+/';
11my $str;
12my $t;
13 17
14$cmd = "./check_load -w 100,100,100 -c 100,100,100"; 18my $t;
15$str = `$cmd`;
16$t += ok $?>>8,0;
17print "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;
23print "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
26exit(0) if defined($Test::Harness::VERSION); 23exit(0) if defined($Test::Harness::VERSION);
27exit($tests - $t); 24exit($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
3use strict; 8use strict;
4use Helper;
5use Cache;
6use Test; 9use Test;
10use NPTest;
11
7use vars qw($tests); 12use vars qw($tests);
8 13
9BEGIN {$tests = 2; plan tests => $tests} 14BEGIN {$tests = 2; plan tests => $tests}
10 15
11exit(0) unless (-x "./check_mysql");
12
13my $null = '';
14my $cmd;
15my $str;
16my $t; 16my $t;
17 17
18my $mysqlserver = get_option("mysqlserver","host for MYSQL tests"); 18my $failureOutput = '/Access denied for user: /';
19
20if ( -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; 27else
23$t += ok $str, '/Access denied for user: /'; 28{
29 $t += skipMissingCmd( "./check_mysql", $tests );
30}
24 31
25exit(0) if defined($Test::Harness::VERSION); 32exit(0) if defined($Test::Harness::VERSION);
26exit($tests - $t); 33exit($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
3use strict; 8use strict;
4use Cache;
5use Test; 9use Test;
10use NPTest;
11
6use vars qw($tests); 12use vars qw($tests);
7 13
8BEGIN {$tests = 5; plan tests => $tests} 14BEGIN {$tests = 6; plan tests => $tests}
15
16my $successOutput = '/PING (ok|OK) - Packet loss = +[0-9]{1,2}\%, +RTA = [\.0-9]+ ms/';
17my $failureOutput = '/Packet loss = +[0-9]{1,2}\%, +RTA = [\.0-9]+ ms/';
18
19my $host_responsive = getTestParameter( "host_responsive", "NP_HOST_RESPONSIVE", "localhost",
20 "The hostname of system responsive to network requests" );
21
22my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1",
23 "The hostname of system not responsive to network requests" );
24
25my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost",
26 "An invalid (not known to DNS) hostname" );
9 27
10my $null = '';
11my $cmd;
12my $str;
13my $t; 28my $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 );
18print "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;
24print "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;
30print "Test was: $cmd\n" unless ($?);
31 34
32exit(0) if defined($Test::Harness::VERSION); 35exit(0) if defined($Test::Harness::VERSION);
33exit($tests - $t); 36exit($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; 8use strict;
4use Cache;
5use Test; 9use Test;
10use NPTest;
11
6use vars qw($tests); 12use vars qw($tests);
13BEGIN {$tests = 5; plan tests => $tests}
7 14
8BEGIN {$tests = 3; plan tests => $tests} 15my $host_tcp_smtp = getTestParameter( "host_tcp_smtp", "NP_HOST_TCP_SMTP", "mailhost",
16 "A host providing an STMP Service (a mail server)");
9 17
10my $null = ''; 18my $host_tcp_pop = getTestParameter( "host_tcp_pop", "NP_HOST_TCP_POP", $host_tcp_smtp,
11my $cmd; 19 "A host providing an POP Service (a mail server)");
12my $str; 20
13my $t; 21my $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"; 24my $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;
18print "Test was: $cmd\n" if ($?);
19 26
20$cmd = "./check_pop -H $Cache::mailhost -p 110 -w 9 -c 9 -t 10 -e '+OK'"; 27my %exceptions = ( 2 => "No POP Server present?" );
21$str = `$cmd`; 28
22$t += ok $?>>8,0; 29my $t;
23print "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 );
28print "Test was: $cmd\n" if ($?); 34$t += checkCmd( "./check_pop $host_nonresponsive", 2 );
35$t += checkCmd( "./check_pop $hostname_invalid", 2 );
29 36
30exit(0) if defined($Test::Harness::VERSION); 37exit(0) if defined($Test::Harness::VERSION);
31exit($tests - $t); 38exit($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
3use strict; 8use strict;
4use Cache;
5use Test; 9use Test;
6use vars qw($tests); 10use NPTest;
7 11
12use vars qw($tests);
8BEGIN {$tests = 10; plan tests => $tests} 13BEGIN {$tests = 10; plan tests => $tests}
9 14
10my $null = '';
11my $cmd;
12my $str;
13my $t; 15my $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)?$/' );
19print "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;
26print "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;
33print "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;
40print "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;
47print "Test was: $cmd\n" unless ($?);
48$t += ok $str, '/^PROCS CRITICAL: [0-9]+ process(es)? with /';
49 22
50exit(0) if defined($Test::Harness::VERSION); 23exit(0) if defined($Test::Harness::VERSION);
51exit($tests - $t); 24exit($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; 8use strict;
4use Cache;
5use Test; 9use Test;
10use NPTest;
11
6use vars qw($tests); 12use vars qw($tests);
13BEGIN {$tests = 5; plan tests => $tests}
7 14
8BEGIN {$tests = 3; plan tests => $tests} 15my $host_tcp_smtp = getTestParameter( "host_tcp_smtp", "NP_HOST_TCP_SMTP", "mailhost",
16 "A host providing an STMP Service (a mail server)");
9 17
10my $null = ''; 18my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1",
11my $cmd; 19 "The hostname of system not responsive to network requests" );
12my $str;
13my $t;
14 20
15$cmd = "./check_smtp $Cache::mailhost"; 21my $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; 23my %exceptions = ( 2 => "No SMTP Server present?" );
18print "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"; 25my $t;
21$str = `$cmd`;
22$t += ok $?>>8,0;
23print "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 );
28print "Test was: $cmd\n" if ($?); 30$t += checkCmd( "./check_smtp $host_nonresponsive", 2 );
31$t += checkCmd( "./check_smtp $hostname_invalid", 3 );
29 32
30exit(0) if defined($Test::Harness::VERSION); 33exit(0) if defined($Test::Harness::VERSION);
31exit($tests - $t); 34exit($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
3use strict; 8use strict;
4use Helper;
5use Cache;
6use Test; 9use Test;
7use vars qw($tests); 10use NPTest;
8 11
9BEGIN {$tests = 8; plan tests => $tests} 12use vars qw($tests);
13BEGIN {$tests = 12; plan tests => $tests}
10 14
11my $null = '';
12my $cmd;
13my $str;
14my $t; 15my $t;
15my $community=get_option("snmp_community","SNMP community name"); 16
16 17if ( -x "./check_snmp" )
17exit(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",
22print "Test was: $cmd\n" if ($?); 23 "The SNMP Community string for SNMP Testing" );
23chomp $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" );
29print "Test was: $cmd\n" if ($?); 30
30chomp $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
36print "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",
37chomp $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",
43print "Test was: $cmd\n" unless ($?); 44 { 2 => 'continue', 3 => 'skip' }, '/^SNMP CRITICAL - \*1\*\s*$/', %exceptions );
44chomp $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}
51else
52{
53 $t += skipMissingCmd( "./check_snmp", $tests );
54}
50 55
51exit(0) if defined($Test::Harness::VERSION); 56exit(0) if defined($Test::Harness::VERSION);
52exit($tests - $t); 57exit($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
3use strict; 8use strict;
4use Cache;
5use Test; 9use Test;
6use vars qw($tests); 10use NPTest;
7 11
12use vars qw($tests);
8BEGIN {$tests = 6; plan tests => $tests} 13BEGIN {$tests = 6; plan tests => $tests}
9 14
10my $null = '';
11my $cmd;
12my $str;
13my $t; 15my $t;
14 16
15$cmd = "./check_swap 100 100"; 17my $successOutput = '/^SWAP OK - [0-9]+\% free \([0-9]+ MB out of [0-9]+ MB\)/';
16$str = `$cmd`; 18my $failureOutput = '/^SWAP CRITICAL - [0-9]+\% free \([0-9]+ MB out of [0-9]+ MB\)/';
17$t += ok $?>>8,0;
18print "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;
24print "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)
30print "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
33exit(0) if defined($Test::Harness::VERSION); 24exit(0) if defined($Test::Harness::VERSION);
34exit($tests - $t); 25exit($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; 8use strict;
4use Cache;
5use Test; 9use Test;
10use NPTest;
11
6use vars qw($tests); 12use vars qw($tests);
13BEGIN {$tests = 5; plan tests => $tests}
7 14
8BEGIN {$tests = 3; plan tests => $tests} 15my $host_tcp_http = getTestParameter( "host_tcp_http", "NP_HOST_TCP_HTTP", "localhost",
16 "A host providing the HTTP Service (a web server)" );
9 17
10my $null = ''; 18my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1",
11my $cmd; 19 "The hostname of system not responsive to network requests" );
12my $str; 20
13my $t; 21my $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"; 24my $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; 26my $t;
18print "$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 );
24print "$cmd\n" unless ($?); 31$t += checkCmd( "./check_tcp $hostname_invalid -p 80 -wt 0 -ct 0 -to 1", 2 );
25 32
26exit(0) if defined($Test::Harness::VERSION); 33exit(0) if defined($Test::Harness::VERSION);
27exit($tests - $t); 34exit($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
3use strict; 8use strict;
4use Cache;
5use Helper;
6use Test; 9use Test;
10use NPTest;
11
7use vars qw($tests); 12use vars qw($tests);
13BEGIN {$tests = 8; plan tests => $tests}
8 14
9BEGIN {$tests = 6; plan tests => $tests} 15my $host_udp_time = getTestParameter( "host_udp_time", "NP_HOST_UDP_TIME", "localhost",
16 "A host providing the UDP Time Service" );
10 17
11my $null = ''; 18my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1",
12my $cmd; 19 "The hostname of system not responsive to network requests" );
13my $str;
14my $t;
15my $udp_hostname=get_option("udp_hostname","UDP host name");
16 20
17# standard mode 21my $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"; 24my $successOutput = '/^TIME OK - [0-9]+ second time difference/';
20$str = `$cmd`;
21$t += ok $?>>8,0;
22print "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"; 26my $t;
26$str = `$cmd`;
27$t += ok $?>>8,0;
28print "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;
36print "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
51exit(0) if defined($Test::Harness::VERSION); 39exit(0) if defined($Test::Harness::VERSION);
52exit($tests - $t); 40exit($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; 8use strict;
4use Cache;
5use Helper;
6use Test; 9use Test;
10use NPTest;
11
7use vars qw($tests); 12use vars qw($tests);
13BEGIN {$tests = 3; plan tests => $tests} #TODO# Update to 4 when the commented out test is fixed
8 14
9BEGIN {$tests = 3; plan tests => $tests} 15my $host_udp_time = getTestParameter( "host_udp_time", "NP_HOST_UDP_TIME", "localhost",
16 "A host providing the UDP Time Service" );
10 17
11my $null = ''; 18my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1",
12my $str; 19 "The hostname of system not responsive to network requests" );
13my $t; 20
14my $hostname=get_option("udp_hostname","UDP host name"); 21my $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`; 24my $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$/'; 26my $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
23exit(0) if defined($Test::Harness::VERSION); 32exit(0) if defined($Test::Harness::VERSION);
24exit($tests - $t); 33exit($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
3use strict; 8use strict;
4use Cache;
5use Test; 9use Test;
6use vars qw($tests); 10use NPTest;
7 11
12use vars qw($tests);
8BEGIN {$tests = 4; plan tests => $tests} 13BEGIN {$tests = 4; plan tests => $tests}
9 14
10my $null = ''; 15my $successOutput = '/^USERS OK - [0-9]+ users currently logged in/';
11my $cmd; 16my $failureOutput = '/^USERS CRITICAL - [0-9]+ users currently logged in/';
12my $str;
13my $t;
14 17
15$cmd = "./check_users 1000 1000"; 18my $t;
16$str = `$cmd`;
17$t += ok $?>>8,0;
18print "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;
24print "Test was: $cmd\n" unless ($?);
25$t += ok $str, '/^USERS CRITICAL - [0-9]+ +users currently logged in$/';
26 22
27exit(0) if defined($Test::Harness::VERSION); 23exit(0) if defined($Test::Harness::VERSION);
28exit($tests - $t); 24exit($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
3use strict;
4use Cache;
5use Test;
6use vars qw($tests);
7
8BEGIN {$tests = 4; plan tests => $tests}
9
10my $null = '';
11my $cmd;
12my $str;
13my $t;
14
15$cmd = "./check_vsz 100000 1000000 init";
16$str = `$cmd`;
17$t += ok $?>>8,0;
18print "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;
24print "Test was: $cmd\n" unless ($?);
25$t += ok $str, '/^CRITICAL \(VSZ\>[0-9]+\)/';
26
27exit(0) if defined($Test::Harness::VERSION);
28exit($tests - $t);