From 0b9b300f856d021b56950030f4e6053d84bc77c8 Mon Sep 17 00:00:00 2001 From: Jan Wagner Date: Tue, 1 Oct 2013 01:38:45 +0200 Subject: check_file_age: support for --ignore-missing Patch to provide for a -i | --ignore-missing option. This allows files that don't exist to be monitored for without causing an error. The use case is: * one process periodically pushes files to an "input" queue for a second process * the second process, when running cleanly will "consume" (process and remove) these files So the conditions to meet are: 1. If the file doesn't exist, that's fine (OK) 2. If the file exists, but is less than X seconds, that's fine (OK) 3. If the file exists, but greater than X seconds, no good (CRITICAL) Since now check_file_age doesn't permit this behavior, as a non-existent file is considered CRITICAL. Test case was contributed by our lovely Holger. Closes #1181, Closes #989, Closes #862, Closes #1187, Closes #845 Closes Debian Bug #496307 --- plugins-scripts/t/check_file_age.t | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'plugins-scripts/t') diff --git a/plugins-scripts/t/check_file_age.t b/plugins-scripts/t/check_file_age.t index 384c276b..a5156491 100644 --- a/plugins-scripts/t/check_file_age.t +++ b/plugins-scripts/t/check_file_age.t @@ -5,7 +5,7 @@ # use strict; -use Test::More tests => 15; +use Test::More tests => 16; use NPTest; my $successOutput = '/^FILE_AGE OK: /'; @@ -57,6 +57,11 @@ $result = NPTest->testCmd( ); cmp_ok( $result->return_code, '==', 0, "Checking file size" ); +$result = NPTest->testCmd( + "./check_file_age -f /non/existent --ignore-missing" + ); +cmp_ok( $result->return_code, '==', 0, "Honours --ignore-missing" ); + $result = NPTest->testCmd( "./check_file_age -f $temp_file -c 1000 -W 101" ); -- cgit v1.2.3