Remove support for specifying the port number using "-H example.com:80".
[monitoring-plugins.git] / configure.in
blob78434437e94c4a2f2ff8b73a9ab0490a7922e378
1 dnl Process this file with autoconf to produce a configure script.
2 AC_REVISION ($Revision$)
3 AC_PREREQ(2.59)
4 AC_INIT(nagios-plugins,1.4.11)
5 AC_CONFIG_SRCDIR(NPTest.pm)
6 AC_CONFIG_FILES(gl/Makefile)
7 AC_CONFIG_AUX_DIR(build-aux)
8 AM_INIT_AUTOMAKE([1.8.3])
9 AM_CONFIG_HEADER(config.h)
10 AC_CANONICAL_HOST
12 RELEASE=1
13 AC_SUBST(RELEASE)
15 AC_PREFIX_DEFAULT(/usr/local/nagios)
17 dnl Deprecated configure options
20 dnl Append user (-o), group (-g), mode (-m) to install command
21 dnl There is an assumption that this is possible with ./configure's chosen install command
22 extra_install_args=""
23 AC_ARG_WITH(nagios_user,
24         ACX_HELP_STRING([--with-nagios-user=USER],
25                 [Installs executables with this user. Defaults to install user]),
26         extra_install_args="-o $withval")
27 AC_ARG_WITH(nagios_group,
28         ACX_HELP_STRING([--with-nagios-group=GROUP],
29                 [Installs executables with this group. Defaults to install user]),
30         extra_install_args="$extra_install_args -g $withval")
31 AC_ARG_WITH(world_permissions,
32         ACX_HELP_STRING([--without-world-permissions],
33                 [Installs executables without world permissions]))
35 if test "x$with_world_permissions" = xno ; then
36         extra_install_args="$extra_install_args -m 0550"
39 INSTALL="$INSTALL $extra_install_args"
40 INSTALL_STRIP_PROGRAM="$INSTALL_STRIP_PROGRAM $extra_install_args"
41 AC_SUBST(INSTALL)
43 AC_PROG_CC
44 gl_EARLY
45 AC_PROG_GCC_TRADITIONAL
46 AC_PROG_LIBTOOL
48 AM_PROG_CC_C_O
50 AC_FUNC_ERROR_AT_LINE
52 ifdef([AC_FUNC_STRTOD],[AC_FUNC_STRTOD],[AM_FUNC_STRTOD])
54 PLUGIN_TEST=`echo $srcdir/plugins/t/*.t|sed -e 's,\.*/plugins/,,g'`
55 AC_SUBST(PLUGIN_TEST)dnl
57 SCRIPT_TEST=`echo $srcdir/plugins-scripts/t/*.t|sed -e 's,\.*/plugins-scripts/,,g'`
58 AC_SUBST(SCRIPT_TEST)dnl
60 WARRANTY="The nagios plugins come with ABSOLUTELY NO WARRANTY. You may redistribute\ncopies of the plugins under the terms of the GNU General Public License.\nFor more information about these matters, see the file named COPYING.\n"
61 AC_SUBST(WARRANTY)
63 SUPPORT="Send email to nagios-users@lists.sourceforge.net if you have questions\nregarding use of this software. To submit patches or suggest improvements,\nsend email to nagiosplug-devel@lists.sourceforge.net.\nPlease include version information with all correspondence (when possible,\nuse output from the --version option of the plugin itself).\n"
64 AC_SUBST(SUPPORT)
66 dnl CGIURL has changed for Nagios with 1.0 beta
67 AC_ARG_WITH(cgiurl,
68         ACX_HELP_STRING([--with-cgiurl=DIR],
69                 [sets URL for cgi programs]),
70         with_cgiurl=$withval,
71         with_cgiurl=/nagios/cgi-bin)
72 CGIURL="$with_cgiurl"
73 AC_DEFINE_UNQUOTED(CGIURL,"$CGIURL",[URL of CGI programs])
75 AC_ARG_WITH(trusted_path,
76         ACX_HELP_STRING([--with-trusted-path=PATH],
77                 [sets trusted path for executables called by scripts (default=/bin:/sbin:/usr/bin:/usr/sbin)]),
78         with_trusted_path=$withval,
79         with_trusted_path=/bin:/sbin:/usr/bin:/usr/sbin)
80 AC_SUBST(with_trusted_path)
82 EXTRAS=
83 EXTRAS_ROOT=
84 dnl PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/etc:/usr/local/bin:/usr/local/sbin:$PATH
86 LDFLAGS="$LDFLAGS -L."
88 ac_cv_uname_m=`uname -m`
89 ac_cv_uname_s=`uname -s`
90 ac_cv_uname_r=`uname -r`
91 ac_cv_uname_v=`uname -v`
93 PKG_ARCH=`uname -p`
94 REV_DATESTAMP=`date '+%Y.%m.%d.%H.%M'`
95 REV_TIMESTAMP=`date '+%Y%m%d%H%M%S'`
97 AC_SUBST(PKG_ARCH)
98 AC_SUBST(REV_DATESTAMP)
99 AC_SUBST(REV_TIMESTAMP)
101 dnl Checks for programs.
102 AC_PATH_PROG(PYTHON,python)
103 AC_PATH_PROG(SH,sh)
104 AC_PATH_PROG(PERL,perl)
105 AC_PATH_PROG(LIBGNUTLS_CONFIG,libgnutls-config)
106 AC_PATH_PROG(HOSTNAME,hostname)
107 AC_PATH_PROG(BASENAME,basename)
109 dnl allow them to override the path of perl
110 AC_ARG_WITH(perl,
111         ACX_HELP_STRING([--with-perl=PATH],
112                         [sets path to perl executable]),
113                         with_perl=$withval,with_perl=$PERL)
114 AC_SUBST(PERL, $with_perl)
116 dnl openssl/gnutls
117 AC_ARG_WITH(openssl,
118             AC_HELP_STRING([--with-openssl=DIR], 
119                            [path to openssl installation]),)
121 AC_ARG_WITH(gnutls,
122             ACX_HELP_STRING([--with-gnutls=PATH],
123                             [path to gnutls installation root]),)
125 dnl you can only have one or the other
126 if test ! "$with_openssl" = "" && test ! "$with_openssl" = "no"; then
127         with_gnutls="no"
129 if test ! "$with_gnutls" = "" && test ! "$with_gnutls" = "no"; then
130         with_openssl="no"
133 dnl list of possible dirs to try to autodetect openssl
134 dnl if $dir/include exists, we consider it found
135 dnl the order should allow locally installed versions to override distros' ones
136 OPENSSL_DIRS="/usr /usr/local /usr/slocal /usr/local/openssl /usr/local/ssl \
137               /opt /opt/openssl"
141 dnl Checks for libraries.
144 AC_CHECK_LIB(dce,main,SOCKETLIBS="$SOCKETLIBS -ldce")
145 AC_CHECK_LIB(nsl,main,SOCKETLIBS="$SOCKETLIBS -lnsl")
146 AC_CHECK_LIB(socket,socket,SOCKETLIBS="$SOCKETLIBS -lsocket")
147 AC_CHECK_LIB(resolv,main,SOCKETLIBS="$SOCKETLIBS -lresolv")
148 AC_SUBST(SOCKETLIBS)
151 dnl check for math-related functions needing -lm
152 AC_CHECK_HEADERS(math.h)
153 AC_CHECK_LIB(m,floor,MATHLIBS="-lm")
154 AC_SUBST(MATHLIBS)
156 dnl Check for libtap, to run perl-like tests
157 AC_CHECK_LIB(tap, plan_tests, 
158         EXTRA_TEST="test_utils test_disk test_tcp test_cmd test_base64"
159         AC_SUBST(EXTRA_TEST)
160         )
162 dnl Check for PostgreSQL libraries
163 _SAVEDLIBS="$LIBS"
164 _SAVEDCPPFLAGS="$CPPFLAGS"
165 AC_ARG_WITH(pgsql,
166         ACX_HELP_STRING([--with-pgsql=DIR],
167                 [sets path to pgsql installation]),
168         PGSQL=$withval,)
169 AC_CHECK_LIB(crypt,main)
170 if test "$ac_cv_lib_crypt_main" = "yes"; then
171   if test -n "$PGSQL"; then
172     LDFLAGS="$LDFLAGS -L$PGSQL/lib"
173     CPPFLAGS="$CPPFLAGS -I$PGSQL/include"
174   fi
175   AC_CHECK_LIB(pq,PQsetdbLogin,,,-lcrypt)
176   if test "$ac_cv_lib_pq_PQsetdbLogin" = "yes"; then
177     AC_CHECK_HEADERS(pgsql/libpq-fe.h)
178     AC_CHECK_HEADERS(postgresql/libpq-fe.h)
179     AC_CHECK_HEADERS(libpq-fe.h)
180     if [[ -n "$PGSQL" -a "$ac_cv_header_libpq_fe_h" = "yes" ]]; then
181       PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
182       PGINCLUDE="-I$PGSQL/include"
183     elif test  "$ac_cv_header_pgsql_libpq_fe_h" = "yes"; then
184       PGLIBS="-lpq -lcrypt"
185       PGINCLUDE="-I/usr/include/pgsql"
186     elif test  "$ac_cv_header_postgresql_libpq_fe_h" = "yes"; then
187       PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
188       PGINCLUDE="-I/usr/include/postgresql"
189     elif test  "$ac_cv_header_libpq_fe_h" = "yes"; then
190       PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
191       PGINCLUDE="-I$PGSQL/include"
192     fi
193     if test -z "$PGINCLUDE"; then
194       AC_MSG_WARN([Skipping PostgreSQL plugin (check_pgsql)])
195       AC_MSG_WARN([install PostgreSQL headers to compile this plugin (see REQUIREMENTS).])
196     else
197       AC_SUBST(PGLIBS)
198       AC_SUBST(PGINCLUDE)
199       EXTRAS="$EXTRAS check_pgsql"
200     fi
201   else
202     AC_MSG_WARN([Skipping PostgreSQL plugin (check_pgsql)])
203     AC_MSG_WARN([LIBS="$LIBS" CPPFLAGS="$CPPFLAGS"])
204     AC_MSG_WARN([install PostgreSQL libs to compile this plugin (see REQUIREMENTS).])
205   fi
206 else
207   AC_MSG_WARN([Skipping PostgreSQL plugin (check_pgsql)])
208   AC_MSG_WARN([install lib crypt and PostgreSQL libs to compile this plugin (see REQUIREMENTS).])
210 LIBS="$_SAVEDLIBS"
211 CPPFLAGS="$_SAVEDCPPFLAGS"
213 dnl Check for radius libraries
214 _SAVEDLIBS="$LIBS"
215 AC_CHECK_LIB(radiusclient,rc_read_config)
216 if test "$ac_cv_lib_radiusclient_rc_read_config" = "yes"; then
217   EXTRAS="$EXTRAS check_radius"
218         RADIUSLIBS="-lradiusclient"
219   AC_SUBST(RADIUSLIBS)
220 else
221   AC_CHECK_LIB(radiusclient-ng,rc_read_config)
222   if test "$ac_cv_lib_radiusclient_ng_rc_read_config" = "yes"; then
223     EXTRAS="$EXTRAS check_radius"
224           RADIUSLIBS="-lradiusclient-ng"
225     AC_SUBST(RADIUSLIBS)
226   else
227     AC_MSG_WARN([Skipping radius plugin])
228     AC_MSG_WARN([install radius libs to compile this plugin (see REQUIREMENTS).])
229   fi
231 LIBS="$_SAVEDLIBS"
233 dnl Check for LDAP libraries
234 _SAVEDLIBS="$LIBS"
235 AC_CHECK_LIB(ldap,main,,,-llber)
236 if test "$ac_cv_lib_ldap_main" = "yes"; then
237   LDAPLIBS="-lldap -llber"\
238   LDAPINCLUDE="-I/usr/include/ldap"
239   AC_SUBST(LDAPLIBS)
240   AC_SUBST(LDAPINCLUDE)
241   AC_CHECK_FUNCS(ldap_set_option)
242   EXTRAS="$EXTRAS check_ldap"
243         AC_CHECK_FUNCS(ldap_init ldap_set_option ldap_get_option ldap_start_tls_s)
244 else
245   AC_MSG_WARN([Skipping LDAP plugin])
246   AC_MSG_WARN([install LDAP libs to compile this plugin (see REQUIREMENTS).])
248 LIBS="$_SAVEDLIBS"
250 dnl Check for headers used by check_ide_smart
251 AC_CHECK_HEADER(linux/hdreg.h, FOUNDINCLUDE=yes, FOUNDINCLUDE=no)
252 if test "$FOUNDINCLUDE" = "yes" ; then
253         AC_CHECK_HEADER(linux/types.h, FOUNDINCLUDE=yes, FOUNDINCLUDE=no)
256 if test "$FOUNDINCLUDE" = "yes" ; then
257         EXTRAS="$EXTRAS check_ide_smart"
258 else
259         AC_MSG_WARN([Skipping check_ide_smart plugin.]) 
260         AC_MSG_WARN([check_ide_smart is linux specific. It requires linux/hdreg.h and linux/types.h.]) 
263 dnl Check for mysql libraries
264 np_mysqlclient
265 if test $with_mysql = "no" ; then
266   AC_MSG_WARN([Skipping mysql plugin])
267   AC_MSG_WARN([install mysql client libs to compile this plugin (see REQUIREMENTS).])
268 else
269   EXTRAS="$EXTRAS check_mysql check_mysql_query"
270   MYSQLINCLUDE="$np_mysql_include"
271   MYSQLLIBS="$np_mysql_libs"
272   MYSQLCFLAGS="$np_mysql_cflags"
273   AC_SUBST(MYSQLINCLUDE)
274   AC_SUBST(MYSQLLIBS)
275   AC_SUBST(MYSQLCFLAGS)
278 AC_ARG_WITH([ipv6],
279         [AS_HELP_STRING([--with-ipv6], [support IPv6 @<:@default=check@:>@])],
280         [], [with_ipv6=check])
282 dnl Check for AF_INET6 support - unistd.h required for Darwin
283 if test "$with_ipv6" != "no"; then
284         AC_CACHE_CHECK([for IPv6 support], np_cv_sys_ipv6, [
285                 AC_TRY_COMPILE(
286                         [#ifdef HAVE_UNISTD_H
287                         #include <unistd.h>
288                         #endif
289                         #include <netinet/in.h>
290                         #include <sys/socket.h>],
291                         [struct sockaddr_in6 sin6;
292                         void *p;
294                         sin6.sin6_family = AF_INET6;
295                         sin6.sin6_port = 587;
296                         p = &sin6.sin6_addr;],
297                         [np_cv_sys_ipv6=yes],
298                         [np_cv_sys_ipv6=no])
299                 ])
300         if test "$np_cv_sys_ipv6" = "no" -a "$with_ipv6" != "check"; then
301                 AC_MSG_FAILURE([--with-ipv6 was given, but test for IPv6 support failed])
302         fi
303         if test "$np_cv_sys_ipv6" = "yes"; then
304                 AC_DEFINE(USE_IPV6,1,[Enable IPv6 support])
305         fi
306         with_ipv6="$np_cv_sys_ipv6"
310 dnl Checks for Kerberos. Must come before openssl checks for Redhat EL 3
311 AC_CHECK_HEADERS(krb5.h,FOUNDINCLUDE=yes,FOUNDINCLUDE=no)
312 if test "$FOUNDINCLUDE" = "no"; then
313   _SAVEDCPPFLAGS="$CPPFLAGS"
314   CPPFLAGS="$_SAVEDCPPFLAGS -I/usr/kerberos/include"
315   unset ac_cv_header_krb5_h
316   AC_CHECK_HEADERS(krb5.h,
317                    KRB5INCLUDE="-I/usr/kerberos/include"
318                    FOUNDINCLUDE=yes,
319                    FOUNDINCLUDE=no)
321 AC_SUBST(KRBINCLUDE)
322 if test "$FOUNDINCLUDE" = "no"; then
323   CPPFLAGS="$_SAVEDCPPFLAGS"
327 dnl openssl detection/configuration
328 if ! test x"$with_openssl" = x"no"; then
329         dnl Check for OpenSSL location if it wasn't already specified
330         if ! test -d "$with_openssl"; then
331                 for d in $OPENSSL_DIRS; do
332                         if test -x ${d}/bin/openssl || test -x ${d}/sbin/openssl ; then
333                                 with_openssl=$d
334                         fi
335                 done
336         fi
338         _SAVEDCPPFLAGS="$CPPFLAGS"
339         _SAVEDLDFLAGS="$LDFLAGS"
340         dnl Check for OpenSSL header files
341         unset FOUNDINCLUDE
342         if test x"$with_openssl" != x"/usr" ; then
343                 CPPFLAGS="$CPPFLAGS -I$with_openssl/include"
344                 LDFLAGS="$LDFLAGS -L$with_openssl/lib"
345         fi
347         dnl check for openssl in $dir/include/openssl
348         AC_CHECK_HEADERS(openssl/ssl.h openssl/x509.h openssl/rsa.h openssl/pem.h openssl/crypto.h openssl/err.h,
349                          SSLINCLUDE="-I$with_openssl/include"
350                          FOUNDINCLUDE=yes,
351                          FOUNDINCLUDE=no)
352         dnl else check to see if $dir/include has it
353         if test "$FOUNDINCLUDE" = "no"; then
354                 AC_CHECK_HEADERS(ssl.h x509.h rsa.h pem.h crypto.h err.h,
355                                  SSLINCLUDE="-I$with_openssl/include"
356                                  FOUNDINCLUDE=yes,
357                                  FOUNDINCLUDE=no)
358         fi
359         AC_SUBST(SSLINCLUDE)
360         dnl if we didn't find it, reset CPPFLAGS
361         if test "$FOUNDINCLUDE" = "no"; then
362                 CPPFLAGS="$_SAVEDCPPFLAGS"
363                 LDFLAGS="$_SAVEDLDFLAGS"
364         fi
366         dnl Check for crypto lib
367         _SAVEDLIBS="$LIBS"
368         LIBS="-L${with_openssl}/lib"
369         AC_CHECK_LIB(crypto,CRYPTO_lock)
370         if test "$ac_cv_lib_crypto_CRYPTO_lock" = "yes"; then
371                 dnl Check for SSL lib
372                 AC_CHECK_LIB(ssl,main, SSLLIBS="-lssl -lcrypto",,-lcrypto)
373         fi
374         LIBS="$_SAVEDLIBS"
376         dnl test headers and libs to decide whether check_http should use SSL
377         if test "$ac_cv_lib_crypto_CRYPTO_lock" = "yes"; then
378                 if test "$ac_cv_lib_ssl_main" = "yes"; then
379                         if test "$FOUNDINCLUDE" = "yes"; then
380                                 FOUNDOPENSSL="yes"
381                         fi
382                 fi
383         fi
387 dnl check for gnutls if openssl isn't found (or is disabled)
388 if test ! "$FOUNDOPENSSL" = "yes" && test ! "$with_gnutls" = "no"; then
389         if test ! "$with_gnutls" = ""; then
390                 CPPFLAGS="$CPPFLAGS -I${with_gnutls}/include"
391         elif test ! "$LIBGNUTLS_CONFIG" = ""; then
392                 CPPFLAGS="$CPPFLAGS -I`$LIBGNUTLS_CONFIG --prefix`"
393         fi
394         AC_CHECK_HEADERS([gnutls/openssl.h],FOUNDGNUTLS="yes",)
395         if test "$FOUNDGNUTLS" = "yes"; then
396                 AC_CHECK_LIB(gnutls-openssl,main,SSLLIBS="-lgnutls-openssl")
397         fi
399 dnl end check for gnutls
401 if test "$FOUNDOPENSSL" = "yes" || test "$FOUNDGNUTLS" = "yes"; then
402         check_tcp_ssl="check_simap check_spop check_jabber check_nntps check_ssmtp"
403         AC_SUBST(check_tcp_ssl)
404         AC_SUBST(SSLLIBS)
405         AC_DEFINE(HAVE_SSL,1,[Define if SSL libraries are found])
406         if test "$FOUNDOPENSSL" = "yes"; then
407                 AC_DEFINE(USE_OPENSSL,1,[Define if using OpenSSL libraries])
408                 with_openssl="yes"
409                 with_gnutls="no"
410         else
411                 AC_DEFINE(USE_GNUTLS,1,[Define if using gnutls libraries])
412                 with_gnutls="yes"
413                 with_openssl="no"
414         fi
415 else
416         dnl else deliberately disabled or no ssl support available
417         AC_MSG_WARN([OpenSSL or GnuTLS libs could not be found or were disabled])
418         with_openssl="no"
419         with_gnutls="no"
423 dnl Checks for header files.
426 AC_HEADER_TIME
427 AC_HEADER_SYS_WAIT
428 AC_CHECK_HEADERS(signal.h syslog.h uio.h errno.h sys/time.h sys/socket.h sys/un.h sys/poll.h)
429 AC_CHECK_HEADERS(features.h stdarg.h sys/unistd.h ctype.h)
431 dnl Checks for typedefs, structures, and compiler characteristics.
432 AC_C_CONST
433 AC_STRUCT_TM
434 AC_TYPE_PID_T
435 AC_TYPE_SIZE_T
436 AC_TYPE_SIGNAL
438 AC_CACHE_CHECK([for va_copy],ac_cv_HAVE_VA_COPY,[
439 AC_TRY_LINK([#include <stdarg.h>
440 va_list ap1,ap2;], [va_copy(ap1,ap2);],
441 ac_cv_HAVE_VA_COPY=yes,
442 ac_cv_HAVE_VA_COPY=no)])
443 if test x"$ac_cv_HAVE_VA_COPY" = x"yes"; then
444     AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available])
445 else    
446     AC_CACHE_CHECK([for __va_copy],ac_cv_HAVE___VA_COPY,[
447     AC_TRY_LINK([#include <stdarg.h>
448     va_list ap1,ap2;], [__va_copy(ap1,ap2);],
449     ac_cv_HAVE___VA_COPY=yes,
450     ac_cv_HAVE___VA_COPY=no)])
451     if test x"$ac_cv_HAVE___VA_COPY" = x"yes"; then
452         AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available])
453     fi
456 AC_TRY_COMPILE([#include <sys/time.h>],
457                [struct timeval *tv;
458                 struct timezone *tz;],
459                AC_DEFINE(HAVE_STRUCT_TIMEVAL,1,[Define if we have a timeval structure])
460                AC_TRY_COMPILE([#include <sys/time.h>],
461                               [struct timeval *tv;
462                                struct timezone *tz;
463                                gettimeofday(tv, tz);],
464                               AC_DEFINE(HAVE_GETTIMEOFDAY,1,[Define if gettimeofday is found]),
465                               AC_DEFINE(NEED_GETTIMEOFDAY,1,[Define if gettimeofday is needed])))
467 dnl Checks for library functions.
468 AC_CHECK_FUNCS(memmove select socket strdup strstr strtol strtoul floor)
469 AC_CHECK_FUNCS(poll)
471 AC_MSG_CHECKING(return type of socket size)
472 AC_TRY_COMPILE([#include <stdlib.h>
473                 #include <sys/types.h>
474                 #include <sys/socket.h>],
475                [int a = send(1, (const void *) buffer, (size_t *) 0, (int *) 0);],
476                ac_cv_socket_size_type=["size_t"]
477                 AC_MSG_RESULT(size_t),
478                ac_cv_socket_size_type=["int"]
479                 AC_MSG_RESULT(int))
481 AC_DEFINE_UNQUOTED(SOCKET_SIZE_TYPE, $ac_cv_socket_size_type ,
482         [Define type of socket size])
485 dnl #### Process table test
487 AC_PATH_PROG(PATH_TO_PS,ps)
489 AC_MSG_CHECKING(for ps syntax)
490 AC_ARG_WITH(ps_command,
491             ACX_HELP_STRING([--with-ps-command=PATH], 
492                             [Verbatim command to execute for ps]),
493             PS_COMMAND=$withval)
494 AC_ARG_WITH(ps_format,
495             ACX_HELP_STRING([--with-ps-format=FORMAT],
496                             [Format string for scanning ps output]),
497             PS_FORMAT=$withval)
498 AC_ARG_WITH(ps_cols,
499             ACX_HELP_STRING([--with-ps-cols=NUM], 
500                             [Number of columns in ps command]),
501             PS_COLS=$withval)
502 AC_ARG_WITH(ps_varlist,
503             ACX_HELP_STRING([--with-ps-varlist=LIST],
504                             [Variable list for sscanf of 'ps' output]),
505             PS_VARLIST=$withval)
507 if test -n "$PS_COMMAND" && test -n "$PS_FORMAT" && test -n "$PS_COLS" && test -n "$PS_VARLIST"; then 
508         ac_cv_ps_command="$PS_COMMAND"
509         ac_cv_ps_format="$PS_FORMAT"
510         ac_cv_ps_varlist="$PS_VARLIST"
511         ac_cv_ps_cols="$PS_COLS"
512         AC_MSG_RESULT([(command-line) $ac_cv_ps_command])
514 dnl Using /usr/ucb/ps on Solaris systems, to avoid truncation
515 dnl Limitation that command name is not available
516 elif test "$ac_cv_uname_s" = "SunOS" && /usr/ucb/ps -alxwwn 2>/dev/null | \
517         egrep -i ["^ *F +UID +PID +PPID +%C +PRI +NI +SZ +RSS +WCHAN +S +TT +TIME +COMMAND"] > /dev/null
518 then
519         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procpcpu,&procvsz,&procrss,procstat,&pos]"
520         ac_cv_ps_command="/usr/ucb/ps -alxwwn"
521         ac_cv_ps_format=["%*s %d %d %d %d %*d %*d %d %d%*[ 0123456789abcdef]%[OSRZT]%*s %*s %n"]
522         ac_cv_ps_cols=8
523         AC_MSG_RESULT([$ac_cv_ps_command])
525 dnl Some gnu/linux systems (debian for one) don't like -axwo and need axwo.
526 dnl so test for this first...
527 elif ps axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
528         egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null
529 then
530         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
531         ac_cv_ps_command="$PATH_TO_PS axwo 'stat uid pid ppid vsz rss pcpu comm args'"
532         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
533         ac_cv_ps_cols=9
534         AC_MSG_RESULT([$ac_cv_ps_command])
536 dnl For OpenBSD 3.2 & 3.3. Must come before ps -weo
537 dnl Should also work for FreeBSD 5.2.1 and 5.3
538 dnl  STAT UCOMM              VSZ   RSS USER      PPID COMMAND
539 elif ps -axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
540         egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null
541 then
542         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
543         ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid pid ppid vsz rss pcpu comm args'"
544         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
545         ac_cv_ps_cols=9
546         AC_MSG_RESULT([$ac_cv_ps_command])
548 dnl Some *BSDs have different format for ps. This is mainly to catch FreeBSD 4. 
549 dnl Limitation: Only first 16 chars returned for ucomm field
550 dnl Must come before ps -weo
551 elif ps -axwo 'stat uid pid ppid vsz rss pcpu ucomm command' 2>/dev/null | \
552         egrep -i ["^ *STAT +UID +PID +PPID +VSZ +RSS +%CPU +UCOMM +COMMAND"] > /dev/null
553 then
554         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
555         ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid pid ppid vsz rss pcpu ucomm command'"
556         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
557         ac_cv_ps_cols=9
558         AC_MSG_RESULT([$ac_cv_ps_command])
560 dnl  STAT UCOMM              VSZ   RSS USER       UID  PPID COMMAND
561 elif ps -weo 'stat comm vsz rss user uid pid ppid etime args' 2>/dev/null | \
562         egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[ID]+ +P[PID]+ +[ELAPSD]+ +[RGSCOMDNA]+"] >/dev/null
563 then
564         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procetime,procprog,&pos]"
565         ac_cv_ps_command="$PATH_TO_PS -weo 'stat uid pid ppid vsz rss pcpu etime comm args'"
566         ac_cv_ps_format="%s %d %d %d %d %d %f %s %s %n"
567         ac_cv_ps_cols=10
568         AC_MSG_RESULT([$ac_cv_ps_command])
570 dnl FreeBSD
571 elif ps waxco 'state command vsz rss uid user pid ppid' 2>/dev/null | \
572         egrep -i ["^STAT +COMMAND +VSZ +RSS +UID +USER +PID +PPID"] >/dev/null
573 then
574         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
575         ac_cv_ps_command="$PATH_TO_PS waxco 'state uid pid ppid vsz rss pcpu command command'"
576         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
577         ac_cv_ps_cols=9
578         AC_MSG_RESULT([$ac_cv_ps_command])
580 dnl BSD-like mode in RH 6.1
581 elif ps waxno 'state comm vsz rss uid user pid ppid args' 2>/dev/null | \
582         egrep -i ["^S +COMMAND +VSZ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
583 then
584         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
585         ac_cv_ps_command="$PATH_TO_PS waxno 'state uid pid ppid vsz rss pcpu comm args'"
586         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
587         ac_cv_ps_cols=9
588         AC_MSG_RESULT([$ac_cv_ps_command])
590 dnl SunOS 4.1.3:
591 dnl  F  UID  PID  PPID  CP  PRI  NI  SZ  RSS  WCHAN  STAT  TT  TIME  COMMAND
592 dnl Need the head -1 otherwise test will work because arguments are found
593 elif ps -laxnwww 2>/dev/null | head -1 | \
594         egrep -i ["^ *F(LAGS)? +UID +PID +PPID +CP +PRI +NI +(SZ)|(VSZ)|(SIZE) +RSS +WCHAN +STAT? +TTY? +TIME +COMMAND"] >/dev/null
595 then
596         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]"
597         ac_cv_ps_command="$PATH_TO_PS -laxnwww"
598         ac_cv_ps_format="%*s %d %d %d %*s %*s %*s %d %d %*s %s %*s %*s %n%s"
599         ac_cv_ps_cols=9
600         AC_MSG_RESULT([$ac_cv_ps_command])
602 dnl Debian Linux / procps v1.2.9:
603 dnl  FLAGS   UID   PID  PPID PRI  NI   SIZE   RSS WCHAN       STA TTY TIME COMMAND
604 dnl    100     0     1     0   0   0    776    76  c0131c8c   S  ffff  0:11 init [2]
606 elif ps laxnwww 2>/dev/null | \
607         egrep -i ["^ *F(LAGS)? +UID +PID +PPID +PRI +NI +(VSZ)|(SIZE) +RSS +WCHAN +STAT? TTY +TIME +COMMAND"] >/dev/null
608 then
609         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,procstat,&procvsz,&procrss,&pos,procprog]"
610         ac_cv_ps_command="$PATH_TO_PS laxnwww"
611         ac_cv_ps_format="%*s %d %d %d %*s %*s %d %d %*s %s %*s %*s %n%s"
612         ac_cv_ps_cols=9
613         AC_MSG_RESULT([$ac_cv_ps_command])
615 dnl OpenBSD (needs to come early because -exo appears to work, but does not give all procs)
616 elif ps -axo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
617         egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[PID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null
618 then
619         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
620         ac_cv_ps_command="$PATH_TO_PS -axo 'stat uid pid ppid vsz rss pcpu comm args'"
621         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
622         ac_cv_ps_cols=9
623         AC_MSG_RESULT([$ac_cv_ps_command])
625 dnl Tru64 - needs %*[ +<>] in PS_FORMAT. 
626 dnl Has /usr/bin/ps and /sbin/ps - force sbin version
627 dnl Can't use vsize and rssize because comes back with text (eg, 1.5M instead 
628 dnl of 1500). Will need big changes to check_procs to support
629 elif /sbin/ps -eo 'stat uid pid ppid pcpu etime comm args' 2>/dev/null | \
630         egrep -i ["^ *S +[UID]+ +[PID]+ +[PID]+ +[%CPU]+ +[ELAPSD]+ +[COMMAND]+ +[COMMAND]+"] > /dev/null
631 then
632         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procpcpu,procetime,procprog,&pos]"
633         ac_cv_ps_command="/sbin/ps -eo 'stat uid pid ppid pcpu etime comm args'"
634         ac_cv_ps_format=["%s%*[ +<>] %d %d %d %f %s %s %n"]
635         ac_cv_ps_cols=8
636         AC_MSG_RESULT([$ac_cv_ps_command])
638 elif ps -eo 's comm vsz rss user uid pid ppid args' 2>/dev/null | \
639         egrep -i ["^S[TAUES]* +C[OMDNA]+ +[VSIZE]+ +U[SER]+ +U[ID]+ +P[PID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null
640 then
641         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
642         ac_cv_ps_command="$PATH_TO_PS -eo 's uid pid ppid vsz rss pcpu comm args'"
643         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
644         ac_cv_ps_cols=9
645         AC_MSG_RESULT([$ac_cv_ps_command])
647 dnl AIX 4.3.3 and 5.1 do not have an rss field
648 elif ps -eo 'stat uid pid ppid vsz pcpu comm args' 2>/dev/null | \
649         egrep -i ["^ *S[TAUES]* +UID +PID +PPID +VSZ +%CPU +COMMAND +COMMAND"] >/dev/null
650 then
651         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procpcpu,procprog,&pos]"
652         ac_cv_ps_command="$PATH_TO_PS -eo 'stat uid pid ppid vsz pcpu comm args'"
653         ac_cv_ps_format="%s %d %d %d %d %f %s %n"
654         ac_cv_ps_cols=8
655         AC_MSG_RESULT([$ac_cv_ps_command - with no RSS])
657 dnl Solaris 2.6
658 elif ps -Ao 's comm vsz rss uid user pid ppid args' 2>/dev/null | \
659         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
660 then
661         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
662         ac_cv_ps_command="$PATH_TO_PS -Ao 's uid pid ppid vsz rss pcpu comm args'"
663         # There must be no space between the %s and %n due to a wierd problem in sscanf where
664         # it will return %n as longer than the line length
665         ac_cv_ps_format="%s %d %d %d %d %d %f %s%n"
666         ac_cv_ps_cols=9
667         AC_MSG_RESULT([$ac_cv_ps_command])
669 elif ps -Ao 'status comm vsz rss uid user pid ppid args' 2>/dev/null | \
670         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
671 then
672         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
673         ac_cv_ps_command="$PATH_TO_PS -Ao 'status uid pid ppid vsz rss pcpu comm args'"
674         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
675         ac_cv_ps_cols=9
676         AC_MSG_RESULT([$ac_cv_ps_command])
678 elif ps -Ao 'state comm vsz rss uid user pid ppid args' 2>/dev/null | \
679         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
680 then
681         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
682         ac_cv_ps_command="$PATH_TO_PS -Ao 'state uid pid ppid vsz rss pcpu comm args'"
683         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
684         ac_cv_ps_cols=9
685         AC_MSG_RESULT([$ac_cv_ps_command])
687 dnl wonder who takes state instead of stat
688 elif ps -ao 'state command vsz rss user pid ppid args' 2>/dev/null | \
689         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
690 then
691         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
692         ac_cv_ps_command="$PATH_TO_PS -ao 'state uid pid ppid vsz rss pcpu command args'"
693         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
694         ac_cv_ps_cols=8
695         AC_MSG_RESULT([$ac_cv_ps_command])
697 dnl IRIX 53
698 elif ps -el 2>/dev/null | \
699         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
700 then
701         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&pos,procprog]"
702         ac_cv_ps_command="$PATH_TO_PS -el (IRIX 53)"
703         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %d %d %*s %*s %*s %n%s"
704         ac_cv_ps_cols=8
705         AC_MSG_RESULT([$ac_cv_ps_command])
707 dnl IRIX 63
708 elif ps -el 2>/dev/null | \
709         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +ADDR +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
710 then
711         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
712         ac_cv_ps_command="$PATH_TO_PS -el (IRIX 63)"
713         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
714         ac_cv_ps_cols=6
715         AC_MSG_RESULT([$ac_cv_ps_command])
717 dnl AIX 4.1:
718 dnl     F S      UID   PID  PPID   C PRI NI ADDR  SZ  RSS   WCHAN    TTY  TIME CMD
719 dnl    303 A        0     0     0 120  16 -- 1c07  20   24              -  0:45 swapper
720 elif ps -el 2>/dev/null | \
721         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +ADDR +SZ +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
722 then
723         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
724         ac_cv_ps_command="$PATH_TO_PS -el (AIX 4.1 and HP-UX)"
725         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
726         ac_cv_ps_cols=6
727         AC_MSG_RESULT([$ac_cv_ps_command])
729 dnl AIX?
730 elif ps glaxen 2>/dev/null | \
731         egrep -i ["^ *F +UID +PID +PPID +PRI +NI +VSZ +RSS +WCHAN +STAT +TTY +TIME +COMMAND"] >/dev/null
732 then
733         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]"
734         ac_cv_ps_command="$PATH_TO_PS glaxen"
735         ac_cv_ps_format="%*s %d %d %d %*s %*s %d %d %*s %s %*s %*s %n%s"
736         ac_cv_ps_cols=8
737         AC_MSG_RESULT([$ac_cv_ps_command])
739 dnl MacOSX / Darwin
740 dnl TODO: MacOSX has commands with spaces which will cause problems to PS_FORMAT
741 dnl Some truncation will happen in UCOMM column
742 dnl STAT      VSZ    RSS   UID  PPID %CPU UCOMM            COMMAND
743 dnl Ss      52756  22496   501     1   6.9 Window Manager   /System/Library/CoreServices/WindowServer -daemon
744 elif ps wwaxo 'state vsz rss uid pid ppid pcpu ucomm command' 2>/dev/null | \
745         egrep -i ["^STAT +VSZ +RSS +UID +PPID +%CPU +UCOMM +COMMAND"] >/dev/null
746 then
747         ac_cv_ps_command="$PATH_TO_PS wwaxo 'state vsz rss uid pid ppid pcpu ucomm command'"
748         ac_cv_ps_varlist="[procstat,&procvsz,&procrss,&procuid,&procpid,&procppid,&procpcpu,procprog,&pos]"
749         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
750         ac_cv_ps_cols=8
751         AC_MSG_RESULT([$ac_cv_ps_command])
753 dnl UnixWare 
754 elif ps -Al 2>/dev/null | \
755         egrep -i ["^ *F +S +UID +PID +PPID +CLS +PRI +NI +C +ADDR +SZ +WCHAN +TTY +TIME +COMD"] >/dev/null
756 then
757         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
758         ac_cv_ps_command="$PATH_TO_PS -Al"
759         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
760         ac_cv_ps_cols=8
761         AC_MSG_RESULT([$ac_cv_ps_command])
763 else
764         AC_MSG_WARN([unable to find usable ps syntax - check_procs and check_nagios will not be compiled])
767 if test -n "$ac_cv_ps_varlist" ; then
768         AC_DEFINE_UNQUOTED(PS_VARLIST,$ac_cv_ps_varlist,
769                 [Variable list for sscanf of 'ps' output])
770         AC_DEFINE_UNQUOTED(PS_COMMAND,"$ac_cv_ps_command",
771                 [Verbatim command to execute for ps in check_procs])
772         AC_DEFINE_UNQUOTED(PS_FORMAT,"$ac_cv_ps_format",
773                 [Format string for scanning ps output in check_procs])
774         AC_DEFINE_UNQUOTED(PS_COLS,$ac_cv_ps_cols,
775                 [Number of columns in ps command])
776         EXTRAS="$EXTRAS check_procs check_nagios"
777         if echo "$ac_cv_ps_varlist" | grep "procetime" >/dev/null; then
778                 AC_DEFINE(PS_USES_PROCETIME,"yes",
779                           [Whether the ps utility uses the "procetime" field])
780         fi
783 AC_PATH_PROG(PATH_TO_PING,ping)
784 AC_PATH_PROG(PATH_TO_PING6,ping6)
786 AC_ARG_WITH(ping_command,
787         ACX_HELP_STRING([--with-ping-command=SYNTAX],
788                 [sets syntax for ICMP ping]),
789         with_ping_command=$withval,)
791 AC_MSG_CHECKING(for ICMP ping syntax)
792 ac_cv_ping_packets_first=no
793 ac_cv_ping_has_timeout=no
794 if test -n "$with_ping_command"
795 then
796         AC_MSG_RESULT([(command-line) $with_ping_command])
797         if test -n "$ac_cv_ping_packets_first"
798         then
799                 ac_cv_ping_packets_first=yes
800                 ac_cv_ping_has_timeout=yes
801         fi
803 elif [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
804         $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
805         egrep -i "^round-trip|^rtt" >/dev/null
806 then
807         with_ping_command="$PATH_TO_PING -n -U -c %d %s"
808         ac_cv_ping_packets_first=yes
809         AC_MSG_RESULT([$with_ping_command])
811 elif $PATH_TO_PING -n -U -w 10 -c 1 127.0.0.1 2>/dev/null | \
812         egrep -i "^round-trip|^rtt" >/dev/null
813 then
814         with_ping_command="$PATH_TO_PING -n -U -w %d -c %d %s"
815         ac_cv_ping_packets_first=yes
816   ac_cv_ping_has_timeout=yes
817         AC_MSG_RESULT([$with_ping_command])
819 elif $PATH_TO_PING -n -U -c 1 127.0.0.1 2>/dev/null | \
820         egrep -i "^round-trip|^rtt" >/dev/null
821 then
822         with_ping_command="$PATH_TO_PING -n -U -c %d %s"
823         ac_cv_ping_packets_first=yes
824         AC_MSG_RESULT([$with_ping_command])
826 elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \
827         egrep -i "^round-trip|^rtt" >/dev/null
828 then
829         with_ping_command="$PATH_TO_PING -n -c %d %s"
830         ac_cv_ping_packets_first=yes
831         AC_MSG_RESULT([$with_ping_command])
833 elif $PATH_TO_PING -n 127.0.0.1 -c 1 2>/dev/null | \
834         egrep -i "^round-trip|^rtt" >/dev/null
835 then
836         with_ping_command="$PATH_TO_PING -n %s -c %d"
837         AC_MSG_RESULT([$with_ping_command])
839 elif $PATH_TO_PING 127.0.0.1 -n 1 2>/dev/null | \
840         egrep -i "^round-trip|^rtt" >/dev/null
841 then
842         with_ping_command="$PATH_TO_PING %s -n %d"
843         AC_MSG_RESULT([$with_ping_command])
845 elif $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
846         egrep -i "^round-trip|^rtt" >/dev/null
847 then
848         with_ping_command="$PATH_TO_PING -n -s %s 56 %d"
849         AC_MSG_RESULT([$with_ping_command])
851 elif $PATH_TO_PING -n -h 127.0.0.1 -s 56 -c 1 2>/dev/null | \
852         egrep -i "^round-trip|^rtt" >/dev/null
853 then
854         with_ping_command="$PATH_TO_PING -n -h %s -s 56 -c %d"
855         AC_MSG_RESULT([$with_ping_command])
857 elif $PATH_TO_PING -n -s 56 -c 1 127.0.0.1 2>/dev/null | \
858         egrep -i "^round-trip|^rtt" >/dev/null
859 then
860         with_ping_command="$PATH_TO_PING -n -s 56 -c %d %s"
861         ac_cv_ping_packets_first=yes
862         AC_MSG_RESULT([$with_ping_command])
864 elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \
865         egrep -i "^round-trip|^rtt" >/dev/null
866 then
867         with_ping_command="$PATH_TO_PING -n -c %d %s"
868         ac_cv_ping_packets_first=yes
869         AC_MSG_RESULT([$with_ping_command])
871 else
872         AC_MSG_WARN([unable to find usable ping syntax])
875 AC_DEFINE_UNQUOTED(PING_COMMAND,"$with_ping_command",
876         [path and args for ICMP ping command])
878 if test "x$ac_cv_ping_packets_first" != "xno"
879 then
880         AC_DEFINE(PING_PACKETS_FIRST,1,
881                 [Define if packet count must precede host])
884 if test "x$ac_cv_ping_has_timeout" != "xno"
885 then
886         AC_DEFINE(PING_HAS_TIMEOUT,1,
887                 [Define if ping has its own timeout option that should be set])
890 AC_ARG_WITH(ping6_command,
891         ACX_HELP_STRING([--with-ping6-command=SYNTAX],
892                 [sets syntax for ICMPv6 ping]),
893         with_ping6_command=$withval,)
895 if test x"$with_ipv6" != xno ; then
896 AC_MSG_CHECKING(for ICMPv6 ping syntax)
897 ac_cv_ping6_packets_first=no
898 if test -n "$with_ping6_command"
899 then
900         AC_MSG_RESULT([(command-line) $with_ping6_command])
901         if test -n "$ac_cv_ping6_packets_first"
902         then
903                 ac_cv_ping6_packets_first=yes
904         fi
906 elif test "x$PATH_TO_PING6" != "x"; then
907         if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
908                 $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \
909                 egrep -i "^round-trip|^rtt" >/dev/null
910         then
911                 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s"
912                 ac_cv_ping6_packets_first=yes
913                 AC_MSG_RESULT([$with_ping6_command])
915         elif $PATH_TO_PING6 -n -U -w 10 -c 1 ::1 2>/dev/null | \
916                 egrep -i "^round-trip|^rtt" >/dev/null
917         then
918                 with_ping6_command="$PATH_TO_PING6 -n -U -w %d -c %d %s"
919                 ac_cv_ping6_packets_first=yes
920                 ac_cv_ping_has_timeout=yes
921                 AC_MSG_RESULT([$with_ping6_command])
923         elif $PATH_TO_PING6 -n -U -c 1 ::1 2>/dev/null | \
924                 egrep -i "^round-trip|^rtt" >/dev/null
925         then
926                 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s"
927                 ac_cv_ping6_packets_first=yes
928                 AC_MSG_RESULT([$with_ping6_command])
930         elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \
931                 egrep -i "^round-trip|^rtt" >/dev/null
932         then
933                 with_ping6_command="$PATH_TO_PING6 -n -c %d %s"
934                 ac_cv_ping6_packets_first=yes
935                 AC_MSG_RESULT([$with_ping6_command])
937         elif $PATH_TO_PING6 -n ::1 -c 1 2>/dev/null | \
938                 egrep -i "^round-trip|^rtt" >/dev/null
939         then
940                 with_ping6_command="$PATH_TO_PING6 -n %s -c %d"
941                 AC_MSG_RESULT([$with_ping6_command])
943         elif $PATH_TO_PING6 ::1 -n 1 2>/dev/null | \
944                 egrep -i "^round-trip|^rtt" >/dev/null
945         then
946                 with_ping6_command="$PATH_TO_PING6 %s -n %d"
947                 AC_MSG_RESULT([$with_ping6_command])
949         elif $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \
950                 egrep -i "^round-trip|^rtt" >/dev/null
951         then
952                 with_ping6_command="$PATH_TO_PING6 -n -s %s 56 %d"
953                 AC_MSG_RESULT([$with_ping6_command])
955         elif $PATH_TO_PING6 -n -h ::1 -s 56 -c 1 2>/dev/null | \
956                 egrep -i "^round-trip|^rtt" >/dev/null
957         then
958                 with_ping6_command="$PATH_TO_PING6 -n -h %s -s 56 -c %d"
959                 AC_MSG_RESULT([$with_ping6_command])
961         elif $PATH_TO_PING6 -n -s 56 -c 1 ::1 2>/dev/null | \
962                 egrep -i "^round-trip|^rtt" >/dev/null
963         then
964                 with_ping6_command="$PATH_TO_PING6 -n -s 56 -c %d %s"
965                 ac_cv_ping6_packets_first=yes
966                 AC_MSG_RESULT([$with_ping_command])
968         elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \
969                 egrep -i "^round-trip|^rtt" >/dev/null
970         then
971                 with_ping6_command="$PATH_TO_PING6 -n -c %d %s"
972                 ac_cv_ping6_packets_first=yes
973                 AC_MSG_RESULT([$with_ping6_command])
975         fi
977 elif test "x$PATH_TO_PING" != "x"; then
978         if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
979                 $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \
980                 egrep -i "^round-trip|^rtt" >/dev/null
981         then
982                 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s"
983                 ac_cv_ping6_packets_first=yes
984                 AC_MSG_RESULT([$with_ping6_command])
986         elif $PATH_TO_PING -A inet6 -n -U -c 1 ::1 2>/dev/null | \
987                 egrep -i "^round-trip|^rtt" >/dev/null
988         then
989                 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s"
990                 ac_cv_ping6_packets_first=yes
991                 AC_MSG_RESULT([$with_ping6_command])
993         elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \
994                 egrep -i "^round-trip|^rtt" >/dev/null
995         then
996                 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s"
997                 ac_cv_ping6_packets_first=yes
998                 AC_MSG_RESULT([$with_ping6_command])
1000         elif $PATH_TO_PING -A inet6 -n ::1 -c 1 2>/dev/null | \
1001                 egrep -i "^round-trip|^rtt" >/dev/null
1002         then
1003                 with_ping6_command="$PATH_TO_PING -A inet6 -n %s -c %d"
1004                 AC_MSG_RESULT([$with_ping6_command])
1006         elif $PATH_TO_PING -A inet6 ::1 -n 1 2>/dev/null | \
1007                 egrep -i "^round-trip|^rtt" >/dev/null
1008         then
1009                 with_ping6_command="$PATH_TO_PING -A inet6 %s -n %d"
1010                 AC_MSG_RESULT([$with_ping6_command])
1012         elif $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \
1013                 egrep -i "^round-trip|^rtt" >/dev/null
1014         then
1015                 with_ping6_command="$PATH_TO_PING -A inet6 -n -s %s 56 %d"
1016                 AC_MSG_RESULT([$with_ping6_command])
1018         elif $PATH_TO_PING -A inet6 -n -h ::1 -s 56 -c 1 2>/dev/null | \
1019                 egrep -i "^round-trip|^rtt" >/dev/null
1020         then
1021                 with_ping6_command="$PATH_TO_PING -A inet6 -n -h %s -s 56 -c %d"
1022                 AC_MSG_RESULT([$with_ping6_command])
1024         elif $PATH_TO_PING -A inet6 -n -s 56 -c 1 ::1 2>/dev/null | \
1025                 egrep -i "^round-trip|^rtt" >/dev/null
1026         then
1027                 with_ping6_command="$PATH_TO_PING -A inet6 -n -s 56 -c %d %s"
1028                 ac_cv_ping6_packets_first=yes
1029                 AC_MSG_RESULT([$with_ping_command])
1031         elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \
1032                 egrep -i "^round-trip|^rtt" >/dev/null
1033         then
1034                 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s"
1035                 ac_cv_ping6_packets_first=yes
1036                 AC_MSG_RESULT([$with_ping6_command])
1038         fi
1042 if test "x$with_ping6_command" != "x"; then
1043         AC_DEFINE_UNQUOTED(PING6_COMMAND,"$with_ping6_command",
1044                 [path and args for ICMPv6 ping command])
1045 else
1046         AC_MSG_RESULT([none])
1049 if test "x$ac_cv_ping6_packets_first" != "xno"; then
1050         AC_DEFINE(PING6_PACKETS_FIRST,1,
1051                 [Define if packet count must precede host])
1056 AC_ARG_WITH(nslookup_command,
1057             ACX_HELP_STRING([--with-nslookup-command=PATH],
1058                             [sets path to nslookup executable]),
1059             ac_cv_nslookup_command=$withval)
1060 if test -n "$ac_cv_nslookup_command"; then
1061         AC_MSG_NOTICE([Using specific nslookup at $ac_cv_nslookup_command])
1062 else
1063         AC_PATH_PROG(PATH_TO_NSLOOKUP,nslookup)
1064         if test -n "$PATH_TO_NSLOOKUP"
1065         then
1066                 AC_MSG_CHECKING(for nslookup syntax)
1067                 if $PATH_TO_NSLOOKUP -sil 127.0.0.1 2>&1 | grep ["Invalid option: sil"] >/dev/null
1068                 then
1069                         ac_cv_nslookup_command="$PATH_TO_NSLOOKUP"
1070                         AC_MSG_RESULT([$ac_cv_nslookup_command])
1072                 else
1073                         ac_cv_nslookup_command="$PATH_TO_NSLOOKUP -sil"
1074                         AC_MSG_RESULT([$ac_cv_nslookup_command])
1076                 fi
1077         else
1078                 AC_MSG_WARN([nslookup command not found])
1079         fi
1082 if test -n "$ac_cv_nslookup_command"; then
1083         EXTRAS="$EXTRAS check_dns"
1084         AC_DEFINE_UNQUOTED(NSLOOKUP_COMMAND,"$ac_cv_nslookup_command", [path and args for nslookup])
1087 AC_MSG_CHECKING([for number of cpus])
1088 AC_TRY_COMPILE([#include <unistd.h>],
1089         [sysconf(_SC_NPROCESSORS_CONF) > 0;],
1090         AC_DEFINE(HAVE_SYSCONF__SC_NPROCESSORS_CONF,1,[Define if sysconf returns number of cpus])
1091         AC_MSG_RESULT([sysconf(_SC_NPROCESSORS_CONF)]),
1092         AC_MSG_RESULT([cannot calculate])
1093         )
1095 AC_PATH_PROG(PATH_TO_UPTIME,uptime)
1096 AC_ARG_WITH(uptime_command,
1097             ACX_HELP_STRING([--with-uptime-command=PATH],
1098                             [sets path to uptime]), PATH_TO_UPTIME=$withval)
1099 AC_DEFINE_UNQUOTED(PATH_TO_UPTIME,"$PATH_TO_UPTIME",[path to uptime binary])
1101 AC_PATH_PROG(PATH_TO_RPCINFO,rpcinfo)
1102 AC_ARG_WITH(rpcinfo_command,
1103             ACX_HELP_STRING([--with-rpcinfo-command=PATH],
1104                             [sets path to rpcinfo]), PATH_TO_RPCINFO=$withval)
1105 AC_DEFINE_UNQUOTED(PATH_TO_RPCINFO,"$PATH_TO_RPCINFO",[path to rpcinfo binary])
1107 AC_PATH_PROG(PATH_TO_LMSTAT,lmstat)
1108 if test -x "$PATH_TO_LMSTAT"
1109 then
1110         AC_DEFINE_UNQUOTED(PATH_TO_LMSTAT,"$PATH_TO_LMSTAT",[path to lmstat])
1111 else
1112         AC_MSG_WARN([Get lmstat from Globetrotter Software to monitor flexlm licenses])
1115 AC_PATH_PROG(PATH_TO_SMBCLIENT,smbclient)
1116 AC_ARG_WITH(smbclient_command,
1117             ACX_HELP_STRING([--with-smbclient-command=PATH],
1118                             [sets path to smbclient]), 
1119             PATH_TO_SMBCLIENT=$withval)
1120 if test -n "$PATH_TO_SMBCLIENT"
1121 then
1122         AC_DEFINE_UNQUOTED(PATH_TO_SMBCLIENT,"$PATH_TO_SMBCLIENT",[path to smbclient binary])
1123 else
1124         AC_MSG_WARN([Get smbclient from Samba.org to monitor SMB shares])
1128 AC_PATH_PROG(PATH_TO_WHO,who)
1130 if [$PATH_TO_WHO -q 2>/dev/null | egrep -i "^# users=[0-9]+$" >/dev/null]
1131 then
1132         ac_cv_path_to_who="$PATH_TO_WHO -q"
1133 else
1134         ac_cv_path_to_who="$PATH_TO_WHO"
1137 AC_DEFINE_UNQUOTED(WHO_COMMAND,"$ac_cv_path_to_who",
1138         [path and arguments for invoking 'who'])
1140 AC_PATH_PROG(PATH_TO_SNMPGET,snmpget)
1141 AC_ARG_WITH(snmpget_command,
1142             ACX_HELP_STRING([--with-snmpget-command=PATH],
1143                             [Path to snmpget command]),
1144             PATH_TO_SNMPGET=$withval)
1145 if test -n "$PATH_TO_SNMPGET"
1146 then
1147         AC_DEFINE_UNQUOTED(PATH_TO_SNMPGET,"$PATH_TO_SNMPGET",[path to snmpget binary])
1148         EXTRAS="$EXTRAS check_hpjd check_snmp"
1149 else
1150         AC_MSG_WARN([Get snmpget from http://net-snmp.sourceforge.net to make check_hpjd and check_snmp plugins])
1153 AC_PATH_PROG(PATH_TO_SNMPGETNEXT,snmpgetnext)
1154 AC_ARG_WITH(snmpgetnext_command,
1155             ACX_HELP_STRING([--with-snmpgetnext-command=PATH],
1156                             [Path to snmpgetnext command]),
1157             PATH_TO_SNMPGETNEXT=$withval)
1158 if test -n "$PATH_TO_SNMPGETNEXT"
1159 then
1160         AC_DEFINE_UNQUOTED(PATH_TO_SNMPGETNEXT,"$PATH_TO_SNMPGETNEXT",[path to snmpgetnext binary])
1163 if ( $PERL -M"Net::SNMP 3.6" -e 'exit' 2>/dev/null  )
1164 then
1165         AC_MSG_CHECKING(for Net::SNMP perl module)
1166         AC_MSG_RESULT([found])
1167 else
1168         AC_MSG_WARN([Tried $PERL - install Net::SNMP perl module if you want to use the perl snmp plugins])
1171 AC_PATH_PROG(PATH_TO_QUAKESTAT,quakestat)
1172 AC_PATH_PROG(PATH_TO_QSTAT,qstat)
1173 AC_ARG_WITH(qstat_command,
1174             ACX_HELP_STRING([--with-qstat-command=PATH], 
1175                             [Path to qstat command]), PATH_TO_QSTAT=$withval)
1177 if test -x "$PATH_TO_QUAKESTAT"
1178 then
1179         ac_cv_path_to_qstat="$PATH_TO_QUAKESTAT"
1180         EXTRAS="$EXTRAS check_game"
1182 elif test -n "$PATH_TO_QSTAT"
1183 then
1184         ac_cv_path_to_qstat="$PATH_TO_QSTAT"
1185         EXTRAS="$EXTRAS check_game"
1186 else
1187         AC_MSG_WARN([Get qstat from http://www.activesw.com/people/steve/qstat.html in order to make check_game plugin])
1190 if test $ac_cv_path_to_qstat 
1191 then
1192         AC_DEFINE_UNQUOTED(PATH_TO_QSTAT,"$ac_cv_path_to_qstat",
1193                 [path to qstat/quakestat])
1196 AC_PATH_PROG(PATH_TO_FPING,fping)
1197 AC_ARG_WITH(fping_command,
1198             ACX_HELP_STRING([--with-fping-command=PATH],
1199                             [Path to fping command]), PATH_TO_FPING=$withval)
1200 if test -n "$PATH_TO_FPING"
1201 then
1202         AC_DEFINE_UNQUOTED(PATH_TO_FPING,"$PATH_TO_FPING",[path to fping])
1203         EXTRAS="$EXTRAS check_fping"
1204 else
1205         AC_MSG_WARN([Get fping from http://www.fping.com in order to make check_fping plugin])
1208 AC_PATH_PROG(PATH_TO_SSH,ssh)
1209 AC_ARG_WITH(ssh_command,
1210             ACX_HELP_STRING([--with-ssh-command=PATH],
1211                             [sets path for ssh]), PATH_TO_SSH=$withval)
1212 if test -n "$PATH_TO_SSH"
1213 then
1214         AC_DEFINE_UNQUOTED(SSH_COMMAND,"$PATH_TO_SSH",[path to ssh binary])
1215         EXTRAS="$EXTRAS check_by_ssh"
1216 else
1217         AC_MSG_WARN([Get ssh in order to make check_by_ssh plugin])
1221 AC_PATH_PROG(PATH_TO_MAILQ,mailq)
1222 AC_ARG_WITH(mailq_command,
1223             ACX_HELP_STRING([--with-mailq-command=PATH],
1224                             [sets path to mailq]), PATH_TO_MAILQ=$withval)
1225 if test -n "$PATH_TO_MAILQ"
1226 then
1227         AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_MAILQ",[path to mailq])
1228 else
1229         AC_MSG_WARN([Could not find mailq or eqivalent])
1232 AC_PATH_PROG(PATH_TO_QMAIL_QSTAT,qmail-qstat)
1233 if test -x "$PATH_TO_QMAIL_QSTAT"
1234 then
1235         AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_QMAIL_QSTAT",[path to qmail-qstat])
1236 else
1237         AC_MSG_WARN([Could not find qmail-qstat or eqivalent])
1240 dnl SWAP info required is amount allocated/available and amount free
1241 dnl The plugin works through all the swap devices and adds up the total swap
1242 dnl available.
1243 AC_PATH_PROG(PATH_TO_SWAP,swap)
1244 if (test -n "$PATH_TO_SWAP")
1245 then
1246 AC_MSG_CHECKING([for $PATH_TO_SWAP format])
1247 if [$PATH_TO_SWAP -l 2>&1 >/dev/null]
1248 then
1249         ac_cv_have_swap=yes
1250         ac_cv_swap_command="$PATH_TO_SWAP -l"
1251         if [$PATH_TO_SWAP -l 2>/dev/null | \
1252                 egrep -i "^lswap +path +pri +swaplo +blocks +free +maxswap" \
1253                 >/dev/null]
1254         then
1255                 ac_cv_swap_format=[" %*d %*s %*d,%*d %*d %*d %f %f"]
1256                 ac_cv_swap_conv=2048
1257                 AC_MSG_RESULT([using IRIX format swap])
1259         elif [$PATH_TO_SWAP -l 2>/dev/null | egrep -i "^path +dev +swaplo +blocks +free" >/dev/null]
1260         then
1261                 ac_cv_swap_format=["%*s %*[0-9,-] %*d %f %f"]
1262                 ac_cv_swap_conv=2048
1263                 AC_MSG_RESULT([using Unixware format swap])
1264         else
1265                 dnl if we don't know what format swap's output is
1266                 dnl we might as well pretend we didn't see it
1267                 ac_cv_have_swap=""
1268                 ac_cv_swap_command=""
1269         fi
1271 dnl end if for PATH_TO_SWAP
1274 AC_PATH_PROG(PATH_TO_SWAPINFO,swapinfo)
1275 if (test -n "$PATH_TO_SWAPINFO")
1276 then
1277 AC_MSG_CHECKING([for $PATH_TO_SWAPINFO format])
1278 if [$PATH_TO_SWAPINFO -k 2>&1 | egrep -i "^Device" >/dev/null]
1279 then
1280         ac_cv_have_swap=yes
1281         ac_cv_swap_command="$PATH_TO_SWAPINFO -k"
1283         if [$PATH_TO_SWAPINFO -k 2>/dev/null | egrep -i "^Device +1K-blocks +Used +Avail" >/dev/null]
1284         then
1285                 ac_cv_swap_format=["%*s %f %*d %f"]
1286                 ac_cv_swap_conv=1024
1287                 AC_MSG_RESULT([using FreeBSD format swapinfo])
1288         fi
1290 elif [$PATH_TO_SWAPINFO -dfM 2>/dev/null | egrep -i "^TYPE +AVAIL +USED +FREE" >/dev/null]
1291 then
1292         ac_cv_have_swap=yes
1293         ac_cv_swap_command="$PATH_TO_SWAPINFO -dfM"
1294         ac_cv_swap_format=["%*s %f %*d %f"]
1295         ac_cv_swap_conv=1024
1296         AC_MSG_RESULT([using HP-UX format swapinfo])
1298 dnl end if for PATH_TO_SWAPINFO
1301 AC_PATH_PROG(PATH_TO_LSPS,lsps)
1302 if (test -n "$PATH_TO_LSPS")
1303 then
1304 AC_MSG_CHECKING([for $PATH_TO_LSPS format])
1305 if [$PATH_TO_LSPS -a 2>/dev/null | egrep -i "^Page Space" > /dev/null]
1306 then
1307         ac_cv_have_swap=yes
1308         ac_cv_swap_command="$PATH_TO_LSPS -a"
1309         ac_cv_swap_format=["%*s %*s %*s %f%*s %f %*s"]
1310         ac_cv_swap_conv=1
1311         AC_MSG_RESULT([using AIX lsps])
1313 dnl end if for PATH_TO_SWAPINFO
1317 dnl test for swapctl system call, both the 2-arg and 3-arg variants
1318 dnl fwict, the 2-arg is an SVR4 standard, whereas the 3-arg is shared
1319 dnl in the various BSD's
1322 AC_CHECK_HEADERS([sys/stat.h sys/param.h])
1323 AC_CHECK_HEADERS([sys/swap.h], [], [], [
1324 #ifdef HAVE_SYS_PARAM_H
1325 #include <sys/param.h>
1326 #endif
1328 AC_CHECK_DECLS([swapctl],,,[
1329                #include <unistd.h>
1330                #include <sys/types.h>
1331                #include <sys/param.h>
1332                #include <sys/stat.h>
1333                #include <sys/swap.h>
1334                ])
1335 AC_CHECK_TYPES([swaptbl_t, swapent_t],,,[
1336                #include <sys/types.h>
1337                #include <sys/param.h>
1338                #include <sys/stat.h>
1339                #include <sys/swap.h>
1340                ])
1341 AC_CHECK_MEMBERS([struct swapent.se_nblks],,,[
1342                #include <unistd.h>
1343                #include <sys/types.h>
1344                #include <sys/param.h>
1345                #include <sys/stat.h>
1346                #include <sys/swap.h>
1347                ])
1349 if test "$ac_cv_have_decl_swapctl" = "yes"; 
1350 then
1351         EXTRAS="$EXTRAS check_swap"
1352         AC_MSG_CHECKING([for 2-arg (SVR4) swapctl])
1353         if test "$ac_cv_type_swaptbl_t" = "yes" -a \
1354                 "$ac_cv_type_swapent_t" = "yes"; 
1355         then
1356                 AC_MSG_RESULT([yes])
1357                 ac_cv_check_swap_swapctl_svr4="1";
1358                 AC_DEFINE([CHECK_SWAP_SWAPCTL_SVR4],1,
1359                           [Define if 2-argument SVR4 swapctl exists])
1360         else
1361                 AC_MSG_RESULT([no])
1362                 AC_MSG_CHECKING([for 3-arg (*BSD) swapctl])
1363                 if test "$ac_cv_member_struct_swapent_se_nblks" = "yes"; 
1364                 then
1365                         AC_MSG_RESULT([yes])
1366                         AC_DEFINE([CHECK_SWAP_SWAPCTL_BSD],1,
1367                                   [Define if 3-argument BSD swapctl exists])
1368                 else
1369                         AC_MSG_RESULT([no])
1370                 fi
1371         fi
1372         AC_MSG_CHECKING([for whether swapctl uses blocks or pages])
1373         if test "$ac_cv_check_swap_swapctl_svr4" = "1";
1374         then
1375                 dnl
1376                 dnl the SVR4 spec returns values in pages
1377                 dnl
1378                 AC_MSG_RESULT([page])
1379                 AC_CHECK_DECLS([sysconf])
1380                 AC_MSG_CHECKING([for system page size])
1381                 if test "$ac_cv_have_decl_sysconf" = "yes";
1382                 then
1383                         AC_MSG_RESULT([determined by sysconf(3)])
1384                         ac_cv_swap_conv="(1048576/sysconf(_SC_PAGESIZE))"
1385                 else
1386                         AC_MSG_WARN([don't know. guessing 4096k])
1387                         ac_cv_swap_conv=256
1388                 fi
1389         else
1390                 dnl
1391                 dnl the BSD spec returns values in blocks
1392                 dnl
1393                 AC_MSG_RESULT([blocks (assuming 512b)])
1394                 ac_cv_swap_conv=2048
1395         fi
1396         AC_DEFINE_UNQUOTED(SWAP_CONVERSION,$ac_cv_swap_conv,
1397                 [Conversion factor to MB])
1400 dnl end tests for the swapctl system calls
1404 if test "x$ac_cv_have_swap" != "x" 
1405 then
1406         AC_DEFINE(HAVE_SWAP,1,[Define if swap/swapinfo command is found])
1407         EXTRAS="$EXTRAS check_swap"
1409 if test "x$ac_cv_swap_command" != "x" 
1410 then
1411         AC_DEFINE_UNQUOTED(SWAP_COMMAND,"$ac_cv_swap_command",
1412                 [Path to swap/swapinfo binary, with any args])
1413         AC_DEFINE_UNQUOTED(SWAP_FORMAT,"$ac_cv_swap_format",
1414                 [Format string for parsing swap output])
1415         AC_DEFINE_UNQUOTED(SWAP_CONVERSION,$ac_cv_swap_conv,
1416                 [Conversion factor to MB])
1419 AC_ARG_WITH(proc-meminfo,
1420             ACX_HELP_STRING([--with-proc-meminfo=PATH],
1421                             [path to /proc/meminfo or equivalent]),
1422                             ac_cv_proc_meminfo=$withval)
1423 dnl dunno why this does not work below - use hack (kbd)
1424 dnl fine on linux, broken on solaris
1425 dnl if /bin/test -e "/proc/meminfo"
1426 AC_MSG_CHECKING([for /proc/meminfo])
1427 if test -n "$ac_cv_proc_meminfo"; then
1428         AC_MSG_RESULT([(command line) $ac_cv_proc_meminfo])
1429 elif [cat /proc/meminfo > /dev/null 2>&1]; then
1430         AC_MSG_RESULT([found /proc/meminfo])
1431         ac_cv_proc_meminfo="/proc/meminfo"
1432 else
1433         AC_MSG_RESULT([no])
1436 if test -n "$ac_cv_proc_meminfo"; then
1437         AC_DEFINE(HAVE_PROC_MEMINFO,1,[Define if we have /proc/meminfo])
1438         AC_DEFINE_UNQUOTED(PROC_MEMINFO,"$ac_cv_proc_meminfo",[path to /proc/meminfo if name changes])
1439         EXTRAS="$EXTRAS check_swap"
1442 AC_PATH_PROG(PATH_TO_DIG,dig)
1443 AC_ARG_WITH(dig_command,
1444             ACX_HELP_STRING([--with-dig-command=PATH],
1445                             [Path to dig command]), PATH_TO_DIG=$withval)
1446 if test -n "$PATH_TO_DIG"; then
1447         EXTRAS="$EXTRAS check_dig"
1448         AC_DEFINE_UNQUOTED(PATH_TO_DIG,"$PATH_TO_DIG",[Path to dig command, if present])
1451 AC_PATH_PROG(PATH_TO_APTGET,apt-get)
1452 AC_ARG_WITH(apt-get_command,
1453             ACX_HELP_STRING([--with-apt-get-command=PATH],
1454                             [Path to apt-get command]), 
1455                             with_apt_get_command=$withval,
1456                             with_apt_get_command=$PATH_TO_APTGET)
1457 AC_DEFINE_UNQUOTED(PATH_TO_APTGET,"$PATH_TO_APTGET",[Path to apt-get command, if present])
1458 if test -n "$PATH_TO_APTGET" ; then
1459         EXTRAS="$EXTRAS check_apt"
1463 if test -f plugins/check_nt.c ; then
1464   EXTRAS="$EXTRAS check_nt"
1465 elif test -f ../plugins/check_nt.c ; then
1466   EXTRAS="$EXTRAS check_nt"
1470 dnl used in check_dhcp
1471 AC_CHECK_HEADERS(sys/sockio.h)
1473 case $host in
1474         *bsd*)
1475                 AC_DEFINE(__bsd__,1,[bsd specific code in check_dhcp.c])
1476         ;;
1477         *linux*)
1478                 AC_DEFINE(__linux__,1,[sun specific code in check_dhcp.c])
1479         ;;
1480         *sun* | solaris*)
1481                 AC_DEFINE(__sun__,1,[sun specific code in check_dhcp.c])
1482         ;;
1483         *hpux*)  
1484                 AC_DEFINE(__hpux__,1,[hpux specific code in check_dhcp.c])
1485         ;;
1486 esac
1488 AC_SUBST(EXTRAS)
1489 AC_SUBST(EXTRAS_ROOT)
1490 AC_SUBST(EXTRA_NETOBJS)
1491 AC_SUBST(DEPLIBS)
1493 AM_GNU_GETTEXT([external], [need-ngettext])
1494 AM_GNU_GETTEXT_VERSION(0.15)
1496 dnl Check for Redhat spopen problem
1497 dnl Wierd problem where ECHILD is returned from a wait call in error
1498 dnl Only appears to affect nslookup and dig calls. Only affects redhat around
1499 dnl 2.6.9-11 (okay in 2.6.9-5). Redhat investigating root cause
1500 dnl We patch plugins/popen.c
1501 dnl Need to add smp because uname different on those
1502 dnl Can force patch to be applied with --enable-redhat-pthread-workaround
1503 AC_ARG_ENABLE(redhat-pthread-workaround, 
1504         AC_HELP_STRING([--enable-redhat-pthread-workaround], 
1505                 [force Redhat patch to be applied (default: test system)]),
1506         [ac_cv_enable_redhat_pthread_workaround=$enableval],
1507         [ac_cv_enable_redhat_pthread_workaround=test])
1508 if test "$ac_cv_enable_redhat_pthread_workaround" = "test" ; then
1509         if echo $ac_cv_uname_r | egrep "\.EL(smp)?$" >/dev/null 2>&1 ; then
1510                 AC_MSG_CHECKING(for redhat spopen problem)
1511                 ( cd config_test && make && make test ) > /dev/null 2>&1
1512                 if test $? -eq 0 ; then
1513                         AC_MSG_RESULT(okay)
1514                 else
1515                         AC_MSG_RESULT(error)
1516                         AC_DEFINE(REDHAT_SPOPEN_ERROR, 1, [Workaround on redhat in spopen])
1517                 fi
1518         fi
1519 elif test "$ac_cv_enable_redhat_pthread_workaround" = "yes" ; then
1520         AC_DEFINE(REDHAT_SPOPEN_ERROR, 1, [Forced workaround on redhat in spopen])
1523 dnl Perl modules
1524 AC_ARG_ENABLE(perl-modules,
1525         AC_HELP_STRING([--enable-perl-modules], 
1526                 [Enables installation of Nagios::Plugin and its dependencies (default: no)]),
1527         [enable_perl_modules=$enableval],
1528         [enable_perl_modules=no])
1529 if test "$enable_perl_modules" = "yes" ; then
1530   AC_SUBST(PERLMODS_DIR,perlmods)
1533 dnl External libraries - see ACKNOWLEDGEMENTS
1534 gl_INIT
1536 dnl Some helpful common compile errors checked here
1537 if test "$ac_cv_uname_s" = 'SunOS' -a "$ac_cv_prog_ac_ct_AR" = 'false' ; then
1538         AC_MSG_ERROR(No ar found for Solaris - is /usr/ccs/bin in PATH?)
1541 AC_OUTPUT(
1542   Makefile 
1543   lib/Makefile 
1544   plugins/Makefile 
1545   lib/tests/Makefile
1546   plugins-root/Makefile
1547   plugins-scripts/Makefile 
1548   plugins-scripts/subst 
1549   plugins-scripts/utils.pm 
1550   plugins-scripts/utils.sh 
1551   perlmods/Makefile
1552   command.cfg 
1553   test.pl 
1554   pkg/solaris/pkginfo 
1555   po/Makefile.in 
1559 dnl the ones below that are commented out need to be cleaned up 
1560 dnl in the configure code above to use with_foo instead of ac_cv_foo
1561 dnl if we want them to show up here.  it'd also make the code cleaner.
1562 dnl i'll get to that on another rainy day :) -sf
1563 ACX_FEATURE([with],[apt-get-command])
1564 dnl ACX_FEATURE([with],[dig-command])
1565 dnl ACX_FEATURE([with],[fping-command])
1566 dnl ACX_FEATURE([with],[mailq-command])
1567 dnl ACX_FEATURE([with],[nslookup-command])
1568 ACX_FEATURE([with],[ping6-command])
1569 ACX_FEATURE([with],[ping-command])
1570 dnl ACX_FEATURE([with],[qstat-command])
1571 dnl ACX_FEATURE([with],[rpcinfo-command])
1572 dnl ACX_FEATURE([with],[smbclient-command])
1573 dnl ACX_FEATURE([with],[snmpget-command])
1574 dnl ACX_FEATURE([with],[snmpgetnext-command])
1575 dnl ACX_FEATURE([with],[ssh-command])
1576 dnl ACX_FEATURE([with],[uptime-command])
1578 dnl ACX_FEATURE([with],[proc-meminfo])
1579 dnl ACX_FEATURE([with],[ps-command])
1580 dnl ACX_FEATURE([with],[ps-format])
1581 dnl ACX_FEATURE([with],[ps-cols])
1582 dnl ACX_FEATURE([with],[ps-varlist])
1584 ACX_FEATURE([with],[ipv6])
1585 ACX_FEATURE([with],[mysql])
1586 ACX_FEATURE([with],[openssl])
1587 ACX_FEATURE([with],[gnutls])
1588 ACX_FEATURE([with],[perl])
1589 ACX_FEATURE([enable],[perl-modules])
1590 ACX_FEATURE([with],[cgiurl])
1591 ACX_FEATURE([with],[trusted-path])