diff options
author | Ethan Galstad <egalstad@users.sourceforge.net> | 2002-02-28 06:42:51 (GMT) |
---|---|---|
committer | Ethan Galstad <egalstad@users.sourceforge.net> | 2002-02-28 06:42:51 (GMT) |
commit | 44a321cb8a42d6c0ea2d96a1086a17f2134c89cc (patch) | |
tree | a1a4d9f7b92412a17ab08f34f04eec45433048b7 /plugins/t | |
parent | 54fd5d7022ff2d6a59bc52b8869182f3fc77a058 (diff) | |
download | monitoring-plugins-44a321cb8a42d6c0ea2d96a1086a17f2134c89cc.tar.gz |
Initial revision
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@2 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/t')
-rw-r--r-- | plugins/t/check_disk.t | 31 | ||||
-rw-r--r-- | plugins/t/check_dns.t | 29 | ||||
-rw-r--r-- | plugins/t/check_fping.t | 37 | ||||
-rw-r--r-- | plugins/t/check_ftp.t | 32 | ||||
-rw-r--r-- | plugins/t/check_hpjd.t | 32 | ||||
-rw-r--r-- | plugins/t/check_http.t | 22 | ||||
-rw-r--r-- | plugins/t/check_imap.t | 34 | ||||
-rw-r--r-- | plugins/t/check_load.t | 27 | ||||
-rw-r--r-- | plugins/t/check_mysql.t | 23 | ||||
-rw-r--r-- | plugins/t/check_ping.t | 33 | ||||
-rw-r--r-- | plugins/t/check_pop.t | 31 | ||||
-rw-r--r-- | plugins/t/check_procs.t | 51 | ||||
-rw-r--r-- | plugins/t/check_smtp.t | 31 | ||||
-rw-r--r-- | plugins/t/check_snmp.t | 52 | ||||
-rw-r--r-- | plugins/t/check_swap.t | 34 | ||||
-rw-r--r-- | plugins/t/check_tcp.t | 27 | ||||
-rw-r--r-- | plugins/t/check_time.t | 52 | ||||
-rw-r--r-- | plugins/t/check_udp.t | 24 | ||||
-rw-r--r-- | plugins/t/check_users.t | 28 | ||||
-rw-r--r-- | plugins/t/check_vsz.t | 28 |
20 files changed, 658 insertions, 0 deletions
diff --git a/plugins/t/check_disk.t b/plugins/t/check_disk.t new file mode 100644 index 0000000..f1e436d --- /dev/null +++ b/plugins/t/check_disk.t | |||
@@ -0,0 +1,31 @@ | |||
1 | use strict; | ||
2 | use Test; | ||
3 | use vars qw($tests); | ||
4 | |||
5 | BEGIN {$tests = 6; plan tests => $tests} | ||
6 | |||
7 | my $null = ''; | ||
8 | my $cmd; | ||
9 | my $str; | ||
10 | my $t; | ||
11 | |||
12 | $cmd = "./check_disk 100 100 /"; | ||
13 | $str = `$cmd`; | ||
14 | $t += ok $?>>8,0; | ||
15 | print "Test was: $cmd\n" if ($?); | ||
16 | $t += ok $str, '/^(Disk ok - +[\.0-9]+|DISK OK - )/'; | ||
17 | |||
18 | $cmd = "./check_disk -w 0 -c 0 /"; | ||
19 | $str = `$cmd`; | ||
20 | $t += ok $?>>8,0; | ||
21 | print "Test was: $cmd\n" if ($?); | ||
22 | $t += ok $str, '/^(Disk ok - +[\.0-9]+|DISK OK - )/'; | ||
23 | |||
24 | $cmd = "./check_disk 0 0 /"; | ||
25 | $str = `$cmd`; | ||
26 | $t += ok $?>>8,2; | ||
27 | print "Test was: $cmd\n" unless ($?); | ||
28 | $t += ok $str, '/^(Only +[\.0-9]+|DISK CRITICAL - )/'; | ||
29 | |||
30 | exit(0) if defined($Test::Harness::VERSION); | ||
31 | exit($tests - $t); | ||
diff --git a/plugins/t/check_dns.t b/plugins/t/check_dns.t new file mode 100644 index 0000000..a85e2e7 --- /dev/null +++ b/plugins/t/check_dns.t | |||
@@ -0,0 +1,29 @@ | |||
1 | #! /usr/bin/perl -w | ||
2 | |||
3 | use strict; | ||
4 | use Cache; | ||
5 | use Test; | ||
6 | use vars qw($tests); | ||
7 | |||
8 | BEGIN {$tests = 3; plan tests => $tests} | ||
9 | |||
10 | #`nslookup localhost > /dev/null 2>&1` || exit(77); | ||
11 | |||
12 | my $null = ''; | ||
13 | my $cmd; | ||
14 | my $str; | ||
15 | my $t; | ||
16 | |||
17 | $cmd = "./check_dns 127.0.0.1 -to 5"; | ||
18 | $str = `$cmd`; | ||
19 | $t += ok $?>>8,0; | ||
20 | print "Test was: $cmd\n" if ($?); | ||
21 | $t += ok $str, '/DNS ok - +[\.0-9]+ seconds response time, Address\(es\) is\/are /'; | ||
22 | |||
23 | $cmd = "./check_dns $Cache::nullhost -to 1"; | ||
24 | $str = `$cmd`; | ||
25 | $t += ok $?>>8,2; | ||
26 | print "Test was: $cmd\n" unless ($?); | ||
27 | |||
28 | exit(0) if defined($Test::Harness::VERSION); | ||
29 | exit($tests - $t); | ||
diff --git a/plugins/t/check_fping.t b/plugins/t/check_fping.t new file mode 100644 index 0000000..629ee35 --- /dev/null +++ b/plugins/t/check_fping.t | |||
@@ -0,0 +1,37 @@ | |||
1 | #! /usr/bin/perl -w | ||
2 | # $Id$ | ||
3 | |||
4 | use strict; | ||
5 | use Cache; | ||
6 | use Test; | ||
7 | use vars qw($tests); | ||
8 | |||
9 | BEGIN {$tests = 3; plan tests => $tests} | ||
10 | |||
11 | exit(0) unless (-x "./check_fping"); | ||
12 | |||
13 | #`fping 127.0.0.1 > /dev/null 2>&1` || exit(77); | ||
14 | |||
15 | my $null = ''; | ||
16 | my $cmd; | ||
17 | my $str; | ||
18 | my $t; | ||
19 | my $stat; | ||
20 | |||
21 | |||
22 | $cmd = "./check_fping 127.0.0.1"; | ||
23 | $str = `$cmd`; | ||
24 | $t += ok $?>>8,0; | ||
25 | print "Test was: $cmd\n" if ($?); | ||
26 | $t += ok $str, '/^FPING OK - 127.0.0.1/'; | ||
27 | |||
28 | $cmd = "./check_fping $Cache::nullhost"; | ||
29 | $str = `$cmd`; | ||
30 | if ($?>>8 == 1 or $?>>8 == 2) { | ||
31 | $stat = 2; | ||
32 | } | ||
33 | $t += ok $stat,2; | ||
34 | print "Test was: $cmd\n" if (($?>>8) < 1); | ||
35 | |||
36 | exit(0) if defined($Test::Harness::VERSION); | ||
37 | exit($tests - $t); | ||
diff --git a/plugins/t/check_ftp.t b/plugins/t/check_ftp.t new file mode 100644 index 0000000..c3f74d9 --- /dev/null +++ b/plugins/t/check_ftp.t | |||
@@ -0,0 +1,32 @@ | |||
1 | #! /usr/bin/perl -w | ||
2 | |||
3 | #use strict; | ||
4 | use Cache; | ||
5 | use Test; | ||
6 | use vars qw($tests); | ||
7 | |||
8 | BEGIN {$tests = 3; plan tests => $tests} | ||
9 | |||
10 | my $null = ''; | ||
11 | my $cmd; | ||
12 | my $str; | ||
13 | my $t; | ||
14 | |||
15 | $cmd = "./check_ftp $Cache::hostname -wt 300 -ct 600"; | ||
16 | $str = `$cmd`; | ||
17 | $t += ok $?>>8,0; | ||
18 | print "Test was: $cmd\n" if ($?); | ||
19 | $t += ok $str, '/FTP ok - [0-9]+ second response time/'; | ||
20 | |||
21 | #$cmd = "./check_ftp $Cache::noserver -wt 0 -ct 0"; | ||
22 | #$str = `$cmd`; | ||
23 | #$t += ok $?>>8,2; | ||
24 | #print "Test was: $cmd\n" unless ($?); | ||
25 | |||
26 | $cmd = "./check_ftp $Cache::nullhost -wt 0 -ct 0 -to 1"; | ||
27 | $str = `$cmd`; | ||
28 | $t += ok $?>>8,2; | ||
29 | print "Test was: $cmd\n" unless ($?); | ||
30 | |||
31 | exit(0) if defined($Test::Harness::VERSION); | ||
32 | exit($tests - $t); | ||
diff --git a/plugins/t/check_hpjd.t b/plugins/t/check_hpjd.t new file mode 100644 index 0000000..b4e198d --- /dev/null +++ b/plugins/t/check_hpjd.t | |||
@@ -0,0 +1,32 @@ | |||
1 | #! /usr/bin/perl -w | ||
2 | |||
3 | use strict; | ||
4 | use Helper; | ||
5 | use Cache; | ||
6 | use Test; | ||
7 | use vars qw($tests); | ||
8 | |||
9 | BEGIN {$tests = 4; plan tests => $tests} | ||
10 | |||
11 | exit(0) unless (-x "./check_hpjd"); | ||
12 | |||
13 | my $null = ''; | ||
14 | my $cmd; | ||
15 | my $str; | ||
16 | my $t; | ||
17 | my $printer = get_option("hpjd_printer","HP Jet-Direct card address"); | ||
18 | |||
19 | $cmd = "./check_hpjd $printer"; | ||
20 | $str = `$cmd`; | ||
21 | $t += ok $?>>8,0; | ||
22 | print "Test was: $cmd\n" if ($?); | ||
23 | $t += ok $str, '/^Printer ok - /'; | ||
24 | |||
25 | $cmd = "./check_hpjd $Cache::noserver"; | ||
26 | $str = `$cmd`; | ||
27 | $t += ok $?>>8,2; | ||
28 | print "Test was: $cmd\n" unless ($?); | ||
29 | $t += ok $str, '/Timeout: No response from /'; | ||
30 | |||
31 | exit(0) if defined($Test::Harness::VERSION); | ||
32 | exit($tests - $t); | ||
diff --git a/plugins/t/check_http.t b/plugins/t/check_http.t new file mode 100644 index 0000000..2782fcd --- /dev/null +++ b/plugins/t/check_http.t | |||
@@ -0,0 +1,22 @@ | |||
1 | #! /usr/bin/perl -w | ||
2 | |||
3 | use strict; | ||
4 | use Cache; | ||
5 | use Test; | ||
6 | use vars qw($tests); | ||
7 | |||
8 | BEGIN {$tests = 3; plan tests => $tests} | ||
9 | |||
10 | my $null = ''; | ||
11 | my $str; | ||
12 | my $t; | ||
13 | |||
14 | $str = `./check_http $Cache::hostname -wt 300 -ct 600`; | ||
15 | $t += ok $?>>8,0; | ||
16 | $t += ok $str, '/HTTP\/1.1 [0-9]{3} (OK|Found) - [0-9]+ second response time/'; | ||
17 | |||
18 | $str = `./check_http $Cache::nullhost -wt 1 -ct 2`; | ||
19 | $t += ok $?>>8,2; | ||
20 | |||
21 | exit(0) if defined($Test::Harness::VERSION); | ||
22 | exit($tests - $t); | ||
diff --git a/plugins/t/check_imap.t b/plugins/t/check_imap.t new file mode 100644 index 0000000..47494e5 --- /dev/null +++ b/plugins/t/check_imap.t | |||
@@ -0,0 +1,34 @@ | |||
1 | #! /usr/bin/perl -w | ||
2 | |||
3 | #use strict; | ||
4 | use Cache; | ||
5 | use Test; | ||
6 | use vars qw($tests); | ||
7 | |||
8 | BEGIN {$tests = 3; plan tests => $tests} | ||
9 | |||
10 | my $null = ''; | ||
11 | my $cmd; | ||
12 | my $str; | ||
13 | my $t; | ||
14 | |||
15 | $cmd = "./check_imap $Cache::mailhost"; | ||
16 | $str = `$cmd`; | ||
17 | $t += ok $?>>8,0; | ||
18 | print "Test was: $cmd\n" if ($?); | ||
19 | |||
20 | $cmd = "./check_imap -H $Cache::mailhost -p 143 -w 9 -c 9 -t 10 -e '* OK'"; | ||
21 | $str = `$cmd`; | ||
22 | $t += ok $?>>8,0; | ||
23 | print "Test was: $cmd\n" if ($?); | ||
24 | |||
25 | |||
26 | # Reverse compatibility | ||
27 | $cmd = "./check_imap $Cache::mailhost -p 143 -wt 9 -ct 9 -to 10 -e '* OK'"; | ||
28 | $str = `$cmd`; | ||
29 | $t += ok $?>>8,0; | ||
30 | print "Test was: $cmd\n" if ($?); | ||
31 | |||
32 | exit(0) if defined($Test::Harness::VERSION); | ||
33 | exit($tests - $t); | ||
34 | |||
diff --git a/plugins/t/check_load.t b/plugins/t/check_load.t new file mode 100644 index 0000000..ac14620 --- /dev/null +++ b/plugins/t/check_load.t | |||
@@ -0,0 +1,27 @@ | |||
1 | #! /usr/bin/perl -w | ||
2 | |||
3 | use strict; | ||
4 | use Test; | ||
5 | use vars qw($tests); | ||
6 | |||
7 | BEGIN {$tests = 4; plan tests => $tests} | ||
8 | |||
9 | my $null = ''; | ||
10 | my $cmd; | ||
11 | my $str; | ||
12 | my $t; | ||
13 | |||
14 | $cmd = "./check_load 100 100 100 100 100 100"; | ||
15 | $str = `$cmd`; | ||
16 | $t += ok $?>>8,0; | ||
17 | print "Test was: $cmd\n" if ($?); | ||
18 | $t += ok $str, '/^load average: +[\.0-9]+, +[\.0-9]+, +[\.0-9]+$/'; | ||
19 | |||
20 | $cmd = "./check_load 0 0 0 0 0 0"; | ||
21 | $str = `$cmd`; | ||
22 | $t += ok $?>>8,2; | ||
23 | print "Test was: $cmd\n" unless ($?); | ||
24 | $t += ok $str, '/^load average: +[\.0-9]+, +[\.0-9]+, +[\.0-9]+ CRITICAL$/'; | ||
25 | |||
26 | exit(0) if defined($Test::Harness::VERSION); | ||
27 | exit($tests - $t); | ||
diff --git a/plugins/t/check_mysql.t b/plugins/t/check_mysql.t new file mode 100644 index 0000000..ae2a008 --- /dev/null +++ b/plugins/t/check_mysql.t | |||
@@ -0,0 +1,23 @@ | |||
1 | #! /usr/bin/perl -w | ||
2 | |||
3 | use strict; | ||
4 | use Cache; | ||
5 | use Test; | ||
6 | use vars qw($tests); | ||
7 | |||
8 | BEGIN {$tests = 1; plan tests => $tests} | ||
9 | |||
10 | exit(0) unless (-x "./check_mysql"); | ||
11 | |||
12 | my $null = ''; | ||
13 | my $cmd; | ||
14 | my $str; | ||
15 | my $t; | ||
16 | |||
17 | $cmd = "./check_mysql -H 127.0.0.1 -P 3306"; | ||
18 | $str = `$cmd`; | ||
19 | $t += ok $?>>8,0; | ||
20 | print "Test was: $cmd\n" if ($?); | ||
21 | |||
22 | exit(0) if defined($Test::Harness::VERSION); | ||
23 | exit($tests - $t); | ||
diff --git a/plugins/t/check_ping.t b/plugins/t/check_ping.t new file mode 100644 index 0000000..97bc660 --- /dev/null +++ b/plugins/t/check_ping.t | |||
@@ -0,0 +1,33 @@ | |||
1 | #! /usr/bin/perl -w | ||
2 | |||
3 | use strict; | ||
4 | use Cache; | ||
5 | use Test; | ||
6 | use vars qw($tests); | ||
7 | |||
8 | BEGIN {$tests = 5; plan tests => $tests} | ||
9 | |||
10 | my $null = ''; | ||
11 | my $cmd; | ||
12 | my $str; | ||
13 | my $t; | ||
14 | |||
15 | $cmd = "./check_ping 127.0.0.1 100 100 1000 1000 -p 1"; | ||
16 | $str = `$cmd`; | ||
17 | $t += ok $?>>8,0; | ||
18 | print "Test was: $cmd\n" if ($?); | ||
19 | $t += ok $str, '/PING (ok|OK) - Packet loss = +[0-9]{1,2}\%, +RTA = [\.0-9]+ ms/'; | ||
20 | |||
21 | $cmd = "./check_ping 127.0.0.1 0 0 0 0 -p 1"; | ||
22 | $str = `$cmd`; | ||
23 | $t += ok $?>>8,2; | ||
24 | print "Test was: $cmd\n" unless ($?); | ||
25 | $t += ok $str, '/Packet loss = +[0-9]{1,2}\%, +RTA = [\.0-9]+ ms/'; | ||
26 | |||
27 | $cmd = "./check_ping $Cache::nullhost 0 0 0 0 -p 1 -to 1"; | ||
28 | $str = `$cmd`; | ||
29 | $t += ok $?>>8,2; | ||
30 | print "Test was: $cmd\n" unless ($?); | ||
31 | |||
32 | exit(0) if defined($Test::Harness::VERSION); | ||
33 | exit($tests - $t); | ||
diff --git a/plugins/t/check_pop.t b/plugins/t/check_pop.t new file mode 100644 index 0000000..60b5a4e --- /dev/null +++ b/plugins/t/check_pop.t | |||
@@ -0,0 +1,31 @@ | |||
1 | #! /usr/bin/perl -w | ||
2 | |||
3 | #use strict; | ||
4 | use Cache; | ||
5 | use Test; | ||
6 | use vars qw($tests); | ||
7 | |||
8 | BEGIN {$tests = 3; plan tests => $tests} | ||
9 | |||
10 | my $null = ''; | ||
11 | my $cmd; | ||
12 | my $str; | ||
13 | my $t; | ||
14 | |||
15 | $cmd = "./check_pop $Cache::mailhost"; | ||
16 | $str = `$cmd`; | ||
17 | $t += ok $?>>8,0; | ||
18 | print "Test was: $cmd\n" if ($?); | ||
19 | |||
20 | $cmd = "./check_pop -H $Cache::mailhost -p 110 -w 9 -c 9 -t 10 -e '+OK'"; | ||
21 | $str = `$cmd`; | ||
22 | $t += ok $?>>8,0; | ||
23 | print "Test was: $cmd\n" if ($?); | ||
24 | |||
25 | $cmd = "./check_pop $Cache::mailhost -p 110 -wt 9 -ct 9 -to 10 -e '+OK'"; | ||
26 | $str = `$cmd`; | ||
27 | $t += ok $?>>8,0; | ||
28 | print "Test was: $cmd\n" if ($?); | ||
29 | |||
30 | exit(0) if defined($Test::Harness::VERSION); | ||
31 | exit($tests - $t); | ||
diff --git a/plugins/t/check_procs.t b/plugins/t/check_procs.t new file mode 100644 index 0000000..9c2330f --- /dev/null +++ b/plugins/t/check_procs.t | |||
@@ -0,0 +1,51 @@ | |||
1 | #! /usr/bin/perl -w | ||
2 | |||
3 | use strict; | ||
4 | use Cache; | ||
5 | use Test; | ||
6 | use vars qw($tests); | ||
7 | |||
8 | BEGIN {$tests = 10; plan tests => $tests} | ||
9 | |||
10 | my $null = ''; | ||
11 | my $cmd; | ||
12 | my $str; | ||
13 | my $t; | ||
14 | |||
15 | # Reverse Compatibility | ||
16 | $cmd = "./check_procs 100000 100000"; | ||
17 | $str = `$cmd`; | ||
18 | $t += ok $?>>8,0; | ||
19 | print "Test was: $cmd\n" if ($?); | ||
20 | $t += ok $str, '/^OK - [0-9]+ processes running$/'; | ||
21 | |||
22 | # Reverse Compatibility | ||
23 | $cmd = "./check_procs 100000 100000 Z"; | ||
24 | $str = `$cmd`; | ||
25 | $t += ok $?>>8,0; | ||
26 | print "Test was: $cmd\n" if ($?); | ||
27 | $t += ok $str, '/^OK - [0-9]+ processes running with /'; | ||
28 | |||
29 | # Reverse Compatibility | ||
30 | $cmd = "./check_procs 0 10000000"; | ||
31 | $str = `$cmd`; | ||
32 | $t += ok $?>>8,1; | ||
33 | print "Test was: $cmd\n" unless ($?); | ||
34 | $t += ok $str, '/^WARNING - [0-9]+ processes running$/'; | ||
35 | |||
36 | # Reverse Compatibility | ||
37 | $cmd = "./check_procs 0 0"; | ||
38 | $str = `$cmd`; | ||
39 | $t += ok $?>>8,2; | ||
40 | print "Test was: $cmd\n" unless ($?); | ||
41 | $t += ok $str, '/^CRITICAL - [0-9]+ processes running$/'; | ||
42 | |||
43 | # Reverse Compatibility | ||
44 | $cmd = "./check_procs 0 0 S"; | ||
45 | $str = `$cmd`; | ||
46 | $t += ok $?>>8,2; | ||
47 | print "Test was: $cmd\n" unless ($?); | ||
48 | $t += ok $str, '/^CRITICAL - [0-9]+ processes running with /'; | ||
49 | |||
50 | exit(0) if defined($Test::Harness::VERSION); | ||
51 | exit($tests - $t); | ||
diff --git a/plugins/t/check_smtp.t b/plugins/t/check_smtp.t new file mode 100644 index 0000000..2a82b87 --- /dev/null +++ b/plugins/t/check_smtp.t | |||
@@ -0,0 +1,31 @@ | |||
1 | #! /usr/bin/perl -w | ||
2 | |||
3 | #use strict; | ||
4 | use Cache; | ||
5 | use Test; | ||
6 | use vars qw($tests); | ||
7 | |||
8 | BEGIN {$tests = 3; plan tests => $tests} | ||
9 | |||
10 | my $null = ''; | ||
11 | my $cmd; | ||
12 | my $str; | ||
13 | my $t; | ||
14 | |||
15 | $cmd = "./check_smtp $Cache::mailhost"; | ||
16 | $str = `$cmd`; | ||
17 | $t += ok $?>>8,0; | ||
18 | print "Test was: $cmd\n" if ($?); | ||
19 | |||
20 | $cmd = "./check_smtp -H $Cache::mailhost -p 25 -t 1 -w 9 -c 9 -t 10 -e 220"; | ||
21 | $str = `$cmd`; | ||
22 | $t += ok $?>>8,0; | ||
23 | print "Test was: $cmd\n" if ($?); | ||
24 | |||
25 | $cmd = "./check_smtp -H $Cache::mailhost -p 25 -wt 9 -ct 9 -to 10 -e 220"; | ||
26 | $str = `$cmd`; | ||
27 | $t += ok $?>>8,0; | ||
28 | print "Test was: $cmd\n" if ($?); | ||
29 | |||
30 | exit(0) if defined($Test::Harness::VERSION); | ||
31 | exit($tests - $t); | ||
diff --git a/plugins/t/check_snmp.t b/plugins/t/check_snmp.t new file mode 100644 index 0000000..162b0b9 --- /dev/null +++ b/plugins/t/check_snmp.t | |||
@@ -0,0 +1,52 @@ | |||
1 | #! /usr/bin/perl -w | ||
2 | |||
3 | use strict; | ||
4 | use Helper; | ||
5 | use Cache; | ||
6 | use Test; | ||
7 | use vars qw($tests); | ||
8 | |||
9 | BEGIN {$tests = 8; plan tests => $tests} | ||
10 | |||
11 | my $null = ''; | ||
12 | my $cmd; | ||
13 | my $str; | ||
14 | my $t; | ||
15 | my $community=get_option("snmp_community","SNMP community name"); | ||
16 | |||
17 | exit(0) unless (-x "./check_snmp"); | ||
18 | |||
19 | $cmd = "./check_snmp -H 127.0.0.1 -C $community -o system.sysUpTime.0 -w 1: -c 1:"; | ||
20 | $str = `$cmd`; | ||
21 | $t += ok $?>>8,0; | ||
22 | print "Test was: $cmd\n" if ($?); | ||
23 | chomp $str; | ||
24 | $t += ok $str, '/^SNMP OK - \d+/'; | ||
25 | |||
26 | $cmd = "./check_snmp -H 127.0.0.1 -C $community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w 1:1 -c 1:1"; | ||
27 | $str = `$cmd`; | ||
28 | $t += ok $?>>8,0; | ||
29 | print "Test was: $cmd\n" if ($?); | ||
30 | chomp $str; | ||
31 | $t += ok $str, '/^SNMP OK - 1\s*$/'; | ||
32 | |||
33 | $cmd = "./check_snmp -H 127.0.0.1 -C $community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w 0 -c 1:"; | ||
34 | $str = `$cmd`; | ||
35 | $t += ok $?>>8,1; | ||
36 | print "Test was: $cmd\n" unless ($?); | ||
37 | chomp $str; | ||
38 | $t += ok $str, '/^SNMP WARNING - \*1\*\s*$/'; | ||
39 | |||
40 | $cmd = "./check_snmp -H 127.0.0.1 -C $community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w :0 -c 0"; | ||
41 | $str = `$cmd`; | ||
42 | $t += ok $?>>8,2; | ||
43 | print "Test was: $cmd\n" unless ($?); | ||
44 | chomp $str; | ||
45 | $t += ok $str, '/^SNMP CRITICAL - \*1\*\s*$/'; | ||
46 | |||
47 | #host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 = 1 | ||
48 | #enterprises.ucdavis.memory.memAvailSwap.0 | ||
49 | #./check_snmp 127.0.0.1 -C staff -o enterprises.ucdavis.diskTable.dskEntry.dskAvail.1,enterprises.ucdavis.diskTable.dskEntry.dskPercent.1 -w 100000: -c 50000: -l Space on root -u 'bytes free (','% used)' | ||
50 | |||
51 | exit(0) if defined($Test::Harness::VERSION); | ||
52 | exit($tests - $t); | ||
diff --git a/plugins/t/check_swap.t b/plugins/t/check_swap.t new file mode 100644 index 0000000..5b702f0 --- /dev/null +++ b/plugins/t/check_swap.t | |||
@@ -0,0 +1,34 @@ | |||
1 | #! /usr/bin/perl -w | ||
2 | |||
3 | use strict; | ||
4 | use Cache; | ||
5 | use Test; | ||
6 | use vars qw($tests); | ||
7 | |||
8 | BEGIN {$tests = 6; plan tests => $tests} | ||
9 | |||
10 | my $null = ''; | ||
11 | my $cmd; | ||
12 | my $str; | ||
13 | my $t; | ||
14 | |||
15 | $cmd = "./check_swap 100 100"; | ||
16 | $str = `$cmd`; | ||
17 | $t += ok $?>>8,0; | ||
18 | print "Test was: $cmd\n" if ($?); | ||
19 | $t += ok $str, '/^Swap ok - Swap used\: +[0-9]{1,2}\% \([0-9]+ bytes out of [0-9]+\)$/'; | ||
20 | |||
21 | $cmd = "./check_swap 0 0"; | ||
22 | $str = `$cmd`; | ||
23 | $t += ok $?>>8,2; | ||
24 | print "Test was: $cmd\n" unless ($?); | ||
25 | $t += ok $str, '/^CRITICAL - Swap used\: +[0-9]{1,2}\% \([0-9]+ bytes out of [0-9]+\)$/'; | ||
26 | |||
27 | $cmd = "./check_swap 100 100 1000000000 1000000000"; | ||
28 | $str = `$cmd`; | ||
29 | $t += ok $?>>8,2; | ||
30 | print "Test was: $cmd\n" unless ($?); | ||
31 | $t += ok $str, '/^CRITICAL - Swap used\: +[0-9]{1,2}\% \([0-9]+ bytes out of [0-9]+\)$/'; | ||
32 | |||
33 | exit(0) if defined($Test::Harness::VERSION); | ||
34 | exit($tests - $t); | ||
diff --git a/plugins/t/check_tcp.t b/plugins/t/check_tcp.t new file mode 100644 index 0000000..1abec76 --- /dev/null +++ b/plugins/t/check_tcp.t | |||
@@ -0,0 +1,27 @@ | |||
1 | #! /usr/bin/perl -w | ||
2 | |||
3 | #use strict; | ||
4 | use Cache; | ||
5 | use Test; | ||
6 | use vars qw($tests); | ||
7 | |||
8 | BEGIN {$tests = 3; plan tests => $tests} | ||
9 | |||
10 | my $null = ''; | ||
11 | my $cmd; | ||
12 | my $str; | ||
13 | my $t; | ||
14 | |||
15 | $cmd = "./check_tcp $Cache::hostname -p 80 -wt 300 -ct 600"; | ||
16 | $str = `$cmd`; | ||
17 | $t += ok $?>>8,0; | ||
18 | print "$cmd\n" if ($?); | ||
19 | $t += ok $str, '/^TCP OK - [0-9]+ second response time on port 80/'; | ||
20 | |||
21 | $cmd = "./check_tcp $Cache::nullhost -p 81 -wt 0 -ct 0 -to 1"; | ||
22 | $str = `$cmd`; | ||
23 | $t += ok $?>>8,2; | ||
24 | print "$cmd\n" unless ($?); | ||
25 | |||
26 | exit(0) if defined($Test::Harness::VERSION); | ||
27 | exit($tests - $t); | ||
diff --git a/plugins/t/check_time.t b/plugins/t/check_time.t new file mode 100644 index 0000000..4d8c5c2 --- /dev/null +++ b/plugins/t/check_time.t | |||
@@ -0,0 +1,52 @@ | |||
1 | #! /usr/bin/perl -w | ||
2 | |||
3 | use strict; | ||
4 | use Cache; | ||
5 | use Helper; | ||
6 | use Test; | ||
7 | use vars qw($tests); | ||
8 | |||
9 | BEGIN {$tests = 6; plan tests => $tests} | ||
10 | |||
11 | my $null = ''; | ||
12 | my $cmd; | ||
13 | my $str; | ||
14 | my $t; | ||
15 | my $udp_hostname=get_option("udp_hostname","UDP host name"); | ||
16 | |||
17 | # standard mode | ||
18 | |||
19 | $cmd = "./check_time -H $udp_hostname -w 999999,59 -c 999999,59 -t 60"; | ||
20 | $str = `$cmd`; | ||
21 | $t += ok $?>>8,0; | ||
22 | print "Test was: $cmd\n" if ($?); | ||
23 | $t += ok $str, '/^TIME OK - [0-9]+ second time difference$/'; | ||
24 | |||
25 | $cmd = "./check_time -H $udp_hostname -w 999999 -W 59 -c 999999 -C 59 -t 60"; | ||
26 | $str = `$cmd`; | ||
27 | $t += ok $?>>8,0; | ||
28 | print "Test was: $cmd\n" if ($?); | ||
29 | $t += ok $str, '/^TIME OK - [0-9]+ second time difference$/'; | ||
30 | |||
31 | # reverse compatibility mode | ||
32 | |||
33 | $cmd = "./check_time $udp_hostname -wt 59 -ct 59 -cd 999999 -wd 999999 -to 60"; | ||
34 | $str = `$cmd`; | ||
35 | $t += ok $?>>8,0; | ||
36 | print "Test was: $cmd\n" if ($?); | ||
37 | $t += ok $str, '/^TIME OK - [0-9]+ second time difference$/'; | ||
38 | |||
39 | # failure mode | ||
40 | |||
41 | #$cmd = "./check_time -H $Cache::nullhost -t 1"; | ||
42 | #$str = `$cmd`; | ||
43 | #$t += ok $?>>8,255; | ||
44 | #print "Test was: $cmd\n" unless ($?); | ||
45 | |||
46 | #$cmd = "./check_time -H $Cache::noserver -t 1"; | ||
47 | #$str = `$cmd`; | ||
48 | #$t += ok $?>>8,255; | ||
49 | #print "$cmd\n" unless ($?); | ||
50 | |||
51 | exit(0) if defined($Test::Harness::VERSION); | ||
52 | exit($tests - $t); | ||
diff --git a/plugins/t/check_udp.t b/plugins/t/check_udp.t new file mode 100644 index 0000000..abbf5e4 --- /dev/null +++ b/plugins/t/check_udp.t | |||
@@ -0,0 +1,24 @@ | |||
1 | #! /usr/bin/perl -w | ||
2 | |||
3 | #use strict; | ||
4 | use Cache; | ||
5 | use Helper; | ||
6 | use Test; | ||
7 | use vars qw($tests); | ||
8 | |||
9 | BEGIN {$tests = 3; plan tests => $tests} | ||
10 | |||
11 | my $null = ''; | ||
12 | my $str; | ||
13 | my $t; | ||
14 | my $hostname=get_option("udp_hostname","UDP host name"); | ||
15 | |||
16 | $str = `./check_udp $hostname -p 37 -wt 300 -ct 600`; | ||
17 | $t += ok $?>>8,0; | ||
18 | $t += ok $str, '/^Connection accepted on port 37 - [0-9]+ second response time$/'; | ||
19 | |||
20 | $str = `./check_udp $Cache::nullhost -p 80 -wt 0 -ct 0 -to 1`; | ||
21 | $t += ok $?>>8,2; | ||
22 | |||
23 | exit(0) if defined($Test::Harness::VERSION); | ||
24 | exit($tests - $t); | ||
diff --git a/plugins/t/check_users.t b/plugins/t/check_users.t new file mode 100644 index 0000000..593f173 --- /dev/null +++ b/plugins/t/check_users.t | |||
@@ -0,0 +1,28 @@ | |||
1 | #! /usr/bin/perl -w | ||
2 | |||
3 | use strict; | ||
4 | use Cache; | ||
5 | use Test; | ||
6 | use vars qw($tests); | ||
7 | |||
8 | BEGIN {$tests = 4; plan tests => $tests} | ||
9 | |||
10 | my $null = ''; | ||
11 | my $cmd; | ||
12 | my $str; | ||
13 | my $t; | ||
14 | |||
15 | $cmd = "./check_users 1000 1000"; | ||
16 | $str = `$cmd`; | ||
17 | $t += ok $?>>8,0; | ||
18 | print "Test was: $cmd\n" if ($?); | ||
19 | $t += ok $str, '/^USERS OK - +[0-9]+ users currently logged in$/'; | ||
20 | |||
21 | $cmd = "./check_users 0 0"; | ||
22 | $str = `$cmd`; | ||
23 | $t += ok $?>>8,2; | ||
24 | print "Test was: $cmd\n" unless ($?); | ||
25 | $t += ok $str, '/^USERS CRITICAL - [0-9]+ +users currently logged in$/'; | ||
26 | |||
27 | exit(0) if defined($Test::Harness::VERSION); | ||
28 | exit($tests - $t); | ||
diff --git a/plugins/t/check_vsz.t b/plugins/t/check_vsz.t new file mode 100644 index 0000000..9597261 --- /dev/null +++ b/plugins/t/check_vsz.t | |||
@@ -0,0 +1,28 @@ | |||
1 | #! /usr/bin/perl -w | ||
2 | |||
3 | use strict; | ||
4 | use Cache; | ||
5 | use Test; | ||
6 | use vars qw($tests); | ||
7 | |||
8 | BEGIN {$tests = 4; plan tests => $tests} | ||
9 | |||
10 | my $null = ''; | ||
11 | my $cmd; | ||
12 | my $str; | ||
13 | my $t; | ||
14 | |||
15 | $cmd = "./check_vsz 100000 1000000 init"; | ||
16 | $str = `$cmd`; | ||
17 | $t += ok $?>>8,0; | ||
18 | print "Test was: $cmd\n" if ($?); | ||
19 | $t += ok $str, '/^ok \(all VSZ\<[0-9]+\)/'; | ||
20 | |||
21 | $cmd = "./check_vsz 0 0"; | ||
22 | $str = `$cmd`; | ||
23 | $t += ok $?>>8,2; | ||
24 | print "Test was: $cmd\n" unless ($?); | ||
25 | $t += ok $str, '/^CRITICAL \(VSZ\>[0-9]+\)/'; | ||
26 | |||
27 | exit(0) if defined($Test::Harness::VERSION); | ||
28 | exit($tests - $t); | ||