aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/t/check_nagios.t20
1 files changed, 13 insertions, 7 deletions
diff --git a/plugins/t/check_nagios.t b/plugins/t/check_nagios.t
index 7722071d..bdb444f4 100644
--- a/plugins/t/check_nagios.t
+++ b/plugins/t/check_nagios.t
@@ -18,8 +18,14 @@ my $nagios2 = "t/check_nagios.nagios2.status.dat";
my $result;
+# Did use init, but MacOSX 10.4 replaces init with launchd
+# Alternative is to insist that nagios is running to run this test
+# Reasonable to expect cron because build servers will
+# invoke cron to run a build
+my $procname = "cron";
+
$result = NPTest->testCmd(
- "./check_nagios -F $nagios1 -e 5 -C init"
+ "./check_nagios -F $nagios1 -e 5 -C $procname"
);
cmp_ok( $result->return_code, '==', 1, "Log over 5 minutes old" );
like ( $result->output, $warningOutput, "Output for warning correct" );
@@ -29,7 +35,7 @@ my $now = time;
system( "perl -pe 's/1133537544/$now/' $nagios1 > $nagios1.tmp" ) == 0 or die "Problem with munging $nagios1";
$result = NPTest->testCmd(
- "./check_nagios -F $nagios1.tmp -e 1 -C init"
+ "./check_nagios -F $nagios1.tmp -e 1 -C $procname"
);
cmp_ok( $result->return_code, "==", 0, "Log up to date" );
like ( $result->output, $successOutput, "Output for success correct" );
@@ -38,7 +44,7 @@ my $later = $now - 61;
system( "perl -pe 's/1133537544/$later/' $nagios1 > $nagios1.tmp" ) == 0 or die "Problem with munging $nagios1";
$result = NPTest->testCmd(
- "./check_nagios -F $nagios1.tmp -e 1 -C init"
+ "./check_nagios -F $nagios1.tmp -e 1 -C $procname"
);
cmp_ok( $result->return_code, "==", 1, "Log correctly seen as over 1 minute old" );
my ($age) = ($_ = $result->output) =~ /status log updated (\d+) seconds ago/;
@@ -51,7 +57,7 @@ cmp_ok( $result->return_code, "==", 2, "Nagios command not found" );
like ( $result->output, $failureOutput, "Output for failure correct" );
$result = NPTest->testCmd(
- "./check_nagios -F $nagios2 -e 5 -C init"
+ "./check_nagios -F $nagios2 -e 5 -C $procname"
);
cmp_ok( $result->return_code, "==", 1, "Nagios2 for logfile over 5 mins old" );
@@ -59,7 +65,7 @@ $now = time;
system( "perl -pe 's/1133537302/$now/' $nagios2 > $nagios2.tmp" ) == 0 or die "Problem with munging $nagios2";
$result = NPTest->testCmd(
- "./check_nagios -F $nagios2.tmp -e 1 -C init"
+ "./check_nagios -F $nagios2.tmp -e 1 -C $procname"
);
cmp_ok( $result->return_code, "==", 0, "Nagios2 log up to date" );
@@ -67,14 +73,14 @@ $later = $now - 61;
system( "perl -pe 's/1133537302/$later/' $nagios2 > $nagios2.tmp" ) == 0 or die "Problem with munging $nagios2";
$result = NPTest->testCmd(
- "./check_nagios -F $nagios2.tmp -e 1 -C init"
+ "./check_nagios -F $nagios2.tmp -e 1 -C $procname"
);
cmp_ok( $result->return_code, "==", 1, "Nagios2 log correctly seen as over 1 minute old" );
($age) = ($_ = $result->output) =~ /status log updated (\d+) seconds ago/;
like( $age, '/^6[0-9]$/', "Log correctly seen as between 60-69 seconds old" );
$result = NPTest->testCmd(
- "./check_nagios -F t/check_nagios.t -e 1 -C init"
+ "./check_nagios -F t/check_nagios.t -e 1 -C $procname"
);
cmp_ok( $result->return_code, "==", 2, "Invalid log file" );