[monitoring-plugins] check_disk: add tests for new option ...

Kristian Schuster git at monitoring-plugins.org
Sat Mar 11 10:30:12 CET 2023


 Module: monitoring-plugins
 Branch: master
 Commit: 0d562a356f45f645014c3908178fc13876006f6e
 Author: Kristian Schuster <116557017+KriSchu at users.noreply.github.com>
   Date: Tue Oct 25 20:49:51 2022 +0200
    URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=0d562a3

check_disk: add tests for new option --ignore-missing

---

 plugins/t/check_disk.t | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/plugins/t/check_disk.t b/plugins/t/check_disk.t
index ec527e7..bea34a4 100644
--- a/plugins/t/check_disk.t
+++ b/plugins/t/check_disk.t
@@ -351,3 +351,18 @@ unlike( $result->output, qr/$mountpoint2_valid/, "output data does not have $mou
 $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");
+
+# ignore-missing: exit okay, when fs is not accessible
+$result = NPTest->testCmd( "./check_disk --ignore-missing -w 0% -c 0% -p /bob");
+cmp_ok( $result->return_code, '==', 0, "ignore-missing: return okay for not existing filesystem /bob");
+like( $result->output, '/^DISK OK - /bob is not accessible .*$/', 'Output OK');
+
+# ignore-missing: exit okay, when regex does not match
+$result = NPTest->testCmd( "./check_disk --ignore-missing -w 0% -c 0% -r /bob");
+cmp_ok( $result->return_code, '==', 0, "ignore-missing: return okay for regular expression not matching");
+like( $result->output, '/^DISK OK: Regular expression did not match any path or disk.*$/', 'Output OK');
+
+# ignore-missing: exit okay, when fs with exact match (-E) is not found
+$result = NPTest->testCmd( "./check_disk --ignore-missing -E -w 0% -c 0% -p /etc");
+cmp_ok( $result->return_code, '==', 0, "ignore-missing: return okay when exact match does not find fs");
+like( $result->output, '/^DISK OK: /etc not found.*$/', 'Output OK');



More information about the Commits mailing list