From 44a321cb8a42d6c0ea2d96a1086a17f2134c89cc Mon Sep 17 00:00:00 2001 From: Ethan Galstad Date: Thu, 28 Feb 2002 06:42:51 +0000 Subject: Initial revision git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@2 f882894a-f735-0410-b71e-b25c423dba1c --- plugins/t/check_disk.t | 31 +++++++++++++++++++++++++++++ plugins/t/check_dns.t | 29 +++++++++++++++++++++++++++ plugins/t/check_fping.t | 37 +++++++++++++++++++++++++++++++++++ plugins/t/check_ftp.t | 32 ++++++++++++++++++++++++++++++ plugins/t/check_hpjd.t | 32 ++++++++++++++++++++++++++++++ plugins/t/check_http.t | 22 +++++++++++++++++++++ plugins/t/check_imap.t | 34 ++++++++++++++++++++++++++++++++ plugins/t/check_load.t | 27 +++++++++++++++++++++++++ plugins/t/check_mysql.t | 23 ++++++++++++++++++++++ plugins/t/check_ping.t | 33 +++++++++++++++++++++++++++++++ plugins/t/check_pop.t | 31 +++++++++++++++++++++++++++++ plugins/t/check_procs.t | 51 ++++++++++++++++++++++++++++++++++++++++++++++++ plugins/t/check_smtp.t | 31 +++++++++++++++++++++++++++++ plugins/t/check_snmp.t | 52 +++++++++++++++++++++++++++++++++++++++++++++++++ plugins/t/check_swap.t | 34 ++++++++++++++++++++++++++++++++ plugins/t/check_tcp.t | 27 +++++++++++++++++++++++++ plugins/t/check_time.t | 52 +++++++++++++++++++++++++++++++++++++++++++++++++ plugins/t/check_udp.t | 24 +++++++++++++++++++++++ plugins/t/check_users.t | 28 ++++++++++++++++++++++++++ plugins/t/check_vsz.t | 28 ++++++++++++++++++++++++++ 20 files changed, 658 insertions(+) create mode 100644 plugins/t/check_disk.t create mode 100644 plugins/t/check_dns.t create mode 100644 plugins/t/check_fping.t create mode 100644 plugins/t/check_ftp.t create mode 100644 plugins/t/check_hpjd.t create mode 100644 plugins/t/check_http.t create mode 100644 plugins/t/check_imap.t create mode 100644 plugins/t/check_load.t create mode 100644 plugins/t/check_mysql.t create mode 100644 plugins/t/check_ping.t create mode 100644 plugins/t/check_pop.t create mode 100644 plugins/t/check_procs.t create mode 100644 plugins/t/check_smtp.t create mode 100644 plugins/t/check_snmp.t create mode 100644 plugins/t/check_swap.t create mode 100644 plugins/t/check_tcp.t create mode 100644 plugins/t/check_time.t create mode 100644 plugins/t/check_udp.t create mode 100644 plugins/t/check_users.t create mode 100644 plugins/t/check_vsz.t (limited to 'plugins/t') diff --git a/plugins/t/check_disk.t b/plugins/t/check_disk.t new file mode 100644 index 00000000..f1e436dc --- /dev/null +++ b/plugins/t/check_disk.t @@ -0,0 +1,31 @@ +use strict; +use Test; +use vars qw($tests); + +BEGIN {$tests = 6; plan tests => $tests} + +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 - )/'; + +exit(0) if defined($Test::Harness::VERSION); +exit($tests - $t); diff --git a/plugins/t/check_dns.t b/plugins/t/check_dns.t new file mode 100644 index 00000000..a85e2e76 --- /dev/null +++ b/plugins/t/check_dns.t @@ -0,0 +1,29 @@ +#! /usr/bin/perl -w + +use strict; +use Cache; +use Test; +use vars qw($tests); + +BEGIN {$tests = 3; plan tests => $tests} + +#`nslookup localhost > /dev/null 2>&1` || exit(77); + +my $null = ''; +my $cmd; +my $str; +my $t; + +$cmd = "./check_dns 127.0.0.1 -to 5"; +$str = `$cmd`; +$t += ok $?>>8,0; +print "Test was: $cmd\n" if ($?); +$t += ok $str, '/DNS ok - +[\.0-9]+ seconds response time, Address\(es\) is\/are /'; + +$cmd = "./check_dns $Cache::nullhost -to 1"; +$str = `$cmd`; +$t += ok $?>>8,2; +print "Test was: $cmd\n" unless ($?); + +exit(0) if defined($Test::Harness::VERSION); +exit($tests - $t); diff --git a/plugins/t/check_fping.t b/plugins/t/check_fping.t new file mode 100644 index 00000000..629ee35f --- /dev/null +++ b/plugins/t/check_fping.t @@ -0,0 +1,37 @@ +#! /usr/bin/perl -w +# $Id$ + +use strict; +use Cache; +use Test; +use vars qw($tests); + +BEGIN {$tests = 3; plan tests => $tests} + +exit(0) unless (-x "./check_fping"); + +#`fping 127.0.0.1 > /dev/null 2>&1` || exit(77); + +my $null = ''; +my $cmd; +my $str; +my $t; +my $stat; + + +$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; +} +$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 new file mode 100644 index 00000000..c3f74d92 --- /dev/null +++ b/plugins/t/check_ftp.t @@ -0,0 +1,32 @@ +#! /usr/bin/perl -w + +#use strict; +use Cache; +use Test; +use vars qw($tests); + +BEGIN {$tests = 3; plan tests => $tests} + +my $null = ''; +my $cmd; +my $str; +my $t; + +$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 - [0-9]+ second response time/'; + +#$cmd = "./check_ftp $Cache::noserver -wt 0 -ct 0"; +#$str = `$cmd`; +#$t += ok $?>>8,2; +#print "Test was: $cmd\n" unless ($?); + +$cmd = "./check_ftp $Cache::nullhost -wt 0 -ct 0 -to 1"; +$str = `$cmd`; +$t += ok $?>>8,2; +print "Test was: $cmd\n" unless ($?); + +exit(0) if defined($Test::Harness::VERSION); +exit($tests - $t); diff --git a/plugins/t/check_hpjd.t b/plugins/t/check_hpjd.t new file mode 100644 index 00000000..b4e198d2 --- /dev/null +++ b/plugins/t/check_hpjd.t @@ -0,0 +1,32 @@ +#! /usr/bin/perl -w + +use strict; +use Helper; +use Cache; +use Test; +use vars qw($tests); + +BEGIN {$tests = 4; plan tests => $tests} + +exit(0) unless (-x "./check_hpjd"); + +my $null = ''; +my $cmd; +my $str; +my $t; +my $printer = get_option("hpjd_printer","HP Jet-Direct card address"); + +$cmd = "./check_hpjd $printer"; +$str = `$cmd`; +$t += ok $?>>8,0; +print "Test was: $cmd\n" if ($?); +$t += ok $str, '/^Printer ok - /'; + +$cmd = "./check_hpjd $Cache::noserver"; +$str = `$cmd`; +$t += ok $?>>8,2; +print "Test was: $cmd\n" unless ($?); +$t += ok $str, '/Timeout: No response from /'; + +exit(0) if defined($Test::Harness::VERSION); +exit($tests - $t); diff --git a/plugins/t/check_http.t b/plugins/t/check_http.t new file mode 100644 index 00000000..2782fcd5 --- /dev/null +++ b/plugins/t/check_http.t @@ -0,0 +1,22 @@ +#! /usr/bin/perl -w + +use strict; +use Cache; +use Test; +use vars qw($tests); + +BEGIN {$tests = 3; plan tests => $tests} + +my $null = ''; +my $str; +my $t; + +$str = `./check_http $Cache::hostname -wt 300 -ct 600`; +$t += ok $?>>8,0; +$t += ok $str, '/HTTP\/1.1 [0-9]{3} (OK|Found) - [0-9]+ second response time/'; + +$str = `./check_http $Cache::nullhost -wt 1 -ct 2`; +$t += ok $?>>8,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 new file mode 100644 index 00000000..47494e59 --- /dev/null +++ b/plugins/t/check_imap.t @@ -0,0 +1,34 @@ +#! /usr/bin/perl -w + +#use strict; +use Cache; +use Test; +use vars qw($tests); + +BEGIN {$tests = 3; plan tests => $tests} + +my $null = ''; +my $cmd; +my $str; +my $t; + +$cmd = "./check_imap $Cache::mailhost"; +$str = `$cmd`; +$t += ok $?>>8,0; +print "Test was: $cmd\n" if ($?); + +$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 ($?); + + +# 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 new file mode 100644 index 00000000..ac14620f --- /dev/null +++ b/plugins/t/check_load.t @@ -0,0 +1,27 @@ +#! /usr/bin/perl -w + +use strict; +use Test; +use vars qw($tests); + +BEGIN {$tests = 4; plan tests => $tests} + +my $null = ''; +my $cmd; +my $str; +my $t; + +$cmd = "./check_load 100 100 100 100 100 100"; +$str = `$cmd`; +$t += ok $?>>8,0; +print "Test was: $cmd\n" if ($?); +$t += ok $str, '/^load average: +[\.0-9]+, +[\.0-9]+, +[\.0-9]+$/'; + +$cmd = "./check_load 0 0 0 0 0 0"; +$str = `$cmd`; +$t += ok $?>>8,2; +print "Test was: $cmd\n" unless ($?); +$t += ok $str, '/^load average: +[\.0-9]+, +[\.0-9]+, +[\.0-9]+ CRITICAL$/'; + +exit(0) if defined($Test::Harness::VERSION); +exit($tests - $t); diff --git a/plugins/t/check_mysql.t b/plugins/t/check_mysql.t new file mode 100644 index 00000000..ae2a0087 --- /dev/null +++ b/plugins/t/check_mysql.t @@ -0,0 +1,23 @@ +#! /usr/bin/perl -w + +use strict; +use Cache; +use Test; +use vars qw($tests); + +BEGIN {$tests = 1; plan tests => $tests} + +exit(0) unless (-x "./check_mysql"); + +my $null = ''; +my $cmd; +my $str; +my $t; + +$cmd = "./check_mysql -H 127.0.0.1 -P 3306"; +$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_ping.t b/plugins/t/check_ping.t new file mode 100644 index 00000000..97bc660e --- /dev/null +++ b/plugins/t/check_ping.t @@ -0,0 +1,33 @@ +#! /usr/bin/perl -w + +use strict; +use Cache; +use Test; +use vars qw($tests); + +BEGIN {$tests = 5; plan tests => $tests} + +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 ($?); + +exit(0) if defined($Test::Harness::VERSION); +exit($tests - $t); diff --git a/plugins/t/check_pop.t b/plugins/t/check_pop.t new file mode 100644 index 00000000..60b5a4ef --- /dev/null +++ b/plugins/t/check_pop.t @@ -0,0 +1,31 @@ +#! /usr/bin/perl -w + +#use strict; +use Cache; +use Test; +use vars qw($tests); + +BEGIN {$tests = 3; plan tests => $tests} + +my $null = ''; +my $cmd; +my $str; +my $t; + +$cmd = "./check_pop $Cache::mailhost"; +$str = `$cmd`; +$t += ok $?>>8,0; +print "Test was: $cmd\n" if ($?); + +$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 ($?); + +$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 ($?); + +exit(0) if defined($Test::Harness::VERSION); +exit($tests - $t); diff --git a/plugins/t/check_procs.t b/plugins/t/check_procs.t new file mode 100644 index 00000000..9c2330f9 --- /dev/null +++ b/plugins/t/check_procs.t @@ -0,0 +1,51 @@ +#! /usr/bin/perl -w + +use strict; +use Cache; +use Test; +use vars qw($tests); + +BEGIN {$tests = 10; plan tests => $tests} + +my $null = ''; +my $cmd; +my $str; +my $t; + +# Reverse Compatibility +$cmd = "./check_procs 100000 100000"; +$str = `$cmd`; +$t += ok $?>>8,0; +print "Test was: $cmd\n" if ($?); +$t += ok $str, '/^OK - [0-9]+ processes running$/'; + +# Reverse Compatibility +$cmd = "./check_procs 100000 100000 Z"; +$str = `$cmd`; +$t += ok $?>>8,0; +print "Test was: $cmd\n" if ($?); +$t += ok $str, '/^OK - [0-9]+ processes running with /'; + +# Reverse Compatibility +$cmd = "./check_procs 0 10000000"; +$str = `$cmd`; +$t += ok $?>>8,1; +print "Test was: $cmd\n" unless ($?); +$t += ok $str, '/^WARNING - [0-9]+ processes running$/'; + +# Reverse Compatibility +$cmd = "./check_procs 0 0"; +$str = `$cmd`; +$t += ok $?>>8,2; +print "Test was: $cmd\n" unless ($?); +$t += ok $str, '/^CRITICAL - [0-9]+ processes running$/'; + +# Reverse Compatibility +$cmd = "./check_procs 0 0 S"; +$str = `$cmd`; +$t += ok $?>>8,2; +print "Test was: $cmd\n" unless ($?); +$t += ok $str, '/^CRITICAL - [0-9]+ processes running 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 new file mode 100644 index 00000000..2a82b877 --- /dev/null +++ b/plugins/t/check_smtp.t @@ -0,0 +1,31 @@ +#! /usr/bin/perl -w + +#use strict; +use Cache; +use Test; +use vars qw($tests); + +BEGIN {$tests = 3; plan tests => $tests} + +my $null = ''; +my $cmd; +my $str; +my $t; + +$cmd = "./check_smtp $Cache::mailhost"; +$str = `$cmd`; +$t += ok $?>>8,0; +print "Test was: $cmd\n" if ($?); + +$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 ($?); + +$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 ($?); + +exit(0) if defined($Test::Harness::VERSION); +exit($tests - $t); diff --git a/plugins/t/check_snmp.t b/plugins/t/check_snmp.t new file mode 100644 index 00000000..162b0b9b --- /dev/null +++ b/plugins/t/check_snmp.t @@ -0,0 +1,52 @@ +#! /usr/bin/perl -w + +use strict; +use Helper; +use Cache; +use Test; +use vars qw($tests); + +BEGIN {$tests = 8; 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)' + +exit(0) if defined($Test::Harness::VERSION); +exit($tests - $t); diff --git a/plugins/t/check_swap.t b/plugins/t/check_swap.t new file mode 100644 index 00000000..5b702f00 --- /dev/null +++ b/plugins/t/check_swap.t @@ -0,0 +1,34 @@ +#! /usr/bin/perl -w + +use strict; +use Cache; +use Test; +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]+\)$/'; + +$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]+\)$/'; + +exit(0) if defined($Test::Harness::VERSION); +exit($tests - $t); diff --git a/plugins/t/check_tcp.t b/plugins/t/check_tcp.t new file mode 100644 index 00000000..1abec769 --- /dev/null +++ b/plugins/t/check_tcp.t @@ -0,0 +1,27 @@ +#! /usr/bin/perl -w + +#use strict; +use Cache; +use Test; +use vars qw($tests); + +BEGIN {$tests = 3; plan tests => $tests} + +my $null = ''; +my $cmd; +my $str; +my $t; + +$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 - [0-9]+ second response time on port 80/'; + +$cmd = "./check_tcp $Cache::nullhost -p 81 -wt 0 -ct 0 -to 1"; +$str = `$cmd`; +$t += ok $?>>8,2; +print "$cmd\n" unless ($?); + +exit(0) if defined($Test::Harness::VERSION); +exit($tests - $t); diff --git a/plugins/t/check_time.t b/plugins/t/check_time.t new file mode 100644 index 00000000..4d8c5c2b --- /dev/null +++ b/plugins/t/check_time.t @@ -0,0 +1,52 @@ +#! /usr/bin/perl -w + +use strict; +use Cache; +use Helper; +use Test; +use vars qw($tests); + +BEGIN {$tests = 6; plan tests => $tests} + +my $null = ''; +my $cmd; +my $str; +my $t; +my $udp_hostname=get_option("udp_hostname","UDP host name"); + +# standard mode + +$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$/'; + +$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$/'; + +# reverse compatibility mode + +$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$/'; + +# 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 ($?); + +exit(0) if defined($Test::Harness::VERSION); +exit($tests - $t); diff --git a/plugins/t/check_udp.t b/plugins/t/check_udp.t new file mode 100644 index 00000000..abbf5e49 --- /dev/null +++ b/plugins/t/check_udp.t @@ -0,0 +1,24 @@ +#! /usr/bin/perl -w + +#use strict; +use Cache; +use Helper; +use Test; +use vars qw($tests); + +BEGIN {$tests = 3; plan tests => $tests} + +my $null = ''; +my $str; +my $t; +my $hostname=get_option("udp_hostname","UDP host name"); + +$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$/'; + +$str = `./check_udp $Cache::nullhost -p 80 -wt 0 -ct 0 -to 1`; +$t += ok $?>>8,2; + +exit(0) if defined($Test::Harness::VERSION); +exit($tests - $t); diff --git a/plugins/t/check_users.t b/plugins/t/check_users.t new file mode 100644 index 00000000..593f1737 --- /dev/null +++ b/plugins/t/check_users.t @@ -0,0 +1,28 @@ +#! /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_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$/'; + +$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$/'; + +exit(0) if defined($Test::Harness::VERSION); +exit($tests - $t); diff --git a/plugins/t/check_vsz.t b/plugins/t/check_vsz.t new file mode 100644 index 00000000..95972619 --- /dev/null +++ b/plugins/t/check_vsz.t @@ -0,0 +1,28 @@ +#! /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); -- cgit v1.2.3-74-g34f1