diff options
author | Gunnar Beutner <gunnar@beutner.name> | 2014-04-21 11:29:45 +0200 |
---|---|---|
committer | Holger Weiss <holger@zedat.fu-berlin.de> | 2014-04-27 19:59:06 +0200 |
commit | e0af39d7e9fcd084cf7d2d8a57d07ab1f8038150 (patch) | |
tree | f6eee031831451476795e139b6ceb33298b1155d | |
parent | d00efeb872c968824879614c848cead71452cbfd (diff) | |
download | monitoring-plugins-e0af39d7e9fcd084cf7d2d8a57d07ab1f8038150.tar.gz |
Make check_ping work on Windows.
-rw-r--r-- | configure.ac | 16 | ||||
-rw-r--r-- | plugins/check_ping.c | 7 |
2 files changed, 19 insertions, 4 deletions
diff --git a/configure.ac b/configure.ac index d73ac545..f405cce7 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 95ac7b44..dbc5c3e4 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; } |