diff options
Diffstat (limited to 'plugins/t')
0 files changed, 0 insertions, 0 deletions
diff --git a/plugins/check_hpjd.c b/plugins/check_hpjd.c index ecc5651..267de2e 100644 --- a/plugins/check_hpjd.c +++ b/plugins/check_hpjd.c | |||
@@ -85,13 +85,15 @@ const char *progname = "check_hpjd"; | |||
85 | #define ONLINE 0 | 85 | #define ONLINE 0 |
86 | #define OFFLINE 1 | 86 | #define OFFLINE 1 |
87 | 87 | ||
88 | #define DEFAULT_COMMUNITY "public" | ||
89 | |||
88 | int process_arguments (int, char **); | 90 | int process_arguments (int, char **); |
89 | int validate_arguments (void); | 91 | int validate_arguments (void); |
90 | void print_help (void); | 92 | void print_help (void); |
91 | void print_usage (void); | 93 | void print_usage (void); |
92 | 94 | ||
93 | char *community = NULL; | 95 | char *community = DEFAULT_COMMUNITY; |
94 | char *address = "127.0.0.1"; | 96 | char *address = NULL; |
95 | 97 | ||
96 | 98 | ||
97 | int | 99 | int |
@@ -392,11 +394,10 @@ process_arguments (int argc, char **argv) | |||
392 | int option_index = 0; | 394 | int option_index = 0; |
393 | static struct option long_options[] = { | 395 | static struct option long_options[] = { |
394 | {"hostname", required_argument, 0, 'H'}, | 396 | {"hostname", required_argument, 0, 'H'}, |
395 | {"expect", required_argument, 0, 'e'}, | 397 | {"community", required_argument, 0, 'C'}, |
396 | /* {"critical", required_argument,0,'c'}, */ | 398 | /* {"critical", required_argument,0,'c'}, */ |
397 | /* {"warning", required_argument,0,'w'}, */ | 399 | /* {"warning", required_argument,0,'w'}, */ |
398 | /* {"port", required_argument,0,'P'}, */ | 400 | /* {"port", required_argument,0,'P'}, */ |
399 | {"verbose", no_argument, 0, 'v'}, | ||
400 | {"version", no_argument, 0, 'V'}, | 401 | {"version", no_argument, 0, 'V'}, |
401 | {"help", no_argument, 0, 'h'}, | 402 | {"help", no_argument, 0, 'h'}, |
402 | {0, 0, 0, 0} | 403 | {0, 0, 0, 0} |
@@ -406,15 +407,7 @@ process_arguments (int argc, char **argv) | |||
406 | if (argc < 2) | 407 | if (argc < 2) |
407 | return ERROR; | 408 | return ERROR; |
408 | 409 | ||
409 | for (c = 1; c < argc; c++) { | 410 | |
410 | if (strcmp ("-to", argv[c]) == 0) | ||
411 | strcpy (argv[c], "-t"); | ||
412 | else if (strcmp ("-wt", argv[c]) == 0) | ||
413 | strcpy (argv[c], "-w"); | ||
414 | else if (strcmp ("-ct", argv[c]) == 0) | ||
415 | strcpy (argv[c], "-c"); | ||
416 | } | ||
417 | |||
418 | while (1) { | 411 | while (1) { |
419 | #ifdef HAVE_GETOPT_H | 412 | #ifdef HAVE_GETOPT_H |
420 | c = getopt_long (argc, argv, "+hVH:C:", long_options, &option_index); | 413 | c = getopt_long (argc, argv, "+hVH:C:", long_options, &option_index); |
@@ -428,14 +421,14 @@ process_arguments (int argc, char **argv) | |||
428 | switch (c) { | 421 | switch (c) { |
429 | case 'H': /* hostname */ | 422 | case 'H': /* hostname */ |
430 | if (is_host (optarg)) { | 423 | if (is_host (optarg)) { |
431 | address = optarg; | 424 | address = strscpy(address, optarg) ; |
432 | } | 425 | } |
433 | else { | 426 | else { |
434 | usage ("Invalid host name\n"); | 427 | usage ("Invalid host name\n"); |
435 | } | 428 | } |
436 | break; | 429 | break; |
437 | case 'C': /* community */ | 430 | case 'C': /* community */ |
438 | community = optarg; | 431 | community = strscpy (community, optarg); |
439 | break; | 432 | break; |
440 | case 'V': /* version */ | 433 | case 'V': /* version */ |
441 | print_revision (progname, REVISION); | 434 | print_revision (progname, REVISION); |
@@ -457,9 +450,9 @@ process_arguments (int argc, char **argv) | |||
457 | usage ("Invalid host name"); | 450 | usage ("Invalid host name"); |
458 | } | 451 | } |
459 | } | 452 | } |
460 | 453 | ||
461 | if (community == NULL) { | 454 | if (argv[c] != NULL ) { |
462 | community = argv[c++]; | 455 | community = argv[c]; |
463 | } | 456 | } |
464 | 457 | ||
465 | return validate_arguments (); | 458 | return validate_arguments (); |
@@ -493,10 +486,10 @@ print_help (void) | |||
493 | " -H, --hostname=STRING or IPADDRESS\n" | 486 | " -H, --hostname=STRING or IPADDRESS\n" |
494 | " Check server on the indicated host\n" | 487 | " Check server on the indicated host\n" |
495 | " -C, --community=STRING\n" | 488 | " -C, --community=STRING\n" |
496 | " The SNMP community name\n" | 489 | " The SNMP community name (default=%s)\n" |
497 | " -h, --help\n" | 490 | " -h, --help\n" |
498 | " Print detailed help screen\n" | 491 | " Print detailed help screen\n" |
499 | " -V, --version\n" " Print version information\n\n"); | 492 | " -V, --version\n" " Print version information\n\n",DEFAULT_COMMUNITY); |
500 | support (); | 493 | support (); |
501 | } | 494 | } |
502 | 495 | ||