diff options
author | Ton Voon <tonvoon@users.sourceforge.net> | 2006-04-19 09:33:44 +0000 |
---|---|---|
committer | Ton Voon <tonvoon@users.sourceforge.net> | 2006-04-19 09:33:44 +0000 |
commit | 37ebbab7fbd251c4c357459ff738847f5a5a4883 (patch) | |
tree | 2b4506f193ca22df0840ff04899b005372b87cc2 /plugins | |
parent | b298721e26c59fe00c3810b40d2bb9f3a08eb269 (diff) | |
download | monitoring-plugins-37ebbab7fbd251c4c357459ff738847f5a5a4883.tar.gz |
Fix check_nagios tests on MacOSX 10.4
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1382 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/t/check_nagios.t | 20 |
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"; | |||
18 | 18 | ||
19 | my $result; | 19 | my $result; |
20 | 20 | ||
21 | # Did use init, but MacOSX 10.4 replaces init with launchd | ||
22 | # Alternative is to insist that nagios is running to run this test | ||
23 | # Reasonable to expect cron because build servers will | ||
24 | # invoke cron to run a build | ||
25 | my $procname = "cron"; | ||
26 | |||
21 | $result = NPTest->testCmd( | 27 | $result = NPTest->testCmd( |
22 | "./check_nagios -F $nagios1 -e 5 -C init" | 28 | "./check_nagios -F $nagios1 -e 5 -C $procname" |
23 | ); | 29 | ); |
24 | cmp_ok( $result->return_code, '==', 1, "Log over 5 minutes old" ); | 30 | cmp_ok( $result->return_code, '==', 1, "Log over 5 minutes old" ); |
25 | like ( $result->output, $warningOutput, "Output for warning correct" ); | 31 | like ( $result->output, $warningOutput, "Output for warning correct" ); |
@@ -29,7 +35,7 @@ my $now = time; | |||
29 | system( "perl -pe 's/1133537544/$now/' $nagios1 > $nagios1.tmp" ) == 0 or die "Problem with munging $nagios1"; | 35 | system( "perl -pe 's/1133537544/$now/' $nagios1 > $nagios1.tmp" ) == 0 or die "Problem with munging $nagios1"; |
30 | 36 | ||
31 | $result = NPTest->testCmd( | 37 | $result = NPTest->testCmd( |
32 | "./check_nagios -F $nagios1.tmp -e 1 -C init" | 38 | "./check_nagios -F $nagios1.tmp -e 1 -C $procname" |
33 | ); | 39 | ); |
34 | cmp_ok( $result->return_code, "==", 0, "Log up to date" ); | 40 | cmp_ok( $result->return_code, "==", 0, "Log up to date" ); |
35 | like ( $result->output, $successOutput, "Output for success correct" ); | 41 | like ( $result->output, $successOutput, "Output for success correct" ); |
@@ -38,7 +44,7 @@ my $later = $now - 61; | |||
38 | system( "perl -pe 's/1133537544/$later/' $nagios1 > $nagios1.tmp" ) == 0 or die "Problem with munging $nagios1"; | 44 | system( "perl -pe 's/1133537544/$later/' $nagios1 > $nagios1.tmp" ) == 0 or die "Problem with munging $nagios1"; |
39 | 45 | ||
40 | $result = NPTest->testCmd( | 46 | $result = NPTest->testCmd( |
41 | "./check_nagios -F $nagios1.tmp -e 1 -C init" | 47 | "./check_nagios -F $nagios1.tmp -e 1 -C $procname" |
42 | ); | 48 | ); |
43 | cmp_ok( $result->return_code, "==", 1, "Log correctly seen as over 1 minute old" ); | 49 | cmp_ok( $result->return_code, "==", 1, "Log correctly seen as over 1 minute old" ); |
44 | my ($age) = ($_ = $result->output) =~ /status log updated (\d+) seconds ago/; | 50 | my ($age) = ($_ = $result->output) =~ /status log updated (\d+) seconds ago/; |
@@ -51,7 +57,7 @@ cmp_ok( $result->return_code, "==", 2, "Nagios command not found" ); | |||
51 | like ( $result->output, $failureOutput, "Output for failure correct" ); | 57 | like ( $result->output, $failureOutput, "Output for failure correct" ); |
52 | 58 | ||
53 | $result = NPTest->testCmd( | 59 | $result = NPTest->testCmd( |
54 | "./check_nagios -F $nagios2 -e 5 -C init" | 60 | "./check_nagios -F $nagios2 -e 5 -C $procname" |
55 | ); | 61 | ); |
56 | cmp_ok( $result->return_code, "==", 1, "Nagios2 for logfile over 5 mins old" ); | 62 | cmp_ok( $result->return_code, "==", 1, "Nagios2 for logfile over 5 mins old" ); |
57 | 63 | ||
@@ -59,7 +65,7 @@ $now = time; | |||
59 | system( "perl -pe 's/1133537302/$now/' $nagios2 > $nagios2.tmp" ) == 0 or die "Problem with munging $nagios2"; | 65 | system( "perl -pe 's/1133537302/$now/' $nagios2 > $nagios2.tmp" ) == 0 or die "Problem with munging $nagios2"; |
60 | 66 | ||
61 | $result = NPTest->testCmd( | 67 | $result = NPTest->testCmd( |
62 | "./check_nagios -F $nagios2.tmp -e 1 -C init" | 68 | "./check_nagios -F $nagios2.tmp -e 1 -C $procname" |
63 | ); | 69 | ); |
64 | cmp_ok( $result->return_code, "==", 0, "Nagios2 log up to date" ); | 70 | cmp_ok( $result->return_code, "==", 0, "Nagios2 log up to date" ); |
65 | 71 | ||
@@ -67,14 +73,14 @@ $later = $now - 61; | |||
67 | system( "perl -pe 's/1133537302/$later/' $nagios2 > $nagios2.tmp" ) == 0 or die "Problem with munging $nagios2"; | 73 | system( "perl -pe 's/1133537302/$later/' $nagios2 > $nagios2.tmp" ) == 0 or die "Problem with munging $nagios2"; |
68 | 74 | ||
69 | $result = NPTest->testCmd( | 75 | $result = NPTest->testCmd( |
70 | "./check_nagios -F $nagios2.tmp -e 1 -C init" | 76 | "./check_nagios -F $nagios2.tmp -e 1 -C $procname" |
71 | ); | 77 | ); |
72 | cmp_ok( $result->return_code, "==", 1, "Nagios2 log correctly seen as over 1 minute old" ); | 78 | cmp_ok( $result->return_code, "==", 1, "Nagios2 log correctly seen as over 1 minute old" ); |
73 | ($age) = ($_ = $result->output) =~ /status log updated (\d+) seconds ago/; | 79 | ($age) = ($_ = $result->output) =~ /status log updated (\d+) seconds ago/; |
74 | like( $age, '/^6[0-9]$/', "Log correctly seen as between 60-69 seconds old" ); | 80 | like( $age, '/^6[0-9]$/', "Log correctly seen as between 60-69 seconds old" ); |
75 | 81 | ||
76 | $result = NPTest->testCmd( | 82 | $result = NPTest->testCmd( |
77 | "./check_nagios -F t/check_nagios.t -e 1 -C init" | 83 | "./check_nagios -F t/check_nagios.t -e 1 -C $procname" |
78 | ); | 84 | ); |
79 | cmp_ok( $result->return_code, "==", 2, "Invalid log file" ); | 85 | cmp_ok( $result->return_code, "==", 2, "Invalid log file" ); |
80 | 86 | ||