summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarl DeBisschop <kdebisschop@users.sourceforge.net>2003-06-01 05:38:12 (GMT)
committerKarl DeBisschop <kdebisschop@users.sourceforge.net>2003-06-01 05:38:12 (GMT)
commite1cef8404234c0222b3b4d6bb974305ee739a10b (patch)
treeed2645b6ac023e3c033a699b67b726a7caeee3f1
parentcc032457cfe982c9b608150a87a54e443903ba16 (diff)
downloadmonitoring-plugins-e1cef8404234c0222b3b4d6bb974305ee739a10b.tar.gz
allow user to limit number of bytes fetched
fix some doco (wait is now delay, server_quit was not shown) git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@529 f882894a-f735-0410-b71e-b25c423dba1c
-rw-r--r--plugins/check_tcp.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/plugins/check_tcp.c b/plugins/check_tcp.c
index 1057fdc..13c34f9 100644
--- a/plugins/check_tcp.c
+++ b/plugins/check_tcp.c
@@ -27,8 +27,9 @@ const char *summary = "\
27This plugin tests %s connections with the specified host.\n"; 27This plugin tests %s connections with the specified host.\n";
28 28
29const char *option_summary = "\ 29const char *option_summary = "\
30-H host -p port [-w warn_time] [-c crit_time] [-s send]\n\ 30-H host -p port [-w warn_time] [-c crit_time] [-s send_string]\n\
31 [-e expect] [-W wait] [-t to_sec] [-r refuse_state] [-v]\n"; 31 [-e expect_string] [-q quit_string] [-m maxbytes] [-d delay]\n\
32 [-t to_sec] [-r refuse_state] [-v]\n";
32 33
33const char *options = "\ 34const char *options = "\
34 -H, --hostname=ADDRESS\n\ 35 -H, --hostname=ADDRESS\n\
@@ -40,7 +41,11 @@ const char *options = "\
40 String to send to the server\n\ 41 String to send to the server\n\
41 -e, --expect=STRING\n\ 42 -e, --expect=STRING\n\
42 String to expect in server response\n\ 43 String to expect in server response\n\
43 -W, --wait=INTEGER\n\ 44 -q, --quit=STRING\n\
45 String to send server to initiate a clean close of the connection\n\
46 -m, --maxbytes=INTEGER\n\
47 Close connection once more than this number of bytes are received\n\
48 -d, --delay=INTEGER\n\
44 Seconds to wait between sending string and polling for response\n\ 49 Seconds to wait between sending string and polling for response\n\
45 -w, --warning=DOUBLE\n\ 50 -w, --warning=DOUBLE\n\
46 Response time to result in warning status (seconds)\n\ 51 Response time to result in warning status (seconds)\n\
@@ -50,8 +55,8 @@ const char *options = "\
50 Seconds before connection times out (default: %d)\n\ 55 Seconds before connection times out (default: %d)\n\
51 -r, --refuse=ok|warn|crit\n\ 56 -r, --refuse=ok|warn|crit\n\
52 Accept tcp refusals with states ok, warn, crit (default: crit)\n\ 57 Accept tcp refusals with states ok, warn, crit (default: crit)\n\
53 -v\n\ 58 -v, --verbose\n\
54 Show details for command-line debugging (do not use with nagios server)\n"; 59 Show details for command-line debugging (Nagios may truncate output)\n";
55 60
56const char *standard_options = "\ 61const char *standard_options = "\
57 -h, --help\n\ 62 -h, --help\n\
@@ -112,6 +117,7 @@ char *server_send = NULL;
112char *server_quit = NULL; 117char *server_quit = NULL;
113char **server_expect = NULL; 118char **server_expect = NULL;
114int server_expect_count = 0; 119int server_expect_count = 0;
120int maxbytes = 0;
115char **warn_codes = NULL; 121char **warn_codes = NULL;
116int warn_codes_count = 0; 122int warn_codes_count = 0;
117char **crit_codes = NULL; 123char **crit_codes = NULL;
@@ -291,6 +297,8 @@ main (int argc, char **argv)
291 asprintf (&status, "%s%s", status, buffer); 297 asprintf (&status, "%s%s", status, buffer);
292 if (buffer[i-2] == '\r' && buffer[i-1] == '\n') 298 if (buffer[i-2] == '\r' && buffer[i-1] == '\n')
293 break; 299 break;
300 if (maxbytes>0 && strlen(status)>maxbytes)
301 break;
294 } 302 }
295 303
296 /* return a CRITICAL status if we couldn't read any data */ 304 /* return a CRITICAL status if we couldn't read any data */
@@ -380,6 +388,7 @@ process_arguments (int argc, char **argv)
380 {"port", required_argument, 0, 'p'}, 388 {"port", required_argument, 0, 'p'},
381 {"send", required_argument, 0, 's'}, 389 {"send", required_argument, 0, 's'},
382 {"expect", required_argument, 0, 'e'}, 390 {"expect", required_argument, 0, 'e'},
391 {"maxbytes", required_argument, 0, 'm'},
383 {"quit", required_argument, 0, 'q'}, 392 {"quit", required_argument, 0, 'q'},
384 {"delay", required_argument, 0, 'd'}, 393 {"delay", required_argument, 0, 'd'},
385 {"refuse", required_argument, 0, 'r'}, 394 {"refuse", required_argument, 0, 'r'},
@@ -410,8 +419,8 @@ process_arguments (int argc, char **argv)
410 } 419 }
411 420
412 while (1) { 421 while (1) {
413 c = getopt_long (argc, argv, "+hVvH:s:e:q:c:w:t:p:C:W:d:Sr:", long_options, 422 c = getopt_long (argc, argv, "+hVvH:s:e:q:m:c:w:t:p:C:W:d:Sr:",
414 &option_index); 423 long_options, &option_index);
415 424
416 if (c == -1 || c == EOF || c == 1) 425 if (c == -1 || c == EOF || c == 1)
417 break; 426 break;
@@ -476,6 +485,10 @@ process_arguments (int argc, char **argv)
476 server_expect = realloc (server_expect, ++server_expect_count); 485 server_expect = realloc (server_expect, ++server_expect_count);
477 server_expect[server_expect_count - 1] = optarg; 486 server_expect[server_expect_count - 1] = optarg;
478 break; 487 break;
488 case 'm':
489 if (!is_intpos (optarg))
490 usage ("Maxbytes must be a positive integer\n");
491 maxbytes = atoi (optarg);
479 case 'q': 492 case 'q':
480 server_quit = optarg; 493 server_quit = optarg;
481 break; 494 break;