diff options
-rw-r--r-- | plugins/check_disk.c | 10 | ||||
-rw-r--r-- | plugins/t/check_disk.t | 8 |
2 files changed, 9 insertions, 9 deletions
diff --git a/plugins/check_disk.c b/plugins/check_disk.c index d32841d..c52d1df 100644 --- a/plugins/check_disk.c +++ b/plugins/check_disk.c | |||
@@ -186,8 +186,8 @@ main (int argc, char **argv) | |||
186 | char mountdir[32]; | 186 | char mountdir[32]; |
187 | #endif | 187 | #endif |
188 | 188 | ||
189 | preamble = strdup (" free space:"); | 189 | preamble = strdup (" - free space:"); |
190 | ignored_preamble = strdup (" ignored paths:"); | 190 | ignored_preamble = strdup (" - ignored paths:"); |
191 | output = strdup (""); | 191 | output = strdup (""); |
192 | ignored = strdup (""); | 192 | ignored = strdup (""); |
193 | details = strdup (""); | 193 | details = strdup (""); |
@@ -455,12 +455,12 @@ main (int argc, char **argv) | |||
455 | if (verbose >= 2) | 455 | if (verbose >= 2) |
456 | xasprintf (&output, "%s%s", output, details); | 456 | xasprintf (&output, "%s%s", output, details); |
457 | 457 | ||
458 | if (strcmp(output, "") == 0) { | 458 | if (strcmp(output, "") == 0 && ! erronly) { |
459 | preamble = ""; | 459 | preamble = ""; |
460 | xasprintf (&output, " No disks were found for provided parameters;"); | 460 | xasprintf (&output, " - No disks were found for provided parameters;"); |
461 | } | 461 | } |
462 | 462 | ||
463 | printf ("DISK %s -%s%s%s%s|%s\n", state_text (result), ((erronly && result==STATE_OK)) ? "" : preamble, output, (strcmp(ignored, "") == 0) ? "" : ignored_preamble, ignored, perf); | 463 | printf ("DISK %s%s%s%s%s|%s\n", state_text (result), ((erronly && result==STATE_OK)) ? "" : preamble, output, (strcmp(ignored, "") == 0) ? "" : ignored_preamble, ignored, perf); |
464 | return result; | 464 | return result; |
465 | } | 465 | } |
466 | 466 | ||
diff --git a/plugins/t/check_disk.t b/plugins/t/check_disk.t index 73f1e37..c8f08f5 100644 --- a/plugins/t/check_disk.t +++ b/plugins/t/check_disk.t | |||
@@ -126,7 +126,7 @@ my $free_mb_on_all = $free_mb_on_mp1 + $free_mb_on_mp2; | |||
126 | 126 | ||
127 | 127 | ||
128 | $result = NPTest->testCmd( "./check_disk -e -w 1 -c 1 -p $more_free" ); | 128 | $result = NPTest->testCmd( "./check_disk -e -w 1 -c 1 -p $more_free" ); |
129 | is( $result->only_output, "DISK OK - No disks were found for provided parameters;", "No print out of disks with -e for OKs"); | 129 | is( $result->only_output, "DISK OK", "No print out of disks with -e for OKs"); |
130 | 130 | ||
131 | $result = NPTest->testCmd( "./check_disk 100 100 $more_free" ); | 131 | $result = NPTest->testCmd( "./check_disk 100 100 $more_free" ); |
132 | cmp_ok( $result->return_code, '==', 0, "Old syntax okay" ); | 132 | cmp_ok( $result->return_code, '==', 0, "Old syntax okay" ); |
@@ -355,7 +355,7 @@ like( $result->output, qr/$mountpoint2_valid/,"ignore: output data does have $mo | |||
355 | # ignore-missing: exit okay, when fs is not accessible | 355 | # ignore-missing: exit okay, when fs is not accessible |
356 | $result = NPTest->testCmd( "./check_disk --ignore-missing -w 0% -c 0% -p /bob"); | 356 | $result = NPTest->testCmd( "./check_disk --ignore-missing -w 0% -c 0% -p /bob"); |
357 | cmp_ok( $result->return_code, '==', 0, "ignore-missing: return okay for not existing filesystem /bob"); | 357 | cmp_ok( $result->return_code, '==', 0, "ignore-missing: return okay for not existing filesystem /bob"); |
358 | like( $result->output, '/^DISK OK - No disks were found for provided parameters; ignored paths: /bob;.*$/', 'Output OK'); | 358 | like( $result->output, '/^DISK OK - No disks were found for provided parameters; - ignored paths: /bob;.*$/', 'Output OK'); |
359 | 359 | ||
360 | # ignore-missing: exit okay, when regex does not match | 360 | # ignore-missing: exit okay, when regex does not match |
361 | $result = NPTest->testCmd( "./check_disk --ignore-missing -w 0% -c 0% -r /bob"); | 361 | $result = NPTest->testCmd( "./check_disk --ignore-missing -w 0% -c 0% -r /bob"); |
@@ -365,7 +365,7 @@ like( $result->output, '/^DISK OK - No disks were found for provided parameters; | |||
365 | # ignore-missing: exit okay, when fs with exact match (-E) is not found | 365 | # ignore-missing: exit okay, when fs with exact match (-E) is not found |
366 | $result = NPTest->testCmd( "./check_disk --ignore-missing -w 0% -c 0% -E -p /etc"); | 366 | $result = NPTest->testCmd( "./check_disk --ignore-missing -w 0% -c 0% -E -p /etc"); |
367 | cmp_ok( $result->return_code, '==', 0, "ignore-missing: return okay when exact match does not find fs"); | 367 | cmp_ok( $result->return_code, '==', 0, "ignore-missing: return okay when exact match does not find fs"); |
368 | like( $result->output, '/^DISK OK - No disks were found for provided parameters; ignored paths: /etc;.*$/', 'Output OK'); | 368 | like( $result->output, '/^DISK OK - No disks were found for provided parameters; - ignored paths: /etc;.*$/', 'Output OK'); |
369 | 369 | ||
370 | # ignore-missing: exit okay, when checking one existing fs and one non-existing fs (regex) | 370 | # ignore-missing: exit okay, when checking one existing fs and one non-existing fs (regex) |
371 | $result = NPTest->testCmd( "./check_disk --ignore-missing -w 0% -c 0% -r '/bob' -r '^/\$'"); | 371 | $result = NPTest->testCmd( "./check_disk --ignore-missing -w 0% -c 0% -r '/bob' -r '^/\$'"); |
@@ -375,4 +375,4 @@ like( $result->output, '/^DISK OK - free space: \/ .*$/', 'Output OK'); | |||
375 | # ignore-missing: exit okay, when checking one existing fs and one non-existing fs (path) | 375 | # ignore-missing: exit okay, when checking one existing fs and one non-existing fs (path) |
376 | $result = NPTest->testCmd( "./check_disk --ignore-missing -w 0% -c 0% -p '/bob' -p '/'"); | 376 | $result = NPTest->testCmd( "./check_disk --ignore-missing -w 0% -c 0% -p '/bob' -p '/'"); |
377 | cmp_ok( $result->return_code, '==', 0, "ignore-missing: return okay for regular expression not matching"); | 377 | cmp_ok( $result->return_code, '==', 0, "ignore-missing: return okay for regular expression not matching"); |
378 | like( $result->output, '/^DISK OK - free space: / .*; ignored paths: /bob;.*$/', 'Output OK'); \ No newline at end of file | 378 | like( $result->output, '/^DISK OK - free space: / .*; - ignored paths: /bob;.*$/', 'Output OK'); \ No newline at end of file |