diff options
Diffstat (limited to 'plugins/check_time.c')
-rw-r--r-- | plugins/check_time.c | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/plugins/check_time.c b/plugins/check_time.c index 314b768..617b9e0 100644 --- a/plugins/check_time.c +++ b/plugins/check_time.c | |||
@@ -14,6 +14,8 @@ | |||
14 | along with this program; if not, write to the Free Software | 14 | along with this program; if not, write to the Free Software |
15 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 15 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
16 | 16 | ||
17 | $Id$ | ||
18 | |||
17 | ******************************************************************************/ | 19 | ******************************************************************************/ |
18 | 20 | ||
19 | #include "common.h" | 21 | #include "common.h" |
@@ -61,7 +63,7 @@ main (int argc, char **argv) | |||
61 | textdomain (PACKAGE); | 63 | textdomain (PACKAGE); |
62 | 64 | ||
63 | if (process_arguments (argc, argv) != OK) | 65 | if (process_arguments (argc, argv) != OK) |
64 | usage (_("Incorrect arguments supplied\n")); | 66 | usage (_("check_time: could not parse arguments\n")); |
65 | 67 | ||
66 | /* initialize alarm signal handling */ | 68 | /* initialize alarm signal handling */ |
67 | signal (SIGALRM, socket_timeout_alarm_handler); | 69 | signal (SIGALRM, socket_timeout_alarm_handler); |
@@ -168,9 +170,6 @@ main (int argc, char **argv) | |||
168 | 170 | ||
169 | 171 | ||
170 | 172 | ||
171 | |||
172 | |||
173 | |||
174 | /* process command-line arguments */ | 173 | /* process command-line arguments */ |
175 | int | 174 | int |
176 | process_arguments (int argc, char **argv) | 175 | process_arguments (int argc, char **argv) |
@@ -217,7 +216,9 @@ process_arguments (int argc, char **argv) | |||
217 | 216 | ||
218 | switch (c) { | 217 | switch (c) { |
219 | case '?': /* print short usage statement if args not parsable */ | 218 | case '?': /* print short usage statement if args not parsable */ |
220 | usage3 (_("Unknown argument"), optopt); | 219 | printf (_("%s: Unknown argument: %s\n\n"), progname, optarg); |
220 | print_usage (); | ||
221 | exit (STATE_UNKNOWN); | ||
221 | case 'h': /* help */ | 222 | case 'h': /* help */ |
222 | print_help (); | 223 | print_help (); |
223 | exit (STATE_OK); | 224 | exit (STATE_OK); |
@@ -226,7 +227,7 @@ process_arguments (int argc, char **argv) | |||
226 | exit (STATE_OK); | 227 | exit (STATE_OK); |
227 | case 'H': /* hostname */ | 228 | case 'H': /* hostname */ |
228 | if (is_host (optarg) == FALSE) | 229 | if (is_host (optarg) == FALSE) |
229 | usage2 (_("Invalid host name/address"), optarg); | 230 | usage2 (_("Invalid hostname/address"), optarg); |
230 | server_address = optarg; | 231 | server_address = optarg; |
231 | break; | 232 | break; |
232 | case 'w': /* warning-variance */ | 233 | case 'w': /* warning-variance */ |
@@ -240,11 +241,11 @@ process_arguments (int argc, char **argv) | |||
240 | check_warning_time = TRUE; | 241 | check_warning_time = TRUE; |
241 | } | 242 | } |
242 | else { | 243 | else { |
243 | usage (_("Warning thresholds must be a nonnegative integer\n")); | 244 | usage (_("Warning thresholds must be a positive integer\n")); |
244 | } | 245 | } |
245 | } | 246 | } |
246 | else { | 247 | else { |
247 | usage (_("Warning threshold must be a nonnegative integer\n")); | 248 | usage (_("Warning threshold must be a positive integer\n")); |
248 | } | 249 | } |
249 | break; | 250 | break; |
250 | case 'c': /* critical-variance */ | 251 | case 'c': /* critical-variance */ |
@@ -259,30 +260,30 @@ process_arguments (int argc, char **argv) | |||
259 | check_critical_time = TRUE; | 260 | check_critical_time = TRUE; |
260 | } | 261 | } |
261 | else { | 262 | else { |
262 | usage (_("Critical thresholds must be a nonnegative integer\n")); | 263 | usage (_("Critical thresholds must be a positive integer\n")); |
263 | } | 264 | } |
264 | } | 265 | } |
265 | else { | 266 | else { |
266 | usage (_("Critical threshold must be a nonnegative integer\n")); | 267 | usage (_("Critical threshold must be a positive integer\n")); |
267 | } | 268 | } |
268 | break; | 269 | break; |
269 | case 'W': /* warning-connect */ | 270 | case 'W': /* warning-connect */ |
270 | if (!is_intnonneg (optarg)) | 271 | if (!is_intnonneg (optarg)) |
271 | usage (_("Warning threshold must be a nonnegative integer\n")); | 272 | usage (_("Warning threshold must be a positive integer\n")); |
272 | else | 273 | else |
273 | warning_time = atoi (optarg); | 274 | warning_time = atoi (optarg); |
274 | check_warning_time = TRUE; | 275 | check_warning_time = TRUE; |
275 | break; | 276 | break; |
276 | case 'C': /* critical-connect */ | 277 | case 'C': /* critical-connect */ |
277 | if (!is_intnonneg (optarg)) | 278 | if (!is_intnonneg (optarg)) |
278 | usage (_("Critical threshold must be a nonnegative integer\n")); | 279 | usage (_("Critical threshold must be a positive integer\n")); |
279 | else | 280 | else |
280 | critical_time = atoi (optarg); | 281 | critical_time = atoi (optarg); |
281 | check_critical_time = TRUE; | 282 | check_critical_time = TRUE; |
282 | break; | 283 | break; |
283 | case 'p': /* port */ | 284 | case 'p': /* port */ |
284 | if (!is_intnonneg (optarg)) | 285 | if (!is_intnonneg (optarg)) |
285 | usage (_("Server port must be a nonnegative integer\n")); | 286 | usage (_("Port must be a positive integer\n")); |
286 | else | 287 | else |
287 | server_port = atoi (optarg); | 288 | server_port = atoi (optarg); |
288 | break; | 289 | break; |
@@ -301,11 +302,11 @@ process_arguments (int argc, char **argv) | |||
301 | if (server_address == NULL) { | 302 | if (server_address == NULL) { |
302 | if (argc > c) { | 303 | if (argc > c) { |
303 | if (is_host (argv[c]) == FALSE) | 304 | if (is_host (argv[c]) == FALSE) |
304 | usage2 (_("Invalid host name/address"), optarg); | 305 | usage2 (_("Invalid hostname/address"), optarg); |
305 | server_address = argv[c]; | 306 | server_address = argv[c]; |
306 | } | 307 | } |
307 | else { | 308 | else { |
308 | usage (_("Host name was not supplied\n")); | 309 | usage (_("Hostname was not supplied\n")); |
309 | } | 310 | } |
310 | } | 311 | } |
311 | 312 | ||
@@ -314,9 +315,6 @@ process_arguments (int argc, char **argv) | |||
314 | 315 | ||
315 | 316 | ||
316 | 317 | ||
317 | |||
318 | |||
319 | |||
320 | void | 318 | void |
321 | print_help (void) | 319 | print_help (void) |
322 | { | 320 | { |
@@ -356,7 +354,6 @@ This plugin will check the time on the specified host.\n\n")); | |||
356 | 354 | ||
357 | 355 | ||
358 | 356 | ||
359 | |||
360 | void | 357 | void |
361 | print_usage (void) | 358 | print_usage (void) |
362 | { | 359 | { |