diff options
author | Jeremy T. Bouse <undrgrid@users.sourceforge.net> | 2003-06-29 06:36:55 (GMT) |
---|---|---|
committer | Jeremy T. Bouse <undrgrid@users.sourceforge.net> | 2003-06-29 06:36:55 (GMT) |
commit | d77d183ddb8bdff5069ba5fa008406087162d117 (patch) | |
tree | 35ece18bb2080b168605c5533e4ff6b1574f9f88 /plugins | |
parent | cb448eb1d57259641e10494e8d74d885e44c215d (diff) | |
download | monitoring-plugins-d77d183ddb8bdff5069ba5fa008406087162d117.tar.gz |
Added address_family extern int variable to netutils to allow for -4 & -6
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
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/check_ssh.c | 15 | ||||
-rw-r--r-- | plugins/check_tcp.c | 16 | ||||
-rw-r--r-- | plugins/netutils.c | 3 | ||||
-rw-r--r-- | plugins/netutils.h | 1 |
4 files changed, 30 insertions, 5 deletions
diff --git a/plugins/check_ssh.c b/plugins/check_ssh.c index f3a351e..421fc01 100644 --- a/plugins/check_ssh.c +++ b/plugins/check_ssh.c | |||
@@ -68,6 +68,8 @@ process_arguments (int argc, char **argv) | |||
68 | static struct option long_options[] = { | 68 | static struct option long_options[] = { |
69 | {"version", no_argument, 0, 'V'}, | 69 | {"version", no_argument, 0, 'V'}, |
70 | {"help", no_argument, 0, 'h'}, | 70 | {"help", no_argument, 0, 'h'}, |
71 | {"use-ipv4", no_argument, 0, '4'}, | ||
72 | {"use-ipv6", no_argument, 0, '6'}, | ||
71 | {"verbose", no_argument, 0, 'v'}, | 73 | {"verbose", no_argument, 0, 'v'}, |
72 | {"timeout", required_argument, 0, 't'}, | 74 | {"timeout", required_argument, 0, 't'}, |
73 | {"host", required_argument, 0, 'H'}, | 75 | {"host", required_argument, 0, 'H'}, |
@@ -82,7 +84,7 @@ process_arguments (int argc, char **argv) | |||
82 | strcpy (argv[c], "-t"); | 84 | strcpy (argv[c], "-t"); |
83 | 85 | ||
84 | while (1) { | 86 | while (1) { |
85 | c = getopt_long (argc, argv, "+Vhvt:H:p:", long_options, &option_index); | 87 | c = getopt_long (argc, argv, "+Vhv46t:H:p:", long_options, &option_index); |
86 | 88 | ||
87 | if (c == -1 || c == EOF) | 89 | if (c == -1 || c == EOF) |
88 | break; | 90 | break; |
@@ -104,6 +106,12 @@ process_arguments (int argc, char **argv) | |||
104 | usage ("Timeout Interval must be an integer!\n\n"); | 106 | usage ("Timeout Interval must be an integer!\n\n"); |
105 | socket_timeout = atoi (optarg); | 107 | socket_timeout = atoi (optarg); |
106 | break; | 108 | break; |
109 | case '4': | ||
110 | address_family = AF_INET; | ||
111 | break; | ||
112 | case '6': | ||
113 | address_family = AF_INET6; | ||
114 | break; | ||
107 | case 'H': /* host */ | 115 | case 'H': /* host */ |
108 | if (is_host (optarg) == FALSE) | 116 | if (is_host (optarg) == FALSE) |
109 | usage ("Invalid hostname/address\n"); | 117 | usage ("Invalid hostname/address\n"); |
@@ -217,7 +225,10 @@ print_usage (void) | |||
217 | ("Usage:\n" | 225 | ("Usage:\n" |
218 | " %s -t [timeout] -p [port] <host>\n" | 226 | " %s -t [timeout] -p [port] <host>\n" |
219 | " %s -V prints version info\n" | 227 | " %s -V prints version info\n" |
220 | " %s -h prints more detailed help\n", progname, progname, progname); | 228 | " %s -4 use IPv4 connection\n" |
229 | " %s -6 use IPv6 connection\n" | ||
230 | " %s -h prints more detailed help\n", | ||
231 | progname, progname, progname, progname, progname); | ||
221 | } | 232 | } |
222 | 233 | ||
223 | /* end of check_ssh.c */ | 234 | /* end of check_ssh.c */ |
diff --git a/plugins/check_tcp.c b/plugins/check_tcp.c index f4fe5f4..0f19c01 100644 --- a/plugins/check_tcp.c +++ b/plugins/check_tcp.c | |||
@@ -29,7 +29,7 @@ This plugin tests %s connections with the specified host.\n"; | |||
29 | const char *option_summary = "\ | 29 | const char *option_summary = "\ |
30 | -H host -p port [-w warn_time] [-c crit_time] [-s send_string]\n\ | 30 | -H host -p port [-w warn_time] [-c crit_time] [-s send_string]\n\ |
31 | [-e expect_string] [-q quit_string] [-m maxbytes] [-d delay]\n\ | 31 | [-e expect_string] [-q quit_string] [-m maxbytes] [-d delay]\n\ |
32 | [-t to_sec] [-r refuse_state] [-v]\n"; | 32 | [-t to_sec] [-r refuse_state] [-v] [-4] [-6]\n"; |
33 | 33 | ||
34 | const char *options = "\ | 34 | const char *options = "\ |
35 | -H, --hostname=ADDRESS\n\ | 35 | -H, --hostname=ADDRESS\n\ |
@@ -37,6 +37,10 @@ const char *options = "\ | |||
37 | address if possible to bypass DNS lookup).\n\ | 37 | address if possible to bypass DNS lookup).\n\ |
38 | -p, --port=INTEGER\n\ | 38 | -p, --port=INTEGER\n\ |
39 | Port number\n\ | 39 | Port number\n\ |
40 | -4, --use-ipv4\n\ | ||
41 | Use IPv4 connection\n\ | ||
42 | -6, --use-ipv6\n\ | ||
43 | Use IPv6 connection\n\ | ||
40 | -s, --send=STRING\n\ | 44 | -s, --send=STRING\n\ |
41 | String to send to the server\n\ | 45 | String to send to the server\n\ |
42 | -e, --expect=STRING\n\ | 46 | -e, --expect=STRING\n\ |
@@ -392,6 +396,8 @@ process_arguments (int argc, char **argv) | |||
392 | {"quit", required_argument, 0, 'q'}, | 396 | {"quit", required_argument, 0, 'q'}, |
393 | {"delay", required_argument, 0, 'd'}, | 397 | {"delay", required_argument, 0, 'd'}, |
394 | {"refuse", required_argument, 0, 'r'}, | 398 | {"refuse", required_argument, 0, 'r'}, |
399 | {"use-ipv4", no_argument, 0, '4'}, | ||
400 | {"use-ipv6", no_argument, 0, '6'}, | ||
395 | {"verbose", no_argument, 0, 'v'}, | 401 | {"verbose", no_argument, 0, 'v'}, |
396 | {"version", no_argument, 0, 'V'}, | 402 | {"version", no_argument, 0, 'V'}, |
397 | {"help", no_argument, 0, 'h'}, | 403 | {"help", no_argument, 0, 'h'}, |
@@ -419,7 +425,7 @@ process_arguments (int argc, char **argv) | |||
419 | } | 425 | } |
420 | 426 | ||
421 | while (1) { | 427 | while (1) { |
422 | c = getopt_long (argc, argv, "+hVvH:s:e:q:m:c:w:t:p:C:W:d:Sr:", | 428 | c = getopt_long (argc, argv, "+hVv46H:s:e:q:m:c:w:t:p:C:W:d:Sr:", |
423 | long_options, &option_index); | 429 | long_options, &option_index); |
424 | 430 | ||
425 | if (c == -1 || c == EOF || c == 1) | 431 | if (c == -1 || c == EOF || c == 1) |
@@ -439,6 +445,12 @@ process_arguments (int argc, char **argv) | |||
439 | case 'v': /* verbose mode */ | 445 | case 'v': /* verbose mode */ |
440 | verbose = TRUE; | 446 | verbose = TRUE; |
441 | break; | 447 | break; |
448 | case '4': | ||
449 | address_family = AF_INET; | ||
450 | break; | ||
451 | case '6': | ||
452 | address_family = AF_INET6; | ||
453 | break; | ||
442 | case 'H': /* hostname */ | 454 | case 'H': /* hostname */ |
443 | if (is_host (optarg) == FALSE) | 455 | if (is_host (optarg) == FALSE) |
444 | usage2 ("invalid host name or address", optarg); | 456 | usage2 ("invalid host name or address", optarg); |
diff --git a/plugins/netutils.c b/plugins/netutils.c index c567df5..dc679e2 100644 --- a/plugins/netutils.c +++ b/plugins/netutils.c | |||
@@ -35,6 +35,7 @@ | |||
35 | int socket_timeout = DEFAULT_SOCKET_TIMEOUT; | 35 | int socket_timeout = DEFAULT_SOCKET_TIMEOUT; |
36 | int econn_refuse_state = STATE_CRITICAL; | 36 | int econn_refuse_state = STATE_CRITICAL; |
37 | int was_refused = FALSE; | 37 | int was_refused = FALSE; |
38 | int address_family = AF_UNSPEC; | ||
38 | 39 | ||
39 | /* handles socket timeouts */ | 40 | /* handles socket timeouts */ |
40 | void | 41 | void |
@@ -254,7 +255,7 @@ my_connect (char *host_name, int port, int *sd, int proto) | |||
254 | int result; | 255 | int result; |
255 | 256 | ||
256 | memset (&hints, 0, sizeof (hints)); | 257 | memset (&hints, 0, sizeof (hints)); |
257 | hints.ai_family = PF_UNSPEC; | 258 | hints.ai_family = address_family; |
258 | hints.ai_protocol = proto; | 259 | hints.ai_protocol = proto; |
259 | hints.ai_socktype = (proto == IPPROTO_UDP) ? SOCK_DGRAM : SOCK_STREAM; | 260 | hints.ai_socktype = (proto == IPPROTO_UDP) ? SOCK_DGRAM : SOCK_STREAM; |
260 | 261 | ||
diff --git a/plugins/netutils.h b/plugins/netutils.h index 2ad0dba..8f53497 100644 --- a/plugins/netutils.h +++ b/plugins/netutils.h | |||
@@ -61,3 +61,4 @@ int is_hostname (char *); | |||
61 | extern int socket_timeout; | 61 | extern int socket_timeout; |
62 | extern int econn_refuse_state; | 62 | extern int econn_refuse_state; |
63 | extern int was_refused; | 63 | extern int was_refused; |
64 | extern int address_family; | ||