diff options
-rw-r--r-- | configure.ac | 7 | ||||
-rw-r--r-- | plugins/check_fping.c | 33 |
2 files changed, 18 insertions, 22 deletions
diff --git a/configure.ac b/configure.ac index fdc9b699..bd3de196 100644 --- a/configure.ac +++ b/configure.ac | |||
@@ -1524,17 +1524,10 @@ AC_PATH_PROG(PATH_TO_FPING6,fping6) | |||
1524 | AC_ARG_WITH(fping_command, | 1524 | AC_ARG_WITH(fping_command, |
1525 | ACX_HELP_STRING([--with-fping-command=PATH], | 1525 | ACX_HELP_STRING([--with-fping-command=PATH], |
1526 | [Path to fping command]), PATH_TO_FPING=$withval) | 1526 | [Path to fping command]), PATH_TO_FPING=$withval) |
1527 | AC_ARG_WITH(fping6_command, | ||
1528 | ACX_HELP_STRING([--with-fping6-command=PATH], | ||
1529 | [Path to fping6 command]), PATH_TO_FPING6=$withval) | ||
1530 | |||
1531 | if test -n "$PATH_TO_FPING" | 1527 | if test -n "$PATH_TO_FPING" |
1532 | then | 1528 | then |
1533 | AC_DEFINE_UNQUOTED(PATH_TO_FPING,"$PATH_TO_FPING",[path to fping]) | 1529 | AC_DEFINE_UNQUOTED(PATH_TO_FPING,"$PATH_TO_FPING",[path to fping]) |
1534 | EXTRAS="$EXTRAS check_fping\$(EXEEXT)" | 1530 | EXTRAS="$EXTRAS check_fping\$(EXEEXT)" |
1535 | if test x"$with_ipv6" != xno && test -n "$PATH_TO_FPING6"; then | ||
1536 | AC_DEFINE_UNQUOTED(PATH_TO_FPING6,"$PATH_TO_FPING6",[path to fping6]) | ||
1537 | fi | ||
1538 | else | 1531 | else |
1539 | AC_MSG_WARN([Get fping from http://www.fping.com in order to make check_fping plugin]) | 1532 | AC_MSG_WARN([Get fping from http://www.fping.com in order to make check_fping plugin]) |
1540 | fi | 1533 | fi |
diff --git a/plugins/check_fping.c b/plugins/check_fping.c index ec7abb67..e05056b2 100644 --- a/plugins/check_fping.c +++ b/plugins/check_fping.c | |||
@@ -79,6 +79,24 @@ int main(int argc, char **argv) { | |||
79 | server = strscpy(server, config.server_name); | 79 | server = strscpy(server, config.server_name); |
80 | 80 | ||
81 | char *option_string = ""; | 81 | char *option_string = ""; |
82 | char *fping_prog = NULL; | ||
83 | |||
84 | /* First determine if the target is dualstack or ipv6 only. */ | ||
85 | bool server_is_inet6_addr = is_inet6_addr(server); | ||
86 | |||
87 | /* | ||
88 | * If the user requested -6 OR the user made no assertion and the address is v6 or dualstack | ||
89 | * -> we use ipv6 | ||
90 | * If the user requested -4 OR the user made no assertion and the address is v4 ONLY | ||
91 | * -> we use ipv4 | ||
92 | */ | ||
93 | if (address_family == AF_INET6 || (address_family == AF_UNSPEC && server_is_inet6_addr)) { | ||
94 | xasprintf(&option_string, "%s-6 ", option_string); | ||
95 | } else { | ||
96 | xasprintf(&option_string, "%s-4 ", option_string); | ||
97 | } | ||
98 | fping_prog = strdup(PATH_TO_FPING); | ||
99 | |||
82 | /* compose the command */ | 100 | /* compose the command */ |
83 | if (config.target_timeout) { | 101 | if (config.target_timeout) { |
84 | xasprintf(&option_string, "%s-t %d ", option_string, config.target_timeout); | 102 | xasprintf(&option_string, "%s-t %d ", option_string, config.target_timeout); |
@@ -99,17 +117,6 @@ int main(int argc, char **argv) { | |||
99 | xasprintf(&option_string, "%s-R ", option_string); | 117 | xasprintf(&option_string, "%s-R ", option_string); |
100 | } | 118 | } |
101 | 119 | ||
102 | char *fping_prog = NULL; | ||
103 | #ifdef PATH_TO_FPING6 | ||
104 | if (address_family != AF_INET && is_inet6_addr(server)) { | ||
105 | fping_prog = strdup(PATH_TO_FPING6); | ||
106 | } else { | ||
107 | fping_prog = strdup(PATH_TO_FPING); | ||
108 | } | ||
109 | #else | ||
110 | fping_prog = strdup(PATH_TO_FPING); | ||
111 | #endif | ||
112 | |||
113 | char *command_line = NULL; | 120 | char *command_line = NULL; |
114 | xasprintf(&command_line, "%s %s-b %d -c %d %s", fping_prog, option_string, config.packet_size, config.packet_count, server); | 121 | xasprintf(&command_line, "%s %s-b %d -c %d %s", fping_prog, option_string, config.packet_size, config.packet_count, server); |
115 | 122 | ||
@@ -340,11 +347,7 @@ check_fping_config_wrapper process_arguments(int argc, char **argv) { | |||
340 | address_family = AF_INET; | 347 | address_family = AF_INET; |
341 | break; | 348 | break; |
342 | case '6': /* IPv6 only */ | 349 | case '6': /* IPv6 only */ |
343 | #ifdef USE_IPV6 | ||
344 | address_family = AF_INET6; | 350 | address_family = AF_INET6; |
345 | #else | ||
346 | usage(_("IPv6 support not available\n")); | ||
347 | #endif | ||
348 | break; | 351 | break; |
349 | case 'c': | 352 | case 'c': |
350 | get_threshold(optarg, rv); | 353 | get_threshold(optarg, rv); |