Imported Upstream version 1.4.10
This commit is contained in:
parent
6dd54dd8e2
commit
cff68b4c0a
203 changed files with 15026 additions and 8063 deletions
|
@ -2,7 +2,7 @@
|
|||
#
|
||||
# Disk Space Tests via check_disk
|
||||
#
|
||||
# $Id: check_disk.t,v 1.20 2007/03/30 09:00:06 psychotrahe Exp $
|
||||
# $Id: check_disk.t 1786 2007-09-22 17:40:35Z psychotrahe $
|
||||
#
|
||||
|
||||
# TODO: Add in tests for perf data. Need to beef up Nagios::Plugin::Performance to cater for max, min, etc
|
||||
|
@ -24,7 +24,7 @@ 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 => 68;
|
||||
plan tests => 78;
|
||||
}
|
||||
|
||||
$result = NPTest->testCmd(
|
||||
|
@ -114,10 +114,8 @@ 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";
|
||||
|
||||
|
||||
|
||||
|
@ -255,6 +253,7 @@ cmp_ok( $result->return_code, "==", 2, "100 GB empty" );
|
|||
# Checking old syntax of check_disk warn crit [fs], with warn/crit at USED% thresholds
|
||||
$result = NPTest->testCmd( "./check_disk 0 0 ".${mountpoint_valid} );
|
||||
cmp_ok( $result->return_code, "==", 2, "Old syntax: 0% used");
|
||||
like ( $result->only_output, qr(^[^;]*;[^;]*$), "Select only one path with positional arguments");
|
||||
|
||||
$result = NPTest->testCmd( "./check_disk 100 100 $mountpoint_valid" );
|
||||
cmp_ok( $result->return_code, '==', 0, "Old syntax: 100% used" );
|
||||
|
@ -276,7 +275,7 @@ TODO: {
|
|||
|
||||
$result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p /bob" );
|
||||
cmp_ok( $result->return_code, '==', 2, "Checking /bob - return error because /bob does not exist" );
|
||||
cmp_ok( $result->output, 'eq', 'DISK CRITICAL - /bob does not exist', 'Output OK');
|
||||
like( $result->output, '/^DISK CRITICAL - /bob is not accessible:.*$/', 'Output OK');
|
||||
|
||||
$result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p /" );
|
||||
my $root_output = $result->output;
|
||||
|
@ -285,9 +284,15 @@ $result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p /etc" );
|
|||
cmp_ok( $result->return_code, '==', 0, "Checking /etc - should return info for /" );
|
||||
cmp_ok( $result->output, 'eq', $root_output, "check_disk /etc gives same as check_disk /");
|
||||
|
||||
$result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p /etc -E" );
|
||||
$result = NPTest->testCmd( "./check_disk -w 0% -c 0% -E -p /etc " );
|
||||
cmp_ok( $result->return_code, '==', 2, "... unless -E/--exact-match is specified");
|
||||
|
||||
$result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p /etc -E " );
|
||||
cmp_ok( $result->return_code, '==', 3, "-E/--exact-match must be specified before -p");
|
||||
|
||||
$result = NPTest->testCmd( "./check_disk -w 0% -c 0% -r /etc -E " );
|
||||
cmp_ok( $result->return_code, '==', 3, "-E/--exact-match must be specified before -r");
|
||||
|
||||
$result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p / -p /bob" );
|
||||
cmp_ok( $result->return_code, '==', 2, "Checking / and /bob gives critical");
|
||||
unlike( $result->perf_output, '/\/bob/', "perf data does not have /bob in it");
|
||||
|
@ -319,3 +324,24 @@ cmp_ok( $result->return_code, '==', 3, "Invalid options: -p must come after grou
|
|||
$result = NPTest->testCmd( "./check_disk -w 1 -c 1 -r '('" );
|
||||
cmp_ok( $result->return_code, '==', 3, "Exit UNKNOWN if regex is not compileable");
|
||||
|
||||
# ignore: exit unknown, if all pathes are deselected using -i
|
||||
$result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p $mountpoint_valid -p $mountpoint2_valid -i '$mountpoint_valid' -i '$mountpoint2_valid'" );
|
||||
cmp_ok( $result->return_code, '==', 3, "ignore-ereg: Unknown if all fs are ignored (case sensitive)");
|
||||
|
||||
# ignore: exit unknown, if all pathes are deselected using -I
|
||||
$result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p $mountpoint_valid -p $mountpoint2_valid -I '".uc($mountpoint_valid)."' -I '".uc($mountpoint2_valid)."'" );
|
||||
cmp_ok( $result->return_code, '==', 3, "ignore-ereg: Unknown if all fs are ignored (case insensitive)");
|
||||
|
||||
# ignore: exit unknown, if all pathes are deselected using -i
|
||||
$result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p $mountpoint_valid -p $mountpoint2_valid -i '.*'" );
|
||||
cmp_ok( $result->return_code, '==', 3, "ignore-ereg: Unknown if all fs are ignored using -i '.*'");
|
||||
|
||||
# ignore: test if ignored path is actually ignored
|
||||
$result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p $mountpoint_valid -p $mountpoint2_valid -i '^$mountpoint2_valid\$'");
|
||||
like( $result->output, qr/$mountpoint_valid/, "output data does have $mountpoint_valid in it");
|
||||
unlike( $result->output, qr/$mountpoint2_valid/, "output data does not have $mountpoint2_valid in it");
|
||||
|
||||
# ignore: test if all pathes are listed when ignore regex doesn't match
|
||||
$result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p $mountpoint_valid -p $mountpoint2_valid -i '^barbazJodsf\$'");
|
||||
like( $result->output, qr/$mountpoint_valid/, "ignore: output data does have $mountpoint_valid when regex doesn't match");
|
||||
like( $result->output, qr/$mountpoint2_valid/,"ignore: output data does have $mountpoint2_valid when regex doesn't match");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue