diff options
-rw-r--r-- | configure.in | 15 | ||||
-rw-r--r-- | plugins/check_ping.c | 37 |
2 files changed, 34 insertions, 18 deletions
diff --git a/configure.in b/configure.in index 5dc04f94..3f909295 100644 --- a/configure.in +++ b/configure.in | |||
@@ -871,6 +871,7 @@ AC_ARG_WITH(ping_command, | |||
871 | 871 | ||
872 | AC_MSG_CHECKING(for ICMP ping syntax) | 872 | AC_MSG_CHECKING(for ICMP ping syntax) |
873 | ac_cv_ping_packets_first=no | 873 | ac_cv_ping_packets_first=no |
874 | ac_cv_ping_has_timeout=no | ||
874 | if test -n "$with_ping_command" | 875 | if test -n "$with_ping_command" |
875 | then | 876 | then |
876 | AC_MSG_RESULT([(command-line) $with_ping_command]) | 877 | AC_MSG_RESULT([(command-line) $with_ping_command]) |
@@ -887,6 +888,14 @@ then | |||
887 | ac_cv_ping_packets_first=yes | 888 | ac_cv_ping_packets_first=yes |
888 | AC_MSG_RESULT([$with_ping_command]) | 889 | AC_MSG_RESULT([$with_ping_command]) |
889 | 890 | ||
891 | elif $PATH_TO_PING -n -U -w 10 -c 1 127.0.0.1 2>/dev/null | \ | ||
892 | egrep -i "^round-trip|^rtt" >/dev/null | ||
893 | then | ||
894 | with_ping_command="$PATH_TO_PING -n -U -w %d -c %d %s" | ||
895 | ac_cv_ping_packets_first=yes | ||
896 | ac_cv_ping_has_timeout=yes | ||
897 | AC_MSG_RESULT([$with_ping_command]) | ||
898 | |||
890 | elif $PATH_TO_PING -n -U -c 1 127.0.0.1 2>/dev/null | \ | 899 | elif $PATH_TO_PING -n -U -c 1 127.0.0.1 2>/dev/null | \ |
891 | egrep -i "^round-trip|^rtt" >/dev/null | 900 | egrep -i "^round-trip|^rtt" >/dev/null |
892 | then | 901 | then |
@@ -952,6 +961,12 @@ then | |||
952 | [Define if packet count must precede host]) | 961 | [Define if packet count must precede host]) |
953 | fi | 962 | fi |
954 | 963 | ||
964 | if test "x$ac_cv_ping_has_timeout" != "xno" | ||
965 | then | ||
966 | AC_DEFINE(PING_HAS_TIMEOUT,1, | ||
967 | [Define if ping has its own timeout option that should be set]) | ||
968 | fi | ||
969 | |||
955 | AC_ARG_WITH(ping6_command, | 970 | AC_ARG_WITH(ping6_command, |
956 | ACX_HELP_STRING([--with-ping6-command=SYNTAX], | 971 | ACX_HELP_STRING([--with-ping6-command=SYNTAX], |
957 | [sets syntax for ICMPv6 ping]), | 972 | [sets syntax for ICMPv6 ping]), |
diff --git a/plugins/check_ping.c b/plugins/check_ping.c index 1d34656c..26810f32 100644 --- a/plugins/check_ping.c +++ b/plugins/check_ping.c | |||
@@ -66,6 +66,7 @@ int | |||
66 | main (int argc, char **argv) | 66 | main (int argc, char **argv) |
67 | { | 67 | { |
68 | char *cmd = NULL; | 68 | char *cmd = NULL; |
69 | char *rawcmd = NULL; | ||
69 | int result = STATE_UNKNOWN; | 70 | int result = STATE_UNKNOWN; |
70 | int this_result = STATE_UNKNOWN; | 71 | int this_result = STATE_UNKNOWN; |
71 | int i; | 72 | int i; |
@@ -90,27 +91,26 @@ main (int argc, char **argv) | |||
90 | alarm (timeout_interval); | 91 | alarm (timeout_interval); |
91 | 92 | ||
92 | for (i = 0 ; i < n_addresses ; i++) { | 93 | for (i = 0 ; i < n_addresses ; i++) { |
94 | |||
95 | #ifdef PING6_COMMAND | ||
96 | if (is_inet6_addr(addresses[i]) && address_family != AF_INET) | ||
97 | rawcmd = strdup(PING6_COMMAND); | ||
98 | else | ||
99 | rawcmd = strdup(PING_COMMAND); | ||
100 | #else | ||
101 | rawcmd = strdup(PING_COMMAND); | ||
102 | #endif | ||
93 | 103 | ||
94 | /* does the host address of number of packets argument come first? */ | 104 | /* does the host address of number of packets argument come first? */ |
95 | #ifdef PING6_COMMAND | 105 | #ifdef PING_PACKETS_FIRST |
96 | # ifdef PING_PACKETS_FIRST | 106 | # ifdef PING_HAS_TIMEOUT |
97 | if (is_inet6_addr(addresses[i]) && address_family != AF_INET) | 107 | asprintf (&cmd, rawcmd, timeout_interval, max_packets, addresses[i]); |
98 | asprintf (&cmd, PING6_COMMAND, max_packets, addresses[i]); | ||
99 | else | ||
100 | asprintf (&cmd, PING_COMMAND, max_packets, addresses[i]); | ||
101 | # else | 108 | # else |
102 | if (is_inet6_addr(addresses[i]) && address_family != AF_INET) | 109 | asprintf (&cmd, rawcmd, max_packets, addresses[i]); |
103 | asprintf (&cmd, PING6_COMMAND, addresses[i], max_packets); | ||
104 | else | ||
105 | asprintf (&cmd, PING_COMMAND, addresses[i], max_packets); | ||
106 | # endif | 110 | # endif |
107 | #else /* USE_IPV6 */ | 111 | #else |
108 | # ifdef PING_PACKETS_FIRST | 112 | asprintf (&cmd, rawcmd, addresses[i], max_packets); |
109 | asprintf (&cmd, PING_COMMAND, max_packets, addresses[i]); | 113 | #endif |
110 | # else | ||
111 | asprintf (&cmd, PING_COMMAND, addresses[i], max_packets); | ||
112 | # endif | ||
113 | #endif /* USE_IPV6 */ | ||
114 | 114 | ||
115 | if (verbose) | 115 | if (verbose) |
116 | printf ("%s ==> ", cmd); | 116 | printf ("%s ==> ", cmd); |
@@ -150,7 +150,8 @@ main (int argc, char **argv) | |||
150 | printf ("%f:%d%% %f:%d%%\n", wrta, wpl, crta, cpl); | 150 | printf ("%f:%d%% %f:%d%%\n", wrta, wpl, crta, cpl); |
151 | 151 | ||
152 | result = max_state (result, this_result); | 152 | result = max_state (result, this_result); |
153 | 153 | free (rawcmd); | |
154 | free (cmd); | ||
154 | } | 155 | } |
155 | 156 | ||
156 | return result; | 157 | return result; |