diff options
Diffstat (limited to 'plugins-scripts/t/check_uptime.t')
-rw-r--r-- | plugins-scripts/t/check_uptime.t | 58 |
1 files changed, 57 insertions, 1 deletions
diff --git a/plugins-scripts/t/check_uptime.t b/plugins-scripts/t/check_uptime.t index 4606718..c395307 100644 --- a/plugins-scripts/t/check_uptime.t +++ b/plugins-scripts/t/check_uptime.t | |||
@@ -5,7 +5,7 @@ | |||
5 | # | 5 | # |
6 | 6 | ||
7 | use strict; | 7 | use strict; |
8 | use Test::More tests => 21; | 8 | use Test::More tests => 40; |
9 | use NPTest; | 9 | use NPTest; |
10 | 10 | ||
11 | my $result; | 11 | my $result; |
@@ -71,3 +71,59 @@ cmp_ok( $result->return_code, '==', 0, "Uptime lower than 111222 days" ); | |||
71 | like ( $result->output, '/^OK: uptime is \d+ seconds/', "Output for uptime lower than 111222 days correct" ); | 71 | like ( $result->output, '/^OK: uptime is \d+ seconds/', "Output for uptime lower than 111222 days correct" ); |
72 | like ( $result->output, '/\|uptime=[0-9]+s;9609580800;19209571200;/', "Checking for performance output" ); | 72 | like ( $result->output, '/\|uptime=[0-9]+s;9609580800;19209571200;/', "Checking for performance output" ); |
73 | 73 | ||
74 | # Same as before, hopefully uptime is higher than 2 seconds so no warning | ||
75 | $result = NPTest->testCmd( | ||
76 | "./check_uptime -w 2:111222d -c 1:222333d" | ||
77 | ); | ||
78 | cmp_ok( $result->return_code, '==', 0, "Uptime lower than 111222 days, and higher 2 seconds" ); | ||
79 | like ( $result->output, '/^OK: uptime is \d+ seconds/', "Output for uptime lower than 111222 days, and higher 2 seconds correct" ); | ||
80 | like ( $result->output, '/\|uptime=[0-9]+s;9609580800;19209571200;/', "Checking for performance output" ); | ||
81 | |||
82 | # Same as before, now the low warning should trigger | ||
83 | $result = NPTest->testCmd( | ||
84 | "./check_uptime -w 111221d:111222d -c 1:222333d" | ||
85 | ); | ||
86 | cmp_ok( $result->return_code, '==', 1, "Uptime lower than 111221 days raises warning" ); | ||
87 | like ( $result->output, '/^WARNING: uptime is \d+ seconds/', "Output for uptime lower than 111221 days correct" ); | ||
88 | like ( $result->output, '/Exceeds lower warn threshold/', "Exceeds text correct" ); | ||
89 | like ( $result->output, '/\|uptime=[0-9]+s;9609580800;19209571200;/', "Checking for performance output" ); | ||
90 | |||
91 | # Same as before, now the low critical should trigger | ||
92 | $result = NPTest->testCmd( | ||
93 | "./check_uptime -w 111221d:111222d -c 111220d:222333d" | ||
94 | ); | ||
95 | cmp_ok( $result->return_code, '==', 2, "Uptime lower than 111220 days raises critical" ); | ||
96 | like ( $result->output, '/^CRITICAL: uptime is \d+ seconds/', "Output for uptime lower than 111220 days correct" ); | ||
97 | like ( $result->output, '/Exceeds lower crit threshold/', "Exceeds text correct" ); | ||
98 | like ( $result->output, '/\|uptime=[0-9]+s;9609580800;19209571200;/', "Checking for performance output" ); | ||
99 | |||
100 | |||
101 | # | ||
102 | # Range values using ":" without two parts ("a:b") is invalid | ||
103 | # Strings without two parts are always considered as upper threshold | ||
104 | # | ||
105 | |||
106 | $result = NPTest->testCmd( | ||
107 | "./check_uptime -w 2: -c 1:4" | ||
108 | ); | ||
109 | cmp_ok( $result->return_code, '==', 3, "Wrong parameter format raises unknown" ); | ||
110 | like ( $result->output, '/^Upper warning .* is not numeric/', "Output for wrong parameter format correct" ); | ||
111 | |||
112 | $result = NPTest->testCmd( | ||
113 | "./check_uptime -w 2:3 -c 1:" | ||
114 | ); | ||
115 | cmp_ok( $result->return_code, '==', 3, "Wrong parameter format raises unknown" ); | ||
116 | like ( $result->output, '/^Upper critical .* is not numeric/', "Output for wrong parameter format correct" ); | ||
117 | |||
118 | $result = NPTest->testCmd( | ||
119 | "./check_uptime -w :3 -c 1:4" | ||
120 | ); | ||
121 | cmp_ok( $result->return_code, '==', 3, "Wrong parameter format raises unknown" ); | ||
122 | like ( $result->output, '/^Upper warning .* is not numeric/', "Output for wrong parameter format correct" ); | ||
123 | |||
124 | $result = NPTest->testCmd( | ||
125 | "./check_uptime -w 2:3 -c :4" | ||
126 | ); | ||
127 | cmp_ok( $result->return_code, '==', 3, "Wrong parameter format raises unknown" ); | ||
128 | like ( $result->output, '/^Upper critical .* is not numeric/', "Output for wrong parameter format correct" ); | ||
129 | |||