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/t | |
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/t')
-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 @@ +#! /usr/bin/perl -w -I .. +# +# Disk Space Tests via check_disk +# +# $Id$ +# + use strict; use Test; +use NPTest; + use vars qw($tests); +BEGIN {$tests = 10; plan tests => $tests} + +my $successOutput = '/^DISK OK - /'; +my $failureOutput = '/^DISK CRITICAL - /'; + +my $mountpoint_valid = getTestParameter( "mountpoint_valid", "NP_MOUNTPOINT_VALID", "/", + "The path to a valid mountpoint" ); -BEGIN {$tests = 6; plan tests => $tests} +my $mountpoint_invalid = getTestParameter( "mountpoint_invalid", "NP_MOUNTPOINT_INVALID", "/missing", + "The path to a invalid (non-existent) mountpoint" ); -my $null = ''; -my $cmd; -my $str; my $t; -$cmd = "./check_disk 100 100 /"; -$str = `$cmd`; -$t += ok $?>>8,0; -print "Test was: $cmd\n" if ($?); -$t += ok $str, '/^(Disk ok - +[\.0-9]+|DISK OK - )/'; - -$cmd = "./check_disk -w 0 -c 0 /"; -$str = `$cmd`; -$t += ok $?>>8,0; -print "Test was: $cmd\n" if ($?); -$t += ok $str, '/^(Disk ok - +[\.0-9]+|DISK OK - )/'; - -$cmd = "./check_disk 0 0 /"; -$str = `$cmd`; -$t += ok $?>>8,2; -print "Test was: $cmd\n" unless ($?); -$t += ok $str, '/^(Only +[\.0-9]+|DISK CRITICAL - )/'; +$t += checkCmd( "./check_disk 100 100 ${mountpoint_valid}", 0, $successOutput ); +$t += checkCmd( "./check_disk -w 0 -c 0 ${mountpoint_valid}", 0, $successOutput ); +$t += checkCmd( "./check_disk -w 1\% -c 1\% ${mountpoint_valid}", 0, $successOutput ); +$t += checkCmd( "./check_disk 0 0 ${mountpoint_valid}", 2, $failureOutput ); +$t += checkCmd( "./check_disk 100 100 ${mountpoint_invalid}", 2, '/not found/' ); exit(0) if defined($Test::Harness::VERSION); 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 @@ -#! /usr/bin/perl -w +#! /usr/bin/perl -w -I .. +# +# Domain Name Server (DNS) Tests via check_dns +# +# $Id$ +# use strict; -use Cache; use Test; +use NPTest; + use vars qw($tests); +BEGIN {$tests = 6; plan tests => $tests} + +my $successOutput = '/DNS OK: [\.0-9]+ seconds response time/'; -BEGIN {$tests = 3; plan tests => $tests} +my $hostname_valid = getTestParameter( "hostname_valid", "NP_HOSTNAME_VALID", "localhost", + "A valid (known to DNS) hostname" ); -#`nslookup localhost > /dev/null 2>&1` || exit(77); +my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost", + "An invalid (not known to DNS) hostname" ); + +my $dns_server = getTestParameter( "dns_server", "NP_DNS_SERVER", undef, + "A non default (remote) DNS server" ); -my $null = ''; -my $cmd; -my $str; my $t; -$str = `./check_dns $Cache::dnshost -to 5`; -$t += ok $?>>8,0; -print "Test was: $cmd\n" if ($?); -$t += ok $str, '/DNS OK: +[\.0-9]+ seconds response time, /'; +# +# Default DNS Server +# +$t += checkCmd( "./check_dns -H $hostname_valid -t 5", 0, $successOutput ); +$t += checkCmd( "./check_dns -H $hostname_invalid -t 1", 2 ); -$cmd = "./check_dns $Cache::nullhost -to 1"; -$str = `$cmd`; -$t += ok $?>>8,2; -print "Test was: $cmd\n" unless ($?); +# +# Specified DNS Server +# +$t += checkCmd( "./check_dns -H $hostname_valid -s $dns_server -t 5", 0, $successOutput ); +$t += checkCmd( "./check_dns -H $hostname_invalid -s $dns_server -t 1", 2 ); exit(0) if defined($Test::Harness::VERSION); exit($tests - $t); + 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 @@ -#! /usr/bin/perl -w +#! /usr/bin/perl -w -I .. +# +# FPing Tests via check_fping +# # $Id$ +# use strict; -use Cache; use Test; +use NPTest; + use vars qw($tests); -BEGIN {$tests = 3; plan tests => $tests} +BEGIN {$tests = 4; plan tests => $tests} -exit(0) unless (-x "./check_fping"); +my $successOutput = '/^FPING OK - /'; +my $failureOutput = '/^FPING CRITICAL - /'; -#`fping 127.0.0.1 > /dev/null 2>&1` || exit(77); +my $host_responsive = getTestParameter( "host_responsive", "NP_HOST_RESPONSIVE", "localhost", + "The hostname of system responsive to network requests" ); -my $null = ''; -my $cmd; -my $str; -my $t; -my $stat; +my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1", + "The hostname of system not responsive to network requests" ); +my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost", + "An invalid (not known to DNS) hostname" ); -$cmd = "./check_fping 127.0.0.1"; -$str = `$cmd`; -$t += ok $?>>8,0; -print "Test was: $cmd\n" if ($?); -$t += ok $str, '/^FPING OK - 127.0.0.1/'; -$cmd = "./check_fping $Cache::nullhost"; -$str = `$cmd`; -if ($?>>8 == 1 or $?>>8 == 2) { - $stat = 2; +my $t; + +if ( -x "./check_fping" ) +{ + $t += checkCmd( "./check_fping $host_responsive", 0, $successOutput ); + $t += checkCmd( "./check_fping $host_nonresponsive", [ 1, 2 ] ); + $t += checkCmd( "./check_fping $hostname_invalid", [ 1, 2 ] ); +} +else +{ + $t += skipMissingCmd( "./check_fping", $tests ); } -$t += ok $stat,2; -print "Test was: $cmd\n" if (($?>>8) < 1); exit(0) if defined($Test::Harness::VERSION); 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 @@ -#! /usr/bin/perl -w +#! /usr/bin/perl -w -I .. +# +# File Transfer Protocol (FTP) Test via check_ftp +# +# $Id$ +# -#use strict; -use Cache; +use strict; use Test; +use NPTest; + use vars qw($tests); +BEGIN {$tests = 4; plan tests => $tests} -BEGIN {$tests = 3; plan tests => $tests} +my $host_tcp_ftp = getTestParameter( "host_tcp_ftp", "NP_HOST_TCP_FTP", "localhost", + "A host providing the FTP Service (an FTP server)"); -my $null = ''; -my $cmd; -my $str; -my $t; +my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1", + "The hostname of system not responsive to network requests" ); -$cmd = "./check_ftp $Cache::hostname -wt 300 -ct 600"; -$str = `$cmd`; -$t += ok $?>>8,0; -print "Test was: $cmd\n" if ($?); -$t += ok $str, '/FTP OK -\s+[0-9]?\.?[0-9]+ second response time/'; +my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost", + "An invalid (not known to DNS) hostname" ); -#$cmd = "./check_ftp $Cache::noserver -wt 0 -ct 0"; -#$str = `$cmd`; -#$t += ok $?>>8,2; -#print "Test was: $cmd\n" unless ($?); +my $successOutput = '/FTP OK -\s+[0-9]?\.?[0-9]+ second response time/'; -$cmd = "./check_ftp $Cache::nullhost -wt 0 -ct 0 -to 1"; -$str = `$cmd`; -$t += ok $?>>8,2; -print "Test was: $cmd\n" unless ($?); +my $t; + +$t += checkCmd( "./check_ftp $host_tcp_ftp -wt 300 -ct 600", 0, $successOutput ); +$t += checkCmd( "./check_ftp $host_nonresponsive -wt 0 -ct 0 -to 1", 2 ); +$t += checkCmd( "./check_ftp $hostname_invalid -wt 0 -ct 0", 2 ); exit(0) if defined($Test::Harness::VERSION); exit($tests - $t); + 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 @@ -#! /usr/bin/perl -w +#! /usr/bin/perl -w -I .. +# +# HP JetDirect Test via check_hpjd +# +# $Id$ +# use strict; -use Helper; -use Cache; use Test; +use NPTest; + use vars qw($tests); +BEGIN {$tests = 5; plan tests => $tests} -BEGIN {$tests = 4; plan tests => $tests} +my $successOutput = '/^Printer ok - /'; +my $failureOutput = '/Timeout: No [Rr]esponse from /'; -exit(0) unless (-x "./check_hpjd"); +my $host_tcp_hpjd = getTestParameter( "host_tcp_hpjd", "NP_HOST_TCP_HPJD", undef, + "A host (usually a printer) providing the HP-JetDirect Services" ); -my $null = ''; -my $cmd; -my $str; -my $t; -my $printer = get_option("hpjd_printer","HP Jet-Direct card address"); +my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1", + "The hostname of system not responsive to network requests" ); -$cmd = "./check_hpjd $printer"; -$str = `$cmd`; -$t += ok $?>>8,0; -print "Test was: $cmd\n" if ($?); -$t += ok $str, '/^Printer ok - /'; +my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost", + "An invalid (not known to DNS) hostname" ); -$cmd = "./check_hpjd $Cache::noserver"; -$str = `$cmd`; -$t += ok $?>>8,2; -print "Test was: $cmd\n" unless ($?); -$t += ok $str, '/Timeout: No response from /'; +my $t; + +if ( -x "./check_hpjd" ) +{ + $t += checkCmd( "./check_hpjd $host_tcp_hpjd", 0, $successOutput ); + $t += checkCmd( "./check_hpjd $host_nonresponsive", 2, $failureOutput ); + $t += checkCmd( "./check_hpjd $hostname_invalid", 3 ); +} +else +{ + $t += skipMissingCmd( "./check_hpjd", $tests ); +} exit(0) if defined($Test::Harness::VERSION); exit($tests - $t); + 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 @@ -#! /usr/bin/perl -w +#! /usr/bin/perl -w -I .. +# +# HyperText Transfer Protocol (HTTP) Test via check_http +# +# $Id$ +# use strict; -use Cache; use Test; +use NPTest; + use vars qw($tests); +BEGIN {$tests = 4; plan tests => $tests} -BEGIN {$tests = 3; plan tests => $tests} +my $host_tcp_http = getTestParameter( "host_tcp_http", "NP_HOST_TCP_HTTP", "localhost", + "A host providing the HTTP Service (a web server)" ); -my $null = ''; -my $str; -my $t; +my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1", + "The hostname of system not responsive to network requests" ); -$str = `./check_http $Cache::httphost -wt 300 -ct 600`; -$t += ok $?>>8,0; -$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/'; +my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost", + "An invalid (not known to DNS) hostname" ); -$str = `./check_http $Cache::nullhost -wt 1 -ct 2`; -$t += ok $?>>8,2; +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/'; + +my %exceptions = ( 2 => "No Web Server present?" ); + +my $t; + +$t += checkCmd( "./check_http $host_tcp_http -wt 300 -ct 600", { 0 => 'continue', 2 => 'skip' }, $successOutput, %exceptions ); +$t += checkCmd( "./check_http $host_nonresponsive -wt 1 -ct 2", 2 ); +$t += checkCmd( "./check_http $hostname_invalid -wt 1 -ct 2", 2 ); exit(0) if defined($Test::Harness::VERSION); exit($tests - $t); + 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 @@ -#! /usr/bin/perl -w - -#use strict; -use Cache; +#! /usr/bin/perl -w -I .. +# +# Internet Mail Access Protocol (IMAP) Server Tests via check_imap +# +# $Id$ +# + +use strict; use Test; +use NPTest; + use vars qw($tests); +BEGIN {$tests = 5; plan tests => $tests} -BEGIN {$tests = 3; plan tests => $tests} +my $host_tcp_smtp = getTestParameter( "host_tcp_smtp", "NP_HOST_TCP_SMTP", "mailhost", + "A host providing an STMP Service (a mail server)"); -my $null = ''; -my $cmd; -my $str; -my $t; +my $host_tcp_imap = getTestParameter( "host_tcp_imap", "NP_HOST_TCP_IMAP", $host_tcp_smtp, + "A host providing an IMAP Service (a mail server)"); -$cmd = "./check_imap $Cache::mailhost"; -$str = `$cmd`; -$t += ok $?>>8,0; -print "Test was: $cmd\n" if ($?); +my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1", + "The hostname of system not responsive to network requests" ); -$cmd = "./check_imap -H $Cache::mailhost -p 143 -w 9 -c 9 -t 10 -e '* OK'"; -$str = `$cmd`; -$t += ok $?>>8,0; -print "Test was: $cmd\n" if ($?); +my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost", + "An invalid (not known to DNS) hostname" ); +my %exceptions = ( 2 => "No IMAP Server present?" ); + +my $t; + +$t += checkCmd( "./check_imap $host_tcp_imap", 0, undef, %exceptions ); +$t += checkCmd( "./check_imap -H $host_tcp_imap -p 143 -w 9 -c 9 -t 10 -e '* OK'", 0, undef, %exceptions ); +$t += checkCmd( "./check_imap $host_tcp_imap -p 143 -wt 9 -ct 9 -to 10 -e '* OK'", 0, undef, %exceptions ); +$t += checkCmd( "./check_imap $host_nonresponsive", 2 ); +$t += checkCmd( "./check_imap $hostname_invalid", 2 ); -# Reverse compatibility -$cmd = "./check_imap $Cache::mailhost -p 143 -wt 9 -ct 9 -to 10 -e '* OK'"; -$str = `$cmd`; -$t += ok $?>>8,0; -print "Test was: $cmd\n" if ($?); exit(0) if defined($Test::Harness::VERSION); exit($tests - $t); - 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 @@ -#! /usr/bin/perl -w +#! /usr/bin/perl -w -I .. +# +# Load Average Tests via check_load +# +# $Id$ +# use strict; use Test; -use vars qw($tests); +use NPTest; +use vars qw($tests); BEGIN {$tests = 4; plan tests => $tests} -my $null = ''; -my $cmd; -my $str; -my $t; +my $successOutput = '/^OK - load average: [0-9]\.?[0-9]+, [0-9]\.?[0-9]+, [0-9]\.?[0-9]+/'; +my $failureOutput = '/^CRITICAL - load average: [0-9]\.?[0-9]+, [0-9]\.?[0-9]+, [0-9]\.?[0-9]+/'; -$cmd = "./check_load -w 100,100,100 -c 100,100,100"; -$str = `$cmd`; -$t += ok $?>>8,0; -print "Test was: $cmd\n" if ($?); -$t += ok $str, '/^OK - load average: [0-9]\.?[0-9]+, [0-9]\.?[0-9]+, [0-9]\.?[0-9]+/'; +my $t; -$cmd = "./check_load -w 0,0,0 -c 0,0,0"; -$str = `$cmd`; -$t += ok $?>>8,2; -print "Test was: $cmd\n" unless ($?); -$t += ok $str, '/^CRITICAL - load average: [0-9]\.?[0-9]+, [0-9]\.?[0-9]+, [0-9]\.?[0-9]+/'; +$t += checkCmd( "./check_load -w 100,100,100 -c 100,100,100", 0, $successOutput ); +$t += checkCmd( "./check_load -w 0,0,0 -c 0,0,0", 2, $failureOutput ); exit(0) if defined($Test::Harness::VERSION); exit($tests - $t); + 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 @@ -#! /usr/bin/perl -w +#! /usr/bin/perl -w -I .. +# +# MySQL Database Server Tests via check_mysql +# +# $Id$ +# use strict; -use Helper; -use Cache; use Test; +use NPTest; + use vars qw($tests); BEGIN {$tests = 2; plan tests => $tests} -exit(0) unless (-x "./check_mysql"); - -my $null = ''; -my $cmd; -my $str; my $t; -my $mysqlserver = get_option("mysqlserver","host for MYSQL tests"); +my $failureOutput = '/Access denied for user: /'; + +if ( -x "./check_mysql" ) +{ + my $mysqlserver = getTestParameter( "mysql_server", "NP_MYSQL_SERVER", undef, + "A MySQL Server"); -$cmd = "./check_mysql -H $mysqlserver -P 3306"; -$str = `$cmd`; -$t += ok $?>>8,2; -$t += ok $str, '/Access denied for user: /'; + $t += checkCmd( "./check_mysql -H $mysqlserver -P 3306", 2, $failureOutput ); +} +else +{ + $t += skipMissingCmd( "./check_mysql", $tests ); +} exit(0) if defined($Test::Harness::VERSION); 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 @@ -#! /usr/bin/perl -w +#! /usr/bin/perl -w -I .. +# +# Ping Response Tests via check_ping +# +# $Id$ +# use strict; -use Cache; use Test; +use NPTest; + use vars qw($tests); -BEGIN {$tests = 5; plan tests => $tests} +BEGIN {$tests = 6; plan tests => $tests} + +my $successOutput = '/PING (ok|OK) - Packet loss = +[0-9]{1,2}\%, +RTA = [\.0-9]+ ms/'; +my $failureOutput = '/Packet loss = +[0-9]{1,2}\%, +RTA = [\.0-9]+ ms/'; + +my $host_responsive = getTestParameter( "host_responsive", "NP_HOST_RESPONSIVE", "localhost", + "The hostname of system responsive to network requests" ); + +my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1", + "The hostname of system not responsive to network requests" ); + +my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost", + "An invalid (not known to DNS) hostname" ); -my $null = ''; -my $cmd; -my $str; my $t; -$cmd = "./check_ping 127.0.0.1 100 100 1000 1000 -p 1"; -$str = `$cmd`; -$t += ok $?>>8,0; -print "Test was: $cmd\n" if ($?); -$t += ok $str, '/PING (ok|OK) - Packet loss = +[0-9]{1,2}\%, +RTA = [\.0-9]+ ms/'; - -$cmd = "./check_ping 127.0.0.1 0 0 0 0 -p 1"; -$str = `$cmd`; -$t += ok $?>>8,2; -print "Test was: $cmd\n" unless ($?); -$t += ok $str, '/Packet loss = +[0-9]{1,2}\%, +RTA = [\.0-9]+ ms/'; - -$cmd = "./check_ping $Cache::nullhost 0 0 0 0 -p 1 -to 1"; -$str = `$cmd`; -$t += ok $?>>8,2; -print "Test was: $cmd\n" unless ($?); +$t += checkCmd( "./check_ping $host_responsive 100 100 1000 1000 -p 1", 0, $successOutput ); +$t += checkCmd( "./check_ping $host_responsive 0 0 0 0 -p 1", 2, $failureOutput ); +$t += checkCmd( "./check_ping $host_nonresponsive 0 0 0 0 -p 1 -to 1", 2 ); +$t += checkCmd( "./check_ping $hostname_invalid 0 0 0 0 -p 1 -to 1", 3 ); exit(0) if defined($Test::Harness::VERSION); 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 @@ -#! /usr/bin/perl -w +#! /usr/bin/perl -w -I .. +# +# Post Office Protocol (POP) Server Tests via check_pop +# +# $Id$ +# -#use strict; -use Cache; +use strict; use Test; +use NPTest; + use vars qw($tests); +BEGIN {$tests = 5; plan tests => $tests} -BEGIN {$tests = 3; plan tests => $tests} +my $host_tcp_smtp = getTestParameter( "host_tcp_smtp", "NP_HOST_TCP_SMTP", "mailhost", + "A host providing an STMP Service (a mail server)"); -my $null = ''; -my $cmd; -my $str; -my $t; +my $host_tcp_pop = getTestParameter( "host_tcp_pop", "NP_HOST_TCP_POP", $host_tcp_smtp, + "A host providing an POP Service (a mail server)"); + +my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1", + "The hostname of system not responsive to network requests" ); -$cmd = "./check_pop $Cache::mailhost"; -$str = `$cmd`; -$t += ok $?>>8,0; -print "Test was: $cmd\n" if ($?); +my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost", + "An invalid (not known to DNS) hostname" ); -$cmd = "./check_pop -H $Cache::mailhost -p 110 -w 9 -c 9 -t 10 -e '+OK'"; -$str = `$cmd`; -$t += ok $?>>8,0; -print "Test was: $cmd\n" if ($?); +my %exceptions = ( 2 => "No POP Server present?" ); + +my $t; -$cmd = "./check_pop $Cache::mailhost -p 110 -wt 9 -ct 9 -to 10 -e '+OK'"; -$str = `$cmd`; -$t += ok $?>>8,0; -print "Test was: $cmd\n" if ($?); +$t += checkCmd( "./check_pop $host_tcp_pop", 0, undef, %exceptions ); +$t += checkCmd( "./check_pop -H $host_tcp_pop -p 110 -w 9 -c 9 -t 10 -e '+OK'", 0, undef, %exceptions ); +$t += checkCmd( "./check_pop $host_tcp_pop -p 110 -wt 9 -ct 9 -to 10 -e '+OK'", 0, undef, %exceptions ); +$t += checkCmd( "./check_pop $host_nonresponsive", 2 ); +$t += checkCmd( "./check_pop $hostname_invalid", 2 ); exit(0) if defined($Test::Harness::VERSION); 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 @@ -#! /usr/bin/perl -w +#! /usr/bin/perl -w -I .. +# +# Process Tests via check_procs +# +# $Id$ +# use strict; -use Cache; use Test; -use vars qw($tests); +use NPTest; +use vars qw($tests); BEGIN {$tests = 10; plan tests => $tests} -my $null = ''; -my $cmd; -my $str; my $t; -# Reverse Compatibility -$cmd = "./check_procs -w 100000 -c 100000"; -$str = `$cmd`; -$t += ok $?>>8,0; -print "Test was: $cmd\n" if ($?); -$t += ok $str, '/^PROCS OK: [0-9]+ process(es)?$/'; - -# Reverse Compatibility -$cmd = "./check_procs -w 100000 -c 100000 -s Z"; -$str = `$cmd`; -$t += ok $?>>8,0; -print "Test was: $cmd\n" if ($?); -$t += ok $str, '/^PROCS OK: [0-9]+ process(es)? with /'; - -# Reverse Compatibility -$cmd = "./check_procs -w 0 -c 10000000"; -$str = `$cmd`; -$t += ok $?>>8,1; -print "Test was: $cmd\n" unless ($?); -$t += ok $str, '/^PROCS WARNING: [0-9]+ process(es)?$/'; - -# Reverse Compatibility -$cmd = "./check_procs -w 0 -c 0"; -$str = `$cmd`; -$t += ok $?>>8,2; -print "Test was: $cmd\n" unless ($?); -$t += ok $str, '/^PROCS CRITICAL: [0-9]+ process(es)?$/'; - -# Reverse Compatibility -$cmd = "./check_procs -w 0 -c 0 -s S"; -$str = `$cmd`; -$t += ok $?>>8,2; -print "Test was: $cmd\n" unless ($?); -$t += ok $str, '/^PROCS CRITICAL: [0-9]+ process(es)? with /'; +$t += checkCmd( "./check_procs -w 100000 -c 100000", 0, '/^PROCS OK: [0-9]+ process(es)?$/' ); +$t += checkCmd( "./check_procs -w 100000 -c 100000 -s Z", 0, '/^PROCS OK: [0-9]+ process(es)? with /' ); +$t += checkCmd( "./check_procs -w 0 -c 10000000", 1, '/^PROCS WARNING: [0-9]+ process(es)?$/' ); +$t += checkCmd( "./check_procs -w 0 -c 0", 2, '/^PROCS CRITICAL: [0-9]+ process(es)?$/' ); +$t += checkCmd( "./check_procs -w 0 -c 0 -s S", 2, '/^PROCS CRITICAL: [0-9]+ process(es)? with /' ); exit(0) if defined($Test::Harness::VERSION); 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 @@ -#! /usr/bin/perl -w +#! /usr/bin/perl -w -I .. +# +# Simple Mail Transfer Protocol (SMTP) Test via check_smtp +# +# $Id$ +# -#use strict; -use Cache; +use strict; use Test; +use NPTest; + use vars qw($tests); +BEGIN {$tests = 5; plan tests => $tests} -BEGIN {$tests = 3; plan tests => $tests} +my $host_tcp_smtp = getTestParameter( "host_tcp_smtp", "NP_HOST_TCP_SMTP", "mailhost", + "A host providing an STMP Service (a mail server)"); -my $null = ''; -my $cmd; -my $str; -my $t; +my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1", + "The hostname of system not responsive to network requests" ); -$cmd = "./check_smtp $Cache::mailhost"; -$str = `$cmd`; -$t += ok $?>>8,0; -print "Test was: $cmd\n" if ($?); +my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost", + "An invalid (not known to DNS) hostname" ); +my %exceptions = ( 2 => "No SMTP Server present?" ); -$cmd = "./check_smtp -H $Cache::mailhost -p 25 -t 1 -w 9 -c 9 -t 10 -e 220"; -$str = `$cmd`; -$t += ok $?>>8,0; -print "Test was: $cmd\n" if ($?); +my $t; -$cmd = "./check_smtp -H $Cache::mailhost -p 25 -wt 9 -ct 9 -to 10 -e 220"; -$str = `$cmd`; -$t += ok $?>>8,0; -print "Test was: $cmd\n" if ($?); +$t += checkCmd( "./check_smtp $host_tcp_smtp", 0, undef, %exceptions ); +$t += checkCmd( "./check_smtp -H $host_tcp_smtp -p 25 -t 1 -w 9 -c 9 -t 10 -e 220", 0, undef, %exceptions ); +$t += checkCmd( "./check_smtp -H $host_tcp_smtp -p 25 -wt 9 -ct 9 -to 10 -e 220", 0, undef, %exceptions ); +$t += checkCmd( "./check_smtp $host_nonresponsive", 2 ); +$t += checkCmd( "./check_smtp $hostname_invalid", 3 ); exit(0) if defined($Test::Harness::VERSION); 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 @@ -#! /usr/bin/perl -w +#! /usr/bin/perl -w -I .. +# +# Simple Network Management Protocol (SNMP) Test via check_snmp +# +# $Id$ +# use strict; -use Helper; -use Cache; use Test; -use vars qw($tests); +use NPTest; -BEGIN {$tests = 8; plan tests => $tests} +use vars qw($tests); +BEGIN {$tests = 12; plan tests => $tests} -my $null = ''; -my $cmd; -my $str; my $t; -my $community=get_option("snmp_community","SNMP community name"); - -exit(0) unless (-x "./check_snmp"); - -$cmd = "./check_snmp -H 127.0.0.1 -C $community -o system.sysUpTime.0 -w 1: -c 1:"; -$str = `$cmd`; -$t += ok $?>>8,0; -print "Test was: $cmd\n" if ($?); -chomp $str; -$t += ok $str, '/^SNMP OK - \d+/'; - -$cmd = "./check_snmp -H 127.0.0.1 -C $community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w 1:1 -c 1:1"; -$str = `$cmd`; -$t += ok $?>>8,0; -print "Test was: $cmd\n" if ($?); -chomp $str; -$t += ok $str, '/^SNMP OK - 1\s*$/'; - -$cmd = "./check_snmp -H 127.0.0.1 -C $community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w 0 -c 1:"; -$str = `$cmd`; -$t += ok $?>>8,1; -print "Test was: $cmd\n" unless ($?); -chomp $str; -$t += ok $str, '/^SNMP WARNING - \*1\*\s*$/'; - -$cmd = "./check_snmp -H 127.0.0.1 -C $community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w :0 -c 0"; -$str = `$cmd`; -$t += ok $?>>8,2; -print "Test was: $cmd\n" unless ($?); -chomp $str; -$t += ok $str, '/^SNMP CRITICAL - \*1\*\s*$/'; - -#host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 = 1 -#enterprises.ucdavis.memory.memAvailSwap.0 -#./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)' + +if ( -x "./check_snmp" ) +{ + my $host_snmp = getTestParameter( "host_snmp", "NP_HOST_SNMP", "localhost", + "A host providing an SNMP Service"); + + my $snmp_community = getTestParameter( "snmp_community", "NP_SNMP_COMMUNITY", "public", + "The SNMP Community string for SNMP Testing" ); + + my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1", + "The hostname of system not responsive to network requests" ); + + my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost", + "An invalid (not known to DNS) hostname" ); + + my %exceptions = ( 3 => "No SNMP Server present?" ); + + + $t += checkCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0 -w 1: -c 1:", + { 0 => 'continue', 3 => 'skip' }, '/^SNMP OK - \d+/', %exceptions ); + + $t += checkCmd( "./check_snmp -H $host_snmp -C $snmp_community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w 1:1 -c 1:1", + { 0 => 'continue', 3 => 'skip' }, '/^SNMP OK - 1\s*$/', %exceptions ); + + $t += checkCmd( "./check_snmp -H $host_snmp -C $snmp_community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w 0 -c 1:", + { 1 => 'continue', 3 => 'skip' }, '/^SNMP WARNING - \*1\*\s*$/', %exceptions ); + + $t += checkCmd( "./check_snmp -H $host_snmp -C $snmp_community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w :0 -c 0", + { 2 => 'continue', 3 => 'skip' }, '/^SNMP CRITICAL - \*1\*\s*$/', %exceptions ); + + $t += checkCmd( "./check_snmp -H $host_nonresponsive -C $snmp_community -o system.sysUpTime.0 -w 1: -c 1:", 3, '/SNMP problem - /' ); + + $t += checkCmd( "./check_snmp -H $hostname_invalid -C $snmp_community -o system.sysUpTime.0 -w 1: -c 1:", 3, '/SNMP problem - /' ); + +} +else +{ + $t += skipMissingCmd( "./check_snmp", $tests ); +} exit(0) if defined($Test::Harness::VERSION); 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 @@ -#! /usr/bin/perl -w +#! /usr/bin/perl -w -I .. +# +# Swap Space Tests via check_swap +# +# $Id$ +# use strict; -use Cache; use Test; -use vars qw($tests); +use NPTest; +use vars qw($tests); BEGIN {$tests = 6; plan tests => $tests} -my $null = ''; -my $cmd; -my $str; my $t; -$cmd = "./check_swap 100 100"; -$str = `$cmd`; -$t += ok $?>>8,0; -print "Test was: $cmd\n" if ($?); -$t += ok $str, '/^Swap ok - Swap used\: +[0-9]{1,2}\% \([0-9]+ bytes out of [0-9]+\)$/'; - -$cmd = "./check_swap 0 0"; -$str = `$cmd`; -$t += ok $?>>8,2; -print "Test was: $cmd\n" unless ($?); -$t += ok $str, '/^CRITICAL - Swap used\: +[0-9]{1,2}\% \([0-9]+ bytes out of [0-9]+\)$/'; +my $successOutput = '/^SWAP OK - [0-9]+\% free \([0-9]+ MB out of [0-9]+ MB\)/'; +my $failureOutput = '/^SWAP CRITICAL - [0-9]+\% free \([0-9]+ MB out of [0-9]+ MB\)/'; -$cmd = "./check_swap 100 100 1000000000 1000000000"; -$str = `$cmd`; -$t += ok $?>>8,2; -print "Test was: $cmd\n" unless ($?); -$t += ok $str, '/^CRITICAL - Swap used\: +[0-9]{1,2}\% \([0-9]+ bytes out of [0-9]+\)$/'; +$t += checkCmd( "./check_swap -w 1048576 -c 1048576", 0, $successOutput ); # 1MB free +$t += checkCmd( "./check_swap -w 1\% -c 1\%", 0, $successOutput ); # 1% free +$t += checkCmd( "./check_swap -w 100\% -c 100\%", 2, $failureOutput ); # 100% free (always fails) exit(0) if defined($Test::Harness::VERSION); 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 @@ -#! /usr/bin/perl -w +#! /usr/bin/perl -w -I .. +# +# TCP Connection Based Tests via check_tcp +# +# $Id$ +# -#use strict; -use Cache; +use strict; use Test; +use NPTest; + use vars qw($tests); +BEGIN {$tests = 5; plan tests => $tests} -BEGIN {$tests = 3; plan tests => $tests} +my $host_tcp_http = getTestParameter( "host_tcp_http", "NP_HOST_TCP_HTTP", "localhost", + "A host providing the HTTP Service (a web server)" ); -my $null = ''; -my $cmd; -my $str; -my $t; +my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1", + "The hostname of system not responsive to network requests" ); + +my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost", + "An invalid (not known to DNS) hostname" ); -$cmd = "./check_tcp $Cache::hostname -p 80 -wt 300 -ct 600"; -$str = `$cmd`; -$t += ok $?>>8,0; -print "$cmd\n" if ($?); -$t += ok $str, '/^TCP OK\s-\s+[0-9]?\.?[0-9]+ second response time on port 80/'; +my $successOutput = '/^TCP OK\s-\s+[0-9]?\.?[0-9]+ second response time on port [0-9]+/'; + +my $t; -$cmd = "./check_tcp $Cache::nullhost -p 81 -wt 0 -ct 0 -to 1"; -$str = `$cmd`; -$t += ok $?>>8,2; -print "$cmd\n" unless ($?); +$t += checkCmd( "./check_tcp $host_tcp_http -p 80 -wt 300 -ct 600", 0, $successOutput ); +$t += checkCmd( "./check_tcp $host_tcp_http -p 81 -wt 0 -ct 0 -to 1", 2 ); # use invalid port for this test +$t += checkCmd( "./check_tcp $host_nonresponsive -p 80 -wt 0 -ct 0 -to 1", 2 ); +$t += checkCmd( "./check_tcp $hostname_invalid -p 80 -wt 0 -ct 0 -to 1", 2 ); exit(0) if defined($Test::Harness::VERSION); 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 @@ -#! /usr/bin/perl -w +#! /usr/bin/perl -w -I .. +# +# System Time Tests via check_time +# +# $Id$ +# use strict; -use Cache; -use Helper; use Test; +use NPTest; + use vars qw($tests); +BEGIN {$tests = 8; plan tests => $tests} -BEGIN {$tests = 6; plan tests => $tests} +my $host_udp_time = getTestParameter( "host_udp_time", "NP_HOST_UDP_TIME", "localhost", + "A host providing the UDP Time Service" ); -my $null = ''; -my $cmd; -my $str; -my $t; -my $udp_hostname=get_option("udp_hostname","UDP host name"); +my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1", + "The hostname of system not responsive to network requests" ); -# standard mode +my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost", + "An invalid (not known to DNS) hostname" ); -$cmd = "./check_time -H $udp_hostname -w 999999,59 -c 999999,59 -t 60"; -$str = `$cmd`; -$t += ok $?>>8,0; -print "Test was: $cmd\n" if ($?); -$t += ok $str, '/^TIME OK - [0-9]+ second time difference$/'; +my $successOutput = '/^TIME OK - [0-9]+ second time difference/'; -$cmd = "./check_time -H $udp_hostname -w 999999 -W 59 -c 999999 -C 59 -t 60"; -$str = `$cmd`; -$t += ok $?>>8,0; -print "Test was: $cmd\n" if ($?); -$t += ok $str, '/^TIME OK - [0-9]+ second time difference$/'; +my $t; -# reverse compatibility mode +# standard mode +$t += checkCmd( "./check_time -H $host_udp_time -w 999999,59 -c 999999,59 -t 60", 0, $successOutput ); +$t += checkCmd( "./check_time -H $host_udp_time -w 999999 -W 59 -c 999999 -C 59 -t 60", 0, $successOutput ); -$cmd = "./check_time $udp_hostname -wt 59 -ct 59 -cd 999999 -wd 999999 -to 60"; -$str = `$cmd`; -$t += ok $?>>8,0; -print "Test was: $cmd\n" if ($?); -$t += ok $str, '/^TIME OK - [0-9]+ second time difference$/'; +# reverse compatibility mode +$t += checkCmd( "./check_time $host_udp_time -wt 59 -ct 59 -cd 999999 -wd 999999 -to 60", 0, $successOutput ); # failure mode - -#$cmd = "./check_time -H $Cache::nullhost -t 1"; -#$str = `$cmd`; -#$t += ok $?>>8,255; -#print "Test was: $cmd\n" unless ($?); - -#$cmd = "./check_time -H $Cache::noserver -t 1"; -#$str = `$cmd`; -#$t += ok $?>>8,255; -#print "$cmd\n" unless ($?); +$t += checkCmd( "./check_time -H $host_nonresponsive -t 1", 2 ); +$t += checkCmd( "./check_time -H $hostname_invalid -t 1", 3 ); exit(0) if defined($Test::Harness::VERSION); 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 @@ -#! /usr/bin/perl -w +#! /usr/bin/perl -w -I .. +# +# UDP Connection Based Tests via check_udp +# +# $Id$ +# -#use strict; -use Cache; -use Helper; +use strict; use Test; +use NPTest; + use vars qw($tests); +BEGIN {$tests = 3; plan tests => $tests} #TODO# Update to 4 when the commented out test is fixed -BEGIN {$tests = 3; plan tests => $tests} +my $host_udp_time = getTestParameter( "host_udp_time", "NP_HOST_UDP_TIME", "localhost", + "A host providing the UDP Time Service" ); -my $null = ''; -my $str; -my $t; -my $hostname=get_option("udp_hostname","UDP host name"); +my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1", + "The hostname of system not responsive to network requests" ); + +my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost", + "An invalid (not known to DNS) hostname" ); -$str = `./check_udp $hostname -p 37 -wt 300 -ct 600`; -$t += ok $?>>8,0; -$t += ok $str, '/^Connection accepted on port 37 - [0-9]+ second response time$/'; +my $successOutput = '/^Connection accepted on port [0-9]+ - [0-9]+ second response time$/'; + +my $t; -$str = `./check_udp $Cache::nullhost -p 80 -wt 0 -ct 0 -to 1`; -$t += ok $?>>8,2; +$t += checkCmd( "./check_udp -H $host_udp_time -p 37 -wt 300 -ct 600", 0, $successOutput ); +$t += checkCmd( "./check_udp $host_nonresponsive -p 37 -wt 0 -ct 0 -to 1", 2 ); +#TODO# $t += checkCmd( "./check_udp $hostname_invalid -p 37 -wt 0 -ct 0 -to 1", 2 ); # Currently returns 0 (ie success) exit(0) if defined($Test::Harness::VERSION); 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 @@ -#! /usr/bin/perl -w +#! /usr/bin/perl -w -I .. +# +# Logged in Users Tests via check_users +# +# $Id$ +# use strict; -use Cache; use Test; -use vars qw($tests); +use NPTest; +use vars qw($tests); BEGIN {$tests = 4; plan tests => $tests} -my $null = ''; -my $cmd; -my $str; -my $t; +my $successOutput = '/^USERS OK - [0-9]+ users currently logged in/'; +my $failureOutput = '/^USERS CRITICAL - [0-9]+ users currently logged in/'; -$cmd = "./check_users 1000 1000"; -$str = `$cmd`; -$t += ok $?>>8,0; -print "Test was: $cmd\n" if ($?); -$t += ok $str, '/^USERS OK - +[0-9]+ users currently logged in$/'; +my $t; -$cmd = "./check_users 0 0"; -$str = `$cmd`; -$t += ok $?>>8,2; -print "Test was: $cmd\n" unless ($?); -$t += ok $str, '/^USERS CRITICAL - [0-9]+ +users currently logged in$/'; +$t += checkCmd( "./check_users 1000 1000", 0, $successOutput ); +$t += checkCmd( "./check_users 0 0", 2, $failureOutput ); exit(0) if defined($Test::Harness::VERSION); exit($tests - $t); + 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 @@ -#! /usr/bin/perl -w - -use strict; -use Cache; -use Test; -use vars qw($tests); - -BEGIN {$tests = 4; plan tests => $tests} - -my $null = ''; -my $cmd; -my $str; -my $t; - -$cmd = "./check_vsz 100000 1000000 init"; -$str = `$cmd`; -$t += ok $?>>8,0; -print "Test was: $cmd\n" if ($?); -$t += ok $str, '/^ok \(all VSZ\<[0-9]+\)/'; - -$cmd = "./check_vsz 0 0"; -$str = `$cmd`; -$t += ok $?>>8,2; -print "Test was: $cmd\n" unless ($?); -$t += ok $str, '/^CRITICAL \(VSZ\>[0-9]+\)/'; - -exit(0) if defined($Test::Harness::VERSION); -exit($tests - $t); |