diff options
Diffstat (limited to 'plugins/check_time.c')
-rw-r--r-- | plugins/check_time.c | 113 |
1 files changed, 61 insertions, 52 deletions
diff --git a/plugins/check_time.c b/plugins/check_time.c index dde6eea..36b622f 100644 --- a/plugins/check_time.c +++ b/plugins/check_time.c | |||
@@ -29,51 +29,6 @@ enum { | |||
29 | TIME_PORT = 37 | 29 | TIME_PORT = 37 |
30 | }; | 30 | }; |
31 | 31 | ||
32 | void | ||
33 | print_usage (void) | ||
34 | { | ||
35 | printf (_("\ | ||
36 | Usage: %s -H <host_address> [-p port] [-w variance] [-c variance]\n\ | ||
37 | [-W connect_time] [-C connect_time] [-t timeout]\n"), progname); | ||
38 | printf (_(UT_HLP_VRS), progname, progname); | ||
39 | } | ||
40 | |||
41 | void | ||
42 | print_help (void) | ||
43 | { | ||
44 | char *myport; | ||
45 | asprintf (&myport, "%d", TIME_PORT); | ||
46 | |||
47 | print_revision (progname, revision); | ||
48 | |||
49 | printf (_("Copyright (c) 1999 Ethan Galstad\n")); | ||
50 | printf (_(COPYRIGHT), copyright, email); | ||
51 | |||
52 | printf (_("\ | ||
53 | This plugin will check the time on the specified host.\n\n")); | ||
54 | |||
55 | print_usage (); | ||
56 | |||
57 | printf (_(UT_HELP_VRSN)); | ||
58 | |||
59 | printf (_(UT_HOST_PORT), 'p', myport); | ||
60 | |||
61 | printf (_("\ | ||
62 | -w, --warning-variance=INTEGER\n\ | ||
63 | Time difference (sec.) necessary to result in a warning status\n\ | ||
64 | -c, --critical-variance=INTEGER\n\ | ||
65 | Time difference (sec.) necessary to result in a critical status\n\ | ||
66 | -W, --warning-connect=INTEGER\n\ | ||
67 | Response time (sec.) necessary to result in warning status\n\ | ||
68 | -C, --critical-connect=INTEGER\n\ | ||
69 | Response time (sec.) necessary to result in critical status\n")); | ||
70 | |||
71 | printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT); | ||
72 | |||
73 | support (); | ||
74 | } | ||
75 | |||
76 | |||
77 | #define UNIX_EPOCH 2208988800UL | 32 | #define UNIX_EPOCH 2208988800UL |
78 | 33 | ||
79 | unsigned long server_time, raw_server_time; | 34 | unsigned long server_time, raw_server_time; |
@@ -89,11 +44,9 @@ int check_critical_diff = FALSE; | |||
89 | int server_port = TIME_PORT; | 44 | int server_port = TIME_PORT; |
90 | char *server_address = NULL; | 45 | char *server_address = NULL; |
91 | 46 | ||
92 | |||
93 | int process_arguments (int, char **); | 47 | int process_arguments (int, char **); |
94 | void print_usage (void); | ||
95 | void print_help (void); | 48 | void print_help (void); |
96 | 49 | void print_usage (void); | |
97 | 50 | ||
98 | int | 51 | int |
99 | main (int argc, char **argv) | 52 | main (int argc, char **argv) |
@@ -276,24 +229,28 @@ process_arguments (int argc, char **argv) | |||
276 | case 'W': /* warning-connect */ | 229 | case 'W': /* warning-connect */ |
277 | if (!is_intnonneg (optarg)) | 230 | if (!is_intnonneg (optarg)) |
278 | usage (_("Warning threshold must be a nonnegative integer\n")); | 231 | usage (_("Warning threshold must be a nonnegative integer\n")); |
279 | warning_time = atoi (optarg); | 232 | else |
233 | warning_time = atoi (optarg); | ||
280 | check_warning_time = TRUE; | 234 | check_warning_time = TRUE; |
281 | break; | 235 | break; |
282 | case 'C': /* critical-connect */ | 236 | case 'C': /* critical-connect */ |
283 | if (!is_intnonneg (optarg)) | 237 | if (!is_intnonneg (optarg)) |
284 | usage (_("Critical threshold must be a nonnegative integer\n")); | 238 | usage (_("Critical threshold must be a nonnegative integer\n")); |
285 | critical_time = atoi (optarg); | 239 | else |
240 | critical_time = atoi (optarg); | ||
286 | check_critical_time = TRUE; | 241 | check_critical_time = TRUE; |
287 | break; | 242 | break; |
288 | case 'p': /* port */ | 243 | case 'p': /* port */ |
289 | if (!is_intnonneg (optarg)) | 244 | if (!is_intnonneg (optarg)) |
290 | usage (_("Server port must be a nonnegative integer\n")); | 245 | usage (_("Server port must be a nonnegative integer\n")); |
291 | server_port = atoi (optarg); | 246 | else |
247 | server_port = atoi (optarg); | ||
292 | break; | 248 | break; |
293 | case 't': /* timeout */ | 249 | case 't': /* timeout */ |
294 | if (!is_intnonneg (optarg)) | 250 | if (!is_intnonneg (optarg)) |
295 | usage (_("Timeout interval must be a nonnegative integer\n")); | 251 | usage (_("Timeout interval must be a nonnegative integer\n")); |
296 | socket_timeout = atoi (optarg); | 252 | else |
253 | socket_timeout = atoi (optarg); | ||
297 | break; | 254 | break; |
298 | } | 255 | } |
299 | } | 256 | } |
@@ -312,3 +269,55 @@ process_arguments (int argc, char **argv) | |||
312 | 269 | ||
313 | return OK; | 270 | return OK; |
314 | } | 271 | } |
272 | |||
273 | |||
274 | |||
275 | |||
276 | |||
277 | |||
278 | void | ||
279 | print_help (void) | ||
280 | { | ||
281 | char *myport; | ||
282 | asprintf (&myport, "%d", TIME_PORT); | ||
283 | |||
284 | print_revision (progname, revision); | ||
285 | |||
286 | printf (_("Copyright (c) 1999 Ethan Galstad\n")); | ||
287 | printf (_(COPYRIGHT), copyright, email); | ||
288 | |||
289 | printf (_("\ | ||
290 | This plugin will check the time on the specified host.\n\n")); | ||
291 | |||
292 | print_usage (); | ||
293 | |||
294 | printf (_(UT_HELP_VRSN)); | ||
295 | |||
296 | printf (_(UT_HOST_PORT), 'p', myport); | ||
297 | |||
298 | printf (_("\ | ||
299 | -w, --warning-variance=INTEGER\n\ | ||
300 | Time difference (sec.) necessary to result in a warning status\n\ | ||
301 | -c, --critical-variance=INTEGER\n\ | ||
302 | Time difference (sec.) necessary to result in a critical status\n\ | ||
303 | -W, --warning-connect=INTEGER\n\ | ||
304 | Response time (sec.) necessary to result in warning status\n\ | ||
305 | -C, --critical-connect=INTEGER\n\ | ||
306 | Response time (sec.) necessary to result in critical status\n")); | ||
307 | |||
308 | printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT); | ||
309 | |||
310 | support (); | ||
311 | } | ||
312 | |||
313 | |||
314 | |||
315 | |||
316 | void | ||
317 | print_usage (void) | ||
318 | { | ||
319 | printf (_("\ | ||
320 | Usage: %s -H <host_address> [-p port] [-w variance] [-c variance]\n\ | ||
321 | [-W connect_time] [-C connect_time] [-t timeout]\n"), progname); | ||
322 | printf (_(UT_HLP_VRS), progname, progname); | ||
323 | } | ||