Code

A few minor fixes/improvements which were included with (but unrelated
[nagiosplug.git] / configure.in
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.9)
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"
37 fi
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"
128 fi
129 if test ! "$with_gnutls" = "" && test ! "$with_gnutls" = "no"; then
130         with_openssl="no"
131 fi
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"
140 dnl
141 dnl Checks for libraries.
142 dnl
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)
150 dnl
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"
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).])
209 fi
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_MSG_WARN([Skipping radius plugin])
222   AC_MSG_WARN([install radius libs to compile this plugin (see REQUIREMENTS).])
223 fi
224 LIBS="$_SAVEDLIBS"
226 dnl Check for LDAP libraries
227 _SAVEDLIBS="$LIBS"
228 AC_CHECK_LIB(ldap,main,,,-llber)
229 if test "$ac_cv_lib_ldap_main" = "yes"; then
230   LDAPLIBS="-lldap -llber"\
231   LDAPINCLUDE="-I/usr/include/ldap"
232   AC_SUBST(LDAPLIBS)
233   AC_SUBST(LDAPINCLUDE)
234   AC_CHECK_FUNCS(ldap_set_option)
235   EXTRAS="$EXTRAS check_ldap"
236         AC_CHECK_FUNCS(ldap_init ldap_set_option ldap_get_option ldap_start_tls_s)
237 else
238   AC_MSG_WARN([Skipping LDAP plugin])
239   AC_MSG_WARN([install LDAP libs to compile this plugin (see REQUIREMENTS).])
240 fi
241 LIBS="$_SAVEDLIBS"
243 dnl Check for headers used by check_ide_smart
244 AC_CHECK_HEADER(linux/hdreg.h, FOUNDINCLUDE=yes, FOUNDINCLUDE=no)
245 if test "$FOUNDINCLUDE" = "yes" ; then
246         AC_CHECK_HEADER(linux/types.h, FOUNDINCLUDE=yes, FOUNDINCLUDE=no)
247 fi
249 if test "$FOUNDINCLUDE" = "yes" ; then
250         EXTRAS="$EXTRAS check_ide_smart"
251 else
252         AC_MSG_WARN([Skipping check_ide_smart plugin.]) 
253         AC_MSG_WARN([check_ide_smart is linux specific. It requires linux/hdreg.h and linux/types.h.]) 
254 fi
256 dnl Check for mysql libraries
257 np_mysqlclient
258 if test $with_mysql = "no" ; then
259   AC_MSG_WARN([Skipping mysql plugin])
260   AC_MSG_WARN([install mysql client libs to compile this plugin (see REQUIREMENTS).])
261 else
262   EXTRAS="$EXTRAS check_mysql check_mysql_query"
263   MYSQLINCLUDE="$np_mysql_include"
264   MYSQLLIBS="$np_mysql_libs"
265   MYSQLCFLAGS="$np_mysql_cflags"
266   AC_SUBST(MYSQLINCLUDE)
267   AC_SUBST(MYSQLLIBS)
268   AC_SUBST(MYSQLCFLAGS)
269 fi
271 dnl Check for AF_INET6 support - unistd.h required for Darwin
272 AC_CACHE_CHECK([for IPv6 support], with_ipv6, [
273         AC_TRY_COMPILE([#ifdef HAVE_UNISTD_H
274                         #include <unistd.h>
275                         #endif
276                         #include <netinet/in.h>
277                         #include <sys/socket.h>],
278                         [struct sockaddr_in6 sin6;
279                         void *p;
281                         sin6.sin6_family = AF_INET6;
282                         sin6.sin6_port = 587;
283                         p = &sin6.sin6_addr;],
284                         [with_ipv6=yes], 
285                         [with_ipv6=no])
286         ])
288 if test x"$with_ipv6" != xno ; then
289         AC_DEFINE(USE_IPV6,1,[Enable IPv6 support])
290 fi
293 dnl Checks for Kerberos. Must come before openssl checks for Redhat EL 3
294 AC_CHECK_HEADERS(krb5.h,FOUNDINCLUDE=yes,FOUNDINCLUDE=no)
295 if test "$FOUNDINCLUDE" = "no"; then
296   _SAVEDCPPFLAGS="$CPPFLAGS"
297   CPPFLAGS="$_SAVEDCPPFLAGS -I/usr/kerberos/include"
298   unset ac_cv_header_krb5_h
299   AC_CHECK_HEADERS(krb5.h,
300                    KRB5INCLUDE="-I/usr/kerberos/include"
301                    FOUNDINCLUDE=yes,
302                    FOUNDINCLUDE=no)
303 fi
304 AC_SUBST(KRBINCLUDE)
305 if test "$FOUNDINCLUDE" = "no"; then
306   CPPFLAGS="$_SAVEDCPPFLAGS"
307 fi
310 dnl openssl detection/configuration
311 if ! test x"$with_openssl" = x"no"; then
312         dnl Check for OpenSSL location if it wasn't already specified
313         if ! test -d "$with_openssl"; then
314                 for d in $OPENSSL_DIRS; do
315                         if test -x ${d}/bin/openssl || test -x ${d}/sbin/openssl ; then
316                                 with_openssl=$d
317                         fi
318                 done
319         fi
321         _SAVEDCPPFLAGS="$CPPFLAGS"
322         _SAVEDLDFLAGS="$LDFLAGS"
323         dnl Check for OpenSSL header files
324         unset FOUNDINCLUDE
325         if test x"$with_openssl" != x"/usr" ; then
326                 CPPFLAGS="$CPPFLAGS -I$with_openssl/include"
327                 LDFLAGS="$LDFLAGS -L$with_openssl/lib"
328         fi
330         dnl check for openssl in $dir/include/openssl
331         AC_CHECK_HEADERS(openssl/ssl.h openssl/x509.h openssl/rsa.h openssl/pem.h openssl/crypto.h openssl/err.h,
332                          SSLINCLUDE="-I$with_openssl/include"
333                          FOUNDINCLUDE=yes,
334                          FOUNDINCLUDE=no)
335         dnl else check to see if $dir/include has it
336         if test "$FOUNDINCLUDE" = "no"; then
337                 AC_CHECK_HEADERS(ssl.h x509.h rsa.h pem.h crypto.h err.h,
338                                  SSLINCLUDE="-I$with_openssl/include"
339                                  FOUNDINCLUDE=yes,
340                                  FOUNDINCLUDE=no)
341         fi
342         AC_SUBST(SSLINCLUDE)
343         dnl if we didn't find it, reset CPPFLAGS
344         if test "$FOUNDINCLUDE" = "no"; then
345                 CPPFLAGS="$_SAVEDCPPFLAGS"
346                 LDFLAGS="$_SAVEDLDFLAGS"
347         fi
349         dnl Check for crypto lib
350         _SAVEDLIBS="$LIBS"
351         LIBS="-L${with_openssl}/lib"
352         AC_CHECK_LIB(crypto,CRYPTO_lock)
353         if test "$ac_cv_lib_crypto_CRYPTO_lock" = "yes"; then
354                 dnl Check for SSL lib
355                 AC_CHECK_LIB(ssl,main, SSLLIBS="-lssl -lcrypto",,-lcrypto)
356         fi
357         LIBS="$_SAVEDLIBS"
359         dnl test headers and libs to decide whether check_http should use SSL
360         if test "$ac_cv_lib_crypto_CRYPTO_lock" = "yes"; then
361                 if test "$ac_cv_lib_ssl_main" = "yes"; then
362                         if test "$FOUNDINCLUDE" = "yes"; then
363                                 FOUNDOPENSSL="yes"
364                         fi
365                 fi
366         fi
367 fi
370 dnl check for gnutls if openssl isn't found (or is disabled)
371 if test ! "$FOUNDOPENSSL" = "yes" && test ! "$with_gnutls" = "no"; then
372         if test ! "$with_gnutls" = ""; then
373                 CPPFLAGS="$CPPFLAGS -I${with_gnutls}/include"
374         elif test ! "$LIBGNUTLS_CONFIG" = ""; then
375                 CPPFLAGS="$CPPFLAGS -I`$LIBGNUTLS_CONFIG --prefix`"
376         fi
377         AC_CHECK_HEADERS([gnutls/openssl.h],FOUNDGNUTLS="yes",)
378         if test "$FOUNDGNUTLS" = "yes"; then
379                 AC_CHECK_LIB(gnutls-openssl,main,SSLLIBS="-lgnutls-openssl")
380         fi
381 fi
382 dnl end check for gnutls
384 if test "$FOUNDOPENSSL" = "yes" || test "$FOUNDGNUTLS" = "yes"; then
385         check_tcp_ssl="check_simap check_spop check_jabber check_nntps check_ssmtp"
386         AC_SUBST(check_tcp_ssl)
387         AC_SUBST(SSLLIBS)
388         AC_DEFINE(HAVE_SSL,1,[Define if SSL libraries are found])
389         if test "$FOUNDOPENSSL" = "yes"; then
390                 AC_DEFINE(USE_OPENSSL,1,[Define if using OpenSSL libraries])
391                 with_openssl="yes"
392                 with_gnutls="no"
393         else
394                 AC_DEFINE(USE_GNUTLS,1,[Define if using gnutls libraries])
395                 with_gnutls="yes"
396                 with_openssl="no"
397         fi
398 else
399         dnl else deliberately disabled or no ssl support available
400         AC_MSG_WARN([OpenSSL or GnuTLS libs could not be found or were disabled])
401         with_openssl="no"
402         with_gnutls="no"
403 fi
405 dnl
406 dnl Checks for header files.
407 dnl
409 AC_HEADER_TIME
410 AC_HEADER_SYS_WAIT
411 AC_CHECK_HEADERS(signal.h syslog.h uio.h errno.h sys/time.h sys/socket.h sys/un.h sys/poll.h)
412 AC_CHECK_HEADERS(features.h stdarg.h sys/unistd.h ctype.h)
414 dnl Checks for typedefs, structures, and compiler characteristics.
415 AC_C_CONST
416 AC_STRUCT_TM
417 AC_TYPE_PID_T
418 AC_TYPE_SIZE_T
419 AC_TYPE_SIGNAL
421 AC_CACHE_CHECK([for va_copy],ac_cv_HAVE_VA_COPY,[
422 AC_TRY_LINK([#include <stdarg.h>
423 va_list ap1,ap2;], [va_copy(ap1,ap2);],
424 ac_cv_HAVE_VA_COPY=yes,
425 ac_cv_HAVE_VA_COPY=no)])
426 if test x"$ac_cv_HAVE_VA_COPY" = x"yes"; then
427     AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available])
428 else    
429     AC_CACHE_CHECK([for __va_copy],ac_cv_HAVE___VA_COPY,[
430     AC_TRY_LINK([#include <stdarg.h>
431     va_list ap1,ap2;], [__va_copy(ap1,ap2);],
432     ac_cv_HAVE___VA_COPY=yes,
433     ac_cv_HAVE___VA_COPY=no)])
434     if test x"$ac_cv_HAVE___VA_COPY" = x"yes"; then
435         AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available])
436     fi
437 fi
439 AC_TRY_COMPILE([#include <sys/time.h>],
440                [struct timeval *tv;
441                 struct timezone *tz;],
442                AC_DEFINE(HAVE_STRUCT_TIMEVAL,1,[Define if we have a timeval structure])
443                AC_TRY_COMPILE([#include <sys/time.h>],
444                               [struct timeval *tv;
445                                struct timezone *tz;
446                                gettimeofday(tv, tz);],
447                               AC_DEFINE(HAVE_GETTIMEOFDAY,1,[Define if gettimeofday is found]),
448                               AC_DEFINE(NEED_GETTIMEOFDAY,1,[Define if gettimeofday is needed])))
450 dnl Checks for library functions.
451 AC_CHECK_FUNCS(memmove select socket strdup strstr strtol strtoul floor)
452 AC_CHECK_FUNCS(poll)
454 AC_MSG_CHECKING(return type of socket size)
455 AC_TRY_COMPILE([#include <stdlib.h>
456                 #include <sys/types.h>
457                 #include <sys/socket.h>],
458                [int a = send(1, (const void *) buffer, (size_t *) 0, (int *) 0);],
459                ac_cv_socket_size_type=["size_t"]
460                 AC_MSG_RESULT(size_t),
461                ac_cv_socket_size_type=["int"]
462                 AC_MSG_RESULT(int))
464 AC_DEFINE_UNQUOTED(SOCKET_SIZE_TYPE, $ac_cv_socket_size_type ,
465         [Define type of socket size])
468 dnl #### Process table test
470 AC_PATH_PROG(PATH_TO_PS,ps)
472 AC_MSG_CHECKING(for ps syntax)
473 AC_ARG_WITH(ps_command,
474             ACX_HELP_STRING([--with-ps-command=PATH], 
475                             [Verbatim command to execute for ps]),
476             PS_COMMAND=$withval)
477 AC_ARG_WITH(ps_format,
478             ACX_HELP_STRING([--with-ps-format=FORMAT],
479                             [Format string for scanning ps output]),
480             PS_FORMAT=$withval)
481 AC_ARG_WITH(ps_cols,
482             ACX_HELP_STRING([--with-ps-cols=NUM], 
483                             [Number of columns in ps command]),
484             PS_COLS=$withval)
485 AC_ARG_WITH(ps_varlist,
486             ACX_HELP_STRING([--with-ps-varlist=LIST],
487                             [Variable list for sscanf of 'ps' output]),
488             PS_VARLIST=$withval)
490 if test -n "$PS_COMMAND" && test -n "$PS_FORMAT" && test -n "$PS_COLS" && test -n "$PS_VARLIST"; then 
491         ac_cv_ps_command="$PS_COMMAND"
492         ac_cv_ps_format="$PS_FORMAT"
493         ac_cv_ps_varlist="$PS_VARLIST"
494         ac_cv_ps_cols="$PS_COLS"
495         AC_MSG_RESULT([(command-line) $ac_cv_ps_command])
497 dnl Using /usr/ucb/ps on Solaris systems, to avoid truncation
498 dnl Limitation that command name is not available
499 elif test "$ac_cv_uname_s" = "SunOS" && /usr/ucb/ps -alxwwn 2>/dev/null | \
500         egrep -i ["^ *F +UID +PID +PPID +%C +PRI +NI +SZ +RSS +WCHAN +S +TT +TIME +COMMAND"] > /dev/null
501 then
502         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procpcpu,&procvsz,&procrss,procstat,&pos]"
503         ac_cv_ps_command="/usr/ucb/ps -alxwwn"
504         ac_cv_ps_format=["%*s %d %d %d %d %*d %*d %d %d%*[ 0123456789abcdef]%[OSRZT]%*s %*s %n"]
505         ac_cv_ps_cols=8
506         AC_MSG_RESULT([$ac_cv_ps_command])
508 dnl Some gnu/linux systems (debian for one) don't like -axwo and need axwo.
509 dnl so test for this first...
510 elif ps axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
511         egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null
512 then
513         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
514         ac_cv_ps_command="$PATH_TO_PS axwo 'stat uid pid ppid vsz rss pcpu comm args'"
515         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
516         ac_cv_ps_cols=9
517         AC_MSG_RESULT([$ac_cv_ps_command])
519 dnl For OpenBSD 3.2 & 3.3. Must come before ps -weo
520 dnl Should also work for FreeBSD 5.2.1 and 5.3
521 dnl  STAT UCOMM              VSZ   RSS USER      PPID COMMAND
522 elif ps -axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
523         egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null
524 then
525         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
526         ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid pid ppid vsz rss pcpu comm args'"
527         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
528         ac_cv_ps_cols=9
529         AC_MSG_RESULT([$ac_cv_ps_command])
531 dnl Some *BSDs have different format for ps. This is mainly to catch FreeBSD 4. 
532 dnl Limitation: Only first 16 chars returned for ucomm field
533 dnl Must come before ps -weo
534 elif ps -axwo 'stat uid pid ppid vsz rss pcpu ucomm command' 2>/dev/null | \
535         egrep -i ["^ *STAT +UID +PID +PPID +VSZ +RSS +%CPU +UCOMM +COMMAND"] > /dev/null
536 then
537         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
538         ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid pid ppid vsz rss pcpu ucomm command'"
539         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
540         ac_cv_ps_cols=9
541         AC_MSG_RESULT([$ac_cv_ps_command])
543 dnl  STAT UCOMM              VSZ   RSS USER       UID  PPID COMMAND
544 elif ps -weo 'stat comm vsz rss user uid pid ppid etime args' 2>/dev/null | \
545         egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[ID]+ +P[PID]+ +[ELAPSD]+ +[RGSCOMDNA]+"] >/dev/null
546 then
547         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procetime,procprog,&pos]"
548         ac_cv_ps_command="$PATH_TO_PS -weo 'stat uid pid ppid vsz rss pcpu etime comm args'"
549         ac_cv_ps_format="%s %d %d %d %d %d %f %s %s %n"
550         ac_cv_ps_cols=10
551         AC_MSG_RESULT([$ac_cv_ps_command])
553 dnl FreeBSD
554 elif ps waxco 'state command vsz rss uid user pid ppid' 2>/dev/null | \
555         egrep -i ["^STAT +COMMAND +VSZ +RSS +UID +USER +PID +PPID"] >/dev/null
556 then
557         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
558         ac_cv_ps_command="$PATH_TO_PS waxco 'state uid pid ppid vsz rss pcpu command command'"
559         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
560         ac_cv_ps_cols=9
561         AC_MSG_RESULT([$ac_cv_ps_command])
563 dnl BSD-like mode in RH 6.1
564 elif ps waxno 'state comm vsz rss uid user pid ppid args' 2>/dev/null | \
565         egrep -i ["^S +COMMAND +VSZ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
566 then
567         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
568         ac_cv_ps_command="$PATH_TO_PS waxno 'state uid pid ppid vsz rss pcpu comm args'"
569         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
570         ac_cv_ps_cols=9
571         AC_MSG_RESULT([$ac_cv_ps_command])
573 dnl SunOS 4.1.3:
574 dnl  F  UID  PID  PPID  CP  PRI  NI  SZ  RSS  WCHAN  STAT  TT  TIME  COMMAND
575 dnl Need the head -1 otherwise test will work because arguments are found
576 elif ps -laxnwww 2>/dev/null | head -1 | \
577         egrep -i ["^ *F(LAGS)? +UID +PID +PPID +CP +PRI +NI +(SZ)|(VSZ)|(SIZE) +RSS +WCHAN +STAT? +TTY? +TIME +COMMAND"] >/dev/null
578 then
579         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]"
580         ac_cv_ps_command="$PATH_TO_PS -laxnwww"
581         ac_cv_ps_format="%*s %d %d %d %*s %*s %*s %d %d %*s %s %*s %*s %n%s"
582         ac_cv_ps_cols=9
583         AC_MSG_RESULT([$ac_cv_ps_command])
585 dnl Debian Linux / procps v1.2.9:
586 dnl  FLAGS   UID   PID  PPID PRI  NI   SIZE   RSS WCHAN       STA TTY TIME COMMAND
587 dnl    100     0     1     0   0   0    776    76  c0131c8c   S  ffff  0:11 init [2]
588 dnl
589 elif ps laxnwww 2>/dev/null | \
590         egrep -i ["^ *F(LAGS)? +UID +PID +PPID +PRI +NI +(VSZ)|(SIZE) +RSS +WCHAN +STAT? TTY +TIME +COMMAND"] >/dev/null
591 then
592         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,procstat,&procvsz,&procrss,&pos,procprog]"
593         ac_cv_ps_command="$PATH_TO_PS laxnwww"
594         ac_cv_ps_format="%*s %d %d %d %*s %*s %d %d %*s %s %*s %*s %n%s"
595         ac_cv_ps_cols=9
596         AC_MSG_RESULT([$ac_cv_ps_command])
598 dnl OpenBSD (needs to come early because -exo appears to work, but does not give all procs)
599 elif ps -axo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
600         egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[PID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null
601 then
602         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
603         ac_cv_ps_command="$PATH_TO_PS -axo 'stat uid pid ppid vsz rss pcpu comm args'"
604         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
605         ac_cv_ps_cols=9
606         AC_MSG_RESULT([$ac_cv_ps_command])
608 dnl Tru64 - needs %*[ +<>] in PS_FORMAT. 
609 dnl Has /usr/bin/ps and /sbin/ps - force sbin version
610 dnl Can't use vsize and rssize because comes back with text (eg, 1.5M instead 
611 dnl of 1500). Will need big changes to check_procs to support
612 elif /sbin/ps -eo 'stat uid pid ppid pcpu etime comm args' 2>/dev/null | \
613         egrep -i ["^ *S +[UID]+ +[PID]+ +[PID]+ +[%CPU]+ +[ELAPSD]+ +[COMMAND]+ +[COMMAND]+"] > /dev/null
614 then
615         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procpcpu,procetime,procprog,&pos]"
616         ac_cv_ps_command="/sbin/ps -eo 'stat uid pid ppid pcpu etime comm args'"
617         ac_cv_ps_format=["%s%*[ +<>] %d %d %d %f %s %s %n"]
618         ac_cv_ps_cols=8
619         AC_MSG_RESULT([$ac_cv_ps_command])
621 elif ps -eo 's comm vsz rss user uid pid ppid args' 2>/dev/null | \
622         egrep -i ["^S[TAUES]* +C[OMDNA]+ +[VSIZE]+ +U[SER]+ +U[ID]+ +P[PID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null
623 then
624         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
625         ac_cv_ps_command="$PATH_TO_PS -eo 's uid pid ppid vsz rss pcpu comm args'"
626         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
627         ac_cv_ps_cols=9
628         AC_MSG_RESULT([$ac_cv_ps_command])
630 dnl AIX 4.3.3 and 5.1 do not have an rss field
631 elif ps -eo 'stat uid pid ppid vsz pcpu comm args' 2>/dev/null | \
632         egrep -i ["^ *S[TAUES]* +UID +PID +PPID +VSZ +%CPU +COMMAND +COMMAND"] >/dev/null
633 then
634         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procpcpu,procprog,&pos]"
635         ac_cv_ps_command="$PATH_TO_PS -eo 'stat uid pid ppid vsz pcpu comm args'"
636         ac_cv_ps_format="%s %d %d %d %d %f %s %n"
637         ac_cv_ps_cols=8
638         AC_MSG_RESULT([$ac_cv_ps_command - with no RSS])
640 dnl Solaris 2.6
641 elif ps -Ao 's comm vsz rss uid user pid ppid args' 2>/dev/null | \
642         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
643 then
644         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
645         ac_cv_ps_command="$PATH_TO_PS -Ao 's uid pid ppid vsz rss pcpu comm args'"
646         # There must be no space between the %s and %n due to a wierd problem in sscanf where
647         # it will return %n as longer than the line length
648         ac_cv_ps_format="%s %d %d %d %d %d %f %s%n"
649         ac_cv_ps_cols=9
650         AC_MSG_RESULT([$ac_cv_ps_command])
652 elif ps -Ao 'status comm vsz rss uid user pid ppid args' 2>/dev/null | \
653         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
654 then
655         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
656         ac_cv_ps_command="$PATH_TO_PS -Ao 'status uid pid ppid vsz rss pcpu comm args'"
657         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
658         ac_cv_ps_cols=9
659         AC_MSG_RESULT([$ac_cv_ps_command])
661 elif ps -Ao 'state comm vsz rss uid user pid ppid args' 2>/dev/null | \
662         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
663 then
664         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
665         ac_cv_ps_command="$PATH_TO_PS -Ao 'state uid pid ppid vsz rss pcpu comm args'"
666         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
667         ac_cv_ps_cols=9
668         AC_MSG_RESULT([$ac_cv_ps_command])
670 dnl wonder who takes state instead of stat
671 elif ps -ao 'state command vsz rss user pid ppid args' 2>/dev/null | \
672         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
673 then
674         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
675         ac_cv_ps_command="$PATH_TO_PS -ao 'state uid pid ppid vsz rss pcpu command args'"
676         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
677         ac_cv_ps_cols=8
678         AC_MSG_RESULT([$ac_cv_ps_command])
680 dnl IRIX 53
681 elif ps -el 2>/dev/null | \
682         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
683 then
684         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&pos,procprog]"
685         ac_cv_ps_command="$PATH_TO_PS -el (IRIX 53)"
686         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %d %d %*s %*s %*s %n%s"
687         ac_cv_ps_cols=8
688         AC_MSG_RESULT([$ac_cv_ps_command])
690 dnl IRIX 63
691 elif ps -el 2>/dev/null | \
692         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +ADDR +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
693 then
694         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
695         ac_cv_ps_command="$PATH_TO_PS -el (IRIX 63)"
696         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
697         ac_cv_ps_cols=6
698         AC_MSG_RESULT([$ac_cv_ps_command])
700 dnl AIX 4.1:
701 dnl     F S      UID   PID  PPID   C PRI NI ADDR  SZ  RSS   WCHAN    TTY  TIME CMD
702 dnl    303 A        0     0     0 120  16 -- 1c07  20   24              -  0:45 swapper
703 elif ps -el 2>/dev/null | \
704         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +ADDR +SZ +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
705 then
706         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
707         ac_cv_ps_command="$PATH_TO_PS -el (AIX 4.1 and HP-UX)"
708         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
709         ac_cv_ps_cols=6
710         AC_MSG_RESULT([$ac_cv_ps_command])
712 dnl AIX?
713 elif ps glaxen 2>/dev/null | \
714         egrep -i ["^ *F +UID +PID +PPID +PRI +NI +VSZ +RSS +WCHAN +STAT +TTY +TIME +COMMAND"] >/dev/null
715 then
716         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]"
717         ac_cv_ps_command="$PATH_TO_PS glaxen"
718         ac_cv_ps_format="%*s %d %d %d %*s %*s %d %d %*s %s %*s %*s %n%s"
719         ac_cv_ps_cols=8
720         AC_MSG_RESULT([$ac_cv_ps_command])
722 dnl MacOSX / Darwin
723 dnl TODO: MacOSX has commands with spaces which will cause problems to PS_FORMAT
724 dnl Some truncation will happen in UCOMM column
725 dnl STAT      VSZ    RSS   UID  PPID %CPU UCOMM            COMMAND
726 dnl Ss      52756  22496   501     1   6.9 Window Manager   /System/Library/CoreServices/WindowServer -daemon
727 elif ps wwaxo 'state vsz rss uid pid ppid pcpu ucomm command' 2>/dev/null | \
728         egrep -i ["^STAT +VSZ +RSS +UID +PPID +%CPU +UCOMM +COMMAND"] >/dev/null
729 then
730         ac_cv_ps_command="$PATH_TO_PS wwaxo 'state vsz rss uid pid ppid pcpu ucomm command'"
731         ac_cv_ps_varlist="[procstat,&procvsz,&procrss,&procuid,&procpid,&procppid,&procpcpu,procprog,&pos]"
732         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
733         ac_cv_ps_cols=8
734         AC_MSG_RESULT([$ac_cv_ps_command])
736 dnl UnixWare 
737 elif ps -Al 2>/dev/null | \
738         egrep -i ["^ *F +S +UID +PID +PPID +CLS +PRI +NI +C +ADDR +SZ +WCHAN +TTY +TIME +COMD"] >/dev/null
739 then
740         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
741         ac_cv_ps_command="$PATH_TO_PS -Al"
742         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
743         ac_cv_ps_cols=8
744         AC_MSG_RESULT([$ac_cv_ps_command])
746 else
747         AC_MSG_WARN([unable to find usable ps syntax - check_procs and check_nagios will not be compiled])
748 fi
750 if test -n "$ac_cv_ps_varlist" ; then
751         AC_DEFINE_UNQUOTED(PS_VARLIST,$ac_cv_ps_varlist,
752                 [Variable list for sscanf of 'ps' output])
753         AC_DEFINE_UNQUOTED(PS_COMMAND,"$ac_cv_ps_command",
754                 [Verbatim command to execute for ps in check_procs])
755         AC_DEFINE_UNQUOTED(PS_FORMAT,"$ac_cv_ps_format",
756                 [Format string for scanning ps output in check_procs])
757         AC_DEFINE_UNQUOTED(PS_COLS,$ac_cv_ps_cols,
758                 [Number of columns in ps command])
759         EXTRAS="$EXTRAS check_procs check_nagios"
760         if echo "$ac_cv_ps_varlist" | grep "procetime" >/dev/null; then
761                 AC_DEFINE(PS_USES_PROCETIME,"yes",
762                           [Whether the ps utility uses the "procetime" field])
763         fi
764 fi
766 AC_PATH_PROG(PATH_TO_PING,ping)
767 AC_PATH_PROG(PATH_TO_PING6,ping6)
769 AC_ARG_WITH(ping_command,
770         ACX_HELP_STRING([--with-ping-command=SYNTAX],
771                 [sets syntax for ICMP ping]),
772         with_ping_command=$withval,)
774 AC_MSG_CHECKING(for ICMP ping syntax)
775 ac_cv_ping_packets_first=no
776 ac_cv_ping_has_timeout=no
777 if test -n "$with_ping_command"
778 then
779         AC_MSG_RESULT([(command-line) $with_ping_command])
780         if test -n "$ac_cv_ping_packets_first"
781         then
782                 ac_cv_ping_packets_first=yes
783                 ac_cv_ping_has_timeout=yes
784         fi
786 elif [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
787         $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
788         egrep -i "^round-trip|^rtt" >/dev/null
789 then
790         with_ping_command="$PATH_TO_PING -n -U -c %d %s"
791         ac_cv_ping_packets_first=yes
792         AC_MSG_RESULT([$with_ping_command])
794 elif $PATH_TO_PING -n -U -w 10 -c 1 127.0.0.1 2>/dev/null | \
795         egrep -i "^round-trip|^rtt" >/dev/null
796 then
797         with_ping_command="$PATH_TO_PING -n -U -w %d -c %d %s"
798         ac_cv_ping_packets_first=yes
799   ac_cv_ping_has_timeout=yes
800         AC_MSG_RESULT([$with_ping_command])
802 elif $PATH_TO_PING -n -U -c 1 127.0.0.1 2>/dev/null | \
803         egrep -i "^round-trip|^rtt" >/dev/null
804 then
805         with_ping_command="$PATH_TO_PING -n -U -c %d %s"
806         ac_cv_ping_packets_first=yes
807         AC_MSG_RESULT([$with_ping_command])
809 elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \
810         egrep -i "^round-trip|^rtt" >/dev/null
811 then
812         with_ping_command="$PATH_TO_PING -n -c %d %s"
813         ac_cv_ping_packets_first=yes
814         AC_MSG_RESULT([$with_ping_command])
816 elif $PATH_TO_PING -n 127.0.0.1 -c 1 2>/dev/null | \
817         egrep -i "^round-trip|^rtt" >/dev/null
818 then
819         with_ping_command="$PATH_TO_PING -n %s -c %d"
820         AC_MSG_RESULT([$with_ping_command])
822 elif $PATH_TO_PING 127.0.0.1 -n 1 2>/dev/null | \
823         egrep -i "^round-trip|^rtt" >/dev/null
824 then
825         with_ping_command="$PATH_TO_PING %s -n %d"
826         AC_MSG_RESULT([$with_ping_command])
828 elif $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
829         egrep -i "^round-trip|^rtt" >/dev/null
830 then
831         with_ping_command="$PATH_TO_PING -n -s %s 56 %d"
832         AC_MSG_RESULT([$with_ping_command])
834 elif $PATH_TO_PING -n -h 127.0.0.1 -s 56 -c 1 2>/dev/null | \
835         egrep -i "^round-trip|^rtt" >/dev/null
836 then
837         with_ping_command="$PATH_TO_PING -n -h %s -s 56 -c %d"
838         AC_MSG_RESULT([$with_ping_command])
840 elif $PATH_TO_PING -n -s 56 -c 1 127.0.0.1 2>/dev/null | \
841         egrep -i "^round-trip|^rtt" >/dev/null
842 then
843         with_ping_command="$PATH_TO_PING -n -s 56 -c %d %s"
844         ac_cv_ping_packets_first=yes
845         AC_MSG_RESULT([$with_ping_command])
847 elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \
848         egrep -i "^round-trip|^rtt" >/dev/null
849 then
850         with_ping_command="$PATH_TO_PING -n -c %d %s"
851         ac_cv_ping_packets_first=yes
852         AC_MSG_RESULT([$with_ping_command])
854 else
855         AC_MSG_WARN([unable to find usable ping syntax])
856 fi
858 AC_DEFINE_UNQUOTED(PING_COMMAND,"$with_ping_command",
859         [path and args for ICMP ping command])
861 if test "x$ac_cv_ping_packets_first" != "xno"
862 then
863         AC_DEFINE(PING_PACKETS_FIRST,1,
864                 [Define if packet count must precede host])
865 fi
867 if test "x$ac_cv_ping_has_timeout" != "xno"
868 then
869         AC_DEFINE(PING_HAS_TIMEOUT,1,
870                 [Define if ping has its own timeout option that should be set])
871 fi
873 AC_ARG_WITH(ping6_command,
874         ACX_HELP_STRING([--with-ping6-command=SYNTAX],
875                 [sets syntax for ICMPv6 ping]),
876         with_ping6_command=$withval,)
878 if test x"$with_ipv6" != xno ; then
879 AC_MSG_CHECKING(for ICMPv6 ping syntax)
880 ac_cv_ping6_packets_first=no
881 if test -n "$with_ping6_command"
882 then
883         AC_MSG_RESULT([(command-line) $with_ping6_command])
884         if test -n "$ac_cv_ping6_packets_first"
885         then
886                 ac_cv_ping6_packets_first=yes
887         fi
889 elif test "x$PATH_TO_PING6" != "x"; then
890         if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
891                 $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \
892                 egrep -i "^round-trip|^rtt" >/dev/null
893         then
894                 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s"
895                 ac_cv_ping6_packets_first=yes
896                 AC_MSG_RESULT([$with_ping6_command])
898         elif $PATH_TO_PING6 -n -U -w 10 -c 1 ::1 2>/dev/null | \
899                 egrep -i "^round-trip|^rtt" >/dev/null
900         then
901                 with_ping6_command="$PATH_TO_PING6 -n -U -w %d -c %d %s"
902                 ac_cv_ping6_packets_first=yes
903                 ac_cv_ping_has_timeout=yes
904                 AC_MSG_RESULT([$with_ping6_command])
906         elif $PATH_TO_PING6 -n -U -c 1 ::1 2>/dev/null | \
907                 egrep -i "^round-trip|^rtt" >/dev/null
908         then
909                 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s"
910                 ac_cv_ping6_packets_first=yes
911                 AC_MSG_RESULT([$with_ping6_command])
913         elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \
914                 egrep -i "^round-trip|^rtt" >/dev/null
915         then
916                 with_ping6_command="$PATH_TO_PING6 -n -c %d %s"
917                 ac_cv_ping6_packets_first=yes
918                 AC_MSG_RESULT([$with_ping6_command])
920         elif $PATH_TO_PING6 -n ::1 -c 1 2>/dev/null | \
921                 egrep -i "^round-trip|^rtt" >/dev/null
922         then
923                 with_ping6_command="$PATH_TO_PING6 -n %s -c %d"
924                 AC_MSG_RESULT([$with_ping6_command])
926         elif $PATH_TO_PING6 ::1 -n 1 2>/dev/null | \
927                 egrep -i "^round-trip|^rtt" >/dev/null
928         then
929                 with_ping6_command="$PATH_TO_PING6 %s -n %d"
930                 AC_MSG_RESULT([$with_ping6_command])
932         elif $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \
933                 egrep -i "^round-trip|^rtt" >/dev/null
934         then
935                 with_ping6_command="$PATH_TO_PING6 -n -s %s 56 %d"
936                 AC_MSG_RESULT([$with_ping6_command])
938         elif $PATH_TO_PING6 -n -h ::1 -s 56 -c 1 2>/dev/null | \
939                 egrep -i "^round-trip|^rtt" >/dev/null
940         then
941                 with_ping6_command="$PATH_TO_PING6 -n -h %s -s 56 -c %d"
942                 AC_MSG_RESULT([$with_ping6_command])
944         elif $PATH_TO_PING6 -n -s 56 -c 1 ::1 2>/dev/null | \
945                 egrep -i "^round-trip|^rtt" >/dev/null
946         then
947                 with_ping6_command="$PATH_TO_PING6 -n -s 56 -c %d %s"
948                 ac_cv_ping6_packets_first=yes
949                 AC_MSG_RESULT([$with_ping_command])
951         elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \
952                 egrep -i "^round-trip|^rtt" >/dev/null
953         then
954                 with_ping6_command="$PATH_TO_PING6 -n -c %d %s"
955                 ac_cv_ping6_packets_first=yes
956                 AC_MSG_RESULT([$with_ping6_command])
958         fi
960 elif test "x$PATH_TO_PING" != "x"; then
961         if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
962                 $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \
963                 egrep -i "^round-trip|^rtt" >/dev/null
964         then
965                 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s"
966                 ac_cv_ping6_packets_first=yes
967                 AC_MSG_RESULT([$with_ping6_command])
969         elif $PATH_TO_PING -A inet6 -n -U -c 1 ::1 2>/dev/null | \
970                 egrep -i "^round-trip|^rtt" >/dev/null
971         then
972                 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s"
973                 ac_cv_ping6_packets_first=yes
974                 AC_MSG_RESULT([$with_ping6_command])
976         elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \
977                 egrep -i "^round-trip|^rtt" >/dev/null
978         then
979                 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s"
980                 ac_cv_ping6_packets_first=yes
981                 AC_MSG_RESULT([$with_ping6_command])
983         elif $PATH_TO_PING -A inet6 -n ::1 -c 1 2>/dev/null | \
984                 egrep -i "^round-trip|^rtt" >/dev/null
985         then
986                 with_ping6_command="$PATH_TO_PING -A inet6 -n %s -c %d"
987                 AC_MSG_RESULT([$with_ping6_command])
989         elif $PATH_TO_PING -A inet6 ::1 -n 1 2>/dev/null | \
990                 egrep -i "^round-trip|^rtt" >/dev/null
991         then
992                 with_ping6_command="$PATH_TO_PING -A inet6 %s -n %d"
993                 AC_MSG_RESULT([$with_ping6_command])
995         elif $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \
996                 egrep -i "^round-trip|^rtt" >/dev/null
997         then
998                 with_ping6_command="$PATH_TO_PING -A inet6 -n -s %s 56 %d"
999                 AC_MSG_RESULT([$with_ping6_command])
1001         elif $PATH_TO_PING -A inet6 -n -h ::1 -s 56 -c 1 2>/dev/null | \
1002                 egrep -i "^round-trip|^rtt" >/dev/null
1003         then
1004                 with_ping6_command="$PATH_TO_PING -A inet6 -n -h %s -s 56 -c %d"
1005                 AC_MSG_RESULT([$with_ping6_command])
1007         elif $PATH_TO_PING -A inet6 -n -s 56 -c 1 ::1 2>/dev/null | \
1008                 egrep -i "^round-trip|^rtt" >/dev/null
1009         then
1010                 with_ping6_command="$PATH_TO_PING -A inet6 -n -s 56 -c %d %s"
1011                 ac_cv_ping6_packets_first=yes
1012                 AC_MSG_RESULT([$with_ping_command])
1014         elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \
1015                 egrep -i "^round-trip|^rtt" >/dev/null
1016         then
1017                 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s"
1018                 ac_cv_ping6_packets_first=yes
1019                 AC_MSG_RESULT([$with_ping6_command])
1021         fi
1023 fi
1025 if test "x$with_ping6_command" != "x"; then
1026         AC_DEFINE_UNQUOTED(PING6_COMMAND,"$with_ping6_command",
1027                 [path and args for ICMPv6 ping command])
1028 else
1029         AC_MSG_RESULT([none])
1030 fi
1032 if test "x$ac_cv_ping6_packets_first" != "xno"; then
1033         AC_DEFINE(PING6_PACKETS_FIRST,1,
1034                 [Define if packet count must precede host])
1035 fi
1036 fi
1039 AC_ARG_WITH(nslookup_command,
1040             ACX_HELP_STRING([--with-nslookup-command=PATH],
1041                             [sets path to nslookup executable]),
1042             ac_cv_nslookup_command=$withval)
1043 if test -n "$ac_cv_nslookup_command"; then
1044         AC_MSG_NOTICE([Using specific nslookup at $ac_cv_nslookup_command])
1045 else
1046         AC_PATH_PROG(PATH_TO_NSLOOKUP,nslookup)
1047         if test -n "$PATH_TO_NSLOOKUP"
1048         then
1049                 AC_MSG_CHECKING(for nslookup syntax)
1050                 if $PATH_TO_NSLOOKUP -sil 127.0.0.1 2>&1 | grep ["Invalid option: sil"] >/dev/null
1051                 then
1052                         ac_cv_nslookup_command="$PATH_TO_NSLOOKUP"
1053                         AC_MSG_RESULT([$ac_cv_nslookup_command])
1055                 else
1056                         ac_cv_nslookup_command="$PATH_TO_NSLOOKUP -sil"
1057                         AC_MSG_RESULT([$ac_cv_nslookup_command])
1059                 fi
1060         else
1061                 AC_MSG_WARN([nslookup command not found])
1062         fi
1063 fi
1065 if test -n "$ac_cv_nslookup_command"; then
1066         EXTRAS="$EXTRAS check_dns"
1067         AC_DEFINE_UNQUOTED(NSLOOKUP_COMMAND,"$ac_cv_nslookup_command", [path and args for nslookup])
1068 fi
1070 AC_MSG_CHECKING([for number of cpus])
1071 AC_TRY_COMPILE([#include <unistd.h>],
1072         [sysconf(_SC_NPROCESSORS_CONF) > 0;],
1073         AC_DEFINE(HAVE_SYSCONF__SC_NPROCESSORS_CONF,1,[Define if sysconf returns number of cpus])
1074         AC_MSG_RESULT([sysconf(_SC_NPROCESSORS_CONF)]),
1075         AC_MSG_RESULT([cannot calculate])
1076         )
1078 AC_PATH_PROG(PATH_TO_UPTIME,uptime)
1079 AC_ARG_WITH(uptime_command,
1080             ACX_HELP_STRING([--with-uptime-command=PATH],
1081                             [sets path to uptime]), PATH_TO_UPTIME=$withval)
1082 AC_DEFINE_UNQUOTED(PATH_TO_UPTIME,"$PATH_TO_UPTIME",[path to uptime binary])
1084 AC_PATH_PROG(PATH_TO_RPCINFO,rpcinfo)
1085 AC_ARG_WITH(rpcinfo_command,
1086             ACX_HELP_STRING([--with-rpcinfo-command=PATH],
1087                             [sets path to rpcinfo]), PATH_TO_RPCINFO=$withval)
1088 AC_DEFINE_UNQUOTED(PATH_TO_RPCINFO,"$PATH_TO_RPCINFO",[path to rpcinfo binary])
1090 AC_PATH_PROG(PATH_TO_LMSTAT,lmstat)
1091 if test -x "$PATH_TO_LMSTAT"
1092 then
1093         AC_DEFINE_UNQUOTED(PATH_TO_LMSTAT,"$PATH_TO_LMSTAT",[path to lmstat])
1094 else
1095         AC_MSG_WARN([Get lmstat from Globetrotter Software to monitor flexlm licenses])
1096 fi
1098 AC_PATH_PROG(PATH_TO_SMBCLIENT,smbclient)
1099 AC_ARG_WITH(smbclient_command,
1100             ACX_HELP_STRING([--with-smbclient-command=PATH],
1101                             [sets path to smbclient]), 
1102             PATH_TO_SMBCLIENT=$withval)
1103 if test -n "$PATH_TO_SMBCLIENT"
1104 then
1105         AC_DEFINE_UNQUOTED(PATH_TO_SMBCLIENT,"$PATH_TO_SMBCLIENT",[path to smbclient binary])
1106 else
1107         AC_MSG_WARN([Get smbclient from Samba.org to monitor SMB shares])
1108 fi
1111 AC_PATH_PROG(PATH_TO_WHO,who)
1113 if [$PATH_TO_WHO -q 2>/dev/null | egrep -i "^# users=[0-9]+$" >/dev/null]
1114 then
1115         ac_cv_path_to_who="$PATH_TO_WHO -q"
1116 else
1117         ac_cv_path_to_who="$PATH_TO_WHO"
1118 fi
1120 AC_DEFINE_UNQUOTED(WHO_COMMAND,"$ac_cv_path_to_who",
1121         [path and arguments for invoking 'who'])
1123 AC_PATH_PROG(PATH_TO_SNMPGET,snmpget)
1124 AC_ARG_WITH(snmpget_command,
1125             ACX_HELP_STRING([--with-snmpget-command=PATH],
1126                             [Path to snmpget command]),
1127             PATH_TO_SNMPGET=$withval)
1128 if test -n "$PATH_TO_SNMPGET"
1129 then
1130         AC_DEFINE_UNQUOTED(PATH_TO_SNMPGET,"$PATH_TO_SNMPGET",[path to snmpget binary])
1131         EXTRAS="$EXTRAS check_hpjd check_snmp"
1132 else
1133         AC_MSG_WARN([Get snmpget from http://net-snmp.sourceforge.net to make check_hpjd and check_snmp plugins])
1134 fi
1136 AC_PATH_PROG(PATH_TO_SNMPGETNEXT,snmpgetnext)
1137 AC_ARG_WITH(snmpgetnext_command,
1138             ACX_HELP_STRING([--with-snmpgetnext-command=PATH],
1139                             [Path to snmpgetnext command]),
1140             PATH_TO_SNMPGETNEXT=$withval)
1141 if test -n "$PATH_TO_SNMPGETNEXT"
1142 then
1143         AC_DEFINE_UNQUOTED(PATH_TO_SNMPGETNEXT,"$PATH_TO_SNMPGETNEXT",[path to snmpgetnext binary])
1144 fi
1146 if ( $PERL -M"Net::SNMP 3.6" -e 'exit' 2>/dev/null  )
1147 then
1148         AC_MSG_CHECKING(for Net::SNMP perl module)
1149         AC_MSG_RESULT([found])
1150 else
1151         AC_MSG_WARN([Tried $PERL - install Net::SNMP perl module if you want to use the perl snmp plugins])
1152 fi
1154 AC_PATH_PROG(PATH_TO_QUAKESTAT,quakestat)
1155 AC_PATH_PROG(PATH_TO_QSTAT,qstat)
1156 AC_ARG_WITH(qstat_command,
1157             ACX_HELP_STRING([--with-qstat-command=PATH], 
1158                             [Path to qstat command]), PATH_TO_QSTAT=$withval)
1160 if test -x "$PATH_TO_QUAKESTAT"
1161 then
1162         ac_cv_path_to_qstat="$PATH_TO_QUAKESTAT"
1163         EXTRAS="$EXTRAS check_game"
1165 elif test -n "$PATH_TO_QSTAT"
1166 then
1167         ac_cv_path_to_qstat="$PATH_TO_QSTAT"
1168         EXTRAS="$EXTRAS check_game"
1169 else
1170         AC_MSG_WARN([Get qstat from http://www.activesw.com/people/steve/qstat.html in order to make check_game plugin])
1171 fi
1173 if test $ac_cv_path_to_qstat 
1174 then
1175         AC_DEFINE_UNQUOTED(PATH_TO_QSTAT,"$ac_cv_path_to_qstat",
1176                 [path to qstat/quakestat])
1177 fi
1179 AC_PATH_PROG(PATH_TO_FPING,fping)
1180 AC_ARG_WITH(fping_command,
1181             ACX_HELP_STRING([--with-fping-command=PATH],
1182                             [Path to fping command]), PATH_TO_FPING=$withval)
1183 if test -n "$PATH_TO_FPING"
1184 then
1185         AC_DEFINE_UNQUOTED(PATH_TO_FPING,"$PATH_TO_FPING",[path to fping])
1186         EXTRAS="$EXTRAS check_fping"
1187 else
1188         AC_MSG_WARN([Get fping from http://www.fping.com in order to make check_fping plugin])
1189 fi
1191 AC_PATH_PROG(PATH_TO_SSH,ssh)
1192 AC_ARG_WITH(ssh_command,
1193             ACX_HELP_STRING([--with-ssh-command=PATH],
1194                             [sets path for ssh]), PATH_TO_SSH=$withval)
1195 if test -n "$PATH_TO_SSH"
1196 then
1197         AC_DEFINE_UNQUOTED(SSH_COMMAND,"$PATH_TO_SSH",[path to ssh binary])
1198         EXTRAS="$EXTRAS check_by_ssh"
1199 else
1200         AC_MSG_WARN([Get ssh in order to make check_by_ssh plugin])
1201 fi
1204 AC_PATH_PROG(PATH_TO_MAILQ,mailq)
1205 AC_ARG_WITH(mailq_command,
1206             ACX_HELP_STRING([--with-mailq-command=PATH],
1207                             [sets path to mailq]), PATH_TO_MAILQ=$withval)
1208 if test -n "$PATH_TO_MAILQ"
1209 then
1210         AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_MAILQ",[path to mailq])
1211 else
1212         AC_MSG_WARN([Could not find mailq or eqivalent])
1213 fi
1215 AC_PATH_PROG(PATH_TO_QMAIL_QSTAT,qmail-qstat)
1216 if test -x "$PATH_TO_QMAIL_QSTAT"
1217 then
1218         AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_QMAIL_QSTAT",[path to qmail-qstat])
1219 else
1220         AC_MSG_WARN([Could not find qmail-qstat or eqivalent])
1221 fi
1223 dnl SWAP info required is amount allocated/available and amount free
1224 dnl The plugin works through all the swap devices and adds up the total swap
1225 dnl available.
1226 AC_PATH_PROG(PATH_TO_SWAP,swap)
1227 if (test -n "$PATH_TO_SWAP")
1228 then
1229 AC_MSG_CHECKING([for $PATH_TO_SWAP format])
1230 if [$PATH_TO_SWAP -l 2>&1 >/dev/null]
1231 then
1232         ac_cv_have_swap=yes
1233         ac_cv_swap_command="$PATH_TO_SWAP -l"
1234         if [$PATH_TO_SWAP -l 2>/dev/null | \
1235                 egrep -i "^lswap +path +pri +swaplo +blocks +free +maxswap" \
1236                 >/dev/null]
1237         then
1238                 ac_cv_swap_format=[" %*d %*s %*d,%*d %*d %*d %f %f"]
1239                 ac_cv_swap_conv=2048
1240                 AC_MSG_RESULT([using IRIX format swap])
1242         elif [$PATH_TO_SWAP -l 2>/dev/null | egrep -i "^path +dev +swaplo +blocks +free" >/dev/null]
1243         then
1244                 ac_cv_swap_format=["%*s %*[0-9,-] %*d %f %f"]
1245                 ac_cv_swap_conv=2048
1246                 AC_MSG_RESULT([using Unixware format swap])
1247         else
1248                 dnl if we don't know what format swap's output is
1249                 dnl we might as well pretend we didn't see it
1250                 ac_cv_have_swap=""
1251                 ac_cv_swap_command=""
1252         fi
1253 fi
1254 dnl end if for PATH_TO_SWAP
1255 fi
1257 AC_PATH_PROG(PATH_TO_SWAPINFO,swapinfo)
1258 if (test -n "$PATH_TO_SWAPINFO")
1259 then
1260 AC_MSG_CHECKING([for $PATH_TO_SWAPINFO format])
1261 if [$PATH_TO_SWAPINFO -k 2>&1 | egrep -i "^Device" >/dev/null]
1262 then
1263         ac_cv_have_swap=yes
1264         ac_cv_swap_command="$PATH_TO_SWAPINFO -k"
1266         if [$PATH_TO_SWAPINFO -k 2>/dev/null | egrep -i "^Device +1K-blocks +Used +Avail" >/dev/null]
1267         then
1268                 ac_cv_swap_format=["%*s %f %*d %f"]
1269                 ac_cv_swap_conv=1024
1270                 AC_MSG_RESULT([using FreeBSD format swapinfo])
1271         fi
1273 elif [$PATH_TO_SWAPINFO -dfM 2>/dev/null | egrep -i "^TYPE +AVAIL +USED +FREE" >/dev/null]
1274 then
1275         ac_cv_have_swap=yes
1276         ac_cv_swap_command="$PATH_TO_SWAPINFO -dfM"
1277         ac_cv_swap_format=["%*s %f %*d %f"]
1278         ac_cv_swap_conv=1024
1279         AC_MSG_RESULT([using HP-UX format swapinfo])
1280 fi
1281 dnl end if for PATH_TO_SWAPINFO
1282 fi
1284 AC_PATH_PROG(PATH_TO_LSPS,lsps)
1285 if (test -n "$PATH_TO_LSPS")
1286 then
1287 AC_MSG_CHECKING([for $PATH_TO_LSPS format])
1288 if [$PATH_TO_LSPS -a 2>/dev/null | egrep -i "^Page Space" > /dev/null]
1289 then
1290         ac_cv_have_swap=yes
1291         ac_cv_swap_command="$PATH_TO_LSPS -a"
1292         ac_cv_swap_format=["%*s %*s %*s %f%*s %f %*s"]
1293         ac_cv_swap_conv=1
1294         AC_MSG_RESULT([using AIX lsps])
1295 fi
1296 dnl end if for PATH_TO_SWAPINFO
1297 fi
1299 dnl
1300 dnl test for swapctl system call, both the 2-arg and 3-arg variants
1301 dnl fwict, the 2-arg is an SVR4 standard, whereas the 3-arg is shared
1302 dnl in the various BSD's
1303 dnl
1305 AC_CHECK_HEADERS([sys/stat.h sys/param.h])
1306 AC_CHECK_HEADERS([sys/swap.h], [], [], [
1307 #ifdef HAVE_SYS_PARAM_H
1308 #include <sys/param.h>
1309 #endif
1310 ])
1311 AC_CHECK_DECLS([swapctl],,,[
1312                #include <unistd.h>
1313                #include <sys/types.h>
1314                #include <sys/param.h>
1315                #include <sys/stat.h>
1316                #include <sys/swap.h>
1317                ])
1318 AC_CHECK_TYPES([swaptbl_t, swapent_t],,,[
1319                #include <sys/types.h>
1320                #include <sys/param.h>
1321                #include <sys/stat.h>
1322                #include <sys/swap.h>
1323                ])
1324 AC_CHECK_MEMBERS([struct swapent.se_nblks],,,[
1325                #include <unistd.h>
1326                #include <sys/types.h>
1327                #include <sys/param.h>
1328                #include <sys/stat.h>
1329                #include <sys/swap.h>
1330                ])
1332 if test "$ac_cv_have_decl_swapctl" = "yes"; 
1333 then
1334         EXTRAS="$EXTRAS check_swap"
1335         AC_MSG_CHECKING([for 2-arg (SVR4) swapctl])
1336         if test "$ac_cv_type_swaptbl_t" = "yes" -a \
1337                 "$ac_cv_type_swapent_t" = "yes"; 
1338         then
1339                 AC_MSG_RESULT([yes])
1340                 ac_cv_check_swap_swapctl_svr4="1";
1341                 AC_DEFINE([CHECK_SWAP_SWAPCTL_SVR4],1,
1342                           [Define if 2-argument SVR4 swapctl exists])
1343         else
1344                 AC_MSG_RESULT([no])
1345                 AC_MSG_CHECKING([for 3-arg (*BSD) swapctl])
1346                 if test "$ac_cv_member_struct_swapent_se_nblks" = "yes"; 
1347                 then
1348                         AC_MSG_RESULT([yes])
1349                         AC_DEFINE([CHECK_SWAP_SWAPCTL_BSD],1,
1350                                   [Define if 3-argument BSD swapctl exists])
1351                 else
1352                         AC_MSG_RESULT([no])
1353                 fi
1354         fi
1355         AC_MSG_CHECKING([for whether swapctl uses blocks or pages])
1356         if test "$ac_cv_check_swap_swapctl_svr4" = "1";
1357         then
1358                 dnl
1359                 dnl the SVR4 spec returns values in pages
1360                 dnl
1361                 AC_MSG_RESULT([page])
1362                 AC_CHECK_DECLS([sysconf])
1363                 AC_MSG_CHECKING([for system page size])
1364                 if test "$ac_cv_have_decl_sysconf" = "yes";
1365                 then
1366                         AC_MSG_RESULT([determined by sysconf(3)])
1367                         ac_cv_swap_conv="(1048576/sysconf(_SC_PAGESIZE))"
1368                 else
1369                         AC_MSG_WARN([don't know. guessing 4096k])
1370                         ac_cv_swap_conv=256
1371                 fi
1372         else
1373                 dnl
1374                 dnl the BSD spec returns values in blocks
1375                 dnl
1376                 AC_MSG_RESULT([blocks (assuming 512b)])
1377                 ac_cv_swap_conv=2048
1378         fi
1379         AC_DEFINE_UNQUOTED(SWAP_CONVERSION,$ac_cv_swap_conv,
1380                 [Conversion factor to MB])
1381 fi
1382 dnl
1383 dnl end tests for the swapctl system calls
1384 dnl
1387 if test "x$ac_cv_have_swap" != "x" 
1388 then
1389         AC_DEFINE(HAVE_SWAP,1,[Define if swap/swapinfo command is found])
1390         EXTRAS="$EXTRAS check_swap"
1391 fi
1392 if test "x$ac_cv_swap_command" != "x" 
1393 then
1394         AC_DEFINE_UNQUOTED(SWAP_COMMAND,"$ac_cv_swap_command",
1395                 [Path to swap/swapinfo binary, with any args])
1396         AC_DEFINE_UNQUOTED(SWAP_FORMAT,"$ac_cv_swap_format",
1397                 [Format string for parsing swap output])
1398         AC_DEFINE_UNQUOTED(SWAP_CONVERSION,$ac_cv_swap_conv,
1399                 [Conversion factor to MB])
1400 fi
1402 AC_ARG_WITH(proc-meminfo,
1403             ACX_HELP_STRING([--with-proc-meminfo=PATH],
1404                             [path to /proc/meminfo or equivalent]),
1405                             ac_cv_proc_meminfo=$withval)
1406 dnl dunno why this does not work below - use hack (kbd)
1407 dnl fine on linux, broken on solaris
1408 dnl if /bin/test -e "/proc/meminfo"
1409 AC_MSG_CHECKING([for /proc/meminfo])
1410 if test -n "$ac_cv_proc_meminfo"; then
1411         AC_MSG_RESULT([(command line) $ac_cv_proc_meminfo])
1412 elif [cat /proc/meminfo > /dev/null 2>&1]; then
1413         AC_MSG_RESULT([found /proc/meminfo])
1414         ac_cv_proc_meminfo="/proc/meminfo"
1415 else
1416         AC_MSG_RESULT([no])
1417 fi
1419 if test -n "$ac_cv_proc_meminfo"; then
1420         AC_DEFINE(HAVE_PROC_MEMINFO,1,[Define if we have /proc/meminfo])
1421         AC_DEFINE_UNQUOTED(PROC_MEMINFO,"$ac_cv_proc_meminfo",[path to /proc/meminfo if name changes])
1422         EXTRAS="$EXTRAS check_swap"
1423 fi
1425 AC_PATH_PROG(PATH_TO_DIG,dig)
1426 AC_ARG_WITH(dig_command,
1427             ACX_HELP_STRING([--with-dig-command=PATH],
1428                             [Path to dig command]), PATH_TO_DIG=$withval)
1429 if test -n "$PATH_TO_DIG"; then
1430         EXTRAS="$EXTRAS check_dig"
1431         AC_DEFINE_UNQUOTED(PATH_TO_DIG,"$PATH_TO_DIG",[Path to dig command, if present])
1432 fi
1434 AC_PATH_PROG(PATH_TO_APTGET,apt-get)
1435 AC_ARG_WITH(apt-get_command,
1436             ACX_HELP_STRING([--with-apt-get-command=PATH],
1437                             [Path to apt-get command]), 
1438                             with_apt_get_command=$withval,
1439                             with_apt_get_command=$PATH_TO_APTGET)
1440 AC_DEFINE_UNQUOTED(PATH_TO_APTGET,"$PATH_TO_APTGET",[Path to apt-get command, if present])
1441 if test -n "$PATH_TO_APTGET" ; then
1442         EXTRAS="$EXTRAS check_apt"
1443 fi
1446 if test -f plugins/check_nt.c ; then
1447   EXTRAS="$EXTRAS check_nt"
1448 elif test -f ../plugins/check_nt.c ; then
1449   EXTRAS="$EXTRAS check_nt"
1450 fi
1453 dnl used in check_dhcp
1454 AC_CHECK_HEADERS(sys/sockio.h)
1456 case $host in
1457         *bsd*)
1458                 AC_DEFINE(__bsd__,1,[bsd specific code in check_dhcp.c])
1459         ;;
1460         *linux*)
1461                 AC_DEFINE(__linux__,1,[sun specific code in check_dhcp.c])
1462         ;;
1463         *sun* | solaris*)
1464                 AC_DEFINE(__sun__,1,[sun specific code in check_dhcp.c])
1465         ;;
1466         *hpux*)  
1467                 AC_DEFINE(__hpux__,1,[hpux specific code in check_dhcp.c])
1468         ;;
1469 esac
1471 AC_SUBST(EXTRAS)
1472 AC_SUBST(EXTRAS_ROOT)
1473 AC_SUBST(EXTRA_NETOBJS)
1474 AC_SUBST(DEPLIBS)
1476 AM_GNU_GETTEXT([external], [need-ngettext])
1477 AM_GNU_GETTEXT_VERSION(0.15)
1479 dnl Check for Redhat spopen problem
1480 dnl Wierd problem where ECHILD is returned from a wait call in error
1481 dnl Only appears to affect nslookup and dig calls. Only affects redhat around
1482 dnl 2.6.9-11 (okay in 2.6.9-5). Redhat investigating root cause
1483 dnl We patch plugins/popen.c
1484 dnl Need to add smp because uname different on those
1485 dnl Can force patch to be applied with --enable-redhat-pthread-workaround
1486 AC_ARG_ENABLE(redhat-pthread-workaround, 
1487         AC_HELP_STRING([--enable-redhat-pthread-workaround], 
1488                 [force Redhat patch to be applied (default: test system)]),
1489         [ac_cv_enable_redhat_pthread_workaround=$enableval],
1490         [ac_cv_enable_redhat_pthread_workaround=test])
1491 if test "$ac_cv_enable_redhat_pthread_workaround" = "test" ; then
1492         if echo $ac_cv_uname_r | egrep "\.EL(smp)?$" >/dev/null 2>&1 ; then
1493                 AC_MSG_CHECKING(for redhat spopen problem)
1494                 ( cd config_test && make && make test ) > /dev/null 2>&1
1495                 if test $? -eq 0 ; then
1496                         AC_MSG_RESULT(okay)
1497                 else
1498                         AC_MSG_RESULT(error)
1499                         AC_DEFINE(REDHAT_SPOPEN_ERROR, 1, [Workaround on redhat in spopen])
1500                 fi
1501         fi
1502 elif test "$ac_cv_enable_redhat_pthread_workaround" = "yes" ; then
1503         AC_DEFINE(REDHAT_SPOPEN_ERROR, 1, [Forced workaround on redhat in spopen])
1504 fi
1506 dnl External libraries - see ACKNOWLEDGEMENTS
1507 gl_INIT
1509 dnl Some helpful common compile errors checked here
1510 if test "$ac_cv_uname_s" = 'SunOS' -a "$ac_cv_prog_ac_ct_AR" = 'false' ; then
1511         AC_MSG_ERROR(No ar found for Solaris - is /usr/ccs/bin in PATH?)
1512 fi
1514 AC_OUTPUT(
1515   Makefile 
1516   lib/Makefile 
1517   plugins/Makefile 
1518   lib/tests/Makefile
1519   plugins-root/Makefile
1520   plugins-scripts/Makefile 
1521   plugins-scripts/subst 
1522   plugins-scripts/utils.pm 
1523   plugins-scripts/utils.sh 
1524   command.cfg 
1525   test.pl 
1526   pkg/solaris/pkginfo 
1527   po/Makefile.in 
1531 dnl the ones below that are commented out need to be cleaned up 
1532 dnl in the configure code above to use with_foo instead of ac_cv_foo
1533 dnl if we want them to show up here.  it'd also make the code cleaner.
1534 dnl i'll get to that on another rainy day :) -sf
1535 ACX_FEATURE([with],[apt-get-command])
1536 dnl ACX_FEATURE([with],[dig-command])
1537 dnl ACX_FEATURE([with],[fping-command])
1538 dnl ACX_FEATURE([with],[mailq-command])
1539 dnl ACX_FEATURE([with],[nslookup-command])
1540 ACX_FEATURE([with],[ping6-command])
1541 ACX_FEATURE([with],[ping-command])
1542 dnl ACX_FEATURE([with],[qstat-command])
1543 dnl ACX_FEATURE([with],[rpcinfo-command])
1544 dnl ACX_FEATURE([with],[smbclient-command])
1545 dnl ACX_FEATURE([with],[snmpget-command])
1546 dnl ACX_FEATURE([with],[snmpgetnext-command])
1547 dnl ACX_FEATURE([with],[ssh-command])
1548 dnl ACX_FEATURE([with],[uptime-command])
1550 dnl ACX_FEATURE([with],[proc-meminfo])
1551 dnl ACX_FEATURE([with],[ps-command])
1552 dnl ACX_FEATURE([with],[ps-format])
1553 dnl ACX_FEATURE([with],[ps-cols])
1554 dnl ACX_FEATURE([with],[ps-varlist])
1556 ACX_FEATURE([with],[ipv6])
1557 ACX_FEATURE([with],[mysql])
1558 ACX_FEATURE([with],[openssl])
1559 ACX_FEATURE([with],[gnutls])
1560 ACX_FEATURE([with],[perl])
1561 ACX_FEATURE([with],[cgiurl])
1562 ACX_FEATURE([with],[trusted-path])