mirror of
https://github.com/monitoring-plugins/monitoring-plugins.git
synced 2026-02-20 00:10:09 -05:00
Merge pull request #2115 from Firstyear/20250327-use-flags-fping
Improve handling of -4/-6 This changes the handling of `-4`/`-6` flags for check_fping to make it more explicit which IP stack is used in which case. Additionally, the deprecated `fping6` command is removed wholesale and the explicit `-4`/`-6` flags are used instead.
This commit is contained in:
commit
af88e3ced3
2 changed files with 18 additions and 22 deletions
|
|
@ -1524,17 +1524,10 @@ AC_PATH_PROG(PATH_TO_FPING6,fping6)
|
|||
AC_ARG_WITH(fping_command,
|
||||
ACX_HELP_STRING([--with-fping-command=PATH],
|
||||
[Path to fping command]), PATH_TO_FPING=$withval)
|
||||
AC_ARG_WITH(fping6_command,
|
||||
ACX_HELP_STRING([--with-fping6-command=PATH],
|
||||
[Path to fping6 command]), PATH_TO_FPING6=$withval)
|
||||
|
||||
if test -n "$PATH_TO_FPING"
|
||||
then
|
||||
AC_DEFINE_UNQUOTED(PATH_TO_FPING,"$PATH_TO_FPING",[path to fping])
|
||||
EXTRAS="$EXTRAS check_fping\$(EXEEXT)"
|
||||
if test x"$with_ipv6" != xno && test -n "$PATH_TO_FPING6"; then
|
||||
AC_DEFINE_UNQUOTED(PATH_TO_FPING6,"$PATH_TO_FPING6",[path to fping6])
|
||||
fi
|
||||
else
|
||||
AC_MSG_WARN([Get fping from http://www.fping.com in order to make check_fping plugin])
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -79,6 +79,24 @@ int main(int argc, char **argv) {
|
|||
server = strscpy(server, config.server_name);
|
||||
|
||||
char *option_string = "";
|
||||
char *fping_prog = NULL;
|
||||
|
||||
/* First determine if the target is dualstack or ipv6 only. */
|
||||
bool server_is_inet6_addr = is_inet6_addr(server);
|
||||
|
||||
/*
|
||||
* If the user requested -6 OR the user made no assertion and the address is v6 or dualstack
|
||||
* -> we use ipv6
|
||||
* If the user requested -4 OR the user made no assertion and the address is v4 ONLY
|
||||
* -> we use ipv4
|
||||
*/
|
||||
if (address_family == AF_INET6 || (address_family == AF_UNSPEC && server_is_inet6_addr)) {
|
||||
xasprintf(&option_string, "%s-6 ", option_string);
|
||||
} else {
|
||||
xasprintf(&option_string, "%s-4 ", option_string);
|
||||
}
|
||||
fping_prog = strdup(PATH_TO_FPING);
|
||||
|
||||
/* compose the command */
|
||||
if (config.target_timeout) {
|
||||
xasprintf(&option_string, "%s-t %d ", option_string, config.target_timeout);
|
||||
|
|
@ -99,17 +117,6 @@ int main(int argc, char **argv) {
|
|||
xasprintf(&option_string, "%s-R ", option_string);
|
||||
}
|
||||
|
||||
char *fping_prog = NULL;
|
||||
#ifdef PATH_TO_FPING6
|
||||
if (address_family != AF_INET && is_inet6_addr(server)) {
|
||||
fping_prog = strdup(PATH_TO_FPING6);
|
||||
} else {
|
||||
fping_prog = strdup(PATH_TO_FPING);
|
||||
}
|
||||
#else
|
||||
fping_prog = strdup(PATH_TO_FPING);
|
||||
#endif
|
||||
|
||||
char *command_line = NULL;
|
||||
xasprintf(&command_line, "%s %s-b %d -c %d %s", fping_prog, option_string, config.packet_size, config.packet_count, server);
|
||||
|
||||
|
|
@ -340,11 +347,7 @@ check_fping_config_wrapper process_arguments(int argc, char **argv) {
|
|||
address_family = AF_INET;
|
||||
break;
|
||||
case '6': /* IPv6 only */
|
||||
#ifdef USE_IPV6
|
||||
address_family = AF_INET6;
|
||||
#else
|
||||
usage(_("IPv6 support not available\n"));
|
||||
#endif
|
||||
break;
|
||||
case 'c':
|
||||
get_threshold(optarg, rv);
|
||||
|
|
|
|||
Loading…
Reference in a new issue