Create expired cert for testing purposes. Updated tests to check
[monitoring-plugins.git] / configure.in
blob68ac0a00efd0729119f5b04576eab7280c389bc4
1 dnl Process this file with autoconf to produce a configure script.
2 AC_PREREQ(2.59)
3 AC_INIT(nagios-plugins,1.4.13)
4 AC_CONFIG_SRCDIR(NPTest.pm)
5 AC_CONFIG_FILES(gl/Makefile)
6 AC_CONFIG_AUX_DIR(build-aux)
7 AM_INIT_AUTOMAKE([1.8.3])
8 AM_CONFIG_HEADER(config.h)
9 AC_CANONICAL_HOST
11 RELEASE=1
12 AC_SUBST(RELEASE)
14 AC_PREFIX_DEFAULT(/usr/local/nagios)
16 dnl Deprecated configure options
19 dnl Append user (-o), group (-g), mode (-m) to install command
20 dnl There is an assumption that this is possible with ./configure's chosen install command
21 extra_install_args=""
22 AC_ARG_WITH(nagios_user,
23         ACX_HELP_STRING([--with-nagios-user=USER],
24                 [Installs executables with this user. Defaults to install user]),
25         extra_install_args="-o $withval")
26 AC_ARG_WITH(nagios_group,
27         ACX_HELP_STRING([--with-nagios-group=GROUP],
28                 [Installs executables with this group. Defaults to install user]),
29         extra_install_args="$extra_install_args -g $withval")
30 AC_ARG_WITH(world_permissions,
31         ACX_HELP_STRING([--without-world-permissions],
32                 [Installs executables without world permissions]))
34 if test "x$with_world_permissions" = xno ; then
35         extra_install_args="$extra_install_args -m 0550"
38 INSTALL="$INSTALL $extra_install_args"
39 INSTALL_STRIP_PROGRAM="$INSTALL_STRIP_PROGRAM $extra_install_args"
40 AC_SUBST(INSTALL)
42 AC_PROG_CC
43 gl_EARLY
44 AC_PROG_GCC_TRADITIONAL
45 AC_PROG_LIBTOOL
47 AM_PROG_CC_C_O
49 AC_FUNC_ERROR_AT_LINE
50 AC_SYS_LARGEFILE
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 Check if version file is present
102 AM_CONDITIONAL([RELEASE_PRESENT], [test -f release])
104 dnl Checks for programs.
105 AC_PATH_PROG(PYTHON,python)
106 AC_PATH_PROG(SH,sh)
107 AC_PATH_PROG(PERL,perl)
108 AC_PATH_PROG(LIBGNUTLS_CONFIG,libgnutls-config)
109 AC_PATH_PROG(HOSTNAME,hostname)
110 AC_PATH_PROG(BASENAME,basename)
112 dnl allow them to override the path of perl
113 AC_ARG_WITH(perl,
114         ACX_HELP_STRING([--with-perl=PATH],
115                         [sets path to perl executable]),
116                         with_perl=$withval,with_perl=$PERL)
117 AC_SUBST(PERL, $with_perl)
119 dnl openssl/gnutls
120 AC_ARG_WITH(openssl,
121             AC_HELP_STRING([--with-openssl=DIR],
122                            [path to openssl installation]),)
124 AC_ARG_WITH(gnutls,
125             ACX_HELP_STRING([--with-gnutls=PATH],
126                             [path to gnutls installation root]),)
128 dnl you can only have one or the other
129 if test ! "$with_openssl" = "" && test ! "$with_openssl" = "no"; then
130         with_gnutls="no"
132 if test ! "$with_gnutls" = "" && test ! "$with_gnutls" = "no"; then
133         with_openssl="no"
136 dnl list of possible dirs to try to autodetect openssl
137 dnl if $dir/include exists, we consider it found
138 dnl the order should allow locally installed versions to override distros' ones
139 OPENSSL_DIRS="/usr /usr/local /usr/slocal /usr/local/openssl /usr/local/ssl \
140               /opt /opt/openssl"
144 dnl Checks for libraries.
147 AC_CHECK_LIB(dce,main,SOCKETLIBS="$SOCKETLIBS -ldce")
148 AC_CHECK_LIB(nsl,main,SOCKETLIBS="$SOCKETLIBS -lnsl")
149 AC_CHECK_LIB(socket,socket,SOCKETLIBS="$SOCKETLIBS -lsocket")
150 AC_CHECK_LIB(resolv,main,SOCKETLIBS="$SOCKETLIBS -lresolv")
151 AC_SUBST(SOCKETLIBS)
154 dnl check for math-related functions needing -lm
155 AC_CHECK_HEADERS(math.h)
156 AC_CHECK_LIB(m,floor,MATHLIBS="-lm")
157 AC_SUBST(MATHLIBS)
159 dnl Check if we buils local libtap
160 AC_ARG_ENABLE(libtap,
161   AC_HELP_STRING([--enable-libtap],
162                 [Enable built-in libtap for unit-testing (default: autodetect system library).]),
163         [enable_libtap=$enableval],
164         [enable_libtap=no])
165 AM_CONDITIONAL([USE_LIBTAP_LOCAL],[test "$enable_libtap" = "yes"])
167 # If not local, check if we can use the system one
168 if test "$enable_libtap" != "yes" ; then
169         dnl Check for libtap, to run perl-like tests
170         AC_CHECK_LIB(tap, plan_tests,
171                 enable_libtap="yes"
172                 )
175 # Finally, define tests if we use libtap
176 if test "$enable_libtap" = "yes" ; then
177         EXTRA_TEST="test_utils test_disk test_tcp test_cmd test_base64"
178         AC_SUBST(EXTRA_TEST)
181 dnl INI Parsing
182 AC_ARG_ENABLE(extra-opts,
183   AC_HELP_STRING([--enable-extra-opts],
184                 [Enables parsing of plugins ini config files for extra options (default: no)]),
185         [enable_extra_opts=$enableval],
186         [enable_extra_opts=no])
187 AM_CONDITIONAL([USE_PARSE_INI],[test "$enable_extra_opts" = "yes"])
188 if test "$enable_extra_opts" = "yes" ; then
189         AC_DEFINE(NP_EXTRA_OPTS,[1],[Enable INI file parsing.])
190         if test "$enable_libtap" = "yes"; then
191                 EXTRA_TEST="$EXTRA_TEST test_ini1 test_ini3 test_opts1 test_opts2 test_opts3"
192                 AC_SUBST(EXTRA_TEST)
193         fi
196 dnl Check for PostgreSQL libraries
197 _SAVEDLIBS="$LIBS"
198 _SAVEDCPPFLAGS="$CPPFLAGS"
199 AC_ARG_WITH(pgsql,
200         ACX_HELP_STRING([--with-pgsql=DIR],
201                 [sets path to pgsql installation]),
202         PGSQL=$withval,)
203 AC_CHECK_LIB(crypt,main)
204 if test "$ac_cv_lib_crypt_main" = "yes" -a "x$PGSQL" != "xno"; then
205   if test -n "$PGSQL"; then
206     LDFLAGS="$LDFLAGS -L$PGSQL/lib"
207     CPPFLAGS="$CPPFLAGS -I$PGSQL/include"
208   fi
209   AC_CHECK_LIB(pq,PQsetdbLogin,,,-lcrypt)
210   if test "$ac_cv_lib_pq_PQsetdbLogin" = "yes"; then
211     AC_CHECK_HEADERS(pgsql/libpq-fe.h)
212     AC_CHECK_HEADERS(postgresql/libpq-fe.h)
213     AC_CHECK_HEADERS(libpq-fe.h)
214     if [[ -n "$PGSQL" -a "$ac_cv_header_libpq_fe_h" = "yes" ]]; then
215       PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
216       PGINCLUDE="-I$PGSQL/include"
217     elif test  "$ac_cv_header_pgsql_libpq_fe_h" = "yes"; then
218       PGLIBS="-lpq -lcrypt"
219       PGINCLUDE="-I/usr/include/pgsql"
220     elif test  "$ac_cv_header_postgresql_libpq_fe_h" = "yes"; then
221       PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
222       PGINCLUDE="-I/usr/include/postgresql"
223     elif test  "$ac_cv_header_libpq_fe_h" = "yes"; then
224       PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
225       PGINCLUDE="-I$PGSQL/include"
226     fi
227     if test -z "$PGINCLUDE"; then
228       AC_MSG_WARN([Skipping PostgreSQL plugin (check_pgsql)])
229       AC_MSG_WARN([install PostgreSQL headers to compile this plugin (see REQUIREMENTS).])
230     else
231       AC_SUBST(PGLIBS)
232       AC_SUBST(PGINCLUDE)
233       EXTRAS="$EXTRAS check_pgsql"
234     fi
235   else
236     AC_MSG_WARN([Skipping PostgreSQL plugin (check_pgsql)])
237     AC_MSG_WARN([LIBS="$LIBS" CPPFLAGS="$CPPFLAGS"])
238     AC_MSG_WARN([install PostgreSQL libs to compile this plugin (see REQUIREMENTS).])
239   fi
240 else
241   AC_MSG_WARN([Skipping PostgreSQL plugin (check_pgsql)])
242   AC_MSG_WARN([install lib crypt and PostgreSQL libs to compile this plugin (see REQUIREMENTS).])
244 LIBS="$_SAVEDLIBS"
245 CPPFLAGS="$_SAVEDCPPFLAGS"
247 dnl Check for radius libraries
248 _SAVEDLIBS="$LIBS"
249 AC_CHECK_LIB(radiusclient,rc_read_config)
250 if test "$ac_cv_lib_radiusclient_rc_read_config" = "yes"; then
251   EXTRAS="$EXTRAS check_radius"
252         RADIUSLIBS="-lradiusclient"
253   AC_SUBST(RADIUSLIBS)
254 else
255   AC_CHECK_LIB(radiusclient-ng,rc_read_config)
256   if test "$ac_cv_lib_radiusclient_ng_rc_read_config" = "yes"; then
257     EXTRAS="$EXTRAS check_radius"
258           RADIUSLIBS="-lradiusclient-ng"
259     AC_SUBST(RADIUSLIBS)
260   else
261     AC_MSG_WARN([Skipping radius plugin])
262     AC_MSG_WARN([install radius libs to compile this plugin (see REQUIREMENTS).])
263   fi
265 LIBS="$_SAVEDLIBS"
267 dnl Check for LDAP libraries
268 _SAVEDLIBS="$LIBS"
269 AC_CHECK_LIB(ldap,main,,,-llber)
270 if test "$ac_cv_lib_ldap_main" = "yes"; then
271   LDAPLIBS="-lldap -llber"\
272   LDAPINCLUDE="-I/usr/include/ldap"
273   AC_SUBST(LDAPLIBS)
274   AC_SUBST(LDAPINCLUDE)
275   AC_CHECK_FUNCS(ldap_set_option)
276   EXTRAS="$EXTRAS check_ldap"
277         AC_CHECK_FUNCS(ldap_init ldap_set_option ldap_get_option ldap_start_tls_s)
278 else
279   AC_MSG_WARN([Skipping LDAP plugin])
280   AC_MSG_WARN([install LDAP libs to compile this plugin (see REQUIREMENTS).])
282 LIBS="$_SAVEDLIBS"
284 dnl Check for headers used by check_ide_smart
285 AC_CHECK_HEADER(linux/hdreg.h, FOUNDINCLUDE=yes, FOUNDINCLUDE=no)
286 if test "$FOUNDINCLUDE" = "yes" ; then
287         AC_CHECK_HEADER(linux/types.h, FOUNDINCLUDE=yes, FOUNDINCLUDE=no)
290 if test "$FOUNDINCLUDE" = "yes" ; then
291         EXTRAS="$EXTRAS check_ide_smart"
292 else
293         AC_MSG_WARN([Skipping check_ide_smart plugin.])
294         AC_MSG_WARN([check_ide_smart is linux specific. It requires linux/hdreg.h and linux/types.h.])
297 dnl Check for mysql libraries
298 np_mysqlclient
299 if test $with_mysql = "no" ; then
300   AC_MSG_WARN([Skipping mysql plugin])
301   AC_MSG_WARN([install mysql client libs to compile this plugin (see REQUIREMENTS).])
302 else
303   EXTRAS="$EXTRAS check_mysql check_mysql_query"
304   MYSQLINCLUDE="$np_mysql_include"
305   MYSQLLIBS="$np_mysql_libs"
306   MYSQLCFLAGS="$np_mysql_cflags"
307   AC_SUBST(MYSQLINCLUDE)
308   AC_SUBST(MYSQLLIBS)
309   AC_SUBST(MYSQLCFLAGS)
312 AC_ARG_WITH([ipv6],
313         [AS_HELP_STRING([--with-ipv6], [support IPv6 @<:@default=check@:>@])],
314         [], [with_ipv6=check])
316 dnl Check for AF_INET6 support - unistd.h required for Darwin
317 if test "$with_ipv6" != "no"; then
318         AC_CACHE_CHECK([for IPv6 support], np_cv_sys_ipv6, [
319                 AC_TRY_COMPILE(
320                         [#ifdef HAVE_UNISTD_H
321                         #include <unistd.h>
322                         #endif
323                         #include <netinet/in.h>
324                         #include <sys/socket.h>],
325                         [struct sockaddr_in6 sin6;
326                         void *p;
328                         sin6.sin6_family = AF_INET6;
329                         sin6.sin6_port = 587;
330                         p = &sin6.sin6_addr;],
331                         [np_cv_sys_ipv6=yes],
332                         [np_cv_sys_ipv6=no])
333                 ])
334         if test "$np_cv_sys_ipv6" = "no" -a "$with_ipv6" != "check"; then
335                 AC_MSG_FAILURE([--with-ipv6 was given, but test for IPv6 support failed])
336         fi
337         if test "$np_cv_sys_ipv6" = "yes"; then
338                 AC_DEFINE(USE_IPV6,1,[Enable IPv6 support])
339         fi
340         with_ipv6="$np_cv_sys_ipv6"
344 dnl Checks for Kerberos. Must come before openssl checks for Redhat EL 3
345 AC_CHECK_HEADERS(krb5.h,FOUNDINCLUDE=yes,FOUNDINCLUDE=no)
346 if test "$FOUNDINCLUDE" = "no"; then
347   _SAVEDCPPFLAGS="$CPPFLAGS"
348   CPPFLAGS="$_SAVEDCPPFLAGS -I/usr/kerberos/include"
349   unset ac_cv_header_krb5_h
350   AC_CHECK_HEADERS(krb5.h,
351                    KRB5INCLUDE="-I/usr/kerberos/include"
352                    FOUNDINCLUDE=yes,
353                    FOUNDINCLUDE=no)
355 AC_SUBST(KRBINCLUDE)
356 if test "$FOUNDINCLUDE" = "no"; then
357   CPPFLAGS="$_SAVEDCPPFLAGS"
360 dnl *** The following block comes from wget configure.ac ***
361 dnl Unfortunately, as of this writing (OpenSSL 0.9.6), the libcrypto
362 dnl shared library doesn't record its dependency on libdl, so we
363 dnl need to check for it ourselves so we won't fail to link due to a
364 dnl lack of -ldl.  Most OSes use dlopen(), but HP-UX uses
365 dnl shl_load().
366 AC_CHECK_LIB(dl,dlopen)
367 AC_CHECK_LIB(dl,shl_load)
369 dnl openssl detection/configuration
370 if ! test x"$with_openssl" = x"no"; then
371         dnl Check for OpenSSL location if it wasn't already specified
372         if ! test -d "$with_openssl"; then
373                 for d in $OPENSSL_DIRS; do
374                         if test -x ${d}/bin/openssl || test -x ${d}/sbin/openssl ; then
375                                 with_openssl=$d
376                         fi
377                 done
378         fi
380         _SAVEDCPPFLAGS="$CPPFLAGS"
381         _SAVEDLDFLAGS="$LDFLAGS"
382         dnl Check for OpenSSL header files
383         unset FOUNDINCLUDE
384         if test x"$with_openssl" != x"/usr" ; then
385                 CPPFLAGS="$CPPFLAGS -I$with_openssl/include"
386                 LDFLAGS="$LDFLAGS -L$with_openssl/lib"
387         fi
389         dnl check for openssl in $dir/include/openssl
390         AC_CHECK_HEADERS(openssl/ssl.h openssl/x509.h openssl/rsa.h openssl/pem.h openssl/crypto.h openssl/err.h,
391                          SSLINCLUDE="-I$with_openssl/include"
392                          FOUNDINCLUDE=yes,
393                          FOUNDINCLUDE=no)
394         dnl else check to see if $dir/include has it
395         if test "$FOUNDINCLUDE" = "no"; then
396                 AC_CHECK_HEADERS(ssl.h x509.h rsa.h pem.h crypto.h err.h,
397                                  SSLINCLUDE="-I$with_openssl/include"
398                                  FOUNDINCLUDE=yes,
399                                  FOUNDINCLUDE=no)
400         fi
401         AC_SUBST(SSLINCLUDE)
402         dnl if we didn't find it, reset CPPFLAGS
403         if test "$FOUNDINCLUDE" = "no"; then
404                 CPPFLAGS="$_SAVEDCPPFLAGS"
405                 LDFLAGS="$_SAVEDLDFLAGS"
406         fi
408         dnl Check for crypto lib
409         _SAVEDLIBS="$LIBS"
410         LIBS="-L${with_openssl}/lib"
411         AC_CHECK_LIB(crypto,CRYPTO_lock)
412         if test "$ac_cv_lib_crypto_CRYPTO_lock" = "yes"; then
413                 dnl Check for SSL lib
414                 AC_CHECK_LIB(ssl,main, SSLLIBS="-lssl -lcrypto",,-lcrypto)
415         fi
416         LIBS="$_SAVEDLIBS"
418         dnl test headers and libs to decide whether check_http should use SSL
419         if test "$ac_cv_lib_crypto_CRYPTO_lock" = "yes"; then
420                 if test "$ac_cv_lib_ssl_main" = "yes"; then
421                         if test "$FOUNDINCLUDE" = "yes"; then
422                                 FOUNDOPENSSL="yes"
423                         fi
424                 fi
425         fi
429 dnl check for gnutls if openssl isn't found (or is disabled)
430 if test ! "$FOUNDOPENSSL" = "yes" && test ! "$with_gnutls" = "no"; then
431         if test ! "$with_gnutls" = ""; then
432                 CPPFLAGS="$CPPFLAGS -I${with_gnutls}/include"
433         elif test ! "$LIBGNUTLS_CONFIG" = ""; then
434                 CPPFLAGS="$CPPFLAGS -I`$LIBGNUTLS_CONFIG --prefix`"
435         fi
436         AC_CHECK_HEADERS([gnutls/openssl.h],FOUNDGNUTLS="yes",)
437         if test "$FOUNDGNUTLS" = "yes"; then
438                 AC_CHECK_LIB(gnutls-openssl,main,SSLLIBS="-lgnutls-openssl")
439         fi
441 dnl end check for gnutls
443 if test "$FOUNDOPENSSL" = "yes" || test "$FOUNDGNUTLS" = "yes"; then
444         check_tcp_ssl="check_simap check_spop check_jabber check_nntps check_ssmtp"
445         AC_SUBST(check_tcp_ssl)
446         AC_SUBST(SSLLIBS)
447         AC_DEFINE(HAVE_SSL,1,[Define if SSL libraries are found])
448         if test "$FOUNDOPENSSL" = "yes"; then
449                 AC_DEFINE(USE_OPENSSL,1,[Define if using OpenSSL libraries])
450                 with_openssl="yes"
451                 with_gnutls="no"
452         else
453                 AC_DEFINE(USE_GNUTLS,1,[Define if using gnutls libraries])
454                 with_gnutls="yes"
455                 with_openssl="no"
456         fi
457 else
458         dnl else deliberately disabled or no ssl support available
459         AC_MSG_WARN([OpenSSL or GnuTLS libs could not be found or were disabled])
460         with_openssl="no"
461         with_gnutls="no"
465 dnl Checks for header files.
468 AC_HEADER_TIME
469 AC_HEADER_SYS_WAIT
470 AC_CHECK_HEADERS(signal.h syslog.h uio.h errno.h sys/time.h sys/socket.h sys/un.h sys/poll.h)
471 AC_CHECK_HEADERS(features.h stdarg.h sys/unistd.h ctype.h)
473 dnl Checks for typedefs, structures, and compiler characteristics.
474 AC_C_CONST
475 AC_STRUCT_TM
476 AC_TYPE_PID_T
477 AC_TYPE_SIZE_T
478 AC_TYPE_SIGNAL
480 AC_CACHE_CHECK([for va_copy],ac_cv_HAVE_VA_COPY,[
481 AC_TRY_LINK([#include <stdarg.h>
482 va_list ap1,ap2;], [va_copy(ap1,ap2);],
483 ac_cv_HAVE_VA_COPY=yes,
484 ac_cv_HAVE_VA_COPY=no)])
485 if test x"$ac_cv_HAVE_VA_COPY" = x"yes"; then
486     AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available])
487 else
488     AC_CACHE_CHECK([for __va_copy],ac_cv_HAVE___VA_COPY,[
489     AC_TRY_LINK([#include <stdarg.h>
490     va_list ap1,ap2;], [__va_copy(ap1,ap2);],
491     ac_cv_HAVE___VA_COPY=yes,
492     ac_cv_HAVE___VA_COPY=no)])
493     if test x"$ac_cv_HAVE___VA_COPY" = x"yes"; then
494         AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available])
495     fi
498 AC_TRY_COMPILE([#include <sys/time.h>],
499                [struct timeval *tv;
500                 struct timezone *tz;],
501                AC_DEFINE(HAVE_STRUCT_TIMEVAL,1,[Define if we have a timeval structure])
502                AC_TRY_COMPILE([#include <sys/time.h>],
503                               [struct timeval *tv;
504                                struct timezone *tz;
505                                gettimeofday(tv, tz);],
506                               AC_DEFINE(HAVE_GETTIMEOFDAY,1,[Define if gettimeofday is found]),
507                               AC_DEFINE(NEED_GETTIMEOFDAY,1,[Define if gettimeofday is needed])))
509 dnl Checks for library functions.
510 AC_CHECK_FUNCS(memmove select socket strdup strstr strtol strtoul floor)
511 AC_CHECK_FUNCS(poll)
513 AC_MSG_CHECKING(return type of socket size)
514 AC_TRY_COMPILE([#include <stdlib.h>
515                 #include <sys/types.h>
516                 #include <sys/socket.h>],
517                [int a = send(1, (const void *) buffer, (size_t *) 0, (int *) 0);],
518                ac_cv_socket_size_type=["size_t"]
519                 AC_MSG_RESULT(size_t),
520                ac_cv_socket_size_type=["int"]
521                 AC_MSG_RESULT(int))
523 AC_DEFINE_UNQUOTED(SOCKET_SIZE_TYPE, $ac_cv_socket_size_type ,
524         [Define type of socket size])
527 dnl #### Process table test
529 AC_PATH_PROG(PATH_TO_PS,ps)
531 AC_MSG_CHECKING(for ps syntax)
532 AC_ARG_WITH(ps_command,
533             ACX_HELP_STRING([--with-ps-command=PATH],
534                             [Verbatim command to execute for ps]),
535             PS_COMMAND=$withval)
536 AC_ARG_WITH(ps_format,
537             ACX_HELP_STRING([--with-ps-format=FORMAT],
538                             [Format string for scanning ps output]),
539             PS_FORMAT=$withval)
540 AC_ARG_WITH(ps_cols,
541             ACX_HELP_STRING([--with-ps-cols=NUM],
542                             [Number of columns in ps command]),
543             PS_COLS=$withval)
544 AC_ARG_WITH(ps_varlist,
545             ACX_HELP_STRING([--with-ps-varlist=LIST],
546                             [Variable list for sscanf of 'ps' output]),
547             PS_VARLIST=$withval)
549 if test -n "$PS_COMMAND" && test -n "$PS_FORMAT" && test -n "$PS_COLS" && test -n "$PS_VARLIST"; then
550         ac_cv_ps_command="$PS_COMMAND"
551         ac_cv_ps_format="$PS_FORMAT"
552         ac_cv_ps_varlist="$PS_VARLIST"
553         ac_cv_ps_cols="$PS_COLS"
554         AC_MSG_RESULT([(command-line) $ac_cv_ps_command])
556 dnl Now using the pst3/kmem hack for solaris systems to avoid truncation
557 elif test "$ac_cv_uname_s" = "SunOS"; then
558         #
559         # this is a very, very ugly hack, to hardcode the location for plugins
560         #
561         if test "$libexecdir" = '${exec_prefix}/libexec'; then
562                 if test "$exec_prefix" = "NONE"; then
563                         if test "$prefix" = "NONE"; then
564                                 pst3="$ac_default_prefix/libexec/pst3"
565                         else
566                                 pst3="$prefix/libexec/pst3"
567                         fi
568                 else
569                         pst3="$exec_prefix/libexec/pst3"
570                 fi
571         else
572                 pst3="$libexecdir/pst3"
573         fi
574         ac_cv_ps_command="$pst3"
575         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
576         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
577         ac_cv_ps_cols=9
578         AC_MSG_RESULT([using nagios-plugins internal ps command (pst3) for solaris])
579         if test `isainfo -b` = 64 ; then
580                 PST3CFLAGS="-m64"
581                 AC_SUBST(PST3CFLAGS)
582                 AC_MSG_NOTICE([using 64bit pst3])       
583         else
584                 AC_MSG_NOTICE([using 32bit pst3])
585         fi
586         EXTRAS_ROOT="$EXTRAS_ROOT pst3"
588 dnl Removing this for the moment - Ton
589 dnl Using /usr/ucb/ps on Solaris systems, to avoid truncation
590 dnl Limitation that command name is not available
591 dnl elif test "$ac_cv_uname_s" = "SunOS" && /usr/ucb/ps -alxwwn 2>/dev/null | \
592 dnl     egrep -i ["^ *F +UID +PID +PPID +%C +PRI +NI +SZ +RSS +WCHAN +S +TT +TIME +COMMAND"] > /dev/null
593 dnl then
594 dnl     ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procpcpu,&procvsz,&procrss,procstat,&pos]"
595 dnl     ac_cv_ps_command="/usr/ucb/ps -alxwwn"
596 dnl     ac_cv_ps_format=["%*s %d %d %d %d %*d %*d %d %d%*[ 0123456789abcdef]%[OSRZT]%*s %*s %n"]
597 dnl     ac_cv_ps_cols=8
598 dnl     AC_MSG_RESULT([$ac_cv_ps_command])
600 dnl Some gnu/linux systems (debian for one) don't like -axwo and need axwo.
601 dnl so test for this first...
602 elif ps axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
603         egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null
604 then
605         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
606         ac_cv_ps_command="$PATH_TO_PS axwo 'stat uid pid ppid vsz rss pcpu comm args'"
607         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
608         ac_cv_ps_cols=9
609         AC_MSG_RESULT([$ac_cv_ps_command])
611 dnl For OpenBSD 3.2 & 3.3. Must come before ps -weo
612 dnl Should also work for FreeBSD 5.2.1 and 5.3
613 dnl  STAT UCOMM              VSZ   RSS USER      PPID COMMAND
614 elif ps -axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
615         egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null
616 then
617         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
618         ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid pid ppid vsz rss pcpu comm args'"
619         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
620         ac_cv_ps_cols=9
621         AC_MSG_RESULT([$ac_cv_ps_command])
623 dnl Some *BSDs have different format for ps. This is mainly to catch FreeBSD 4.
624 dnl Limitation: Only first 16 chars returned for ucomm field
625 dnl Must come before ps -weo
626 elif ps -axwo 'stat uid pid ppid vsz rss pcpu ucomm command' 2>/dev/null | \
627         egrep -i ["^ *STAT +UID +PID +PPID +VSZ +RSS +%CPU +UCOMM +COMMAND"] > /dev/null
628 then
629         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
630         ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid pid ppid vsz rss pcpu ucomm command'"
631         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
632         ac_cv_ps_cols=9
633         AC_MSG_RESULT([$ac_cv_ps_command])
635 dnl  STAT UCOMM              VSZ   RSS USER       UID  PPID COMMAND
636 elif ps -weo 'stat comm vsz rss user uid pid ppid etime args' 2>/dev/null | \
637         egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[ID]+ +P[PID]+ +[ELAPSD]+ +[RGSCOMDNA]+"] >/dev/null
638 then
639         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procetime,procprog,&pos]"
640         ac_cv_ps_command="$PATH_TO_PS -weo 'stat uid pid ppid vsz rss pcpu etime comm args'"
641         ac_cv_ps_format="%s %d %d %d %d %d %f %s %s %n"
642         ac_cv_ps_cols=10
643         AC_MSG_RESULT([$ac_cv_ps_command])
645 dnl FreeBSD
646 elif ps waxco 'state command vsz rss uid user pid ppid' 2>/dev/null | \
647         egrep -i ["^STAT +COMMAND +VSZ +RSS +UID +USER +PID +PPID"] >/dev/null
648 then
649         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
650         ac_cv_ps_command="$PATH_TO_PS waxco 'state uid pid ppid vsz rss pcpu command command'"
651         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
652         ac_cv_ps_cols=9
653         AC_MSG_RESULT([$ac_cv_ps_command])
655 dnl BSD-like mode in RH 6.1
656 elif ps waxno 'state comm vsz rss uid user pid ppid args' 2>/dev/null | \
657         egrep -i ["^S +COMMAND +VSZ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
658 then
659         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
660         ac_cv_ps_command="$PATH_TO_PS waxno 'state uid pid ppid vsz rss pcpu comm args'"
661         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
662         ac_cv_ps_cols=9
663         AC_MSG_RESULT([$ac_cv_ps_command])
665 dnl SunOS 4.1.3:
666 dnl  F  UID  PID  PPID  CP  PRI  NI  SZ  RSS  WCHAN  STAT  TT  TIME  COMMAND
667 dnl Need the head -1 otherwise test will work because arguments are found
668 elif ps -laxnwww 2>/dev/null | head -1 | \
669         egrep -i ["^ *F(LAGS)? +UID +PID +PPID +CP +PRI +NI +(SZ)|(VSZ)|(SIZE) +RSS +WCHAN +STAT? +TTY? +TIME +COMMAND"] >/dev/null
670 then
671         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]"
672         ac_cv_ps_command="$PATH_TO_PS -laxnwww"
673         ac_cv_ps_format="%*s %d %d %d %*s %*s %*s %d %d %*s %s %*s %*s %n%s"
674         ac_cv_ps_cols=9
675         AC_MSG_RESULT([$ac_cv_ps_command])
677 dnl Debian Linux / procps v1.2.9:
678 dnl  FLAGS   UID   PID  PPID PRI  NI   SIZE   RSS WCHAN       STA TTY TIME COMMAND
679 dnl    100     0     1     0   0   0    776    76  c0131c8c   S  ffff  0:11 init [2]
681 elif ps laxnwww 2>/dev/null | \
682         egrep -i ["^ *F(LAGS)? +UID +PID +PPID +PRI +NI +(VSZ)|(SIZE) +RSS +WCHAN +STAT? TTY +TIME +COMMAND"] >/dev/null
683 then
684         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,procstat,&procvsz,&procrss,&pos,procprog]"
685         ac_cv_ps_command="$PATH_TO_PS laxnwww"
686         ac_cv_ps_format="%*s %d %d %d %*s %*s %d %d %*s %s %*s %*s %n%s"
687         ac_cv_ps_cols=9
688         AC_MSG_RESULT([$ac_cv_ps_command])
690 dnl OpenBSD (needs to come early because -exo appears to work, but does not give all procs)
691 elif ps -axo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
692         egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[PID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null
693 then
694         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
695         ac_cv_ps_command="$PATH_TO_PS -axo 'stat uid pid ppid vsz rss pcpu comm args'"
696         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
697         ac_cv_ps_cols=9
698         AC_MSG_RESULT([$ac_cv_ps_command])
700 dnl Tru64 - needs %*[ +<>] in PS_FORMAT.
701 dnl Has /usr/bin/ps and /sbin/ps - force sbin version
702 dnl Can't use vsize and rssize because comes back with text (eg, 1.5M instead
703 dnl of 1500). Will need big changes to check_procs to support
704 elif /sbin/ps -eo 'stat uid pid ppid pcpu etime comm args' 2>/dev/null | \
705         egrep -i ["^ *S +[UID]+ +[PID]+ +[PID]+ +[%CPU]+ +[ELAPSD]+ +[COMMAND]+ +[COMMAND]+"] > /dev/null
706 then
707         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procpcpu,procetime,procprog,&pos]"
708         ac_cv_ps_command="/sbin/ps -eo 'stat uid pid ppid pcpu etime comm args'"
709         ac_cv_ps_format=["%s%*[ +<>] %d %d %d %f %s %s %n"]
710         ac_cv_ps_cols=8
711         AC_MSG_RESULT([$ac_cv_ps_command])
713 elif ps -eo 's comm vsz rss user uid pid ppid args' 2>/dev/null | \
714         egrep -i ["^S[TAUES]* +C[OMDNA]+ +[VSIZE]+ +U[SER]+ +U[ID]+ +P[PID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null
715 then
716         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
717         ac_cv_ps_command="$PATH_TO_PS -eo 's uid pid ppid vsz rss pcpu comm args'"
718         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
719         ac_cv_ps_cols=9
720         AC_MSG_RESULT([$ac_cv_ps_command])
722 dnl AIX 4.3.3 and 5.1 do not have an rss field
723 elif ps -eo 'stat uid pid ppid vsz pcpu comm args' 2>/dev/null | \
724         egrep -i ["^ *S[TAUES]* +UID +PID +PPID +VSZ +%CPU +COMMAND +COMMAND"] >/dev/null
725 then
726         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procpcpu,procprog,&pos]"
727         ac_cv_ps_command="$PATH_TO_PS -eo 'stat uid pid ppid vsz pcpu comm args'"
728         ac_cv_ps_format="%s %d %d %d %d %f %s %n"
729         ac_cv_ps_cols=8
730         AC_MSG_RESULT([$ac_cv_ps_command - with no RSS])
732 dnl Solaris 2.6
733 elif ps -Ao 's comm vsz rss uid user pid ppid args' 2>/dev/null | \
734         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
735 then
736         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
737         ac_cv_ps_command="$PATH_TO_PS -Ao 's uid pid ppid vsz rss pcpu comm args'"
738         # There must be no space between the %s and %n due to a wierd problem in sscanf where
739         # it will return %n as longer than the line length
740         ac_cv_ps_format="%s %d %d %d %d %d %f %s%n"
741         ac_cv_ps_cols=9
742         AC_MSG_RESULT([$ac_cv_ps_command])
744 elif ps -Ao 'status comm vsz rss uid user pid ppid args' 2>/dev/null | \
745         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
746 then
747         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
748         ac_cv_ps_command="$PATH_TO_PS -Ao 'status uid pid ppid vsz rss pcpu comm args'"
749         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
750         ac_cv_ps_cols=9
751         AC_MSG_RESULT([$ac_cv_ps_command])
753 elif ps -Ao 'state comm vsz rss uid user pid ppid args' 2>/dev/null | \
754         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
755 then
756         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
757         ac_cv_ps_command="$PATH_TO_PS -Ao 'state uid pid ppid vsz rss pcpu comm args'"
758         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
759         ac_cv_ps_cols=9
760         AC_MSG_RESULT([$ac_cv_ps_command])
762 dnl wonder who takes state instead of stat
763 elif ps -ao 'state command vsz rss user pid ppid args' 2>/dev/null | \
764         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
765 then
766         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
767         ac_cv_ps_command="$PATH_TO_PS -ao 'state uid pid ppid vsz rss pcpu command args'"
768         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
769         ac_cv_ps_cols=8
770         AC_MSG_RESULT([$ac_cv_ps_command])
772 dnl IRIX 53
773 elif ps -el 2>/dev/null | \
774         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
775 then
776         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&pos,procprog]"
777         ac_cv_ps_command="$PATH_TO_PS -el (IRIX 53)"
778         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %d %d %*s %*s %*s %n%s"
779         ac_cv_ps_cols=8
780         AC_MSG_RESULT([$ac_cv_ps_command])
782 dnl IRIX 63
783 elif ps -el 2>/dev/null | \
784         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +ADDR +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
785 then
786         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
787         ac_cv_ps_command="$PATH_TO_PS -el (IRIX 63)"
788         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
789         ac_cv_ps_cols=6
790         AC_MSG_RESULT([$ac_cv_ps_command])
792 dnl AIX 4.1:
793 dnl     F S      UID   PID  PPID   C PRI NI ADDR  SZ  RSS   WCHAN    TTY  TIME CMD
794 dnl    303 A        0     0     0 120  16 -- 1c07  20   24              -  0:45 swapper
795 elif ps -el 2>/dev/null | \
796         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +ADDR +SZ +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
797 then
798         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
799         ac_cv_ps_command="$PATH_TO_PS -el (AIX 4.1 and HP-UX)"
800         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
801         ac_cv_ps_cols=6
802         AC_MSG_RESULT([$ac_cv_ps_command])
804 dnl AIX?
805 elif ps glaxen 2>/dev/null | \
806         egrep -i ["^ *F +UID +PID +PPID +PRI +NI +VSZ +RSS +WCHAN +STAT +TTY +TIME +COMMAND"] >/dev/null
807 then
808         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]"
809         ac_cv_ps_command="$PATH_TO_PS glaxen"
810         ac_cv_ps_format="%*s %d %d %d %*s %*s %d %d %*s %s %*s %*s %n%s"
811         ac_cv_ps_cols=8
812         AC_MSG_RESULT([$ac_cv_ps_command])
814 dnl MacOSX / Darwin
815 dnl TODO: MacOSX has commands with spaces which will cause problems to PS_FORMAT
816 dnl Some truncation will happen in UCOMM column
817 dnl STAT      VSZ    RSS   UID  PPID %CPU UCOMM            COMMAND
818 dnl Ss      52756  22496   501     1   6.9 Window Manager   /System/Library/CoreServices/WindowServer -daemon
819 elif ps wwaxo 'state vsz rss uid pid ppid pcpu ucomm command' 2>/dev/null | \
820         egrep -i ["^STAT +VSZ +RSS +UID +PPID +%CPU +UCOMM +COMMAND"] >/dev/null
821 then
822         ac_cv_ps_command="$PATH_TO_PS wwaxo 'state vsz rss uid pid ppid pcpu ucomm command'"
823         ac_cv_ps_varlist="[procstat,&procvsz,&procrss,&procuid,&procpid,&procppid,&procpcpu,procprog,&pos]"
824         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
825         ac_cv_ps_cols=8
826         AC_MSG_RESULT([$ac_cv_ps_command])
828 dnl UnixWare
829 elif ps -Al 2>/dev/null | \
830         egrep -i ["^ *F +S +UID +PID +PPID +CLS +PRI +NI +C +ADDR +SZ +WCHAN +TTY +TIME +COMD"] >/dev/null
831 then
832         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
833         ac_cv_ps_command="$PATH_TO_PS -Al"
834         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
835         ac_cv_ps_cols=8
836         AC_MSG_RESULT([$ac_cv_ps_command])
838 else
839         AC_MSG_WARN([unable to find usable ps syntax - check_procs and check_nagios will not be compiled])
842 if test -n "$ac_cv_ps_varlist" ; then
843         AC_DEFINE_UNQUOTED(PS_VARLIST,$ac_cv_ps_varlist,
844                 [Variable list for sscanf of 'ps' output])
845         AC_DEFINE_UNQUOTED(PS_COMMAND,"$ac_cv_ps_command",
846                 [Verbatim command to execute for ps in check_procs])
847         AC_DEFINE_UNQUOTED(PS_FORMAT,"$ac_cv_ps_format",
848                 [Format string for scanning ps output in check_procs])
849         AC_DEFINE_UNQUOTED(PS_COLS,$ac_cv_ps_cols,
850                 [Number of columns in ps command])
851         EXTRAS="$EXTRAS check_procs check_nagios"
852         if echo "$ac_cv_ps_varlist" | grep "procetime" >/dev/null; then
853                 AC_DEFINE(PS_USES_PROCETIME,"yes",
854                           [Whether the ps utility uses the "procetime" field])
855         fi
858 AC_PATH_PROG(PATH_TO_PING,ping)
859 AC_PATH_PROG(PATH_TO_PING6,ping6)
861 AC_ARG_WITH(ping_command,
862         ACX_HELP_STRING([--with-ping-command=SYNTAX],
863                 [sets syntax for ICMP ping]),
864         with_ping_command=$withval,)
866 AC_MSG_CHECKING(for ICMP ping syntax)
867 ac_cv_ping_packets_first=no
868 ac_cv_ping_has_timeout=no
869 if test -n "$with_ping_command"
870 then
871         AC_MSG_RESULT([(command-line) $with_ping_command])
872         if test -n "$ac_cv_ping_packets_first"
873         then
874                 ac_cv_ping_packets_first=yes
875                 ac_cv_ping_has_timeout=yes
876         fi
878 elif [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
879         $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
880         egrep -i "^round-trip|^rtt" >/dev/null
881 then
882         with_ping_command="$PATH_TO_PING -n -U -c %d %s"
883         ac_cv_ping_packets_first=yes
884         AC_MSG_RESULT([$with_ping_command])
886 elif $PATH_TO_PING -n -U -w 10 -c 1 127.0.0.1 2>/dev/null | \
887         egrep -i "^round-trip|^rtt" >/dev/null
888 then
889         with_ping_command="$PATH_TO_PING -n -U -w %d -c %d %s"
890         ac_cv_ping_packets_first=yes
891   ac_cv_ping_has_timeout=yes
892         AC_MSG_RESULT([$with_ping_command])
894 elif $PATH_TO_PING -n -U -c 1 127.0.0.1 2>/dev/null | \
895         egrep -i "^round-trip|^rtt" >/dev/null
896 then
897         with_ping_command="$PATH_TO_PING -n -U -c %d %s"
898         ac_cv_ping_packets_first=yes
899         AC_MSG_RESULT([$with_ping_command])
901 elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \
902         egrep -i "^round-trip|^rtt" >/dev/null
903 then
904         with_ping_command="$PATH_TO_PING -n -c %d %s"
905         ac_cv_ping_packets_first=yes
906         AC_MSG_RESULT([$with_ping_command])
908 elif $PATH_TO_PING -n 127.0.0.1 -c 1 2>/dev/null | \
909         egrep -i "^round-trip|^rtt" >/dev/null
910 then
911         with_ping_command="$PATH_TO_PING -n %s -c %d"
912         AC_MSG_RESULT([$with_ping_command])
914 elif $PATH_TO_PING 127.0.0.1 -n 1 2>/dev/null | \
915         egrep -i "^round-trip|^rtt" >/dev/null
916 then
917         with_ping_command="$PATH_TO_PING %s -n %d"
918         AC_MSG_RESULT([$with_ping_command])
920 elif $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
921         egrep -i "^round-trip|^rtt" >/dev/null
922 then
923         with_ping_command="$PATH_TO_PING -n -s %s 56 %d"
924         AC_MSG_RESULT([$with_ping_command])
926 elif $PATH_TO_PING -n -h 127.0.0.1 -s 56 -c 1 2>/dev/null | \
927         egrep -i "^round-trip|^rtt" >/dev/null
928 then
929         with_ping_command="$PATH_TO_PING -n -h %s -s 56 -c %d"
930         AC_MSG_RESULT([$with_ping_command])
932 elif $PATH_TO_PING -n -s 56 -c 1 127.0.0.1 2>/dev/null | \
933         egrep -i "^round-trip|^rtt" >/dev/null
934 then
935         with_ping_command="$PATH_TO_PING -n -s 56 -c %d %s"
936         ac_cv_ping_packets_first=yes
937         AC_MSG_RESULT([$with_ping_command])
939 elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \
940         egrep -i "^round-trip|^rtt" >/dev/null
941 then
942         with_ping_command="$PATH_TO_PING -n -c %d %s"
943         ac_cv_ping_packets_first=yes
944         AC_MSG_RESULT([$with_ping_command])
946 else
947         AC_MSG_WARN([unable to find usable ping syntax])
950 AC_DEFINE_UNQUOTED(PING_COMMAND,"$with_ping_command",
951         [path and args for ICMP ping command])
953 if test "x$ac_cv_ping_packets_first" != "xno"
954 then
955         AC_DEFINE(PING_PACKETS_FIRST,1,
956                 [Define if packet count must precede host])
959 if test "x$ac_cv_ping_has_timeout" != "xno"
960 then
961         AC_DEFINE(PING_HAS_TIMEOUT,1,
962                 [Define if ping has its own timeout option that should be set])
965 AC_ARG_WITH(ping6_command,
966         ACX_HELP_STRING([--with-ping6-command=SYNTAX],
967                 [sets syntax for ICMPv6 ping]),
968         with_ping6_command=$withval,)
970 if test x"$with_ipv6" != xno ; then
971 AC_MSG_CHECKING(for ICMPv6 ping syntax)
972 ac_cv_ping6_packets_first=no
973 if test -n "$with_ping6_command"
974 then
975         AC_MSG_RESULT([(command-line) $with_ping6_command])
976         if test -n "$ac_cv_ping6_packets_first"
977         then
978                 ac_cv_ping6_packets_first=yes
979         fi
981 elif test "x$PATH_TO_PING6" != "x"; then
982         if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
983                 $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \
984                 egrep -i "^round-trip|^rtt" >/dev/null
985         then
986                 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s"
987                 ac_cv_ping6_packets_first=yes
988                 AC_MSG_RESULT([$with_ping6_command])
990         elif $PATH_TO_PING6 -n -U -w 10 -c 1 ::1 2>/dev/null | \
991                 egrep -i "^round-trip|^rtt" >/dev/null
992         then
993                 with_ping6_command="$PATH_TO_PING6 -n -U -w %d -c %d %s"
994                 ac_cv_ping6_packets_first=yes
995                 ac_cv_ping_has_timeout=yes
996                 AC_MSG_RESULT([$with_ping6_command])
998         elif $PATH_TO_PING6 -n -U -c 1 ::1 2>/dev/null | \
999                 egrep -i "^round-trip|^rtt" >/dev/null
1000         then
1001                 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s"
1002                 ac_cv_ping6_packets_first=yes
1003                 AC_MSG_RESULT([$with_ping6_command])
1005         elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \
1006                 egrep -i "^round-trip|^rtt" >/dev/null
1007         then
1008                 with_ping6_command="$PATH_TO_PING6 -n -c %d %s"
1009                 ac_cv_ping6_packets_first=yes
1010                 AC_MSG_RESULT([$with_ping6_command])
1012         elif $PATH_TO_PING6 -n ::1 -c 1 2>/dev/null | \
1013                 egrep -i "^round-trip|^rtt" >/dev/null
1014         then
1015                 with_ping6_command="$PATH_TO_PING6 -n %s -c %d"
1016                 AC_MSG_RESULT([$with_ping6_command])
1018         elif $PATH_TO_PING6 ::1 -n 1 2>/dev/null | \
1019                 egrep -i "^round-trip|^rtt" >/dev/null
1020         then
1021                 with_ping6_command="$PATH_TO_PING6 %s -n %d"
1022                 AC_MSG_RESULT([$with_ping6_command])
1024         elif $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \
1025                 egrep -i "^round-trip|^rtt" >/dev/null
1026         then
1027                 with_ping6_command="$PATH_TO_PING6 -n -s %s 56 %d"
1028                 AC_MSG_RESULT([$with_ping6_command])
1030         elif $PATH_TO_PING6 -n -h ::1 -s 56 -c 1 2>/dev/null | \
1031                 egrep -i "^round-trip|^rtt" >/dev/null
1032         then
1033                 with_ping6_command="$PATH_TO_PING6 -n -h %s -s 56 -c %d"
1034                 AC_MSG_RESULT([$with_ping6_command])
1036         elif $PATH_TO_PING6 -n -s 56 -c 1 ::1 2>/dev/null | \
1037                 egrep -i "^round-trip|^rtt" >/dev/null
1038         then
1039                 with_ping6_command="$PATH_TO_PING6 -n -s 56 -c %d %s"
1040                 ac_cv_ping6_packets_first=yes
1041                 AC_MSG_RESULT([$with_ping_command])
1043         elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \
1044                 egrep -i "^round-trip|^rtt" >/dev/null
1045         then
1046                 with_ping6_command="$PATH_TO_PING6 -n -c %d %s"
1047                 ac_cv_ping6_packets_first=yes
1048                 AC_MSG_RESULT([$with_ping6_command])
1050         fi
1052 elif test "x$PATH_TO_PING" != "x"; then
1053         if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
1054                 $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \
1055                 egrep -i "^round-trip|^rtt" >/dev/null
1056         then
1057                 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s"
1058                 ac_cv_ping6_packets_first=yes
1059                 AC_MSG_RESULT([$with_ping6_command])
1061         elif $PATH_TO_PING -A inet6 -n -U -c 1 ::1 2>/dev/null | \
1062                 egrep -i "^round-trip|^rtt" >/dev/null
1063         then
1064                 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s"
1065                 ac_cv_ping6_packets_first=yes
1066                 AC_MSG_RESULT([$with_ping6_command])
1068         elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \
1069                 egrep -i "^round-trip|^rtt" >/dev/null
1070         then
1071                 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s"
1072                 ac_cv_ping6_packets_first=yes
1073                 AC_MSG_RESULT([$with_ping6_command])
1075         elif $PATH_TO_PING -A inet6 -n ::1 -c 1 2>/dev/null | \
1076                 egrep -i "^round-trip|^rtt" >/dev/null
1077         then
1078                 with_ping6_command="$PATH_TO_PING -A inet6 -n %s -c %d"
1079                 AC_MSG_RESULT([$with_ping6_command])
1081         elif $PATH_TO_PING -A inet6 ::1 -n 1 2>/dev/null | \
1082                 egrep -i "^round-trip|^rtt" >/dev/null
1083         then
1084                 with_ping6_command="$PATH_TO_PING -A inet6 %s -n %d"
1085                 AC_MSG_RESULT([$with_ping6_command])
1087         elif $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \
1088                 egrep -i "^round-trip|^rtt" >/dev/null
1089         then
1090                 with_ping6_command="$PATH_TO_PING -A inet6 -n -s %s 56 %d"
1091                 AC_MSG_RESULT([$with_ping6_command])
1093         elif $PATH_TO_PING -A inet6 -n -h ::1 -s 56 -c 1 2>/dev/null | \
1094                 egrep -i "^round-trip|^rtt" >/dev/null
1095         then
1096                 with_ping6_command="$PATH_TO_PING -A inet6 -n -h %s -s 56 -c %d"
1097                 AC_MSG_RESULT([$with_ping6_command])
1099         elif $PATH_TO_PING -A inet6 -n -s 56 -c 1 ::1 2>/dev/null | \
1100                 egrep -i "^round-trip|^rtt" >/dev/null
1101         then
1102                 with_ping6_command="$PATH_TO_PING -A inet6 -n -s 56 -c %d %s"
1103                 ac_cv_ping6_packets_first=yes
1104                 AC_MSG_RESULT([$with_ping_command])
1106         elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \
1107                 egrep -i "^round-trip|^rtt" >/dev/null
1108         then
1109                 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s"
1110                 ac_cv_ping6_packets_first=yes
1111                 AC_MSG_RESULT([$with_ping6_command])
1113         fi
1117 if test "x$with_ping6_command" != "x"; then
1118         AC_DEFINE_UNQUOTED(PING6_COMMAND,"$with_ping6_command",
1119                 [path and args for ICMPv6 ping command])
1120 else
1121         AC_MSG_RESULT([none])
1124 if test "x$ac_cv_ping6_packets_first" != "xno"; then
1125         AC_DEFINE(PING6_PACKETS_FIRST,1,
1126                 [Define if packet count must precede host])
1131 AC_ARG_WITH(nslookup_command,
1132             ACX_HELP_STRING([--with-nslookup-command=PATH],
1133                             [sets path to nslookup executable]),
1134             ac_cv_nslookup_command=$withval)
1135 if test -n "$ac_cv_nslookup_command"; then
1136         AC_MSG_NOTICE([Using specific nslookup at $ac_cv_nslookup_command])
1137 else
1138         AC_PATH_PROG(PATH_TO_NSLOOKUP,nslookup)
1139         if test -n "$PATH_TO_NSLOOKUP"
1140         then
1141                 AC_MSG_CHECKING(for nslookup syntax)
1142                 if $PATH_TO_NSLOOKUP -sil 127.0.0.1 2>&1 | grep ["Invalid option: sil"] >/dev/null
1143                 then
1144                         ac_cv_nslookup_command="$PATH_TO_NSLOOKUP"
1145                         AC_MSG_RESULT([$ac_cv_nslookup_command])
1147                 else
1148                         ac_cv_nslookup_command="$PATH_TO_NSLOOKUP -sil"
1149                         AC_MSG_RESULT([$ac_cv_nslookup_command])
1151                 fi
1152         else
1153                 AC_MSG_WARN([nslookup command not found])
1154         fi
1157 if test -n "$ac_cv_nslookup_command"; then
1158         EXTRAS="$EXTRAS check_dns"
1159         AC_DEFINE_UNQUOTED(NSLOOKUP_COMMAND,"$ac_cv_nslookup_command", [path and args for nslookup])
1162 AC_MSG_CHECKING([for number of cpus])
1163 AC_TRY_COMPILE([#include <unistd.h>],
1164         [sysconf(_SC_NPROCESSORS_CONF) > 0;],
1165         AC_DEFINE(HAVE_SYSCONF__SC_NPROCESSORS_CONF,1,[Define if sysconf returns number of cpus])
1166         AC_MSG_RESULT([sysconf(_SC_NPROCESSORS_CONF)]),
1167         AC_MSG_RESULT([cannot calculate])
1168         )
1170 AC_PATH_PROG(PATH_TO_UPTIME,uptime)
1171 AC_ARG_WITH(uptime_command,
1172             ACX_HELP_STRING([--with-uptime-command=PATH],
1173                             [sets path to uptime]), PATH_TO_UPTIME=$withval)
1174 AC_DEFINE_UNQUOTED(PATH_TO_UPTIME,"$PATH_TO_UPTIME",[path to uptime binary])
1176 AC_PATH_PROG(PATH_TO_RPCINFO,rpcinfo)
1177 AC_ARG_WITH(rpcinfo_command,
1178             ACX_HELP_STRING([--with-rpcinfo-command=PATH],
1179                             [sets path to rpcinfo]), PATH_TO_RPCINFO=$withval)
1180 AC_DEFINE_UNQUOTED(PATH_TO_RPCINFO,"$PATH_TO_RPCINFO",[path to rpcinfo binary])
1182 AC_PATH_PROG(PATH_TO_LMSTAT,lmstat)
1183 if test -x "$PATH_TO_LMSTAT"
1184 then
1185         AC_DEFINE_UNQUOTED(PATH_TO_LMSTAT,"$PATH_TO_LMSTAT",[path to lmstat])
1186 else
1187         AC_MSG_WARN([Get lmstat from Globetrotter Software to monitor flexlm licenses])
1190 AC_PATH_PROG(PATH_TO_SMBCLIENT,smbclient)
1191 AC_ARG_WITH(smbclient_command,
1192             ACX_HELP_STRING([--with-smbclient-command=PATH],
1193                             [sets path to smbclient]),
1194             PATH_TO_SMBCLIENT=$withval)
1195 if test -n "$PATH_TO_SMBCLIENT"
1196 then
1197         AC_DEFINE_UNQUOTED(PATH_TO_SMBCLIENT,"$PATH_TO_SMBCLIENT",[path to smbclient binary])
1198 else
1199         AC_MSG_WARN([Get smbclient from Samba.org to monitor SMB shares])
1203 AC_PATH_PROG(PATH_TO_WHO,who)
1205 if [$PATH_TO_WHO -q 2>/dev/null | egrep -i "^# users=[0-9]+$" >/dev/null]
1206 then
1207         ac_cv_path_to_who="$PATH_TO_WHO -q"
1208 else
1209         ac_cv_path_to_who="$PATH_TO_WHO"
1212 AC_DEFINE_UNQUOTED(WHO_COMMAND,"$ac_cv_path_to_who",
1213         [path and arguments for invoking 'who'])
1215 AC_PATH_PROG(PATH_TO_SNMPGET,snmpget)
1216 AC_ARG_WITH(snmpget_command,
1217             ACX_HELP_STRING([--with-snmpget-command=PATH],
1218                             [Path to snmpget command]),
1219             PATH_TO_SNMPGET=$withval)
1220 if test -n "$PATH_TO_SNMPGET"
1221 then
1222         AC_DEFINE_UNQUOTED(PATH_TO_SNMPGET,"$PATH_TO_SNMPGET",[path to snmpget binary])
1223         EXTRAS="$EXTRAS check_hpjd check_snmp"
1224 else
1225         AC_MSG_WARN([Get snmpget from http://net-snmp.sourceforge.net to make check_hpjd and check_snmp plugins])
1228 AC_PATH_PROG(PATH_TO_SNMPGETNEXT,snmpgetnext)
1229 AC_ARG_WITH(snmpgetnext_command,
1230             ACX_HELP_STRING([--with-snmpgetnext-command=PATH],
1231                             [Path to snmpgetnext command]),
1232             PATH_TO_SNMPGETNEXT=$withval)
1233 if test -n "$PATH_TO_SNMPGETNEXT"
1234 then
1235         AC_DEFINE_UNQUOTED(PATH_TO_SNMPGETNEXT,"$PATH_TO_SNMPGETNEXT",[path to snmpgetnext binary])
1238 if ( $PERL -M"Net::SNMP 3.6" -e 'exit' 2>/dev/null  )
1239 then
1240         AC_MSG_CHECKING(for Net::SNMP perl module)
1241         AC_MSG_RESULT([found])
1242 else
1243         AC_MSG_WARN([Tried $PERL - install Net::SNMP perl module if you want to use the perl snmp plugins])
1246 AC_PATH_PROG(PATH_TO_QUAKESTAT,quakestat)
1247 AC_PATH_PROG(PATH_TO_QSTAT,qstat)
1248 AC_ARG_WITH(qstat_command,
1249             ACX_HELP_STRING([--with-qstat-command=PATH],
1250                             [Path to qstat command]), PATH_TO_QSTAT=$withval)
1252 if test -x "$PATH_TO_QUAKESTAT"
1253 then
1254         ac_cv_path_to_qstat="$PATH_TO_QUAKESTAT"
1255         EXTRAS="$EXTRAS check_game"
1257 elif test -n "$PATH_TO_QSTAT"
1258 then
1259         ac_cv_path_to_qstat="$PATH_TO_QSTAT"
1260         EXTRAS="$EXTRAS check_game"
1261 else
1262         AC_MSG_WARN([Get qstat from http://www.activesw.com/people/steve/qstat.html in order to make check_game plugin])
1265 if test $ac_cv_path_to_qstat
1266 then
1267         AC_DEFINE_UNQUOTED(PATH_TO_QSTAT,"$ac_cv_path_to_qstat",
1268                 [path to qstat/quakestat])
1271 AC_PATH_PROG(PATH_TO_FPING,fping)
1272 AC_ARG_WITH(fping_command,
1273             ACX_HELP_STRING([--with-fping-command=PATH],
1274                             [Path to fping command]), PATH_TO_FPING=$withval)
1275 if test -n "$PATH_TO_FPING"
1276 then
1277         AC_DEFINE_UNQUOTED(PATH_TO_FPING,"$PATH_TO_FPING",[path to fping])
1278         EXTRAS="$EXTRAS check_fping"
1279 else
1280         AC_MSG_WARN([Get fping from http://www.fping.com in order to make check_fping plugin])
1283 AC_PATH_PROG(PATH_TO_SSH,ssh)
1284 AC_ARG_WITH(ssh_command,
1285             ACX_HELP_STRING([--with-ssh-command=PATH],
1286                             [sets path for ssh]), PATH_TO_SSH=$withval)
1287 if test -n "$PATH_TO_SSH"
1288 then
1289         AC_DEFINE_UNQUOTED(SSH_COMMAND,"$PATH_TO_SSH",[path to ssh binary])
1290         EXTRAS="$EXTRAS check_by_ssh"
1291 else
1292         AC_MSG_WARN([Get ssh in order to make check_by_ssh plugin])
1296 AC_PATH_PROG(PATH_TO_MAILQ,mailq)
1297 AC_ARG_WITH(mailq_command,
1298             ACX_HELP_STRING([--with-mailq-command=PATH],
1299                             [sets path to mailq]), PATH_TO_MAILQ=$withval)
1300 if test -n "$PATH_TO_MAILQ"
1301 then
1302         AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_MAILQ",[path to mailq])
1303 else
1304         AC_MSG_WARN([Could not find mailq or eqivalent])
1307 AC_PATH_PROG(PATH_TO_QMAIL_QSTAT,qmail-qstat)
1308 if test -x "$PATH_TO_QMAIL_QSTAT"
1309 then
1310         AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_QMAIL_QSTAT",[path to qmail-qstat])
1311 else
1312         AC_MSG_WARN([Could not find qmail-qstat or eqivalent])
1315 dnl SWAP info required is amount allocated/available and amount free
1316 dnl The plugin works through all the swap devices and adds up the total swap
1317 dnl available.
1318 AC_PATH_PROG(PATH_TO_SWAP,swap)
1319 if (test -n "$PATH_TO_SWAP")
1320 then
1321 AC_MSG_CHECKING([for $PATH_TO_SWAP format])
1322 if [$PATH_TO_SWAP -l 2>&1 >/dev/null]
1323 then
1324         ac_cv_have_swap=yes
1325         ac_cv_swap_command="$PATH_TO_SWAP -l"
1326         if [$PATH_TO_SWAP -l 2>/dev/null | \
1327                 egrep -i "^lswap +path +pri +swaplo +blocks +free +maxswap" \
1328                 >/dev/null]
1329         then
1330                 ac_cv_swap_format=[" %*d %*s %*d,%*d %*d %*d %f %f"]
1331                 ac_cv_swap_conv=2048
1332                 AC_MSG_RESULT([using IRIX format swap])
1334         elif [$PATH_TO_SWAP -l 2>/dev/null | egrep -i "^path +dev +swaplo +blocks +free" >/dev/null]
1335         then
1336                 ac_cv_swap_format=["%*s %*[0-9,-] %*d %f %f"]
1337                 ac_cv_swap_conv=2048
1338                 AC_MSG_RESULT([using Unixware format swap])
1339         else
1340                 dnl if we don't know what format swap's output is
1341                 dnl we might as well pretend we didn't see it
1342                 ac_cv_have_swap=""
1343                 ac_cv_swap_command=""
1344         fi
1346 dnl end if for PATH_TO_SWAP
1349 AC_PATH_PROG(PATH_TO_SWAPINFO,swapinfo)
1350 if (test -n "$PATH_TO_SWAPINFO")
1351 then
1352 AC_MSG_CHECKING([for $PATH_TO_SWAPINFO format])
1353 if [$PATH_TO_SWAPINFO -k 2>&1 | egrep -i "^Device" >/dev/null]
1354 then
1355         ac_cv_have_swap=yes
1356         ac_cv_swap_command="$PATH_TO_SWAPINFO -k"
1358         if [$PATH_TO_SWAPINFO -k 2>/dev/null | egrep -i "^Device +1K-blocks +Used +Avail" >/dev/null]
1359         then
1360                 ac_cv_swap_format=["%*s %f %*d %f"]
1361                 ac_cv_swap_conv=1024
1362                 AC_MSG_RESULT([using FreeBSD format swapinfo])
1363         fi
1365 elif [$PATH_TO_SWAPINFO -dfM 2>/dev/null | egrep -i "^TYPE +AVAIL +USED +FREE" >/dev/null]
1366 then
1367         ac_cv_have_swap=yes
1368         ac_cv_swap_command="$PATH_TO_SWAPINFO -dfM"
1369         ac_cv_swap_format=["%*s %f %*d %f"]
1370         ac_cv_swap_conv=1024
1371         AC_MSG_RESULT([using HP-UX format swapinfo])
1373 dnl end if for PATH_TO_SWAPINFO
1376 AC_PATH_PROG(PATH_TO_LSPS,lsps)
1377 if (test -n "$PATH_TO_LSPS")
1378 then
1379 AC_MSG_CHECKING([for $PATH_TO_LSPS format])
1380 if [$PATH_TO_LSPS -a 2>/dev/null | egrep -i "^Page Space" > /dev/null]
1381 then
1382         ac_cv_have_swap=yes
1383         ac_cv_swap_command="$PATH_TO_LSPS -a"
1384         ac_cv_swap_format=["%*s %*s %*s %f%*s %f %*s"]
1385         ac_cv_swap_conv=1
1386         AC_MSG_RESULT([using AIX lsps])
1388 dnl end if for PATH_TO_SWAPINFO
1392 dnl test for swapctl system call, both the 2-arg and 3-arg variants
1393 dnl fwict, the 2-arg is an SVR4 standard, whereas the 3-arg is shared
1394 dnl in the various BSD's
1397 AC_CHECK_HEADERS([sys/stat.h sys/param.h])
1398 AC_CHECK_HEADERS([sys/swap.h], [], [], [
1399 #ifdef HAVE_SYS_PARAM_H
1400 #include <sys/param.h>
1401 #endif
1403 AC_CHECK_DECLS([swapctl],,,[
1404                #include <unistd.h>
1405                #include <sys/types.h>
1406                #include <sys/param.h>
1407                #include <sys/stat.h>
1408                #include <sys/swap.h>
1409                ])
1410 AC_CHECK_TYPES([swaptbl_t, swapent_t],,,[
1411                #include <sys/types.h>
1412                #include <sys/param.h>
1413                #include <sys/stat.h>
1414                #include <sys/swap.h>
1415                ])
1416 AC_CHECK_MEMBERS([struct swapent.se_nblks],,,[
1417                #include <unistd.h>
1418                #include <sys/types.h>
1419                #include <sys/param.h>
1420                #include <sys/stat.h>
1421                #include <sys/swap.h>
1422                ])
1424 if test "$ac_cv_have_decl_swapctl" = "yes";
1425 then
1426         EXTRAS="$EXTRAS check_swap"
1427         AC_MSG_CHECKING([for 2-arg (SVR4) swapctl])
1428         if test "$ac_cv_type_swaptbl_t" = "yes" -a \
1429                 "$ac_cv_type_swapent_t" = "yes";
1430         then
1431                 AC_MSG_RESULT([yes])
1432                 ac_cv_check_swap_swapctl_svr4="1";
1433                 AC_DEFINE([CHECK_SWAP_SWAPCTL_SVR4],1,
1434                           [Define if 2-argument SVR4 swapctl exists])
1435         else
1436                 AC_MSG_RESULT([no])
1437                 AC_MSG_CHECKING([for 3-arg (*BSD) swapctl])
1438                 if test "$ac_cv_member_struct_swapent_se_nblks" = "yes";
1439                 then
1440                         AC_MSG_RESULT([yes])
1441                         AC_DEFINE([CHECK_SWAP_SWAPCTL_BSD],1,
1442                                   [Define if 3-argument BSD swapctl exists])
1443                 else
1444                         AC_MSG_RESULT([no])
1445                 fi
1446         fi
1447         AC_MSG_CHECKING([for whether swapctl uses blocks or pages])
1448         if test "$ac_cv_check_swap_swapctl_svr4" = "1";
1449         then
1450                 dnl
1451                 dnl the SVR4 spec returns values in pages
1452                 dnl
1453                 AC_MSG_RESULT([page])
1454                 AC_CHECK_DECLS([sysconf])
1455                 AC_MSG_CHECKING([for system page size])
1456                 if test "$ac_cv_have_decl_sysconf" = "yes";
1457                 then
1458                         AC_MSG_RESULT([determined by sysconf(3)])
1459                         ac_cv_swap_conv="(1048576/sysconf(_SC_PAGESIZE))"
1460                 else
1461                         AC_MSG_WARN([don't know. guessing 4096k])
1462                         ac_cv_swap_conv=256
1463                 fi
1464         else
1465                 dnl
1466                 dnl the BSD spec returns values in blocks
1467                 dnl
1468                 AC_MSG_RESULT([blocks (assuming 512b)])
1469                 ac_cv_swap_conv=2048
1470         fi
1471         AC_DEFINE_UNQUOTED(SWAP_CONVERSION,$ac_cv_swap_conv,
1472                 [Conversion factor to MB])
1475 dnl end tests for the swapctl system calls
1479 if test "x$ac_cv_have_swap" != "x"
1480 then
1481         AC_DEFINE(HAVE_SWAP,1,[Define if swap/swapinfo command is found])
1482         EXTRAS="$EXTRAS check_swap"
1484 if test "x$ac_cv_swap_command" != "x"
1485 then
1486         AC_DEFINE_UNQUOTED(SWAP_COMMAND,"$ac_cv_swap_command",
1487                 [Path to swap/swapinfo binary, with any args])
1488         AC_DEFINE_UNQUOTED(SWAP_FORMAT,"$ac_cv_swap_format",
1489                 [Format string for parsing swap output])
1490         AC_DEFINE_UNQUOTED(SWAP_CONVERSION,$ac_cv_swap_conv,
1491                 [Conversion factor to MB])
1494 AC_ARG_WITH(proc-meminfo,
1495             ACX_HELP_STRING([--with-proc-meminfo=PATH],
1496                             [path to /proc/meminfo or equivalent]),
1497                             ac_cv_proc_meminfo=$withval)
1498 dnl dunno why this does not work below - use hack (kbd)
1499 dnl fine on linux, broken on solaris
1500 dnl if /bin/test -e "/proc/meminfo"
1501 AC_MSG_CHECKING([for /proc/meminfo])
1502 if test -n "$ac_cv_proc_meminfo"; then
1503         AC_MSG_RESULT([(command line) $ac_cv_proc_meminfo])
1504 elif [cat /proc/meminfo > /dev/null 2>&1]; then
1505         AC_MSG_RESULT([found /proc/meminfo])
1506         ac_cv_proc_meminfo="/proc/meminfo"
1507 else
1508         AC_MSG_RESULT([no])
1511 if test -n "$ac_cv_proc_meminfo"; then
1512         AC_DEFINE(HAVE_PROC_MEMINFO,1,[Define if we have /proc/meminfo])
1513         AC_DEFINE_UNQUOTED(PROC_MEMINFO,"$ac_cv_proc_meminfo",[path to /proc/meminfo if name changes])
1514         EXTRAS="$EXTRAS check_swap"
1517 AC_PATH_PROG(PATH_TO_DIG,dig)
1518 AC_ARG_WITH(dig_command,
1519             ACX_HELP_STRING([--with-dig-command=PATH],
1520                             [Path to dig command]), PATH_TO_DIG=$withval)
1521 if test -n "$PATH_TO_DIG"; then
1522         EXTRAS="$EXTRAS check_dig"
1523         AC_DEFINE_UNQUOTED(PATH_TO_DIG,"$PATH_TO_DIG",[Path to dig command, if present])
1526 AC_PATH_PROG(PATH_TO_APTGET,apt-get)
1527 AC_ARG_WITH(apt-get_command,
1528             ACX_HELP_STRING([--with-apt-get-command=PATH],
1529                             [Path to apt-get command]),
1530                             with_apt_get_command=$withval,
1531                             with_apt_get_command=$PATH_TO_APTGET)
1532 AC_DEFINE_UNQUOTED(PATH_TO_APTGET,"$PATH_TO_APTGET",[Path to apt-get command, if present])
1533 if test -n "$PATH_TO_APTGET" ; then
1534         EXTRAS="$EXTRAS check_apt"
1538 if test -f plugins/check_nt.c ; then
1539   EXTRAS="$EXTRAS check_nt"
1540 elif test -f ../plugins/check_nt.c ; then
1541   EXTRAS="$EXTRAS check_nt"
1545 dnl used in check_dhcp
1546 AC_CHECK_HEADERS(sys/sockio.h)
1548 case $host in
1549         *bsd*)
1550                 AC_DEFINE(__bsd__,1,[bsd specific code in check_dhcp.c])
1551         ;;
1552         *linux*)
1553                 AC_DEFINE(__linux__,1,[linux specific code in check_dhcp.c])
1554         ;;
1555         *sun* | *solaris*)
1556                 AC_DEFINE(__sun__,1,[sun specific code in check_dhcp.c])
1557         ;;
1558         *hpux*)
1559                 AC_DEFINE(__hpux__,1,[hpux specific code in check_dhcp.c])
1560         ;;
1561 esac
1563 AC_SUBST(EXTRAS)
1564 AC_SUBST(EXTRAS_ROOT)
1565 AC_SUBST(EXTRA_NETOBJS)
1566 AC_SUBST(DEPLIBS)
1568 AM_GNU_GETTEXT([external], [need-ngettext])
1569 AM_GNU_GETTEXT_VERSION(0.15)
1571 dnl Check for Redhat spopen problem
1572 dnl Wierd problem where ECHILD is returned from a wait call in error
1573 dnl Only appears to affect nslookup and dig calls. Only affects redhat around
1574 dnl 2.6.9-11 (okay in 2.6.9-5). Redhat investigating root cause
1575 dnl We patch plugins/popen.c
1576 dnl Need to add smp because uname different on those
1577 dnl Can force patch to be applied with --enable-redhat-pthread-workaround
1578 AC_ARG_ENABLE(redhat-pthread-workaround,
1579         AC_HELP_STRING([--enable-redhat-pthread-workaround],
1580                 [force Redhat patch to be applied (default: test system)]),
1581         [ac_cv_enable_redhat_pthread_workaround=$enableval],
1582         [ac_cv_enable_redhat_pthread_workaround=test])
1583 if test "$ac_cv_enable_redhat_pthread_workaround" = "test" ; then
1584         if echo $ac_cv_uname_r | egrep "\.EL(smp)?$" >/dev/null 2>&1 ; then
1585                 AC_MSG_NOTICE([See http://nagiosplugins.org/faq/compile/configure_appears_to_hang if this next part takes a long time])
1586                 AC_MSG_CHECKING(for redhat spopen problem)
1587                 ( cd config_test && make && make test ) > /dev/null 2>&1
1588                 if test $? -eq 0 ; then
1589                         AC_MSG_RESULT(okay)
1590                 else
1591                         AC_MSG_RESULT(error)
1592                         AC_DEFINE(REDHAT_SPOPEN_ERROR, 1, [Workaround on redhat in spopen])
1593                 fi
1594         fi
1595 elif test "$ac_cv_enable_redhat_pthread_workaround" = "yes" ; then
1596         AC_DEFINE(REDHAT_SPOPEN_ERROR, 1, [Forced workaround on redhat in spopen])
1599 dnl Perl modules
1600 AC_ARG_ENABLE(perl-modules,
1601         AC_HELP_STRING([--enable-perl-modules],
1602                 [Enables installation of Nagios::Plugin and its dependencies (default: no)]),
1603         [enable_perl_modules=$enableval],
1604         [enable_perl_modules=no])
1605 if test "$enable_perl_modules" = "yes" ; then
1606   AC_SUBST(PERLMODS_DIR,perlmods)
1609 # From Tap configure
1610 # Checks for libraries
1611 case "$host" in
1612         *-*-*freebsd4*)
1613                 LDFLAGS="$LDFLAGS -pthread"
1614                 HAVE_LIBPTHREAD=1
1615                 ;;
1616         *)
1617                 AC_CHECK_LIB(pthread, main)
1618                 ;;
1619 esac
1621 dnl External libraries - see ACKNOWLEDGEMENTS
1622 gl_INIT
1624 dnl Some helpful common compile errors checked here
1625 if test "$ac_cv_uname_s" = 'SunOS' -a \( "x$ac_cv_prog_ac_ct_AR" = "x" -o "$ac_cv_prog_ac_ct_AR" = 'false' \) ; then
1626         AC_MSG_ERROR(No ar found for Solaris - is /usr/ccs/bin in PATH?)
1629 AC_OUTPUT(
1630   Makefile
1631   tap/Makefile
1632   lib/Makefile
1633   plugins/Makefile
1634   lib/tests/Makefile
1635   plugins-root/Makefile
1636   plugins-scripts/Makefile
1637   plugins-scripts/subst
1638   plugins-scripts/utils.pm
1639   plugins-scripts/utils.sh
1640   perlmods/Makefile
1641   command.cfg
1642   test.pl
1643   pkg/solaris/pkginfo
1644   po/Makefile.in
1648 dnl the ones below that are commented out need to be cleaned up
1649 dnl in the configure code above to use with_foo instead of ac_cv_foo
1650 dnl if we want them to show up here.  it'd also make the code cleaner.
1651 dnl i'll get to that on another rainy day :) -sf
1652 ACX_FEATURE([with],[apt-get-command])
1653 dnl ACX_FEATURE([with],[dig-command])
1654 dnl ACX_FEATURE([with],[fping-command])
1655 dnl ACX_FEATURE([with],[mailq-command])
1656 dnl ACX_FEATURE([with],[nslookup-command])
1657 ACX_FEATURE([with],[ping6-command])
1658 ACX_FEATURE([with],[ping-command])
1659 dnl ACX_FEATURE([with],[qstat-command])
1660 dnl ACX_FEATURE([with],[rpcinfo-command])
1661 dnl ACX_FEATURE([with],[smbclient-command])
1662 dnl ACX_FEATURE([with],[snmpget-command])
1663 dnl ACX_FEATURE([with],[snmpgetnext-command])
1664 dnl ACX_FEATURE([with],[ssh-command])
1665 dnl ACX_FEATURE([with],[uptime-command])
1667 dnl ACX_FEATURE([with],[proc-meminfo])
1668 dnl ACX_FEATURE([with],[ps-command])
1669 dnl ACX_FEATURE([with],[ps-format])
1670 dnl ACX_FEATURE([with],[ps-cols])
1671 dnl ACX_FEATURE([with],[ps-varlist])
1673 ACX_FEATURE([with],[ipv6])
1674 ACX_FEATURE([with],[mysql])
1675 ACX_FEATURE([with],[openssl])
1676 ACX_FEATURE([with],[gnutls])
1677 ACX_FEATURE([enable],[extra-opts])
1678 ACX_FEATURE([with],[perl])
1679 ACX_FEATURE([enable],[perl-modules])
1680 ACX_FEATURE([with],[cgiurl])
1681 ACX_FEATURE([with],[trusted-path])
1682 ACX_FEATURE([enable],[libtap])