aboutsummaryrefslogtreecommitdiff
path: root/plugins/check_tcp.c
diff options
context:
space:
mode:
authorGravatar M. Sean Finney <seanius@users.sourceforge.net> 2005-10-25 10:38:02 +0000
committerGravatar M. Sean Finney <seanius@users.sourceforge.net> 2005-10-25 10:38:02 +0000
commit16cd0c8151eee652d88b0b6f3aaa5b917cb87e13 (patch)
tree9587540f51701d62d73670c6c1963f9119c793b5 /plugins/check_tcp.c
parentceebd58040b1688749d58dd76963af639cf8c803 (diff)
downloadmonitoring-plugins-16cd0c8151eee652d88b0b6f3aaa5b917cb87e13.tar.gz
- added code to allow check_tcp (via np_net_connect) work with local
unix sockets. some testing would be welcome. based on idea from Alex Samorukov. - also introduced a check_clamd behavior in check_tcp. git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1261 f882894a-f735-0410-b71e-b25c423dba1c
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 1b6513ba..3aef1e7e 100644
--- a/plugins/check_tcp.c
+++ b/plugins/check_tcp.c
@@ -177,6 +177,12 @@ main (int argc, char **argv)
QUIT = "QUIT\r\n";
PORT = 119;
}
+ else if (strncmp(SERVICE, "CLAMD", 5)) {
+ SEND = "PING";
+ EXPECT = "PONG";
+ QUIT = NULL;
+ PORT = 3310;
+ }
/* fallthrough check, so it's supposed to use reverse matching */
else if (strcmp (SERVICE, "TCP"))
usage (_("CRITICAL - Generic check_tcp called with unknown service\n"));
@@ -318,10 +324,14 @@ main (int argc, char **argv)
printf(_("%s %s - "), SERVICE, state_text(result));
if(match == -2 && len && !(flags & FLAG_HIDE_OUTPUT))
- printf("Unexpected response from host: %s", status);
- else
- printf("%.3f second response time on port %d",
- elapsed_time, server_port);
+ printf("Unexpected response from host/socket: %s", status);
+ else {
+ printf("%.3f second response time on ", elapsed_time);
+ if(server_address[0] != '/')
+ printf("port %d", server_port);
+ else
+ printf("socket %s", server_address);
+ }
if (match != -2 && !(flags & FLAG_HIDE_OUTPUT) && len)
printf (" [%s]", status);
@@ -431,8 +441,6 @@ process_arguments (int argc, char **argv)
#endif
break;
case 'H': /* hostname */
- if (is_host (optarg) == FALSE)
- usage2 (_("Invalid hostname/address"), optarg);
server_address = optarg;
break;
case 'c': /* critical */
@@ -542,6 +550,8 @@ process_arguments (int argc, char **argv)
if (server_address == NULL)
usage4 (_("You must provide a server address"));
+ else if (is_host (optarg) == FALSE && optarg[0] != '/')
+ usage2 (_("Invalid hostname, address, or socket"), optarg);
return TRUE;
}
@@ -555,7 +565,7 @@ print_help (void)
printf ("Copyright (c) 1999 Ethan Galstad <nagios@nagios.org>\n");
printf (COPYRIGHT, copyright, email);
- printf (_("This plugin tests %s connections with the specified host.\n\n"),
+ printf (_("This plugin tests %s connections with the specified host (or unix socket).\n\n"),
SERVICE);
print_usage ();