The following diff patches the check_ping.c file from
netsaint-plugins-1.2.9-4.tar.gz so that it will properly
parse the output of the /bin/ping from RH7.3 (maybe
earlier versions too, I no longer run previous versions).
This patch works with Nagios. Note that you have to add
something like:
--with-ping-command="/bin/ping -n -U -c %d %s"
to the options for the configure script from the
aforementioned tarball. Make sure that
PING_PACKETS_FIRST is defined if you use the above
option for configure. I think the "-U" option is superfluous
as I noticed no difference in ping's output when it was
removed. This patch should be suitable for incorporation
on all systems, not just RH7.3.
Diff output is attached, and also follows, at line
beginning with "402d".
402d401
< sscanf (input_buffer, "%*d
packets transmitted, %*d received, %d%% loss", &pl)
== 1 ||
410d408
< sscanf
(input_buffer, "rtt min/avg/max/mdev = %*f/%f/%*f/%*f",
&rta) == 1 ||
416d413
<
Logged In: NO
Here is a more complete version of the patch needed to run
check_ping under RH7.3
diff -uNr netsaint-plugins-1.2.9-4.orig/configure netsaint-
plugins-1.2.9-4/configure
--- netsaint-plugins-1.2.9-4.orig/configure Thu Apr 26
13:46:17 2001
+++ netsaint-plugins-1.2.9-4/configure Fri Jun 21 20:42:13
2002
@@ -4772,6 +4772,20 @@
EOF
fi
+elif ping -U -n -c 1 127.0.0.1 2>/dev/null | egrep -i "^rtt"
>/dev/null
+then
+ PING_COMMAND="$PATH_TO_PING -U -n -c %d %s"
+ cat >> confdefs.h <<EOF
+#define PING_PACKETS_FIRST "$PING_COMMAND"
+EOF
+
+elif ping -U -n -c 1 127.0.0.1 2>/dev/null | egrep -i "^round-
trip" >/dev/null
+then
+ PING_COMMAND="$PATH_TO_PING -U -n -c %d %s"
+ cat >> confdefs.h <<EOF
+#define PING_PACKETS_FIRST "$PING_COMMAND"
+EOF
+
elif ping -n -c 1 127.0.0.1 2>/dev/null | egrep -i "^round-trip"
>/dev/null
then
PING_COMMAND="$PATH_TO_PING -n -c %d %s"
diff -uNr netsaint-plugins-1.2.9-4.orig/configure.in netsaint-
plugins-1.2.9-4/configure.in
--- netsaint-plugins-1.2.9-4.orig/configure.in Thu Apr 26
09:00:26 2001
+++ netsaint-plugins-1.2.9-4/configure.in Fri Jun 21
20:42:38 2002
@@ -556,6 +556,16 @@
then
AC_DEFINE_UNQUOTED
(PING_PACKETS_FIRST,"$PING_COMMAND")
fi
+elif [ping -U -n -c 1 127.0.0.1 2>/dev/null | egrep -i "^rtt"
>/dev/null]
+then
+ PING_COMMAND="$PATH_TO_PING -U -n -c %d %s"
+ AC_DEFINE_UNQUOTED
(PING_PACKETS_FIRST,"$PING_COMMAND")
+ echo " ping syntax... $PATH_TO_PING -U -n -c
<count> <host>"
+elif [ping -U -n -c 1 127.0.0.1 2>/dev/null | egrep -i "^round-
trip" >/dev/null]
+then
+ PING_COMMAND="$PATH_TO_PING -U -n -c %d %s"
+ AC_DEFINE_UNQUOTED
(PING_PACKETS_FIRST,"$PING_COMMAND")
+ echo " ping syntax... $PATH_TO_PING -U -n -c
<count> <host>"
elif [ping -n -c 1 127.0.0.1 2>/dev/null | egrep -i "^round-trip"
>/dev/null]
then
PING_COMMAND="$PATH_TO_PING -n -c %d %s"
diff -uNr netsaint-plugins-1.2.9-4.orig/plugins/check_ping.c
netsaint-plugins-1.2.9-4/plugins/check_ping.c
--- netsaint-plugins-1.2.9-4.orig/plugins/check_ping.c Fri Apr
13 15:19:47 2001
+++ netsaint-plugins-1.2.9-4/plugins/check_ping.c Fri Jun
21 20:34:26 2002
@@ -399,7 +399,8 @@
/* get the percent loss statistics */
if (sscanf (input_buffer, "%*d packets
transmitted, %*d packets received, +%*d errors, %d%%
packet loss", &p
l) == 1 ||
- sscanf (input_buffer, "%*d
packets transmitted, %*d packets received, %d%% packet
loss", &pl
) == 1)
+ sscanf (input_buffer, "%*d
packets transmitted, %*d packets received, %d%% packet
loss", &pl
) == 1 ||
+ sscanf (input_buffer, "%*d
packets transmitted, %*d received, %d%% loss", &pl) == 1)
continue;
/* get the round trip average */
@@ -409,7 +410,8 @@
sscanf (input_buffer, "round-
trip min/avg/max/sdev = %*f/%f/%*f/%*f", &rta) == 1 ||
sscanf (input_buffer, "round-
trip min/avg/max/stddev = %*f/%f/%*f/%*f", &rta) == 1 |
|
sscanf (input_buffer, "round-
trip min/avg/max/std-dev = %*f/%f/%*f/%*f", &rta) == 1
||
- sscanf (input_buffer, "round-
trip (ms) min/avg/max = %*f/%f/%*f", &rta) == 1)
+ sscanf (input_buffer, "round-
trip (ms) min/avg/max = %*f/%f/%*f", &rta) == 1 ||
+ sscanf (input_buffer, "rtt
min/avg/max/mdev = %*f/%f/%*f/%*f", &rta) == 1)
continue;
}