[Nagiosplug-checkins] nagiosplug/plugins/t check_disk.t,1.1.1.1,1.2 check_dns.t,1.2,1.3 check_fping.t,1.1.1.1,1.2 check_ftp.t,1.2,1.3 check_hpjd.t,1.1.1.1,1.2 check_http.t,1.3,1.4 check_imap.t,1.1.1.1,1.2 check_load.t,1.3,1.4 check_mysql.t,1.2,1.3 check_ping.t,1.1.1.1,1.2 check_pop.t,1.1.1.1,1.2 check_procs.t,1.2,1.3 check_smtp.t,1.1.1.1,1.2 check_snmp.t,1.1.1.1,1.2 check_swap.t,1.1.1.1,1.2 check_tcp.t,1.2,1.3 check_time.t,1.1.1.1,1.2 check_udp.t,1.1.1.1,1.2 check_users.t,1.1.1.1,1.2 check_vsz.t,1.1.1.1,NONE

Peter Bray illumino at users.sourceforge.net
Sun Jul 24 18:48:24 CEST 2005


Update of /cvsroot/nagiosplug/nagiosplug/plugins/t
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17473/plugins/t

Modified Files:
	check_disk.t check_dns.t check_fping.t check_ftp.t 
	check_hpjd.t check_http.t check_imap.t check_load.t 
	check_mysql.t check_ping.t check_pop.t check_procs.t 
	check_smtp.t check_snmp.t check_swap.t check_tcp.t 
	check_time.t check_udp.t check_users.t 
Removed Files:
	check_vsz.t 
Log Message:
[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.


Index: check_fping.t
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/t/check_fping.t,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- check_fping.t	28 Feb 2002 06:43:00 -0000	1.1.1.1
+++ check_fping.t	25 Jul 2005 01:47:14 -0000	1.2
@@ -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);

Index: check_udp.t
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/t/check_udp.t,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- check_udp.t	28 Feb 2002 06:43:00 -0000	1.1.1.1
+++ check_udp.t	25 Jul 2005 01:47:15 -0000	1.2
@@ -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" );
 
-$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 $hostname_invalid   = getTestParameter( "hostname_invalid",   "NP_HOSTNAME_INVALID",   "nosuchhost",
+                                           "An invalid (not known to DNS) hostname" );
 
-$str = `./check_udp $Cache::nullhost -p 80 -wt 0 -ct 0 -to 1`;
-$t += ok $?>>8,2;
+my $successOutput = '/^Connection accepted on port [0-9]+ - [0-9]+ second response time$/';
+
+my $t;
+
+$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);

Index: check_imap.t
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/t/check_imap.t,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- check_imap.t	28 Feb 2002 06:43:00 -0000	1.1.1.1
+++ check_imap.t	25 Jul 2005 01:47:14 -0000	1.2
@@ -1,34 +1,39 @@
-#! /usr/bin/perl -w
+#! /usr/bin/perl -w -I ..
+#
+# Internet Mail Access Protocol (IMAP) Server Tests via check_imap
+#
+# $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_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);
-

Index: check_smtp.t
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/t/check_smtp.t,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- check_smtp.t	28 Feb 2002 06:43:00 -0000	1.1.1.1
+++ check_smtp.t	25 Jul 2005 01:47:15 -0000	1.2
@@ -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);

Index: check_time.t
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/t/check_time.t,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- check_time.t	28 Feb 2002 06:43:00 -0000	1.1.1.1
+++ check_time.t	25 Jul 2005 01:47:15 -0000	1.2
@@ -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);

Index: check_procs.t
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/t/check_procs.t,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- check_procs.t	17 May 2003 17:50:40 -0000	1.2
+++ check_procs.t	25 Jul 2005 01:47:15 -0000	1.3
@@ -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);

Index: check_swap.t
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/t/check_swap.t,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- check_swap.t	28 Feb 2002 06:43:00 -0000	1.1.1.1
+++ check_swap.t	25 Jul 2005 01:47:15 -0000	1.2
@@ -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);

Index: check_dns.t
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/t/check_dns.t,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- check_dns.t	25 Nov 2004 05:06:25 -0000	1.2
+++ check_dns.t	25 Jul 2005 01:47:14 -0000	1.3
@@ -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}
 
-BEGIN {$tests = 3; plan tests => $tests}
+my $successOutput = '/DNS OK: [\.0-9]+ seconds response time/';
 
-#`nslookup localhost > /dev/null 2>&1` || exit(77);
+my $hostname_valid   = getTestParameter( "hostname_valid",   "NP_HOSTNAME_VALID",   "localhost",
+					 "A valid (known to DNS) hostname" );
+
+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);
+

Index: check_snmp.t
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/t/check_snmp.t,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- check_snmp.t	28 Feb 2002 06:43:00 -0000	1.1.1.1
+++ check_snmp.t	25 Jul 2005 01:47:15 -0000	1.2
@@ -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");
+if ( -x "./check_snmp" )
+{
+  my $host_snmp          = getTestParameter( "host_snmp",          "NP_HOST_SNMP",      "localhost",
+					     "A host providing an SNMP Service");
 
-$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+/';
+  my $snmp_community     = getTestParameter( "snmp_community",     "NP_SNMP_COMMUNITY", "public",
+					     "The SNMP Community string for SNMP Testing" );
 
-$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*$/';
+  my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1",
+					     "The hostname of system not responsive to network requests" );
 
-$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*$/';
+  my $hostname_invalid   = getTestParameter( "hostname_invalid",   "NP_HOSTNAME_INVALID",   "nosuchhost",
+					     "An invalid (not known to DNS) hostname" );
 
-$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*$/';
+  my %exceptions = ( 3 => "No SNMP Server present?" );
 
-#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)'
+
+  $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);

Index: check_ping.t
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/t/check_ping.t,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- check_ping.t	28 Feb 2002 06:43:00 -0000	1.1.1.1
+++ check_ping.t	25 Jul 2005 01:47:14 -0000	1.2
@@ -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 $null = '';
-my $cmd;
-my $str;
-my $t;
+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/';
 
-$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/';
+my $host_responsive    = getTestParameter( "host_responsive",   "NP_HOST_RESPONSIVE",     "localhost",
+					   "The hostname of system responsive to network requests" );
 
-$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/';
+my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1",
+					   "The hostname of system not responsive to network requests" );
 
-$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 ($?);
+my $hostname_invalid   = getTestParameter( "hostname_invalid",   "NP_HOSTNAME_INVALID",   "nosuchhost",
+                                           "An invalid (not known to DNS) hostname" );
+
+my $t;
+
+$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);

Index: check_users.t
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/t/check_users.t,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- check_users.t	28 Feb 2002 06:43:00 -0000	1.1.1.1
+++ check_users.t	25 Jul 2005 01:47:15 -0000	1.2
@@ -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);
+

Index: check_ftp.t
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/t/check_ftp.t,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- check_ftp.t	17 May 2003 23:10:02 -0000	1.2
+++ check_ftp.t	25 Jul 2005 01:47:14 -0000	1.3
@@ -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);
+

Index: check_mysql.t
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/t/check_mysql.t,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- check_mysql.t	25 Nov 2004 05:06:25 -0000	1.2
+++ check_mysql.t	25 Jul 2005 01:47:14 -0000	1.3
@@ -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: /';
 
-$cmd = "./check_mysql -H $mysqlserver -P 3306";
-$str = `$cmd`;
-$t += ok $?>>8,2;
-$t += ok $str, '/Access denied for user: /';
+if ( -x "./check_mysql" )
+{
+  my $mysqlserver = getTestParameter( "mysql_server", "NP_MYSQL_SERVER", undef,
+				      "A MySQL Server");
+
+  $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);

Index: check_hpjd.t
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/t/check_hpjd.t,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- check_hpjd.t	28 Feb 2002 06:43:00 -0000	1.1.1.1
+++ check_hpjd.t	25 Jul 2005 01:47:14 -0000	1.2
@@ -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);
+

Index: check_disk.t
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/t/check_disk.t,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- check_disk.t	28 Feb 2002 06:43:00 -0000	1.1.1.1
+++ check_disk.t	25 Jul 2005 01:47:14 -0000	1.2
@@ -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}
 
-BEGIN {$tests = 6; plan tests => $tests}
+my $successOutput = '/^DISK OK - /';
+my $failureOutput = '/^DISK CRITICAL - /';
 
-my $null = '';
-my $cmd;
-my $str;
-my $t;
+my $mountpoint_valid   = getTestParameter( "mountpoint_valid",   "NP_MOUNTPOINT_VALID",   "/",
+					   "The path to a valid mountpoint" );
 
-$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 - )/';
+my $mountpoint_invalid = getTestParameter( "mountpoint_invalid", "NP_MOUNTPOINT_INVALID", "/missing",
+					   "The path to a invalid (non-existent) mountpoint" );
 
-$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 - )/';
+my $t;
 
-$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);

Index: check_tcp.t
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/t/check_tcp.t,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- check_tcp.t	17 May 2003 17:36:25 -0000	1.2
+++ check_tcp.t	25 Jul 2005 01:47:15 -0000	1.3
@@ -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" );
 
-$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 $hostname_invalid   = getTestParameter( "hostname_invalid",   "NP_HOSTNAME_INVALID",   "nosuchhost",
+                                           "An invalid (not known to DNS) hostname" );
 
-$cmd = "./check_tcp $Cache::nullhost -p 81 -wt 0 -ct 0 -to 1";
-$str = `$cmd`;
-$t += ok $?>>8,2;
-print "$cmd\n" unless ($?);
+my $successOutput = '/^TCP OK\s-\s+[0-9]?\.?[0-9]+ second response time on port [0-9]+/';
+
+my $t;
+
+$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);

Index: check_http.t
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/t/check_http.t,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- check_http.t	25 Nov 2004 05:06:25 -0000	1.3
+++ check_http.t	25 Jul 2005 01:47:14 -0000	1.4
@@ -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);
+

--- check_vsz.t DELETED ---

Index: check_load.t
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/t/check_load.t,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- check_load.t	25 Nov 2004 05:06:25 -0000	1.3
+++ check_load.t	25 Jul 2005 01:47:14 -0000	1.4
@@ -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);
+

Index: check_pop.t
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/t/check_pop.t,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- check_pop.t	28 Feb 2002 06:43:00 -0000	1.1.1.1
+++ check_pop.t	25 Jul 2005 01:47:14 -0000	1.2
@@ -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)");
 
-$cmd = "./check_pop $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_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 $hostname_invalid   = getTestParameter( "hostname_invalid",   "NP_HOSTNAME_INVALID",   "nosuchhost",
+                                           "An invalid (not known to DNS) hostname" );
 
-$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 ($?);
+my %exceptions = ( 2 => "No POP Server present?" );
+
+my $t;
+
+$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);





More information about the Commits mailing list