diff options
Diffstat (limited to 'plugins/t')
0 files changed, 0 insertions, 0 deletions
diff --git a/plugins/check_time.c b/plugins/check_time.c index baf8c59..f50ea42 100644 --- a/plugins/check_time.c +++ b/plugins/check_time.c | |||
@@ -45,16 +45,16 @@ enum { | |||
45 | uint32_t raw_server_time; | 45 | uint32_t raw_server_time; |
46 | unsigned long server_time, diff_time; | 46 | unsigned long server_time, diff_time; |
47 | int warning_time = 0; | 47 | int warning_time = 0; |
48 | int check_warning_time = FALSE; | 48 | bool check_warning_time = false; |
49 | int critical_time = 0; | 49 | int critical_time = 0; |
50 | int check_critical_time = FALSE; | 50 | bool check_critical_time = false; |
51 | unsigned long warning_diff = 0; | 51 | unsigned long warning_diff = 0; |
52 | int check_warning_diff = FALSE; | 52 | bool check_warning_diff = false; |
53 | unsigned long critical_diff = 0; | 53 | unsigned long critical_diff = 0; |
54 | int check_critical_diff = FALSE; | 54 | bool check_critical_diff = false; |
55 | int server_port = TIME_PORT; | 55 | int server_port = TIME_PORT; |
56 | char *server_address = NULL; | 56 | char *server_address = NULL; |
57 | int use_udp = FALSE; | 57 | bool use_udp = false; |
58 | 58 | ||
59 | int process_arguments (int, char **); | 59 | int process_arguments (int, char **); |
60 | void print_help (void); | 60 | void print_help (void); |
@@ -92,9 +92,9 @@ main (int argc, char **argv) | |||
92 | } | 92 | } |
93 | 93 | ||
94 | if (result != STATE_OK) { | 94 | if (result != STATE_OK) { |
95 | if (check_critical_time == TRUE) | 95 | if (check_critical_time) |
96 | result = STATE_CRITICAL; | 96 | result = STATE_CRITICAL; |
97 | else if (check_warning_time == TRUE) | 97 | else if (check_warning_time) |
98 | result = STATE_WARNING; | 98 | result = STATE_WARNING; |
99 | else | 99 | else |
100 | result = STATE_UNKNOWN; | 100 | result = STATE_UNKNOWN; |
@@ -105,9 +105,9 @@ main (int argc, char **argv) | |||
105 | 105 | ||
106 | if (use_udp) { | 106 | if (use_udp) { |
107 | if (send (sd, "", 0, 0) < 0) { | 107 | if (send (sd, "", 0, 0) < 0) { |
108 | if (check_critical_time == TRUE) | 108 | if (check_critical_time) |
109 | result = STATE_CRITICAL; | 109 | result = STATE_CRITICAL; |
110 | else if (check_warning_time == TRUE) | 110 | else if (check_warning_time) |
111 | result = STATE_WARNING; | 111 | result = STATE_WARNING; |
112 | else | 112 | else |
113 | result = STATE_UNKNOWN; | 113 | result = STATE_UNKNOWN; |
@@ -129,9 +129,9 @@ main (int argc, char **argv) | |||
129 | 129 | ||
130 | /* return a WARNING status if we couldn't read any data */ | 130 | /* return a WARNING status if we couldn't read any data */ |
131 | if (result <= 0) { | 131 | if (result <= 0) { |
132 | if (check_critical_time == TRUE) | 132 | if (check_critical_time) |
133 | result = STATE_CRITICAL; | 133 | result = STATE_CRITICAL; |
134 | else if (check_warning_time == TRUE) | 134 | else if (check_warning_time) |
135 | result = STATE_WARNING; | 135 | result = STATE_WARNING; |
136 | else | 136 | else |
137 | result = STATE_UNKNOWN; | 137 | result = STATE_UNKNOWN; |
@@ -143,9 +143,9 @@ main (int argc, char **argv) | |||
143 | result = STATE_OK; | 143 | result = STATE_OK; |
144 | 144 | ||
145 | conntime = (end_time - start_time); | 145 | conntime = (end_time - start_time); |
146 | if (check_critical_time == TRUE && conntime > critical_time) | 146 | if (check_critical_time&& conntime > critical_time) |
147 | result = STATE_CRITICAL; | 147 | result = STATE_CRITICAL; |
148 | else if (check_warning_time == TRUE && conntime > warning_time) | 148 | else if (check_warning_time && conntime > warning_time) |
149 | result = STATE_WARNING; | 149 | result = STATE_WARNING; |
150 | 150 | ||
151 | if (result != STATE_OK) | 151 | if (result != STATE_OK) |
@@ -154,7 +154,7 @@ main (int argc, char **argv) | |||
154 | perfdata ("time", (long)conntime, "s", | 154 | perfdata ("time", (long)conntime, "s", |
155 | check_warning_time, (long)warning_time, | 155 | check_warning_time, (long)warning_time, |
156 | check_critical_time, (long)critical_time, | 156 | check_critical_time, (long)critical_time, |
157 | TRUE, 0, FALSE, 0)); | 157 | true, 0, false, 0)); |
158 | 158 | ||
159 | server_time = ntohl (raw_server_time) - UNIX_EPOCH; | 159 | server_time = ntohl (raw_server_time) - UNIX_EPOCH; |
160 | if (server_time > (unsigned long)end_time) | 160 | if (server_time > (unsigned long)end_time) |
@@ -162,9 +162,9 @@ main (int argc, char **argv) | |||
162 | else | 162 | else |
163 | diff_time = (unsigned long)end_time - server_time; | 163 | diff_time = (unsigned long)end_time - server_time; |
164 | 164 | ||
165 | if (check_critical_diff == TRUE && diff_time > critical_diff) | 165 | if (check_critical_diff&& diff_time > critical_diff) |
166 | result = STATE_CRITICAL; | 166 | result = STATE_CRITICAL; |
167 | else if (check_warning_diff == TRUE && diff_time > warning_diff) | 167 | else if (check_warning_diff&& diff_time > warning_diff) |
168 | result = STATE_WARNING; | 168 | result = STATE_WARNING; |
169 | 169 | ||
170 | printf (_("TIME %s - %lu second time difference|%s %s\n"), | 170 | printf (_("TIME %s - %lu second time difference|%s %s\n"), |
@@ -172,11 +172,11 @@ main (int argc, char **argv) | |||
172 | perfdata ("time", (long)conntime, "s", | 172 | perfdata ("time", (long)conntime, "s", |
173 | check_warning_time, (long)warning_time, | 173 | check_warning_time, (long)warning_time, |
174 | check_critical_time, (long)critical_time, | 174 | check_critical_time, (long)critical_time, |
175 | TRUE, 0, FALSE, 0), | 175 | true, 0, false, 0), |
176 | perfdata ("offset", diff_time, "s", | 176 | perfdata ("offset", diff_time, "s", |
177 | check_warning_diff, warning_diff, | 177 | check_warning_diff, warning_diff, |
178 | check_critical_diff, critical_diff, | 178 | check_critical_diff, critical_diff, |
179 | TRUE, 0, FALSE, 0)); | 179 | true, 0, false, 0)); |
180 | return result; | 180 | return result; |
181 | } | 181 | } |
182 | 182 | ||
@@ -219,7 +219,7 @@ process_arguments (int argc, char **argv) | |||
219 | strcpy (argv[c], "-C"); | 219 | strcpy (argv[c], "-C"); |
220 | } | 220 | } |
221 | 221 | ||
222 | while (1) { | 222 | while (true) { |
223 | c = getopt_long (argc, argv, "hVH:w:c:W:C:p:t:u", longopts, | 223 | c = getopt_long (argc, argv, "hVH:w:c:W:C:p:t:u", longopts, |
224 | &option); | 224 | &option); |
225 | 225 | ||
@@ -236,19 +236,19 @@ process_arguments (int argc, char **argv) | |||
236 | print_revision (progname, NP_VERSION); | 236 | print_revision (progname, NP_VERSION); |
237 | exit (STATE_UNKNOWN); | 237 | exit (STATE_UNKNOWN); |
238 | case 'H': /* hostname */ | 238 | case 'H': /* hostname */ |
239 | if (is_host (optarg) == FALSE) | 239 | if (!is_host (optarg)) |
240 | usage2 (_("Invalid hostname/address"), optarg); | 240 | usage2 (_("Invalid hostname/address"), optarg); |
241 | server_address = optarg; | 241 | server_address = optarg; |
242 | break; | 242 | break; |
243 | case 'w': /* warning-variance */ | 243 | case 'w': /* warning-variance */ |
244 | if (is_intnonneg (optarg)) { | 244 | if (is_intnonneg (optarg)) { |
245 | warning_diff = strtoul (optarg, NULL, 10); | 245 | warning_diff = strtoul (optarg, NULL, 10); |
246 | check_warning_diff = TRUE; | 246 | check_warning_diff = true; |
247 | } | 247 | } |
248 | else if (strspn (optarg, "0123456789:,") > 0) { | 248 | else if (strspn (optarg, "0123456789:,") > 0) { |
249 | if (sscanf (optarg, "%lu%*[:,]%d", &warning_diff, &warning_time) == 2) { | 249 | if (sscanf (optarg, "%lu%*[:,]%d", &warning_diff, &warning_time) == 2) { |
250 | check_warning_diff = TRUE; | 250 | check_warning_diff = true; |
251 | check_warning_time = TRUE; | 251 | check_warning_time = true; |
252 | } | 252 | } |
253 | else { | 253 | else { |
254 | usage4 (_("Warning thresholds must be a positive integer")); | 254 | usage4 (_("Warning thresholds must be a positive integer")); |
@@ -261,13 +261,13 @@ process_arguments (int argc, char **argv) | |||
261 | case 'c': /* critical-variance */ | 261 | case 'c': /* critical-variance */ |
262 | if (is_intnonneg (optarg)) { | 262 | if (is_intnonneg (optarg)) { |
263 | critical_diff = strtoul (optarg, NULL, 10); | 263 | critical_diff = strtoul (optarg, NULL, 10); |
264 | check_critical_diff = TRUE; | 264 | check_critical_diff = true; |
265 | } | 265 | } |
266 | else if (strspn (optarg, "0123456789:,") > 0) { | 266 | else if (strspn (optarg, "0123456789:,") > 0) { |
267 | if (sscanf (optarg, "%lu%*[:,]%d", &critical_diff, &critical_time) == | 267 | if (sscanf (optarg, "%lu%*[:,]%d", &critical_diff, &critical_time) == |
268 | 2) { | 268 | 2) { |
269 | check_critical_diff = TRUE; | 269 | check_critical_diff = true; |
270 | check_critical_time = TRUE; | 270 | check_critical_time = true; |
271 | } | 271 | } |
272 | else { | 272 | else { |
273 | usage4 (_("Critical thresholds must be a positive integer")); | 273 | usage4 (_("Critical thresholds must be a positive integer")); |
@@ -282,14 +282,14 @@ process_arguments (int argc, char **argv) | |||
282 | usage4 (_("Warning threshold must be a positive integer")); | 282 | usage4 (_("Warning threshold must be a positive integer")); |
283 | else | 283 | else |
284 | warning_time = atoi (optarg); | 284 | warning_time = atoi (optarg); |
285 | check_warning_time = TRUE; | 285 | check_warning_time = true; |
286 | break; | 286 | break; |
287 | case 'C': /* critical-connect */ | 287 | case 'C': /* critical-connect */ |
288 | if (!is_intnonneg (optarg)) | 288 | if (!is_intnonneg (optarg)) |
289 | usage4 (_("Critical threshold must be a positive integer")); | 289 | usage4 (_("Critical threshold must be a positive integer")); |
290 | else | 290 | else |
291 | critical_time = atoi (optarg); | 291 | critical_time = atoi (optarg); |
292 | check_critical_time = TRUE; | 292 | check_critical_time = true; |
293 | break; | 293 | break; |
294 | case 'p': /* port */ | 294 | case 'p': /* port */ |
295 | if (!is_intnonneg (optarg)) | 295 | if (!is_intnonneg (optarg)) |
@@ -304,14 +304,14 @@ process_arguments (int argc, char **argv) | |||
304 | socket_timeout = atoi (optarg); | 304 | socket_timeout = atoi (optarg); |
305 | break; | 305 | break; |
306 | case 'u': /* udp */ | 306 | case 'u': /* udp */ |
307 | use_udp = TRUE; | 307 | use_udp = true; |
308 | } | 308 | } |
309 | } | 309 | } |
310 | 310 | ||
311 | c = optind; | 311 | c = optind; |
312 | if (server_address == NULL) { | 312 | if (server_address == NULL) { |
313 | if (argc > c) { | 313 | if (argc > c) { |
314 | if (is_host (argv[c]) == FALSE) | 314 | if (!is_host (argv[c])) |
315 | usage2 (_("Invalid hostname/address"), optarg); | 315 | usage2 (_("Invalid hostname/address"), optarg); |
316 | server_address = argv[c]; | 316 | server_address = argv[c]; |
317 | } | 317 | } |