diff options
author | Holger Weiss <holger@zedat.fu-berlin.de> | 2013-08-18 00:02:32 +0200 |
---|---|---|
committer | Holger Weiss <holger@zedat.fu-berlin.de> | 2013-08-18 00:02:32 +0200 |
commit | e4ccd85c5061fd2cc72e3f8ab7c9371751c93e34 (patch) | |
tree | 8db90384954e8633c85bb937b20e94331b45612d | |
parent | baa388e6fa66a231f79365b77c6dbd8dd4c32db7 (diff) | |
parent | 6515124a47364088f152151490c7a0cefb09b6fb (diff) | |
download | monitoring-plugins-e4ccd85c5061fd2cc72e3f8ab7c9371751c93e34.tar.gz |
Merge remote-tracking branch 'github/villemattila/check_fping_ipv6'
* github/villemattila/check_fping_ipv6:
check_fping: IPv6 support
Conflicts:
plugins/check_fping.c
-rw-r--r-- | configure.in | 11 | ||||
-rw-r--r-- | plugins/check_fping.c | 30 |
2 files changed, 39 insertions, 2 deletions
diff --git a/configure.in b/configure.in index 25c0c9cd..a5d48421 100644 --- a/configure.in +++ b/configure.in | |||
@@ -1389,6 +1389,17 @@ else | |||
1389 | AC_MSG_WARN([Get fping from http://www.fping.com in order to make check_fping plugin]) | 1389 | AC_MSG_WARN([Get fping from http://www.fping.com in order to make check_fping plugin]) |
1390 | fi | 1390 | fi |
1391 | 1391 | ||
1392 | AC_PATH_PROG(PATH_TO_FPING6,fping6) | ||
1393 | AC_ARG_WITH(fping6_command, | ||
1394 | ACX_HELP_STRING([--with-fping6-command=PATH], | ||
1395 | [Path to fping6 command]), PATH_TO_FPING6=$withval) | ||
1396 | if test -n "$PATH_TO_FPING6" | ||
1397 | then | ||
1398 | AC_DEFINE_UNQUOTED(PATH_TO_FPING6,"$PATH_TO_FPING6",[path to fping6]) | ||
1399 | else | ||
1400 | AC_MSG_WARN([Get fping6 from http://www.fping.com in order to make check_fping plugin]) | ||
1401 | fi | ||
1402 | |||
1392 | AC_PATH_PROG(PATH_TO_SSH,ssh) | 1403 | AC_PATH_PROG(PATH_TO_SSH,ssh) |
1393 | AC_ARG_WITH(ssh_command, | 1404 | AC_ARG_WITH(ssh_command, |
1394 | ACX_HELP_STRING([--with-ssh-command=PATH], | 1405 | ACX_HELP_STRING([--with-ssh-command=PATH], |
diff --git a/plugins/check_fping.c b/plugins/check_fping.c index 2c3eceb4..1c227cdb 100644 --- a/plugins/check_fping.c +++ b/plugins/check_fping.c | |||
@@ -74,6 +74,7 @@ main (int argc, char **argv) | |||
74 | /* normaly should be int result = STATE_UNKNOWN; */ | 74 | /* normaly should be int result = STATE_UNKNOWN; */ |
75 | 75 | ||
76 | int status = STATE_UNKNOWN; | 76 | int status = STATE_UNKNOWN; |
77 | char *fping_prog = NULL; | ||
77 | char *server = NULL; | 78 | char *server = NULL; |
78 | char *command_line = NULL; | 79 | char *command_line = NULL; |
79 | char *input_buffer = NULL; | 80 | char *input_buffer = NULL; |
@@ -102,7 +103,16 @@ main (int argc, char **argv) | |||
102 | if (sourceif) | 103 | if (sourceif) |
103 | xasprintf(&option_string, "%s-I %s ", option_string, sourceif); | 104 | xasprintf(&option_string, "%s-I %s ", option_string, sourceif); |
104 | 105 | ||
105 | xasprintf (&command_line, "%s %s-b %d -c %d %s", PATH_TO_FPING, | 106 | #ifdef USE_IPV6 |
107 | if (address_family == AF_INET6) | ||
108 | fping_prog = strdup(PATH_TO_FPING6); | ||
109 | else | ||
110 | fping_prog = strdup(PATH_TO_FPING); | ||
111 | #else | ||
112 | fping_prog = strdup(PATH_TO_FPING); | ||
113 | #endif | ||
114 | |||
115 | xasprintf (&command_line, "%s %s-b %d -c %d %s", fping_prog, | ||
106 | option_string, packet_size, packet_count, server); | 116 | option_string, packet_size, packet_count, server); |
107 | 117 | ||
108 | if (verbose) | 118 | if (verbose) |
@@ -249,6 +259,8 @@ process_arguments (int argc, char **argv) | |||
249 | {"verbose", no_argument, 0, 'v'}, | 259 | {"verbose", no_argument, 0, 'v'}, |
250 | {"version", no_argument, 0, 'V'}, | 260 | {"version", no_argument, 0, 'V'}, |
251 | {"help", no_argument, 0, 'h'}, | 261 | {"help", no_argument, 0, 'h'}, |
262 | {"use-ipv4", no_argument, 0, '4'}, | ||
263 | {"use-ipv6", no_argument, 0, '6'}, | ||
252 | {0, 0, 0, 0} | 264 | {0, 0, 0, 0} |
253 | }; | 265 | }; |
254 | 266 | ||
@@ -266,7 +278,7 @@ process_arguments (int argc, char **argv) | |||
266 | } | 278 | } |
267 | 279 | ||
268 | while (1) { | 280 | while (1) { |
269 | c = getopt_long (argc, argv, "+hVvH:S:c:w:b:n:T:i:I:", longopts, &option); | 281 | c = getopt_long (argc, argv, "+hVvH:S:c:w:b:n:T:i:I:46", longopts, &option); |
270 | 282 | ||
271 | if (c == -1 || c == EOF || c == 1) | 283 | if (c == -1 || c == EOF || c == 1) |
272 | break; | 284 | break; |
@@ -297,6 +309,15 @@ process_arguments (int argc, char **argv) | |||
297 | break; | 309 | break; |
298 | case 'I': /* sourceip */ | 310 | case 'I': /* sourceip */ |
299 | sourceif = strscpy (sourceif, optarg); | 311 | sourceif = strscpy (sourceif, optarg); |
312 | case '4': /* IPv4 only */ | ||
313 | address_family = AF_INET; | ||
314 | break; | ||
315 | case '6': /* IPv6 only */ | ||
316 | #ifdef USE_IPV6 | ||
317 | address_family = AF_INET6; | ||
318 | #else | ||
319 | usage (_("IPv6 support not available\n")); | ||
320 | #endif | ||
300 | break; | 321 | break; |
301 | case 'c': | 322 | case 'c': |
302 | get_threshold (optarg, rv); | 323 | get_threshold (optarg, rv); |
@@ -419,6 +440,8 @@ print_help (void) | |||
419 | printf (UT_HELP_VRSN); | 440 | printf (UT_HELP_VRSN); |
420 | printf (UT_EXTRA_OPTS); | 441 | printf (UT_EXTRA_OPTS); |
421 | 442 | ||
443 | printf (UT_IPv46); | ||
444 | |||
422 | printf (" %s\n", "-H, --hostname=HOST"); | 445 | printf (" %s\n", "-H, --hostname=HOST"); |
423 | printf (" %s\n", _("name or IP Address of host to ping (IP Address bypasses name lookup, reducing system load)")); | 446 | printf (" %s\n", _("name or IP Address of host to ping (IP Address bypasses name lookup, reducing system load)")); |
424 | printf (" %s\n", "-w, --warning=THRESHOLD"); | 447 | printf (" %s\n", "-w, --warning=THRESHOLD"); |
@@ -443,6 +466,9 @@ print_help (void) | |||
443 | printf (" %s\n", _("which triggers a WARNING or CRITICAL state, and <pl> is the percentage of")); | 466 | printf (" %s\n", _("which triggers a WARNING or CRITICAL state, and <pl> is the percentage of")); |
444 | printf (" %s\n", _("packet loss to trigger an alarm state.")); | 467 | printf (" %s\n", _("packet loss to trigger an alarm state.")); |
445 | 468 | ||
469 | printf ("\n"); | ||
470 | printf (" %s\n", _("IPv4 is used by default. Specify -6 to use IPv6.")); | ||
471 | |||
446 | printf (UT_SUPPORT); | 472 | printf (UT_SUPPORT); |
447 | } | 473 | } |
448 | 474 | ||