diff options
| -rw-r--r-- | plugins/check_fping.c | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/plugins/check_fping.c b/plugins/check_fping.c index ec7abb67..1c2b7689 100644 --- a/plugins/check_fping.c +++ b/plugins/check_fping.c | |||
| @@ -79,7 +79,29 @@ 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 | |||
| 82 | /* compose the command */ | 84 | /* compose the command */ |
| 85 | #ifdef PATH_TO_FPING6 | ||
| 86 | if (address_family != AF_INET && is_inet6_addr(server)) { | ||
| 87 | fping_prog = strdup(PATH_TO_FPING6); | ||
| 88 | } else { | ||
| 89 | xasprintf(&option_string, "%s-4 ", option_string); | ||
| 90 | fping_prog = strdup(PATH_TO_FPING); | ||
| 91 | } | ||
| 92 | #else | ||
| 93 | if (address_family != AF_INET) { | ||
| 94 | // -4 / -6 must be set explicitly as when a host has dual stack | ||
| 95 | // if we don't specify -4 then fping selects ipv6 which can mess | ||
| 96 | // with some checks. | ||
| 97 | xasprintf(&option_string, "%s-6 ", option_string); | ||
| 98 | } else { | ||
| 99 | xasprintf(&option_string, "%s-4 ", option_string); | ||
| 100 | } | ||
| 101 | |||
| 102 | fping_prog = strdup(PATH_TO_FPING); | ||
| 103 | #endif | ||
| 104 | |||
| 83 | if (config.target_timeout) { | 105 | if (config.target_timeout) { |
| 84 | xasprintf(&option_string, "%s-t %d ", option_string, config.target_timeout); | 106 | xasprintf(&option_string, "%s-t %d ", option_string, config.target_timeout); |
| 85 | } | 107 | } |
| @@ -99,17 +121,6 @@ int main(int argc, char **argv) { | |||
| 99 | xasprintf(&option_string, "%s-R ", option_string); | 121 | xasprintf(&option_string, "%s-R ", option_string); |
| 100 | } | 122 | } |
| 101 | 123 | ||
| 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; | 124 | 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); | 125 | xasprintf(&command_line, "%s %s-b %d -c %d %s", fping_prog, option_string, config.packet_size, config.packet_count, server); |
| 115 | 126 | ||
