diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/check_tcp.c | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/plugins/check_tcp.c b/plugins/check_tcp.c index 5915af2..5c287b7 100644 --- a/plugins/check_tcp.c +++ b/plugins/check_tcp.c | |||
@@ -54,6 +54,8 @@ static int server_port = 0; | |||
54 | static char *server_address = NULL; | 54 | static char *server_address = NULL; |
55 | static char *server_send = NULL; | 55 | static char *server_send = NULL; |
56 | static char *server_quit = NULL; | 56 | static char *server_quit = NULL; |
57 | char *lineend = ""; | ||
58 | char *lineendquit = "\r\n"; | ||
57 | static char **server_expect; | 59 | static char **server_expect; |
58 | static size_t server_expect_count = 0; | 60 | static size_t server_expect_count = 0; |
59 | static size_t maxbytes = 0; | 61 | static size_t maxbytes = 0; |
@@ -369,6 +371,7 @@ process_arguments (int argc, char **argv) | |||
369 | {"timeout", required_argument, 0, 't'}, | 371 | {"timeout", required_argument, 0, 't'}, |
370 | {"protocol", required_argument, 0, 'P'}, | 372 | {"protocol", required_argument, 0, 'P'}, |
371 | {"port", required_argument, 0, 'p'}, | 373 | {"port", required_argument, 0, 'p'}, |
374 | {"lineend", required_argument, 0, 'l'}, | ||
372 | {"send", required_argument, 0, 's'}, | 375 | {"send", required_argument, 0, 's'}, |
373 | {"expect", required_argument, 0, 'e'}, | 376 | {"expect", required_argument, 0, 'e'}, |
374 | {"maxbytes", required_argument, 0, 'm'}, | 377 | {"maxbytes", required_argument, 0, 'm'}, |
@@ -410,7 +413,7 @@ process_arguments (int argc, char **argv) | |||
410 | } | 413 | } |
411 | 414 | ||
412 | while (1) { | 415 | while (1) { |
413 | c = getopt_long (argc, argv, "+hVv46H:s:e:q:m:c:w:t:p:C:W:d:Sr:jD:M:", | 416 | c = getopt_long (argc, argv, "+hVv46H:l:s:e:q:m:c:w:t:p:C:W:d:Sr:jD:M:", |
414 | longopts, &option); | 417 | longopts, &option); |
415 | 418 | ||
416 | if (c == -1 || c == EOF || c == 1) | 419 | if (c == -1 || c == EOF || c == 1) |
@@ -478,8 +481,30 @@ process_arguments (int argc, char **argv) | |||
478 | else | 481 | else |
479 | server_port = atoi (optarg); | 482 | server_port = atoi (optarg); |
480 | break; | 483 | break; |
484 | case 'l': | ||
485 | switch (*optarg) { | ||
486 | case 'n': | ||
487 | lineend = strdup("\n"); | ||
488 | lineendquit = lineend; | ||
489 | break; | ||
490 | case 'r': | ||
491 | lineend = strdup("\r"); | ||
492 | lineendquit = lineend; | ||
493 | break; | ||
494 | case 'b': | ||
495 | lineend = strdup("\r\n"); | ||
496 | lineendquit = lineend; | ||
497 | break; | ||
498 | case 'e': | ||
499 | lineend = strdup(""); | ||
500 | lineendquit = lineend; | ||
501 | break; | ||
502 | default: | ||
503 | usage4 (_("Unrecognized option to -l, must be r, n, b or e")); | ||
504 | } | ||
505 | break; | ||
481 | case 's': | 506 | case 's': |
482 | server_send = optarg; | 507 | asprintf(&server_send, "%s%s", optarg, lineend); |
483 | break; | 508 | break; |
484 | case 'e': /* expect string (may be repeated) */ | 509 | case 'e': /* expect string (may be repeated) */ |
485 | EXPECT = NULL; | 510 | EXPECT = NULL; |
@@ -496,7 +521,7 @@ process_arguments (int argc, char **argv) | |||
496 | else | 521 | else |
497 | maxbytes = strtol (optarg, NULL, 0); | 522 | maxbytes = strtol (optarg, NULL, 0); |
498 | case 'q': | 523 | case 'q': |
499 | asprintf(&server_quit, "%s\r\n", optarg); | 524 | asprintf(&server_quit, "%s%s", optarg, lineendquit); |
500 | break; | 525 | break; |
501 | case 'r': | 526 | case 'r': |
502 | if (!strncmp(optarg,"ok",2)) | 527 | if (!strncmp(optarg,"ok",2)) |
@@ -575,6 +600,10 @@ print_help (void) | |||
575 | printf (_(UT_IPv46)); | 600 | printf (_(UT_IPv46)); |
576 | 601 | ||
577 | printf (_("\ | 602 | printf (_("\ |
603 | -l, --lineend=b|e|n|r\n\ | ||
604 | Ending on -s and -q strings. b - both: <cr><lf> style, e - empty no\n\ | ||
605 | end, n - newline: newline end, r - return: carriage return end\n\ | ||
606 | Default is \"-l e -s <send> -l b -q <quit>\".\n\ | ||
578 | -s, --send=STRING\n\ | 607 | -s, --send=STRING\n\ |
579 | String to send to the server\n\ | 608 | String to send to the server\n\ |
580 | -e, --expect=STRING\n\ | 609 | -e, --expect=STRING\n\ |
@@ -620,6 +649,6 @@ Usage: %s -H host -p port [-w <warning time>] [-c <critical time>]\n\ | |||
620 | [-s <send string>] [-e <expect string>] [-q <quit string>]\n\ | 649 | [-s <send string>] [-e <expect string>] [-q <quit string>]\n\ |
621 | [-m <maximum bytes>] [-d <delay>] [-t <timeout seconds>]\n\ | 650 | [-m <maximum bytes>] [-d <delay>] [-t <timeout seconds>]\n\ |
622 | [-r <refuse state>] [-M <mismatch state>] [-v] [-4|-6] [-j]\n\ | 651 | [-r <refuse state>] [-M <mismatch state>] [-v] [-4|-6] [-j]\n\ |
623 | [-D <days to cert expiry>] [-S <use SSL>]\n", progname); | 652 | [-D <days to cert expiry>] [-S <use SSL>] [-l <n|r|b|e>]\n", progname); |
624 | } | 653 | } |
625 | 654 | ||