diff options
author | Thomas Guyot-Sionnest <dermoth@users.sourceforge.net> | 2007-05-02 05:22:31 (GMT) |
---|---|---|
committer | Thomas Guyot-Sionnest <dermoth@users.sourceforge.net> | 2007-05-02 05:22:31 (GMT) |
commit | 3013b406f002aaefce9cda35c2486ab1ff2d3892 (patch) | |
tree | a7aa5b84cc32e743cf59240bb8a20ccd356d6d3c | |
parent | 14dd02c058bc34b7b47c31556b7cacaa4ea0942b (diff) | |
download | monitoring-plugins-3013b406f002aaefce9cda35c2486ab1ff2d3892.tar.gz |
Fix check_time returning wrong OK when time is before the epoch on some arch
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1703 f882894a-f735-0410-b71e-b25c423dba1c
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | THANKS.in | 1 | ||||
-rw-r--r-- | plugins/check_time.c | 14 |
3 files changed, 9 insertions, 7 deletions
@@ -6,6 +6,7 @@ This file documents the major additions and syntax changes between releases. | |||
6 | check_snmp now support Counter64 | 6 | check_snmp now support Counter64 |
7 | Fix compilation of check_ldap, check_radius and check_pgsql | 7 | Fix compilation of check_ldap, check_radius and check_pgsql |
8 | check_load can optionally divide by number of cpus | 8 | check_load can optionally divide by number of cpus |
9 | Fix check_time returning wrong OK when time is before the epoch on some arch | ||
9 | 10 | ||
10 | 1.4.8 11th April 2007 | 11 | 1.4.8 11th April 2007 |
11 | Respects --without-world-permissions for setuid plugins | 12 | Respects --without-world-permissions for setuid plugins |
@@ -216,3 +216,4 @@ Stefan Meier | |||
216 | Mark Favas | 216 | Mark Favas |
217 | Felix Frank | 217 | Felix Frank |
218 | Denis Knauf | 218 | Denis Knauf |
219 | Matthias Flacke | ||
diff --git a/plugins/check_time.c b/plugins/check_time.c index d3af3b0..581c42a 100644 --- a/plugins/check_time.c +++ b/plugins/check_time.c | |||
@@ -49,8 +49,8 @@ enum { | |||
49 | 49 | ||
50 | #define UNIX_EPOCH 2208988800UL | 50 | #define UNIX_EPOCH 2208988800UL |
51 | 51 | ||
52 | uint32_t server_time, raw_server_time; | 52 | uint32_t raw_server_time; |
53 | time_t diff_time; | 53 | unsigned long server_time, diff_time; |
54 | int warning_time = 0; | 54 | int warning_time = 0; |
55 | int check_warning_time = FALSE; | 55 | int check_warning_time = FALSE; |
56 | int critical_time = 0; | 56 | int critical_time = 0; |
@@ -166,9 +166,9 @@ main (int argc, char **argv) | |||
166 | else | 166 | else |
167 | diff_time = (unsigned long)end_time - server_time; | 167 | diff_time = (unsigned long)end_time - server_time; |
168 | 168 | ||
169 | if (check_critical_diff == TRUE && diff_time > (time_t)critical_diff) | 169 | if (check_critical_diff == TRUE && diff_time > critical_diff) |
170 | result = STATE_CRITICAL; | 170 | result = STATE_CRITICAL; |
171 | else if (check_warning_diff == TRUE && diff_time > (time_t)warning_diff) | 171 | else if (check_warning_diff == TRUE && diff_time > warning_diff) |
172 | result = STATE_WARNING; | 172 | result = STATE_WARNING; |
173 | 173 | ||
174 | printf (_("TIME %s - %lu second time difference|%s %s\n"), | 174 | printf (_("TIME %s - %lu second time difference|%s %s\n"), |
@@ -177,9 +177,9 @@ main (int argc, char **argv) | |||
177 | check_warning_time, (long)warning_time, | 177 | check_warning_time, (long)warning_time, |
178 | check_critical_time, (long)critical_time, | 178 | check_critical_time, (long)critical_time, |
179 | TRUE, 0, FALSE, 0), | 179 | TRUE, 0, FALSE, 0), |
180 | perfdata ("offset", (long)diff_time, "s", | 180 | perfdata ("offset", diff_time, "s", |
181 | check_warning_diff, (long)warning_diff, | 181 | check_warning_diff, warning_diff, |
182 | check_critical_diff, (long)critical_diff, | 182 | check_critical_diff, critical_diff, |
183 | TRUE, 0, FALSE, 0)); | 183 | TRUE, 0, FALSE, 0)); |
184 | return result; | 184 | return result; |
185 | } | 185 | } |