summaryrefslogtreecommitdiffstats
path: root/plugins/check_tcp.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/check_tcp.c')
-rw-r--r--plugins/check_tcp.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/plugins/check_tcp.c b/plugins/check_tcp.c
index 1b6513b..3aef1e7 100644
--- a/plugins/check_tcp.c
+++ b/plugins/check_tcp.c
@@ -177,6 +177,12 @@ main (int argc, char **argv)
177 QUIT = "QUIT\r\n"; 177 QUIT = "QUIT\r\n";
178 PORT = 119; 178 PORT = 119;
179 } 179 }
180 else if (strncmp(SERVICE, "CLAMD", 5)) {
181 SEND = "PING";
182 EXPECT = "PONG";
183 QUIT = NULL;
184 PORT = 3310;
185 }
180 /* fallthrough check, so it's supposed to use reverse matching */ 186 /* fallthrough check, so it's supposed to use reverse matching */
181 else if (strcmp (SERVICE, "TCP")) 187 else if (strcmp (SERVICE, "TCP"))
182 usage (_("CRITICAL - Generic check_tcp called with unknown service\n")); 188 usage (_("CRITICAL - Generic check_tcp called with unknown service\n"));
@@ -318,10 +324,14 @@ main (int argc, char **argv)
318 printf(_("%s %s - "), SERVICE, state_text(result)); 324 printf(_("%s %s - "), SERVICE, state_text(result));
319 325
320 if(match == -2 && len && !(flags & FLAG_HIDE_OUTPUT)) 326 if(match == -2 && len && !(flags & FLAG_HIDE_OUTPUT))
321 printf("Unexpected response from host: %s", status); 327 printf("Unexpected response from host/socket: %s", status);
322 else 328 else {
323 printf("%.3f second response time on port %d", 329 printf("%.3f second response time on ", elapsed_time);
324 elapsed_time, server_port); 330 if(server_address[0] != '/')
331 printf("port %d", server_port);
332 else
333 printf("socket %s", server_address);
334 }
325 335
326 if (match != -2 && !(flags & FLAG_HIDE_OUTPUT) && len) 336 if (match != -2 && !(flags & FLAG_HIDE_OUTPUT) && len)
327 printf (" [%s]", status); 337 printf (" [%s]", status);
@@ -431,8 +441,6 @@ process_arguments (int argc, char **argv)
431#endif 441#endif
432 break; 442 break;
433 case 'H': /* hostname */ 443 case 'H': /* hostname */
434 if (is_host (optarg) == FALSE)
435 usage2 (_("Invalid hostname/address"), optarg);
436 server_address = optarg; 444 server_address = optarg;
437 break; 445 break;
438 case 'c': /* critical */ 446 case 'c': /* critical */
@@ -542,6 +550,8 @@ process_arguments (int argc, char **argv)
542 550
543 if (server_address == NULL) 551 if (server_address == NULL)
544 usage4 (_("You must provide a server address")); 552 usage4 (_("You must provide a server address"));
553 else if (is_host (optarg) == FALSE && optarg[0] != '/')
554 usage2 (_("Invalid hostname, address, or socket"), optarg);
545 555
546 return TRUE; 556 return TRUE;
547} 557}
@@ -555,7 +565,7 @@ print_help (void)
555 printf ("Copyright (c) 1999 Ethan Galstad <nagios@nagios.org>\n"); 565 printf ("Copyright (c) 1999 Ethan Galstad <nagios@nagios.org>\n");
556 printf (COPYRIGHT, copyright, email); 566 printf (COPYRIGHT, copyright, email);
557 567
558 printf (_("This plugin tests %s connections with the specified host.\n\n"), 568 printf (_("This plugin tests %s connections with the specified host (or unix socket).\n\n"),
559 SERVICE); 569 SERVICE);
560 570
561 print_usage (); 571 print_usage ();