[monitoring-plugins] Make check_ping work on Windows.
Holger Weiss
git at monitoring-plugins.org
Sun Apr 27 20:00:08 CEST 2014
Module: monitoring-plugins
Branch: master
Commit: e0af39d7e9fcd084cf7d2d8a57d07ab1f8038150
Author: Gunnar Beutner <gunnar at beutner.name>
Committer: Holger Weiss <holger at zedat.fu-berlin.de>
Date: Mon Apr 21 11:29:45 2014 +0200
URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=e0af39d
Make check_ping work on Windows.
---
configure.ac | 16 ++++++++++++++--
plugins/check_ping.c | 7 +++++--
2 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/configure.ac b/configure.ac
index d73ac54..f405cce 100644
--- a/configure.ac
+++ b/configure.ac
@@ -90,6 +90,7 @@ ac_cv_uname_m=`uname -m`
ac_cv_uname_s=`uname -s`
ac_cv_uname_r=`uname -r`
ac_cv_uname_v=`uname -v`
+ac_cv_uname_o=`uname -o`
PKG_ARCH=`uname -p`
REV_DATESTAMP=`date '+%Y.%m.%d.%H.%M'`
@@ -1011,6 +1012,13 @@ then
ac_cv_ping_packets_first=yes
fi
+elif [[ "z$ac_cv_uname_o" = "zCygwin" ]]
+then
+ with_ping_command="$PATH_TO_PING -n %d -w %d000 %s"
+ ac_cv_ping_packets_first=yes
+ ac_cv_ping_has_timeout=yes
+ AC_MSG_RESULT([$with_ping_command])
+
elif [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
$PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
egrep -i "^round-trip|^rtt" >/dev/null
@@ -1024,7 +1032,7 @@ elif $PATH_TO_PING -n -U -w 10 -c 1 127.0.0.1 2>/dev/null | \
then
with_ping_command="$PATH_TO_PING -n -U -w %d -c %d %s"
ac_cv_ping_packets_first=yes
- ac_cv_ping_has_timeout=yes
+ ac_cv_ping_has_timeout=yes
AC_MSG_RESULT([$with_ping_command])
elif $PATH_TO_PING -n -U -c 1 127.0.0.1 2>/dev/null | \
@@ -1121,7 +1129,11 @@ then
then
ac_cv_ping6_packets_first=yes
fi
-
+elif [[ "z$ac_cv_uname_o" = "zCygwin" -a "x$PATH_TO_PING" != "x" ]]; then
+ with_ping6_command="$PATH_TO_PING -6 -n %d -w %d000 %s"
+ ac_cv_ping6_packets_first=yes
+ ac_cv_ping_has_timeout=yes
+ AC_MSG_RESULT([$with_ping6_command])
elif test "x$PATH_TO_PING6" != "x"; then
if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
$PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \
diff --git a/plugins/check_ping.c b/plugins/check_ping.c
index 95ac7b4..dbc5c3e 100644
--- a/plugins/check_ping.c
+++ b/plugins/check_ping.c
@@ -458,7 +458,8 @@ run_ping (const char *cmd, const char *addr)
(sscanf(buf,"%*d packets transmitted, %*d received, %d%% loss, time%n",&pl,&match) && match) ||
(sscanf(buf,"%*d packets transmitted, %*d received, %d%% packet loss, time%n",&pl,&match) && match) ||
(sscanf(buf,"%*d packets transmitted, %*d received, +%*d errors, %d%% packet loss%n",&pl,&match) && match) ||
- (sscanf(buf,"%*d packets transmitted %*d received, +%*d errors, %d%% packet loss%n",&pl,&match) && match)
+ (sscanf(buf,"%*d packets transmitted %*d received, +%*d errors, %d%% packet loss%n",&pl,&match) && match) ||
+ (sscanf(buf,"%*[^(](%d%% %*[^)])%n",&pl,&match) && match)
)
continue;
@@ -471,7 +472,9 @@ run_ping (const char *cmd, const char *addr)
(sscanf(buf,"round-trip min/avg/max/std-dev = %*f/%f/%*f/%*f%n",&rta,&match) && match) ||
(sscanf(buf,"round-trip (ms) min/avg/max = %*f/%f/%*f%n",&rta,&match) && match) ||
(sscanf(buf,"round-trip (ms) min/avg/max/stddev = %*f/%f/%*f/%*f%n",&rta,&match) && match) ||
- (sscanf(buf,"rtt min/avg/max/mdev = %*f/%f/%*f/%*f ms%n",&rta,&match) && match))
+ (sscanf(buf,"rtt min/avg/max/mdev = %*f/%f/%*f/%*f ms%n",&rta,&match) && match) ||
+ (sscanf(buf, "%*[^=] = %*fms, %*[^=] = %*fms, %*[^=] = %fms%n", &rta, &match) && match)
+ )
continue;
}
More information about the Commits
mailing list