[Nagiosplug-devel] Would appreciate some configure.in help

Jeremy T. Bouse Jeremy.Bouse at UnderGrid.net
Fri Dec 13 20:58:03 CET 2002


	Attached is a small patch to configure.in that I've done to add
a --with-ping6-command option similar to the already existing
--with-ping-command... My problem is I'm not that great at actually
generating the configure.in so I know this prolly is not too portable at
this time... This is in my work to get IPv6 support and with check_ping
it needs to know how to call the ping command for IPv6... 

	The situation I ran into was that in Linux I have a
/usr/sbin/ping6 that handles IPv6 pings where /usr/sbin/ping only
supports IPv4... However on my Solaris 9 build machine it uses
/usr/sbin/ping for both IPv6 and IPv4, you just give it the "-A inet6"
option for IPv6 otherwise it uses IPv4 by default... What I have in this
patch does not work for the Solaris solution but works fine for Linux...

	I would think the ideal solution I feel would be to have
plugins avoid calling system commands at all as check_ping, check_dns
and check_dig all suffer from similar issues because the call ping,
nslookup and dig through system calls respectively... However until the
time can be taken to make a better solution I'm working with what we
have as a base...

	Jeremy
-------------- next part --------------
Index: configure.in
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/configure.in,v
retrieving revision 1.29
diff -u -r1.29 configure.in
--- configure.in	22 Nov 2002 02:46:49 -0000	1.29
+++ configure.in	14 Dec 2002 04:44:15 -0000
@@ -703,6 +703,57 @@
 fi
 AC_DEFINE_UNQUOTED(PING_COMMAND,"$PING_COMMAND",[path and args for ping command])
 
+AC_PATH_PROG(PATH_TO_PING6,ping6)
+
+AC_ARG_WITH(ping6_command,--with-ping6-command=<syntax> sets syntax for ping,PING6_COMMAND=$withval)
+if test -n "$PING6_COMMAND"
+then
+	echo "      ping6 syntax... (command-line) $PING6_COMMAND"
+	if test -n "$PING6_PACKETS_FIRST"
+	then
+		AC_DEFINE_UNQUOTED(PING6_PACKETS_FIRST,"$PING6_COMMAND",[Define if packet count must precede host])
+	fi
+elif [ping6 -n -U -c 1 ::1 2>/dev/null | egrep -i "^round-trip|^rtt" >/dev/null]
+then
+        PING6_COMMAND="$PATH_TO_PING6 -n -U -c %d %s"
+        AC_DEFINE_UNQUOTED(PING6_PACKETS_FIRST,"$PING6_COMMAND",[Define if packet count must precede host])
+        echo "      ping6 syntax... $PATH_TO_PING6 -n -U -c <count> <host>"
+elif [ping6 -n -c 1 ::1 2>/dev/null | egrep -i "^round-trip|^rtt" >/dev/null]
+then
+	PING6_COMMAND="$PATH_TO_PING6 -n -c %d %s"
+	AC_DEFINE_UNQUOTED(PING6_PACKETS_FIRST,"$PING6_COMMAND",[Define if packet count must precede host])
+	echo "      ping6 syntax... $PATH_TO_PING6 -n -c <count> <host>"
+elif [ping6 -n ::1 -c 1 2>/dev/null | egrep -i "^round-trip|^rtt" >/dev/null]
+then
+	PING6_COMMAND="$PATH_TO_PING6 -n %s -c %d"
+	echo "      ping6 syntax... $PATH_TO_PING6 -n <host> -c <count>"
+elif [ping6 ::1 -n 1 2>/dev/null | egrep -i "^round-trip|^rtt" >/dev/null]
+then
+	PING6_COMMAND="$PATH_TO_PING6 %s -n %d"
+	echo "      ping6 syntax... $PATH_TO_PING6 <host> -n <count>"
+elif [ping6 -n -s ::1 56 1 2>/dev/null | egrep -i "^round-trip|^rtt" >/dev/null]
+then
+	PING6_COMMAND="$PATH_TO_PING6 -n -s %s 56 %d"
+	echo "      ping6 syntax... $PATH_TO_PING6 -n -s <host> 56 <count>"
+elif [ping6 -n -h ::1 -s 56 -c 1 2>/dev/null | egrep -i "^round-trip|^rtt" >/dev/null]
+then
+	PING6_COMMAND="$PATH_TO_PING6 -n -h %s -s 56 -c %d"
+	echo "      ping6 syntax... $PATH_TO_PING6 -n -h <host> -s 56 -c <count>"
+elif [ping6 -n -s 56 -c 1 ::1 2>/dev/null | egrep -i "^round-trip|^rtt" >/dev/null]
+then
+	PING6_COMMAND="$PATH_TO_PING6 -n -s 56 -c %d %s"
+	AC_DEFINE_UNQUOTED(PING6_PACKETS_FIRST,"$PING6_COMMAND",[Define if packet count must precede host])
+	echo "      ping6 syntax... $PATH_TO_PING6 -n -s 56 -c <count> <host>"
+elif [ping6 -n -c 1 ::1 2>/dev/null | egrep -i "^round-trip|^rtt" >/dev/null]
+then
+	PING6_COMMAND="$PATH_TO_PING6 -n -c %d %s"
+	AC_DEFINE_UNQUOTED(PING6_PACKETS_FIRST,"$PING6_COMMAND",[Define if packet count must precede host])
+	echo "      ping6 syntax... $PATH_TO_PING6 -n -c <count> <host>"
+else
+	AC_MSG_WARN("unable to find usable ping6 syntax")
+fi
+AC_DEFINE_UNQUOTED(PING6_COMMAND,"$PING6_COMMAND",[path and args for ping command])
+
 AC_PATH_PROG(PATH_TO_NSLOOKUP,nslookup)
 if test -n "$ac_cv_path_PATH_TO_NSLOOKUP"
 then


More information about the Devel mailing list