summaryrefslogtreecommitdiffstats
path: root/plugins/t
diff options
context:
space:
mode:
authorMatthias Eble <psychotrahe@users.sourceforge.net>2007-09-22 17:40:35 (GMT)
committerMatthias Eble <psychotrahe@users.sourceforge.net>2007-09-22 17:40:35 (GMT)
commitd23b17e6567d8eb983956b36b31a383f3cc639d2 (patch)
tree19ba67a6555bb609875f819af5c4b9c479101820 /plugins/t
parent520f297fa931d391f81af672b5b0e34db71b8c73 (diff)
downloadmonitoring-plugins-d23b17e6567d8eb983956b36b31a383f3cc639d2.tar.gz
Added -i/-I to ignore pathes/partitions based on regular expressions
Added check_disk -A selecting all filesystems -E option must now be passed before -p or -r/-R Passing -E after -p or -r results in UNKNOWN state Fixed bug when mixing case sensitive and insensitive regexes git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1786 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/t')
-rw-r--r--plugins/t/check_disk.t31
1 files changed, 29 insertions, 2 deletions
diff --git a/plugins/t/check_disk.t b/plugins/t/check_disk.t
index 4f5c4bc..99c434a 100644
--- a/plugins/t/check_disk.t
+++ b/plugins/t/check_disk.t
@@ -24,7 +24,7 @@ my $mountpoint2_valid = getTestParameter( "NP_MOUNTPOINT2_VALID", "Path to anoth
24if ($mountpoint_valid eq "" or $mountpoint2_valid eq "") { 24if ($mountpoint_valid eq "" or $mountpoint2_valid eq "") {
25 plan skip_all => "Need 2 mountpoints to test"; 25 plan skip_all => "Need 2 mountpoints to test";
26} else { 26} else {
27 plan tests => 69; 27 plan tests => 78;
28} 28}
29 29
30$result = NPTest->testCmd( 30$result = NPTest->testCmd(
@@ -284,9 +284,15 @@ $result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p /etc" );
284cmp_ok( $result->return_code, '==', 0, "Checking /etc - should return info for /" ); 284cmp_ok( $result->return_code, '==', 0, "Checking /etc - should return info for /" );
285cmp_ok( $result->output, 'eq', $root_output, "check_disk /etc gives same as check_disk /"); 285cmp_ok( $result->output, 'eq', $root_output, "check_disk /etc gives same as check_disk /");
286 286
287$result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p /etc -E" ); 287$result = NPTest->testCmd( "./check_disk -w 0% -c 0% -E -p /etc " );
288cmp_ok( $result->return_code, '==', 2, "... unless -E/--exact-match is specified"); 288cmp_ok( $result->return_code, '==', 2, "... unless -E/--exact-match is specified");
289 289
290$result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p /etc -E " );
291cmp_ok( $result->return_code, '==', 3, "-E/--exact-match must be specified before -p");
292
293$result = NPTest->testCmd( "./check_disk -w 0% -c 0% -r /etc -E " );
294cmp_ok( $result->return_code, '==', 3, "-E/--exact-match must be specified before -r");
295
290$result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p / -p /bob" ); 296$result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p / -p /bob" );
291cmp_ok( $result->return_code, '==', 2, "Checking / and /bob gives critical"); 297cmp_ok( $result->return_code, '==', 2, "Checking / and /bob gives critical");
292unlike( $result->perf_output, '/\/bob/', "perf data does not have /bob in it"); 298unlike( $result->perf_output, '/\/bob/', "perf data does not have /bob in it");
@@ -318,3 +324,24 @@ cmp_ok( $result->return_code, '==', 3, "Invalid options: -p must come after grou
318$result = NPTest->testCmd( "./check_disk -w 1 -c 1 -r '('" ); 324$result = NPTest->testCmd( "./check_disk -w 1 -c 1 -r '('" );
319cmp_ok( $result->return_code, '==', 3, "Exit UNKNOWN if regex is not compileable"); 325cmp_ok( $result->return_code, '==', 3, "Exit UNKNOWN if regex is not compileable");
320 326
327# ignore: exit unknown, if all pathes are deselected using -i
328$result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p $mountpoint_valid -p $mountpoint2_valid -i '$mountpoint_valid' -i '$mountpoint2_valid'" );
329cmp_ok( $result->return_code, '==', 3, "ignore-ereg: Unknown if all fs are ignored (case sensitive)");
330
331# ignore: exit unknown, if all pathes are deselected using -I
332$result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p $mountpoint_valid -p $mountpoint2_valid -I '".uc($mountpoint_valid)."' -I '".uc($mountpoint2_valid)."'" );
333cmp_ok( $result->return_code, '==', 3, "ignore-ereg: Unknown if all fs are ignored (case insensitive)");
334
335# ignore: exit unknown, if all pathes are deselected using -i
336$result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p $mountpoint_valid -p $mountpoint2_valid -i '.*'" );
337cmp_ok( $result->return_code, '==', 3, "ignore-ereg: Unknown if all fs are ignored using -i '.*'");
338
339# ignore: test if ignored path is actually ignored
340$result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p $mountpoint_valid -p $mountpoint2_valid -i '^$mountpoint2_valid\$'");
341like( $result->output, qr/$mountpoint_valid/, "output data does have $mountpoint_valid in it");
342unlike( $result->output, qr/$mountpoint2_valid/, "output data does not have $mountpoint2_valid in it");
343
344# ignore: test if all pathes are listed when ignore regex doesn't match
345$result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p $mountpoint_valid -p $mountpoint2_valid -i '^barbazJodsf\$'");
346like( $result->output, qr/$mountpoint_valid/, "ignore: output data does have $mountpoint_valid when regex doesn't match");
347like( $result->output, qr/$mountpoint2_valid/,"ignore: output data does have $mountpoint2_valid when regex doesn't match");