summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: cb448eb)
raw | patch | inline | side by side (parent: cb448eb)
author | Jeremy T. Bouse <undrgrid@users.sourceforge.net> | |
Sun, 29 Jun 2003 06:36:55 +0000 (06:36 +0000) | ||
committer | Jeremy T. Bouse <undrgrid@users.sourceforge.net> | |
Sun, 29 Jun 2003 06:36:55 +0000 (06:36 +0000) |
options for explicit connection protocol
Added support for -4 & -6 options to check_ssh and check_tcp for testing
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@568 f882894a-f735-0410-b71e-b25c423dba1c
Added support for -4 & -6 options to check_ssh and check_tcp for testing
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@568 f882894a-f735-0410-b71e-b25c423dba1c
plugins/check_ssh.c | patch | blob | history | |
plugins/check_tcp.c | patch | blob | history | |
plugins/netutils.c | patch | blob | history | |
plugins/netutils.h | patch | blob | history |
diff --git a/plugins/check_ssh.c b/plugins/check_ssh.c
index f3a351e6800d82dd24b608705c76bc4501cf7936..421fc01c74df794b9fa51c3096ea31d9999ff862 100644 (file)
--- a/plugins/check_ssh.c
+++ b/plugins/check_ssh.c
static struct option long_options[] = {
{"version", no_argument, 0, 'V'},
{"help", no_argument, 0, 'h'},
+ {"use-ipv4", no_argument, 0, '4'},
+ {"use-ipv6", no_argument, 0, '6'},
{"verbose", no_argument, 0, 'v'},
{"timeout", required_argument, 0, 't'},
{"host", required_argument, 0, 'H'},
strcpy (argv[c], "-t");
while (1) {
- c = getopt_long (argc, argv, "+Vhvt:H:p:", long_options, &option_index);
+ c = getopt_long (argc, argv, "+Vhv46t:H:p:", long_options, &option_index);
if (c == -1 || c == EOF)
break;
usage ("Timeout Interval must be an integer!\n\n");
socket_timeout = atoi (optarg);
break;
+ case '4':
+ address_family = AF_INET;
+ break;
+ case '6':
+ address_family = AF_INET6;
+ break;
case 'H': /* host */
if (is_host (optarg) == FALSE)
usage ("Invalid hostname/address\n");
("Usage:\n"
" %s -t [timeout] -p [port] <host>\n"
" %s -V prints version info\n"
- " %s -h prints more detailed help\n", progname, progname, progname);
+ " %s -4 use IPv4 connection\n"
+ " %s -6 use IPv6 connection\n"
+ " %s -h prints more detailed help\n",
+ progname, progname, progname, progname, progname);
}
/* end of check_ssh.c */
diff --git a/plugins/check_tcp.c b/plugins/check_tcp.c
index f4fe5f40cf84da5e7e814b2b77a2ebc7677cf33b..0f19c01e87b83d61a22b1e4a06c0ab504a5de4f1 100644 (file)
--- a/plugins/check_tcp.c
+++ b/plugins/check_tcp.c
const char *option_summary = "\
-H host -p port [-w warn_time] [-c crit_time] [-s send_string]\n\
[-e expect_string] [-q quit_string] [-m maxbytes] [-d delay]\n\
- [-t to_sec] [-r refuse_state] [-v]\n";
+ [-t to_sec] [-r refuse_state] [-v] [-4] [-6]\n";
const char *options = "\
-H, --hostname=ADDRESS\n\
address if possible to bypass DNS lookup).\n\
-p, --port=INTEGER\n\
Port number\n\
+ -4, --use-ipv4\n\
+ Use IPv4 connection\n\
+ -6, --use-ipv6\n\
+ Use IPv6 connection\n\
-s, --send=STRING\n\
String to send to the server\n\
-e, --expect=STRING\n\
{"quit", required_argument, 0, 'q'},
{"delay", required_argument, 0, 'd'},
{"refuse", required_argument, 0, 'r'},
+ {"use-ipv4", no_argument, 0, '4'},
+ {"use-ipv6", no_argument, 0, '6'},
{"verbose", no_argument, 0, 'v'},
{"version", no_argument, 0, 'V'},
{"help", no_argument, 0, 'h'},
}
while (1) {
- c = getopt_long (argc, argv, "+hVvH:s:e:q:m:c:w:t:p:C:W:d:Sr:",
+ c = getopt_long (argc, argv, "+hVv46H:s:e:q:m:c:w:t:p:C:W:d:Sr:",
long_options, &option_index);
if (c == -1 || c == EOF || c == 1)
case 'v': /* verbose mode */
verbose = TRUE;
break;
+ case '4':
+ address_family = AF_INET;
+ break;
+ case '6':
+ address_family = AF_INET6;
+ break;
case 'H': /* hostname */
if (is_host (optarg) == FALSE)
usage2 ("invalid host name or address", optarg);
diff --git a/plugins/netutils.c b/plugins/netutils.c
index c567df534bf86b3d28eafcb5be34444259b7e464..dc679e2ab336bba80a67fb0e63833e69f1c66675 100644 (file)
--- a/plugins/netutils.c
+++ b/plugins/netutils.c
int socket_timeout = DEFAULT_SOCKET_TIMEOUT;
int econn_refuse_state = STATE_CRITICAL;
int was_refused = FALSE;
+int address_family = AF_UNSPEC;
/* handles socket timeouts */
void
int result;
memset (&hints, 0, sizeof (hints));
- hints.ai_family = PF_UNSPEC;
+ hints.ai_family = address_family;
hints.ai_protocol = proto;
hints.ai_socktype = (proto == IPPROTO_UDP) ? SOCK_DGRAM : SOCK_STREAM;
diff --git a/plugins/netutils.h b/plugins/netutils.h
index 2ad0dba2c33aaa775ccd63c3d638d4b97f6eb57a..8f534976ea5ff45a2cb4fc4a46412c1c2d2a98be 100644 (file)
--- a/plugins/netutils.h
+++ b/plugins/netutils.h
extern int socket_timeout;
extern int econn_refuse_state;
extern int was_refused;
+extern int address_family;