summaryrefslogtreecommitdiffstats
path: root/plugins/check_tcp.c
diff options
context:
space:
mode:
authorJeremy T. Bouse <undrgrid@users.sourceforge.net>2003-03-16 23:28:49 (GMT)
committerJeremy T. Bouse <undrgrid@users.sourceforge.net>2003-03-16 23:28:49 (GMT)
commit33cce285cbfd1d7ca79f2369f9bb735c1720e673 (patch)
tree51d498383281604bfb411a7a91b06f6d76270f17 /plugins/check_tcp.c
parentdf6b0771cde1accb4f7d11fd6ab5829b1e03003d (diff)
downloadmonitoring-plugins-33cce285cbfd1d7ca79f2369f9bb735c1720e673.tar.gz
Applied patch #660973 for tcp refusals
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@426 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/check_tcp.c')
-rw-r--r--plugins/check_tcp.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/plugins/check_tcp.c b/plugins/check_tcp.c
index 7d11551..5bec291 100644
--- a/plugins/check_tcp.c
+++ b/plugins/check_tcp.c
@@ -28,7 +28,7 @@ This 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]\n\
31 [-e expect] [-W wait] [-t to_sec] [-v]\n"; 31 [-e expect] [-W wait] [-t to_sec] [-r refuse_state] [-v]\n";
32 32
33const char *options = "\ 33const char *options = "\
34 -H, --hostname=ADDRESS\n\ 34 -H, --hostname=ADDRESS\n\
@@ -48,6 +48,8 @@ const char *options = "\
48 Response time to result in critical status (seconds)\n\ 48 Response time to result in critical status (seconds)\n\
49 -t, --timeout=INTEGER\n\ 49 -t, --timeout=INTEGER\n\
50 Seconds before connection times out (default: %d)\n\ 50 Seconds before connection times out (default: %d)\n\
51 -r, --refuse=ok|warn|crit\n\
52 Accept tcp refusals with states ok, warn, crit (default: crit)\n\
51 -v\n\ 53 -v\n\
52 Show details for command-line debugging (do not use with nagios server)\n\ 54 Show details for command-line debugging (do not use with nagios server)\n\
53 -h, --help\n\ 55 -h, --help\n\
@@ -337,9 +339,11 @@ main (int argc, char **argv)
337 alarm (0); 339 alarm (0);
338 340
339 printf 341 printf
340 ("%s %s - %.3f second response time on port %d", 342 ("%s %s%s - %.3f second response time on port %d",
341 SERVICE, 343 SERVICE,
342 state_text (result), elapsed_time, server_port); 344 state_text (result),
345 (was_refused) ? " (refused)" : "",
346 elapsed_time, server_port);
343 347
344 if (status && strlen(status) > 0) 348 if (status && strlen(status) > 0)
345 printf (" [%s]", status); 349 printf (" [%s]", status);
@@ -375,6 +379,7 @@ process_arguments (int argc, char **argv)
375 {"expect", required_argument, 0, 'e'}, 379 {"expect", required_argument, 0, 'e'},
376 {"quit", required_argument, 0, 'q'}, 380 {"quit", required_argument, 0, 'q'},
377 {"delay", required_argument, 0, 'd'}, 381 {"delay", required_argument, 0, 'd'},
382 {"refuse", required_argument, 0, 'r'},
378 {"verbose", no_argument, 0, 'v'}, 383 {"verbose", no_argument, 0, 'v'},
379 {"version", no_argument, 0, 'V'}, 384 {"version", no_argument, 0, 'V'},
380 {"help", no_argument, 0, 'h'}, 385 {"help", no_argument, 0, 'h'},
@@ -402,7 +407,7 @@ process_arguments (int argc, char **argv)
402 } 407 }
403 408
404 while (1) { 409 while (1) {
405 c = getopt_long (argc, argv, "+hVvH:s:e:q:c:w:t:p:C:W:d:S", long_options, 410 c = getopt_long (argc, argv, "+hVvH:s:e:q:c:w:t:p:C:W:d:Sr:", long_options,
406 &option_index); 411 &option_index);
407 412
408 if (c == -1 || c == EOF || c == 1) 413 if (c == -1 || c == EOF || c == 1)
@@ -471,6 +476,16 @@ process_arguments (int argc, char **argv)
471 case 'q': 476 case 'q':
472 server_quit = optarg; 477 server_quit = optarg;
473 break; 478 break;
479 case 'r':
480 if (!strncmp(optarg,"ok",2))
481 econn_refuse_state = STATE_OK;
482 else if (!strncmp(optarg,"warn",4))
483 econn_refuse_state = STATE_WARNING;
484 else if (!strncmp(optarg,"crit",4))
485 econn_refuse_state = STATE_CRITICAL;
486 else
487 usage ("Refuse mut be one of ok, warn, crit\n");
488 break;
474 case 'd': 489 case 'd':
475 if (is_intpos (optarg)) 490 if (is_intpos (optarg))
476 delay = atoi (optarg); 491 delay = atoi (optarg);
@@ -541,7 +556,7 @@ connect_SSL (void)
541 time (&start_time); 556 time (&start_time);
542 557
543 /* Make TCP connection */ 558 /* Make TCP connection */
544 if (my_tcp_connect (server_address, server_port, &sd) == STATE_OK) 559 if (my_tcp_connect (server_address, server_port, &sd) == STATE_OK && was_refused == FALSE)
545 { 560 {
546 /* Do the SSL handshake */ 561 /* Do the SSL handshake */
547 if ((ssl = SSL_new (ctx)) != NULL) 562 if ((ssl = SSL_new (ctx)) != NULL)