Imported Upstream version 1.4.8
This commit is contained in:
parent
6a280f6f24
commit
6dd54dd8e2
352 changed files with 42813 additions and 27251 deletions
|
@ -1,26 +0,0 @@
|
|||
/.cvsignore/1.1/Fri Dec 2 22:25:22 2005//Tr1_4_5
|
||||
/check_disk.t/1.14/Wed Oct 18 12:12:11 2006//Tr1_4_5
|
||||
/check_dns.t/1.7/Wed Mar 29 08:13:29 2006//Tr1_4_5
|
||||
/check_fping.t/1.2/Mon Jul 25 01:47:14 2005//Tr1_4_5
|
||||
/check_ftp.t/1.3/Mon Jul 25 01:47:14 2005//Tr1_4_5
|
||||
/check_hpjd.t/1.3/Fri Mar 24 16:13:40 2006//Tr1_4_5
|
||||
/check_http.t/1.12/Thu Oct 19 18:59:58 2006//Tr1_4_5
|
||||
/check_imap.t/1.4/Wed Nov 9 16:40:12 2005//Tr1_4_5
|
||||
/check_load.t/1.6/Mon Oct 2 12:09:18 2006//Tr1_4_5
|
||||
/check_mysql.t/1.8/Fri Mar 17 14:07:34 2006//Tr1_4_5
|
||||
/check_mysql_query.t/1.2/Wed Feb 1 13:23:38 2006//Tr1_4_5
|
||||
/check_nagios.nagios1.status.log/1.1/Fri Dec 2 22:28:06 2005//Tr1_4_5
|
||||
/check_nagios.nagios2.status.dat/1.1/Fri Dec 2 22:28:06 2005//Tr1_4_5
|
||||
/check_nagios.t/1.2/Wed Apr 19 09:33:44 2006//Tr1_4_5
|
||||
/check_ntp.t/1.2/Mon Aug 14 08:42:23 2006//Tr1_4_5
|
||||
/check_ping.t/1.3/Thu Sep 15 08:39:23 2005//Tr1_4_5
|
||||
/check_pop.t/1.3/Wed Mar 22 15:45:49 2006//Tr1_4_5
|
||||
/check_procs.t/1.5/Thu Nov 3 15:13:13 2005//Tr1_4_5
|
||||
/check_smtp.t/1.4/Thu Oct 19 11:56:34 2006//Tr1_4_5
|
||||
/check_snmp.t/1.2/Mon Jul 25 01:47:15 2005//Tr1_4_5
|
||||
/check_swap.t/1.3/Wed Nov 9 16:40:12 2005//Tr1_4_5
|
||||
/check_tcp.t/1.3/Mon Jul 25 01:47:15 2005//Tr1_4_5
|
||||
/check_time.t/1.3/Thu Nov 3 15:04:16 2005//Tr1_4_5
|
||||
/check_udp.t/1.6/Fri Jul 28 22:44:11 2006//Tr1_4_5
|
||||
/check_users.t/1.2/Mon Jul 25 01:47:15 2005//Tr1_4_5
|
||||
D
|
|
@ -1 +0,0 @@
|
|||
nagiosplug/plugins/t
|
|
@ -1 +0,0 @@
|
|||
:ext:tonvoon@nagiosplug.cvs.sourceforge.net:/cvsroot/nagiosplug
|
|
@ -1 +0,0 @@
|
|||
Nr1_4_5
|
|
@ -2,7 +2,7 @@
|
|||
#
|
||||
# Disk Space Tests via check_disk
|
||||
#
|
||||
# $Id: check_disk.t,v 1.14 2006/10/18 12:12:11 tonvoon Exp $
|
||||
# $Id: check_disk.t,v 1.20 2007/03/30 09:00:06 psychotrahe Exp $
|
||||
#
|
||||
|
||||
# TODO: Add in tests for perf data. Need to beef up Nagios::Plugin::Performance to cater for max, min, etc
|
||||
|
@ -24,18 +24,24 @@ my $mountpoint2_valid = getTestParameter( "NP_MOUNTPOINT2_VALID", "Path to anoth
|
|||
if ($mountpoint_valid eq "" or $mountpoint2_valid eq "") {
|
||||
plan skip_all => "Need 2 mountpoints to test";
|
||||
} else {
|
||||
plan tests => 42;
|
||||
plan tests => 68;
|
||||
}
|
||||
|
||||
$result = NPTest->testCmd(
|
||||
"./check_disk -w 1% -c 1% -p $mountpoint_valid -w 1% -c 1% -p $mountpoint2_valid"
|
||||
);
|
||||
cmp_ok( $result->return_code, "==", 0, "Checking two mountpoints (must have at least 1% free)");
|
||||
cmp_ok( $result->return_code, "==", 0, "Checking two mountpoints (must have at least 1% free in space and inodes)");
|
||||
my $c = 0;
|
||||
$_ = $result->output;
|
||||
$c++ while /\(/g; # counts number of "(" - should be two
|
||||
cmp_ok( $c, '==', 2, "Got two mountpoints in output");
|
||||
|
||||
|
||||
# Get perf data
|
||||
# Should use Nagios::Plugin
|
||||
my @perf_data = sort(split(/ /, $result->perf_output));
|
||||
|
||||
|
||||
# Calculate avg_free free on mountpoint1 and mountpoint2
|
||||
# because if you check in the middle, you should get different errors
|
||||
$_ = $result->output;
|
||||
|
@ -54,12 +60,67 @@ if ($free_on_mp1 > $free_on_mp2) {
|
|||
}
|
||||
|
||||
|
||||
# Do same for inodes
|
||||
$_ = $result->output;
|
||||
my ($free_inode_on_mp1, $free_inode_on_mp2) = (m/inode=(\d+)%.*inode=(\d+)%/);
|
||||
die "Cannot parse free inodes: $_" unless ($free_inode_on_mp1 && $free_inode_on_mp2);
|
||||
my $avg_inode_free = ceil(($free_inode_on_mp1 + $free_inode_on_mp2)/2);
|
||||
my ($more_inode_free, $less_inode_free);
|
||||
if ($free_inode_on_mp1 > $free_inode_on_mp2) {
|
||||
$more_inode_free = $mountpoint_valid;
|
||||
$less_inode_free = $mountpoint2_valid;
|
||||
} elsif ($free_inode_on_mp1 < $free_inode_on_mp2) {
|
||||
$more_inode_free = $mountpoint2_valid;
|
||||
$less_inode_free = $mountpoint_valid;
|
||||
} else {
|
||||
die "Two mountpoints with same inodes free - cannot do rest of test";
|
||||
}
|
||||
|
||||
# Verify performance data
|
||||
# First check absolute thresholds...
|
||||
$result = NPTest->testCmd(
|
||||
"./check_disk -w 20 -c 10 -p $mountpoint_valid"
|
||||
);
|
||||
$_ = $result->perf_output;
|
||||
my ($warn_absth_data, $crit_absth_data, $total_absth_data) = (m/=.[^;]*;(\d+);(\d+);\d+;(\d+)/);
|
||||
is ($warn_absth_data, $total_absth_data - 20, "Wrong warning in perf data using absolute thresholds");
|
||||
is ($crit_absth_data, $total_absth_data - 10, "Wrong critical in perf data using absolute thresholds");
|
||||
|
||||
# Then check percent thresholds.
|
||||
$result = NPTest->testCmd(
|
||||
"./check_disk -w 20% -c 10% -p $mountpoint_valid"
|
||||
);
|
||||
$_ = $result->perf_output;
|
||||
my ($warn_percth_data, $crit_percth_data, $total_percth_data) = (m/=.[^;]*;(\d+);(\d+);\d+;(\d+)/);
|
||||
is ($warn_percth_data, int((1-20/100)*$total_percth_data), "Wrong warning in perf data using percent thresholds");
|
||||
is ($crit_percth_data, int((1-10/100)*$total_percth_data), "Wrong critical in perf data using percent thresholds");
|
||||
|
||||
|
||||
# Check when order of mount points are reversed, that perf data remains same
|
||||
$result = NPTest->testCmd(
|
||||
"./check_disk -w 1% -c 1% -p $mountpoint2_valid -w 1% -c 1% -p $mountpoint_valid"
|
||||
);
|
||||
@_ = sort(split(/ /, $result->perf_output));
|
||||
is_deeply( \@perf_data, \@_, "perf data for both filesystems same when reversed");
|
||||
|
||||
|
||||
# Basic filesystem checks for sizes
|
||||
$result = NPTest->testCmd( "./check_disk -w 1 -c 1 -p $more_free" );
|
||||
cmp_ok( $result->return_code, '==', 0, "At least 1 MB available on $more_free");
|
||||
like ( $result->output, $successOutput, "OK output" );
|
||||
like ( $result->only_output, qr/free space/, "Have free space text");
|
||||
like ( $result->only_output, qr/$more_free/, "Have disk name in text");
|
||||
|
||||
$result = NPTest->testCmd( "./check_disk -w 1 -c 1 -p $more_free -p $less_free" );
|
||||
cmp_ok( $result->return_code, '==', 0, "At least 1 MB available on $more_free and $less_free");
|
||||
$_ = $result->output;
|
||||
print $result->output."\n";
|
||||
my ($free_mb_on_mp1, $free_mb_on_mp2) = (m/(\d+) MB .* (\d+) MB /g);
|
||||
my $free_mb_on_all = $free_mb_on_mp1 + $free_mb_on_mp2;
|
||||
print "$free_mb_on_all = $free_mb_on_mp1 + $free_mb_on_mp2\n";
|
||||
|
||||
|
||||
|
||||
$result = NPTest->testCmd( "./check_disk -e -w 1 -c 1 -p $more_free" );
|
||||
is( $result->only_output, "DISK OK", "No print out of disks with -e for OKs");
|
||||
|
||||
|
@ -76,8 +137,6 @@ cmp_ok( $result->return_code, "==", 2, "Get critical on less_free mountpoint $le
|
|||
like( $result->output, $failureOutput, "Right output" );
|
||||
|
||||
|
||||
|
||||
|
||||
$result = NPTest->testCmd(
|
||||
"./check_disk -w $avg_free% -c 0% -p $less_free"
|
||||
);
|
||||
|
@ -98,12 +157,11 @@ $result = NPTest->testCmd(
|
|||
"./check_disk -e -w $avg_free% -c 0% -p $less_free -w $avg_free% -c $avg_free% -p $more_free"
|
||||
);
|
||||
isnt( $result->output, $all_disks, "-e gives different output");
|
||||
like( $result->output, qr/$less_free/, "Found problem $less_free");
|
||||
unlike( $result->only_output, qr/$more_free/, "Has ignored $more_free as not a problem");
|
||||
like( $result->perf_output, qr/$more_free/, "But $more_free is still in perf data");
|
||||
|
||||
|
||||
|
||||
# Need spaces around filesystem name in case less_free and more_free are nested
|
||||
like( $result->output, qr/ $less_free /, "Found problem $less_free");
|
||||
unlike( $result->only_output, qr/ $more_free /, "Has ignored $more_free as not a problem");
|
||||
like( $result->perf_output, qr/ $more_free=/, "But $more_free is still in perf data");
|
||||
|
||||
$result = NPTest->testCmd(
|
||||
"./check_disk -w $avg_free% -c 0% -p $more_free"
|
||||
|
@ -126,6 +184,50 @@ cmp_ok( $result->return_code, '==', 2, "And reversing arguments should not make
|
|||
|
||||
|
||||
|
||||
# Basic inode checks for sizes
|
||||
|
||||
$result = NPTest->testCmd( "./check_disk --icritical 1% --iwarning 1% -p $more_inode_free" );
|
||||
is( $result->return_code, 0, "At least 1% free on inodes for both mountpoints");
|
||||
|
||||
$result = NPTest->testCmd( "./check_disk -K 100% -W 100% -p $less_inode_free" );
|
||||
is( $result->return_code, 2, "Critical requesting 100% free inodes for both mountpoints");
|
||||
|
||||
$result = NPTest->testCmd( "./check_disk --iwarning 1% --icritical 1% -p $more_inode_free -K 100% -W 100% -p $less_inode_free" );
|
||||
is( $result->return_code, 2, "Get critical on less_inode_free mountpoint $less_inode_free");
|
||||
|
||||
$result = NPTest->testCmd( "./check_disk -W $avg_inode_free% -K 0% -p $less_inode_free" );
|
||||
is( $result->return_code, 1, "Get warning on less_inode_free, when checking average");
|
||||
|
||||
$result = NPTest->testCmd( "./check_disk -W $avg_inode_free% -K $avg_inode_free% -p $more_inode_free ");
|
||||
is( $result->return_code, 0, "Get ok on more_inode_free when checking average");
|
||||
|
||||
$result = NPTest->testCmd( "./check_disk -W $avg_inode_free% -K 0% -p $less_inode_free -W $avg_inode_free% -K $avg_inode_free% -p $more_inode_free" );
|
||||
is ($result->return_code, 1, "Combine above two tests, get warning");
|
||||
$all_disks = $result->output;
|
||||
|
||||
$result = NPTest->testCmd( "./check_disk -e -W $avg_inode_free% -K 0% -p $less_inode_free -W $avg_inode_free% -K $avg_inode_free% -p $more_inode_free" );
|
||||
isnt( $result->output, $all_disks, "-e gives different output");
|
||||
like( $result->output, qr/$less_inode_free/, "Found problem $less_inode_free");
|
||||
unlike( $result->only_output, qr/$more_inode_free\s/, "Has ignored $more_inode_free as not a problem");
|
||||
like( $result->perf_output, qr/$more_inode_free/, "But $more_inode_free is still in perf data");
|
||||
|
||||
$result = NPTest->testCmd( "./check_disk -W $avg_inode_free% -K 0% -p $more_inode_free" );
|
||||
is( $result->return_code, 0, "Get ok on more_inode_free mountpoint, checking average");
|
||||
|
||||
$result = NPTest->testCmd( "./check_disk -W $avg_inode_free% -K $avg_inode_free% -p $less_inode_free" );
|
||||
is( $result->return_code, 2, "Get critical on less_inode_free, checking average");
|
||||
|
||||
$result = NPTest->testCmd( "./check_disk -W $avg_inode_free% -K 0% -p $more_inode_free -W $avg_inode_free% -K $avg_inode_free% -p $less_inode_free" );
|
||||
is( $result->return_code, 2, "Combining above two tests, get critical");
|
||||
|
||||
$result = NPTest->testCmd( "./check_disk -W $avg_inode_free% -K $avg_inode_free% -p $less_inode_free -W $avg_inode_free% -K 0% -p $more_inode_free" );
|
||||
cmp_ok( $result->return_code, '==', 2, "And reversing arguments should not make a difference");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
TODO: {
|
||||
local $TODO = "Invalid percent figures";
|
||||
$result = NPTest->testCmd(
|
||||
|
@ -192,3 +294,28 @@ unlike( $result->perf_output, '/\/bob/', "perf data does not have /bob in it");
|
|||
|
||||
$result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p / -p /" );
|
||||
unlike( $result->output, '/ \/ .* \/ /', "Should not show same filesystem twice");
|
||||
|
||||
# are partitions added if -C is given without path selection -p ?
|
||||
$result = NPTest->testCmd( "./check_disk -w 0% -c 0% -C -w 0% -c 0% -p $mountpoint_valid" );
|
||||
like( $result->output, '/;.*;\|/', "-C selects partitions if -p is not given");
|
||||
|
||||
# grouping: exit crit if the sum of free megs on mp1+mp2 is less than warn/crit
|
||||
$result = NPTest->testCmd( "./check_disk -w ". ($free_mb_on_all + 1) ." -c ". ($free_mb_on_all + 1) ."-g group -p $mountpoint_valid -p $mountpoint2_valid" );
|
||||
cmp_ok( $result->return_code, '==', 2, "grouping: exit crit if the sum of free megs on mp1+mp2 is less than warn/crit");
|
||||
|
||||
# grouping: exit warning if the sum of free megs on mp1+mp2 is between -w and -c
|
||||
$result = NPTest->testCmd( "./check_disk -w ". ($free_mb_on_all + 1) ." -c ". ($free_mb_on_all - 1) ." -g group -p $mountpoint_valid -p $mountpoint2_valid" );
|
||||
cmp_ok( $result->return_code, '==', 1, "grouping: exit warning if the sum of free megs on mp1+mp2 is between -w and -c ");
|
||||
|
||||
# grouping: exit ok if the sum of free megs on mp1+mp2 is more than warn/crit
|
||||
$result = NPTest->testCmd( "./check_disk -w ". ($free_mb_on_all - 1) ." -c ". ($free_mb_on_all - 1) ." -g group -p $mountpoint_valid -p $mountpoint2_valid" );
|
||||
cmp_ok( $result->return_code, '==', 0, "grouping: exit ok if the sum of free megs on mp1+mp2 is more than warn/crit");
|
||||
|
||||
# grouping: exit unknown if group name is given after -p
|
||||
$result = NPTest->testCmd( "./check_disk -w ". ($free_mb_on_all - 1) ." -c ". ($free_mb_on_all - 1) ." -p $mountpoint_valid -g group -p $mountpoint2_valid" );
|
||||
cmp_ok( $result->return_code, '==', 3, "Invalid options: -p must come after groupname");
|
||||
|
||||
# regex: exit unknown if given regex is not compileable
|
||||
$result = NPTest->testCmd( "./check_disk -w 1 -c 1 -r '('" );
|
||||
cmp_ok( $result->return_code, '==', 3, "Exit UNKNOWN if regex is not compileable");
|
||||
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
#
|
||||
# HyperText Transfer Protocol (HTTP) Test via check_http
|
||||
#
|
||||
# $Id: check_http.t,v 1.12 2006/10/19 18:59:58 tonvoon Exp $
|
||||
# $Id: check_http.t,v 1.14 2007/04/01 14:21:09 psychotrahe Exp $
|
||||
#
|
||||
|
||||
use strict;
|
||||
use Test::More;
|
||||
use NPTest;
|
||||
|
||||
plan tests => 22;
|
||||
plan tests => 26;
|
||||
|
||||
my $successOutput = '/OK.*HTTP.*second/';
|
||||
|
||||
|
@ -27,6 +27,18 @@ my $hostname_invalid = getTestParameter( "NP_HOSTNAME_INVALID",
|
|||
"An invalid (not known to DNS) hostname",
|
||||
"nosuchhost");
|
||||
|
||||
my $internet_access = getTestParameter( "NP_INTERNET_ACCESS",
|
||||
"Is this system directly connected to the internet?",
|
||||
"yes");
|
||||
|
||||
my $host_tcp_http2;
|
||||
if ($internet_access eq "no") {
|
||||
$host_tcp_http2 = getTestParameter( "NP_HOST_TCP_HTTP2",
|
||||
"A host providing an index page containing the string 'nagios'",
|
||||
"altinity.com" );
|
||||
}
|
||||
|
||||
|
||||
$res = NPTest->testCmd(
|
||||
"./check_http $host_tcp_http -wt 300 -ct 600"
|
||||
);
|
||||
|
@ -58,44 +70,62 @@ cmp_ok( $res->return_code, '==', 2, "Webserver $hostname_invalid not valid" );
|
|||
# Is also possible to get a socket timeout if DNS is not responding fast enough
|
||||
like( $res->output, "/Unable to open TCP socket|Socket timeout after/", "Output OK");
|
||||
|
||||
$res = NPTest->testCmd(
|
||||
"./check_http --ssl www.verisign.com"
|
||||
);
|
||||
cmp_ok( $res->return_code, '==', 0, "Can read https for www.verisign.com" );
|
||||
SKIP: {
|
||||
skip "No internet access and no host serving nagios in index file",
|
||||
7 if $internet_access eq "no" && ! $host_tcp_http2;
|
||||
|
||||
$res = NPTest->testCmd( "./check_http -C 1 --ssl www.verisign.com" );
|
||||
cmp_ok( $res->return_code, '==', 0, "Checking certificate for www.verisign.com");
|
||||
like ( $res->output, '/Certificate will expire on/', "Output OK" );
|
||||
my $saved_cert_output = $res->output;
|
||||
$host_tcp_http2 = "altinity.com" if (! $host_tcp_http2);
|
||||
|
||||
$res = NPTest->testCmd( "./check_http -C 1 www.verisign.com" );
|
||||
cmp_ok( $res->output, 'eq', $saved_cert_output, "--ssl option automatically added");
|
||||
$res = NPTest->testCmd( "./check_http -H $host_tcp_http2 -r 'nagios'" );
|
||||
cmp_ok( $res->return_code, "==", 0, "Got a reference to 'nagios'");
|
||||
|
||||
$res = NPTest->testCmd( "./check_http www.verisign.com -C 1" );
|
||||
cmp_ok( $res->output, 'eq', $saved_cert_output, "Old syntax for cert checking still works");
|
||||
$res = NPTest->testCmd( "./check_http -H $host_tcp_http2 -r 'nAGiOs'" );
|
||||
cmp_ok( $res->return_code, "==", 2, "Not got 'nAGiOs'");
|
||||
like ( $res->output, "/pattern not found/", "Error message says 'pattern not found'");
|
||||
|
||||
$res = NPTest->testCmd(
|
||||
"./check_http --ssl www.e-paycobalt.com"
|
||||
);
|
||||
cmp_ok( $res->return_code, "==", 0, "Can read https for www.e-paycobalt.com (uses AES certificate)" );
|
||||
$res = NPTest->testCmd( "./check_http -H $host_tcp_http2 -R 'nAGiOs'" );
|
||||
cmp_ok( $res->return_code, "==", 0, "But case insensitive doesn't mind 'nAGiOs'");
|
||||
|
||||
$res = NPTest->testCmd( "./check_http -H altinity.com -r 'nagios'" );
|
||||
cmp_ok( $res->return_code, "==", 0, "Got a reference to 'nagios'");
|
||||
$res = NPTest->testCmd( "./check_http -H $host_tcp_http2 -r 'nagios' --invert-regex" );
|
||||
cmp_ok( $res->return_code, "==", 2, "Invert results work when found");
|
||||
like ( $res->output, "/pattern found/", "Error message says 'pattern found'");
|
||||
|
||||
$res = NPTest->testCmd( "./check_http -H altinity.com -r 'nAGiOs'" );
|
||||
cmp_ok( $res->return_code, "==", 2, "Not got 'nAGiOs'");
|
||||
like ( $res->output, "/pattern not found/", "Error message says 'pattern not found'");
|
||||
$res = NPTest->testCmd( "./check_http -H $host_tcp_http2 -r 'nAGiOs' --invert-regex" );
|
||||
cmp_ok( $res->return_code, "==", 0, "And also when not found");
|
||||
}
|
||||
SKIP: {
|
||||
skip "No internet access", 11 if $internet_access eq "no";
|
||||
|
||||
$res = NPTest->testCmd( "./check_http -H altinity.com -R 'nAGiOs'" );
|
||||
cmp_ok( $res->return_code, "==", 0, "But case insensitive doesn't mind 'nAGiOs'");
|
||||
$res = NPTest->testCmd(
|
||||
"./check_http --ssl www.verisign.com"
|
||||
);
|
||||
cmp_ok( $res->return_code, '==', 0, "Can read https for www.verisign.com" );
|
||||
|
||||
$res = NPTest->testCmd( "./check_http -H altinity.com -r 'nagios' --invert-regex" );
|
||||
cmp_ok( $res->return_code, "==", 2, "Invert results work when found");
|
||||
like ( $res->output, "/pattern found/", "Error message says 'pattern found'");
|
||||
$res = NPTest->testCmd( "./check_http -C 1 --ssl www.verisign.com" );
|
||||
cmp_ok( $res->return_code, '==', 0, "Checking certificate for www.verisign.com");
|
||||
like ( $res->output, '/Certificate will expire on/', "Output OK" );
|
||||
my $saved_cert_output = $res->output;
|
||||
|
||||
$res = NPTest->testCmd( "./check_http -H altinity.com -r 'nAGiOs' --invert-regex" );
|
||||
cmp_ok( $res->return_code, "==", 0, "And also when not found");
|
||||
$res = NPTest->testCmd( "./check_http www.verisign.com -C 1" );
|
||||
is( $res->return_code, 0, "Old syntax for cert checking okay" );
|
||||
is( $res->output, $saved_cert_output, "Same output as new syntax" );
|
||||
|
||||
$res = NPTest->testCmd( "./check_http -H www.worldfirefoxday.com -f follow" );
|
||||
is( $res->return_code, 0, "Redirection based on location is okay");
|
||||
$res = NPTest->testCmd( "./check_http -H www.verisign.com -C 1" );
|
||||
is( $res->return_code, 0, "Updated syntax for cert checking okay" );
|
||||
is( $res->output, $saved_cert_output, "Same output as new syntax" );
|
||||
|
||||
$res = NPTest->testCmd( "./check_http -C 1 www.verisign.com" );
|
||||
cmp_ok( $res->output, 'eq', $saved_cert_output, "--ssl option automatically added");
|
||||
|
||||
$res = NPTest->testCmd( "./check_http www.verisign.com -C 1" );
|
||||
cmp_ok( $res->output, 'eq', $saved_cert_output, "Old syntax for cert checking still works");
|
||||
|
||||
$res = NPTest->testCmd(
|
||||
"./check_http --ssl www.e-paycobalt.com"
|
||||
);
|
||||
cmp_ok( $res->return_code, "==", 0, "Can read https for www.e-paycobalt.com (uses AES certificate)" );
|
||||
|
||||
|
||||
$res = NPTest->testCmd( "./check_http -H www.mozilla.com -u /firefox -f follow" );
|
||||
is( $res->return_code, 0, "Redirection based on location is okay");
|
||||
}
|
||||
|
|
65
plugins/t/check_jabber.t
Normal file
65
plugins/t/check_jabber.t
Normal file
|
@ -0,0 +1,65 @@
|
|||
#! /usr/bin/perl -w -I ..
|
||||
#
|
||||
# Jabber Server Tests via check_jabber
|
||||
#
|
||||
# $Id: check_jabber.t,v 1.3 2007/02/01 06:53:12 dermoth Exp $
|
||||
#
|
||||
|
||||
use strict;
|
||||
use Test::More;
|
||||
use NPTest;
|
||||
|
||||
plan tests => 10;
|
||||
|
||||
my $host_tcp_jabber = getTestParameter(
|
||||
"NP_HOST_TCP_JABBER",
|
||||
"A host providing the Jabber Service",
|
||||
"jabber.org"
|
||||
);
|
||||
|
||||
my $host_nonresponsive = getTestParameter(
|
||||
"NP_HOST_NONRESPONSIVE",
|
||||
"The hostname of system not responsive to network requests",
|
||||
"10.0.0.1",
|
||||
);
|
||||
|
||||
my $hostname_invalid = getTestParameter(
|
||||
"NP_HOSTNAME_INVALID",
|
||||
"An invalid (not known to DNS) hostname",
|
||||
"nosuchhost",
|
||||
);
|
||||
|
||||
|
||||
my $jabberOK = '/JABBER OK\s-\s\d+\.\d+\ssecond response time on port 5222/';
|
||||
|
||||
my $jabberUnresponsive = '/CRITICAL\s-\sSocket timeout after\s\d+\sseconds/';
|
||||
|
||||
my $jabberInvalid = '/JABBER CRITICAL - Invalid hostname, address or socket:\s.+/';
|
||||
|
||||
my $r;
|
||||
|
||||
SKIP: {
|
||||
skip "No jabber server defined", 6 unless $host_tcp_jabber;
|
||||
|
||||
$r = NPTest->testCmd( "./check_jabber $host_tcp_jabber" );
|
||||
is( $r->return_code, 0, "Connected okay");
|
||||
like( $r->output, $jabberOK, "Output as expected" );
|
||||
|
||||
$r = NPTest->testCmd( "./check_jabber -H $host_tcp_jabber -w 9 -c 9 -t 10" );
|
||||
is( $r->return_code, 0, "Connected okay, within limits" );
|
||||
like( $r->output, $jabberOK, "Output as expected" );
|
||||
|
||||
$r = NPTest->testCmd( "./check_jabber $host_tcp_jabber -wt 9 -ct 9 -to 10" );
|
||||
is( $r->return_code, 0, "Old syntax okay" );
|
||||
like( $r->output, $jabberOK, "Output as expected" );
|
||||
|
||||
}
|
||||
|
||||
$r = NPTest->testCmd( "./check_jabber $host_nonresponsive" );
|
||||
is( $r->return_code, 2, "Unresponsive host gives critical" );
|
||||
like( $r->output, $jabberUnresponsive );
|
||||
|
||||
$r = NPTest->testCmd( "./check_jabber $hostname_invalid" );
|
||||
is( $r->return_code, 2, "Invalid hostname gives critical" );
|
||||
like( $r->output, $jabberInvalid );
|
||||
|
|
@ -2,36 +2,109 @@
|
|||
#
|
||||
# Ping Response Tests via check_ping
|
||||
#
|
||||
# $Id: check_ping.t,v 1.3 2005/09/15 08:39:23 tonvoon Exp $
|
||||
# $Id: check_ping.t,v 1.5 2007/03/12 10:51:06 tonvoon Exp $
|
||||
#
|
||||
|
||||
use strict;
|
||||
use Test;
|
||||
use Test::More;
|
||||
use NPTest;
|
||||
|
||||
use vars qw($tests);
|
||||
|
||||
BEGIN {$tests = 8; plan tests => $tests}
|
||||
plan tests => 20;
|
||||
|
||||
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_responsive = getTestParameter( "NP_HOST_RESPONSIVE",
|
||||
"The hostname of system responsive to network requests",
|
||||
"localhost" );
|
||||
|
||||
my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1",
|
||||
"The hostname of system not responsive to network requests" );
|
||||
my $host_nonresponsive = getTestParameter( "NP_HOST_NONRESPONSIVE",
|
||||
"The hostname of system not responsive to network requests",
|
||||
"10.0.0.1" );
|
||||
|
||||
my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost",
|
||||
"An invalid (not known to DNS) hostname" );
|
||||
my $hostname_invalid = getTestParameter( "NP_HOSTNAME_INVALID",
|
||||
"An invalid (not known to DNS) hostname",
|
||||
"nosuchhost" );
|
||||
|
||||
my $t;
|
||||
my $res;
|
||||
|
||||
$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 );
|
||||
$t += checkCmd( "./check_ping -w 100,10% -c 200,20%" , 3 , "/You must specify a server address or host name.*/");
|
||||
$res = NPTest->testCmd(
|
||||
"./check_ping -H $host_responsive -w 10,100% -c 10,100% -p 1"
|
||||
);
|
||||
is( $res->return_code, 0, "Syntax ok" );
|
||||
like( $res->output, $successOutput, "Output OK" );
|
||||
|
||||
$res = NPTest->testCmd(
|
||||
"./check_ping -H $host_responsive -w 0,0% -c 10,100% -p 1"
|
||||
);
|
||||
is( $res->return_code, 1, "Syntax ok, with forced warning" );
|
||||
like( $res->output, $failureOutput, "Output OK" );
|
||||
|
||||
$res = NPTest->testCmd(
|
||||
"./check_ping -H $host_responsive -w 0,0% -c 0,0% -p 1"
|
||||
);
|
||||
is( $res->return_code, 2, "Syntax ok, with forced critical" );
|
||||
like( $res->output, $failureOutput, "Output OK" );
|
||||
|
||||
$res = NPTest->testCmd(
|
||||
"./check_ping $host_responsive 100 100 1000 1000 -p 1"
|
||||
);
|
||||
is( $res->return_code, 0, "Old syntax ok" );
|
||||
like( $res->output, $successOutput, "Output OK" );
|
||||
|
||||
$res = NPTest->testCmd(
|
||||
"./check_ping $host_responsive 0 0 0 0 -p 1"
|
||||
);
|
||||
is( $res->return_code, 2, "Old syntax, with forced critical" );
|
||||
like( $res->output, $failureOutput, "Output OK" );
|
||||
|
||||
|
||||
# check_ping results will depend on whether the ping command discovered by
|
||||
# ./configure has a timeout option. If it does, then the timeout will
|
||||
# be set, so check_ping will always get a response. If it doesn't
|
||||
# then check_ping will timeout. We do 2 tests for check_ping's timeout
|
||||
# - 1 second
|
||||
# - 15 seconds
|
||||
# The latter should be higher than normal ping timeouts, so should always give a packet loss result
|
||||
open(F, "../config.h") or die "Cannot open ../config.h";
|
||||
@_ = grep /define PING_HAS_TIMEOUT 1|define PING_PACKETS_FIRST 1/, <F>;
|
||||
my $has_timeout;
|
||||
$has_timeout = 1 if (scalar @_ == 2); # Need both defined
|
||||
close F;
|
||||
$res = NPTest->testCmd(
|
||||
"./check_ping -H $host_nonresponsive -w 10,100% -c 10,100% -p 1 -t 1"
|
||||
);
|
||||
is( $res->return_code, 2, "Timeout 1 second - host nonresponsive" );
|
||||
if ($has_timeout) {
|
||||
like( $res->output, '/100%/', "Error contains '100%' string (for 100% packet loss)" );
|
||||
} else {
|
||||
like( $res->output, '/timed out/', "Error contains 'timed out' string" );
|
||||
}
|
||||
|
||||
$res = NPTest->testCmd(
|
||||
"./check_ping -H $host_nonresponsive -w 10,100% -c 10,100% -p 1 -t 15"
|
||||
);
|
||||
is( $res->return_code, 2, "Timeout 15 seconds - host nonresponsive" );
|
||||
like( $res->output, '/100%/', "Error contains '100%' string (for 100% packet loss)" );
|
||||
|
||||
|
||||
|
||||
|
||||
$res = NPTest->testCmd(
|
||||
"./check_ping $host_nonresponsive -p 1 -t 1 100 100 1000 10000"
|
||||
);
|
||||
is( $res->return_code, 2, "Old syntax: Timeout - host nonresponsive" );
|
||||
like( $res->output, '/100%/', "Error contains '100%' string (for 100% packet loss)" );
|
||||
|
||||
$res = NPTest->testCmd(
|
||||
"./check_ping $hostname_invalid 0 0 0 0 -p 1 -t 1"
|
||||
);
|
||||
is( $res->return_code, 3, "Invalid hostname" );
|
||||
like( $res->output, '/invalid hostname/i', "Error contains 'invalid hostname' string");
|
||||
|
||||
$res = NPTest->testCmd(
|
||||
"./check_ping -w 100,10% -c 200,20%"
|
||||
);
|
||||
is( $res->return_code, 3, "No hostname" );
|
||||
like( $res->output, '/You must specify a server address or host name/', "Output with appropriate error message");
|
||||
|
||||
exit(0) if defined($Test::Harness::VERSION);
|
||||
exit($tests - $t);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#
|
||||
# Simple Network Management Protocol (SNMP) Test via check_snmp
|
||||
#
|
||||
# $Id: check_snmp.t,v 1.2 2005/07/25 01:47:15 illumino Exp $
|
||||
# $Id: check_snmp.t,v 1.3 2006/12/23 18:59:36 dermoth Exp $
|
||||
#
|
||||
|
||||
use strict;
|
||||
|
@ -35,13 +35,13 @@ if ( -x "./check_snmp" )
|
|||
{ 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 );
|
||||
{ 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 );
|
||||
{ 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 );
|
||||
{ 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 - /' );
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#
|
||||
# TCP Connection Based Tests via check_tcp
|
||||
#
|
||||
# $Id: check_tcp.t,v 1.3 2005/07/25 01:47:15 illumino Exp $
|
||||
# $Id: check_tcp.t,v 1.5 2007/02/14 10:11:07 tonvoon Exp $
|
||||
#
|
||||
|
||||
use strict;
|
||||
|
@ -10,7 +10,7 @@ use Test;
|
|||
use NPTest;
|
||||
|
||||
use vars qw($tests);
|
||||
BEGIN {$tests = 5; plan tests => $tests}
|
||||
BEGIN {$tests = 7; 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)" );
|
||||
|
@ -23,6 +23,8 @@ my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_IN
|
|||
|
||||
my $successOutput = '/^TCP OK\s-\s+[0-9]?\.?[0-9]+ second response time on port [0-9]+/';
|
||||
|
||||
my $failedExpect = '/^TCP WARNING\s-\sUnexpected response from host/socket on port [0-9]+/';
|
||||
|
||||
my $t;
|
||||
|
||||
$t += checkCmd( "./check_tcp $host_tcp_http -p 80 -wt 300 -ct 600", 0, $successOutput );
|
||||
|
@ -30,5 +32,9 @@ $t += checkCmd( "./check_tcp $host_tcp_http -p 81 -wt 0 -ct 0 -to 1", 2
|
|||
$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 );
|
||||
|
||||
# Need the \r\n to make it more standards compliant with web servers. Need the various quotes
|
||||
# so that perl doesn't interpret the \r\n and is passed onto command line correctly
|
||||
$t += checkCmd( "./check_tcp $host_tcp_http -p 80 -E -s ".'"GET /\r\n\r\n"'." -e 'ThisShouldntMatch' -j", 1, $failedExpect );
|
||||
|
||||
exit(0) if defined($Test::Harness::VERSION);
|
||||
exit($tests - $t);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue