diff options
Diffstat (limited to 'plugins/t')
0 files changed, 0 insertions, 0 deletions
diff --git a/plugins/check_real.c b/plugins/check_real.c index a910937..ef3581b 100644 --- a/plugins/check_real.c +++ b/plugins/check_real.c | |||
@@ -62,8 +62,8 @@ void print_usage (void); | |||
62 | 62 | ||
63 | int server_port = PORT; | 63 | int server_port = PORT; |
64 | char *server_address = ""; | 64 | char *server_address = ""; |
65 | char *host_name = NULL; | 65 | char *host_name = ""; |
66 | char *server_url = NULL; | 66 | char *server_url = "/"; |
67 | char *server_expect = EXPECT; | 67 | char *server_expect = EXPECT; |
68 | int warning_time = 0; | 68 | int warning_time = 0; |
69 | int check_warning_time = FALSE; | 69 | int check_warning_time = FALSE; |
@@ -162,7 +162,7 @@ main (int argc, char **argv) | |||
162 | } | 162 | } |
163 | 163 | ||
164 | /* Part II - Check stream exists and is ok */ | 164 | /* Part II - Check stream exists and is ok */ |
165 | if ((result == STATE_OK) && (server_url != NULL)) { | 165 | if (result == STATE_OK) { |
166 | 166 | ||
167 | /* Part I - Server Check */ | 167 | /* Part I - Server Check */ |
168 | 168 | ||
@@ -381,7 +381,7 @@ process_arguments (int argc, char **argv) | |||
381 | } | 381 | } |
382 | 382 | ||
383 | c = optind; | 383 | c = optind; |
384 | if (strlen(server_address) == 0 && argc > c) { | 384 | if (strlen(server_address)==0 && argc>c) { |
385 | if (is_host (argv[c])) { | 385 | if (is_host (argv[c])) { |
386 | server_address = argv[c++]; | 386 | server_address = argv[c++]; |
387 | } | 387 | } |
@@ -390,6 +390,12 @@ process_arguments (int argc, char **argv) | |||
390 | } | 390 | } |
391 | } | 391 | } |
392 | 392 | ||
393 | if (strlen(server_address) == 0) | ||
394 | usage ("You must provide a server to check\n"); | ||
395 | |||
396 | if (strlen(host_name) == 0) | ||
397 | asprintf (&host_name, "%s", server_address); | ||
398 | |||
393 | return validate_arguments (); | 399 | return validate_arguments (); |
394 | } | 400 | } |
395 | 401 | ||
@@ -456,161 +462,3 @@ print_usage (void) | |||
456 | " %s --help\n" | 462 | " %s --help\n" |
457 | " %s --version\n", progname, progname, progname); | 463 | " %s --version\n", progname, progname, progname); |
458 | } | 464 | } |
459 | |||
460 | |||
461 | |||
462 | |||
463 | /* | ||
464 | // process command-line arguments | ||
465 | int | ||
466 | process_arguments (int argc, char **argv) | ||
467 | { | ||
468 | int x; | ||
469 | |||
470 | // no options were supplied | ||
471 | if (argc < 2) | ||
472 | return ERROR; | ||
473 | |||
474 | // first option is always the server name/address | ||
475 | strncpy (server_address, argv[1], sizeof (server_address) - 1); | ||
476 | server_address[sizeof (server_address) - 1] = 0; | ||
477 | |||
478 | // set the host name to the server address (until its overridden) | ||
479 | strcpy (host_name, server_address); | ||
480 | |||
481 | // process all remaining arguments | ||
482 | for (x = 3; x <= argc; x++) | ||
483 | { | ||
484 | |||
485 | // we got the string to expect from the server | ||
486 | if (!strcmp (argv[x - 1], "-e")) | ||
487 | { | ||
488 | if (x < argc) | ||
489 | { | ||
490 | strncpy (server_expect, argv[x], sizeof (server_expect) - 1); | ||
491 | server_expect[sizeof (server_expect) - 1] = 0; | ||
492 | x++; | ||
493 | } | ||
494 | else | ||
495 | return ERROR; | ||
496 | } | ||
497 | |||
498 | // we got the URL to check | ||
499 | else if (!strcmp (argv[x - 1], "-u")) | ||
500 | { | ||
501 | if (x < argc) | ||
502 | { | ||
503 | strncpy (server_url, argv[x], sizeof (server_url) - 1); | ||
504 | server_url[sizeof (server_url) - 1] = 0; | ||
505 | x++; | ||
506 | } | ||
507 | else | ||
508 | return ERROR; | ||
509 | } | ||
510 | |||
511 | // we go the host name to use in the host header | ||
512 | else if (!strcmp (argv[x - 1], "-hn")) | ||
513 | { | ||
514 | if (x < argc) | ||
515 | { | ||
516 | strncpy (host_name, argv[x], sizeof (host_name) - 1); | ||
517 | host_name[sizeof (host_name) - 1] = 0; | ||
518 | x++; | ||
519 | } | ||
520 | else | ||
521 | return ERROR; | ||
522 | } | ||
523 | |||
524 | // we got the port number to use | ||
525 | else if (!strcmp (argv[x - 1], "-p")) | ||
526 | { | ||
527 | if (x < argc) | ||
528 | { | ||
529 | server_port = atoi (argv[x]); | ||
530 | x++; | ||
531 | } | ||
532 | else | ||
533 | return ERROR; | ||
534 | } | ||
535 | |||
536 | // we got the socket timeout | ||
537 | else if (!strcmp (argv[x - 1], "-to")) | ||
538 | { | ||
539 | if (x < argc) | ||
540 | { | ||
541 | socket_timeout = atoi (argv[x]); | ||
542 | if (socket_timeout <= 0) | ||
543 | return ERROR; | ||
544 | x++; | ||
545 | } | ||
546 | else | ||
547 | return ERROR; | ||
548 | } | ||
549 | |||
550 | // we got the warning threshold time | ||
551 | else if (!strcmp (argv[x - 1], "-wt")) | ||
552 | { | ||
553 | if (x < argc) | ||
554 | { | ||
555 | warning_time = atoi (argv[x]); | ||
556 | check_warning_time = TRUE; | ||
557 | x++; | ||
558 | } | ||
559 | else | ||
560 | return ERROR; | ||
561 | } | ||
562 | |||
563 | // we got the critical threshold time | ||
564 | else if (!strcmp (argv[x - 1], "-ct")) | ||
565 | { | ||
566 | if (x < argc) | ||
567 | { | ||
568 | critical_time = atoi (argv[x]); | ||
569 | check_critical_time = TRUE; | ||
570 | x++; | ||
571 | } | ||
572 | else | ||
573 | return ERROR; | ||
574 | } | ||
575 | |||
576 | // else we got something else... | ||
577 | else | ||
578 | return ERROR; | ||
579 | } | ||
580 | |||
581 | return OK; | ||
582 | } | ||
583 | |||
584 | result = process_arguments (argc, argv); | ||
585 | |||
586 | if (result != OK) | ||
587 | { | ||
588 | |||
589 | printf ("Incorrect number of arguments supplied\n"); | ||
590 | printf ("\n"); | ||
591 | print_revision(argv[0],"$Revision$"); | ||
592 | printf ("Copyright (c) 1999 Pedro Leite (leite@cic.ua.pt)\n"); | ||
593 | printf ("Last Modified: 30-10-1999\n"); | ||
594 | printf ("License: GPL\n"); | ||
595 | printf ("\n"); | ||
596 | printf ("Usage: %s <host_address> [-e expect] [-u url] [-p port] [-hn host_name] [-wt warn_time]\n",argv[0]); | ||
597 | printf(" [-ct crit_time] [-to to_sec] [-a auth]\n"); | ||
598 | printf ("\n"); | ||
599 | printf ("Options:\n"); | ||
600 | printf (" [expect] = String to expect in first line of server response - default is \"%s\"\n", EXPECT); | ||
601 | printf (" [url] = Optional URL to GET - default is root document\n"); | ||
602 | printf (" [port] = Optional port number to use - default is %d\n", PORT); | ||
603 | printf (" [host_name] = Optional host name argument to GET command - used for servers using host headers\n"); | ||
604 | printf (" [warn_time] = Response time in seconds necessary to result in a warning status\n"); | ||
605 | printf (" [crit_time] = Response time in seconds necessary to result in a critical status\n"); | ||
606 | printf (" [to_sec] = Number of seconds before connection attempt times out - default is %d seconds\n", DEFAULT_SOCKET_TIMEOUT); | ||
607 | printf (" [auth] = Optional username:password for sites requiring basic authentication\n"); | ||
608 | printf ("\n"); | ||
609 | printf ("This plugin attempts to contact the REAL service on the specified host.\n"); | ||
610 | printf ("If possible, supply an IP address for the host address, as this will bypass the DNS lookup.\n"); | ||
611 | printf ("\n"); | ||
612 | |||
613 | return STATE_UNKNOWN; | ||
614 | } | ||
615 | |||
616 | */ | ||