developer-guidelines.sgml: Multiline output
[monitoring-plugins.git] / configure.in
bloba157596f5d071af1b5830ab430dcb9cb14c9ed7d
1 dnl Process this file with autoconf to produce a configure script.
2 AC_PREREQ(2.59)
3 AC_INIT(nagios-plugins,1.4.16)
4 AC_CONFIG_SRCDIR(NPTest.pm)
5 AC_CONFIG_FILES([gl/Makefile 
6         nagios-plugins.spec])
7 AC_CONFIG_AUX_DIR(build-aux)
8 AM_INIT_AUTOMAKE([1.8.3])
9 AM_CONFIG_HEADER(config.h)
10 AC_CANONICAL_HOST
12 RELEASE=1
13 AC_SUBST(RELEASE)
15 AC_PREFIX_DEFAULT(/usr/local/nagios)
17 dnl Deprecated configure options
20 dnl Append user (-o), group (-g), mode (-m) to install command
21 dnl There is an assumption that this is possible with ./configure's chosen install command
22 extra_install_args=""
23 AC_ARG_WITH(nagios_user,
24         ACX_HELP_STRING([--with-nagios-user=USER],
25                 [Installs executables with this user. Defaults to install user]),
26         extra_install_args="-o $withval")
27 AC_ARG_WITH(nagios_group,
28         ACX_HELP_STRING([--with-nagios-group=GROUP],
29                 [Installs executables with this group. Defaults to install user]),
30         extra_install_args="$extra_install_args -g $withval")
31 AC_ARG_WITH(world_permissions,
32         ACX_HELP_STRING([--without-world-permissions],
33                 [Installs executables without world permissions]))
35 if test "x$with_world_permissions" = xno ; then
36         extra_install_args="$extra_install_args -m 0550"
39 INSTALL="$INSTALL $extra_install_args"
40 INSTALL_STRIP_PROGRAM="$INSTALL_STRIP_PROGRAM $extra_install_args"
41 AC_SUBST(INSTALL)
43 AC_PROG_CC
44 gl_EARLY
45 AC_PROG_GCC_TRADITIONAL
46 AC_PROG_LIBTOOL
48 AM_PROG_CC_C_O
50 AC_FUNC_ERROR_AT_LINE
51 AC_SYS_LARGEFILE
53 ifdef([AC_FUNC_STRTOD],[AC_FUNC_STRTOD],[AM_FUNC_STRTOD])
55 PLUGIN_TEST=`echo $srcdir/plugins/t/*.t|sed -e 's,\.*/plugins/,,g'`
56 AC_SUBST(PLUGIN_TEST)dnl
58 SCRIPT_TEST=`echo $srcdir/plugins-scripts/t/*.t|sed -e 's,\.*/plugins-scripts/,,g'`
59 AC_SUBST(SCRIPT_TEST)dnl
61 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"
62 AC_SUBST(WARRANTY)
64 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"
65 AC_SUBST(SUPPORT)
67 dnl CGIURL has changed for Nagios with 1.0 beta
68 AC_ARG_WITH(cgiurl,
69         ACX_HELP_STRING([--with-cgiurl=DIR],
70                 [sets URL for cgi programs]),
71         with_cgiurl=$withval,
72         with_cgiurl=/nagios/cgi-bin)
73 CGIURL="$with_cgiurl"
74 AC_DEFINE_UNQUOTED(CGIURL,"$CGIURL",[URL of CGI programs])
76 AC_ARG_WITH(trusted_path,
77         ACX_HELP_STRING([--with-trusted-path=PATH],
78                 [sets trusted path for executables called by scripts (default=/bin:/sbin:/usr/bin:/usr/sbin)]),
79         with_trusted_path=$withval,
80         with_trusted_path=/bin:/sbin:/usr/bin:/usr/sbin)
81 AC_SUBST(with_trusted_path)
83 EXTRAS=
84 EXTRAS_ROOT=
85 dnl PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/etc:/usr/local/bin:/usr/local/sbin:$PATH
87 LDFLAGS="$LDFLAGS -L."
89 ac_cv_uname_m=`uname -m`
90 ac_cv_uname_s=`uname -s`
91 ac_cv_uname_r=`uname -r`
92 ac_cv_uname_v=`uname -v`
94 PKG_ARCH=`uname -p`
95 REV_DATESTAMP=`date '+%Y.%m.%d.%H.%M'`
96 REV_TIMESTAMP=`date '+%Y%m%d%H%M%S'`
98 AC_SUBST(PKG_ARCH)
99 AC_SUBST(REV_DATESTAMP)
100 AC_SUBST(REV_TIMESTAMP)
102 dnl Check if version file is present
103 AM_CONDITIONAL([RELEASE_PRESENT], [test -f $srcdir/release])
105 # Also read in the version from it
106 if test -f $srcdir/release; then
107         NP_RELEASE="$(<release)"
108 else
109         NP_RELEASE="$PACKAGE_VERSION"
111 AC_SUBST(NP_RELEASE)
113 dnl Checks for programs.
114 AC_PATH_PROG(PYTHON,python)
115 AC_PATH_PROG(SH,sh)
116 AC_PATH_PROG(PERL,perl)
117 AC_PATH_PROG(LIBGNUTLS_CONFIG,libgnutls-config)
118 AC_PATH_PROG(HOSTNAME,hostname)
119 AC_PATH_PROG(BASENAME,basename)
121 dnl allow them to override the path of perl
122 AC_ARG_WITH(perl,
123         ACX_HELP_STRING([--with-perl=PATH],
124                         [sets path to perl executable]),
125                         with_perl=$withval,with_perl=$PERL)
126 AC_SUBST(PERL, $with_perl)
128 dnl openssl/gnutls
129 AC_ARG_WITH(openssl,
130             AC_HELP_STRING([--with-openssl=DIR],
131                            [path to openssl installation]),)
133 AC_ARG_WITH(gnutls,
134             ACX_HELP_STRING([--with-gnutls=PATH],
135                             [path to gnutls installation root]),)
137 dnl you can only have one or the other
138 if test ! "$with_openssl" = "" && test ! "$with_openssl" = "no"; then
139         with_gnutls="no"
141 if test ! "$with_gnutls" = "" && test ! "$with_gnutls" = "no"; then
142         with_openssl="no"
145 dnl list of possible dirs to try to autodetect openssl
146 dnl if $dir/include exists, we consider it found
147 dnl the order should allow locally installed versions to override distros' ones
148 OPENSSL_DIRS="/usr /usr/local /usr/slocal /usr/local/openssl /usr/local/ssl \
149               /opt /opt/openssl"
153 dnl Checks for libraries.
156 AC_CHECK_LIB(dce,main,SOCKETLIBS="$SOCKETLIBS -ldce")
157 AC_CHECK_LIB(nsl,main,SOCKETLIBS="$SOCKETLIBS -lnsl")
158 AC_CHECK_LIB(socket,socket,SOCKETLIBS="$SOCKETLIBS -lsocket")
159 AC_CHECK_LIB(resolv,main,SOCKETLIBS="$SOCKETLIBS -lresolv")
160 AC_SUBST(SOCKETLIBS)
163 dnl check for math-related functions needing -lm
164 AC_CHECK_HEADERS(math.h)
165 AC_CHECK_LIB(m,floor,MATHLIBS="-lm")
166 AC_CHECK_HEADERS(mp.h)
167 AC_CHECK_LIB(bsd,pow,MATHLIBS="$MATHLIBS -lbsd")
168 AC_SUBST(MATHLIBS)
170 dnl Check if we buils local libtap
171 AC_ARG_ENABLE(libtap,
172   AC_HELP_STRING([--enable-libtap],
173                 [Enable built-in libtap for unit-testing (default: autodetect system library).]),
174         [enable_libtap=$enableval],
175         [enable_libtap=no])
176 AM_CONDITIONAL([USE_LIBTAP_LOCAL],[test "$enable_libtap" = "yes"])
178 # If not local, check if we can use the system one
179 if test "$enable_libtap" != "yes" ; then
180         dnl Check for libtap, to run perl-like tests
181         AC_CHECK_LIB(tap, plan_tests,
182                 enable_libtap="yes"
183                 )
186 # Finally, define tests if we use libtap
187 if test "$enable_libtap" = "yes" ; then
188         EXTRA_TEST="test_utils test_disk test_tcp test_cmd test_base64"
189         AC_SUBST(EXTRA_TEST)
192 dnl INI Parsing
193 AC_ARG_ENABLE(extra-opts,
194   AC_HELP_STRING([--enable-extra-opts],
195                 [Enables parsing of plugins ini config files for extra options (default: no)]),
196         [enable_extra_opts=$enableval],
197         [enable_extra_opts=no])
198 AM_CONDITIONAL([USE_PARSE_INI],[test "$enable_extra_opts" = "yes"])
199 if test "$enable_extra_opts" = "yes" ; then
200         AC_DEFINE(NP_EXTRA_OPTS,[1],[Enable INI file parsing.])
201         if test "$enable_libtap" = "yes"; then
202                 EXTRA_TEST="$EXTRA_TEST test_ini1 test_ini3 test_opts1 test_opts2 test_opts3"
203                 AC_SUBST(EXTRA_TEST)
204         fi
207 dnl Check for PostgreSQL libraries
208 _SAVEDLIBS="$LIBS"
209 _SAVEDCPPFLAGS="$CPPFLAGS"
210 AC_ARG_WITH(pgsql,
211         ACX_HELP_STRING([--with-pgsql=DIR],
212                 [sets path to pgsql installation]),
213         PGSQL=$withval,)
214 AC_CHECK_LIB(crypt,main)
215 if test "$ac_cv_lib_crypt_main" = "yes" -a "x$PGSQL" != "xno"; then
216   if test -n "$PGSQL"; then
217     LDFLAGS="$LDFLAGS -L$PGSQL/lib"
218     CPPFLAGS="$CPPFLAGS -I$PGSQL/include"
219   fi
220   AC_CHECK_LIB(pq,PQsetdbLogin,,,-lcrypt)
221   if test "$ac_cv_lib_pq_PQsetdbLogin" = "yes"; then
222     AC_CHECK_HEADERS(pgsql/libpq-fe.h)
223     AC_CHECK_HEADERS(postgresql/libpq-fe.h)
224     AC_CHECK_HEADERS(libpq-fe.h)
225     if [[ -n "$PGSQL" -a "$ac_cv_header_libpq_fe_h" = "yes" ]]; then
226       PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
227       PGINCLUDE="-I$PGSQL/include"
228     elif test  "$ac_cv_header_pgsql_libpq_fe_h" = "yes"; then
229       PGLIBS="-lpq -lcrypt"
230       PGINCLUDE="-I/usr/include/pgsql"
231     elif test  "$ac_cv_header_postgresql_libpq_fe_h" = "yes"; then
232       PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
233       PGINCLUDE="-I/usr/include/postgresql"
234     elif test  "$ac_cv_header_libpq_fe_h" = "yes"; then
235       PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
236       PGINCLUDE="-I$PGSQL/include"
237     fi
238     if test -z "$PGINCLUDE"; then
239       AC_MSG_WARN([Skipping PostgreSQL plugin (check_pgsql)])
240       AC_MSG_WARN([install PostgreSQL headers to compile this plugin (see REQUIREMENTS).])
241     else
242       AC_SUBST(PGLIBS)
243       AC_SUBST(PGINCLUDE)
244       EXTRAS="$EXTRAS check_pgsql"
245     fi
246   else
247     AC_MSG_WARN([Skipping PostgreSQL plugin (check_pgsql)])
248     AC_MSG_WARN([LIBS="$LIBS" CPPFLAGS="$CPPFLAGS"])
249     AC_MSG_WARN([install PostgreSQL libs to compile this plugin (see REQUIREMENTS).])
250   fi
251 else
252   AC_MSG_WARN([Skipping PostgreSQL plugin (check_pgsql)])
253   AC_MSG_WARN([install lib crypt and PostgreSQL libs to compile this plugin (see REQUIREMENTS).])
255 LIBS="$_SAVEDLIBS"
256 CPPFLAGS="$_SAVEDCPPFLAGS"
258 AC_ARG_WITH([dbi], [AS_HELP_STRING([--without-dbi], [Skips the dbi plugin])])
259 dnl Check for DBI libraries
260 AS_IF([test "x$with_dbi" != "xno"], [
261   _SAVEDLIBS="$LIBS"
262   AC_CHECK_LIB(dbi,dbi_initialize)
263   if test "$ac_cv_lib_dbi_dbi_initialize" = "yes"; then
264     EXTRAS="$EXTRAS check_dbi"
265         DBILIBS="-ldbi"
266     AC_SUBST(DBILIBS)
267   else
268     AC_MSG_WARN([Skipping dbi plugin])
269     AC_MSG_WARN([install DBI libs to compile this plugin (see REQUIREMENTS).])
270   fi
271   LIBS="$_SAVEDLIBS"
274 AC_ARG_WITH([radius], [AS_HELP_STRING([--without-radius], [Skips the radius plugin])])
276 dnl Check for radius libraries
277 AS_IF([test "x$with_radius" != "xno"], [
278   _SAVEDLIBS="$LIBS"
279   AC_CHECK_LIB(radiusclient,rc_read_config)
280   if test "$ac_cv_lib_radiusclient_rc_read_config" = "yes"; then
281     EXTRAS="$EXTRAS check_radius"
282         RADIUSLIBS="-lradiusclient"
283     AC_SUBST(RADIUSLIBS)
284   else
285     AC_CHECK_LIB(radiusclient-ng,rc_read_config)
286     if test "$ac_cv_lib_radiusclient_ng_rc_read_config" = "yes"; then
287       EXTRAS="$EXTRAS check_radius"
288           RADIUSLIBS="-lradiusclient-ng"
289       AC_SUBST(RADIUSLIBS)
290     else
291       AC_MSG_WARN([Skipping radius plugin])
292       AC_MSG_WARN([install radius libs to compile this plugin (see REQUIREMENTS).])
293     fi
294   fi
295   LIBS="$_SAVEDLIBS"
298 AC_ARG_WITH([ldap], [AS_HELP_STRING([--without-ldap], [Skips the LDAP plugin])])
300 dnl Check for LDAP libraries
301 AS_IF([test "x$with_ldap" != "xno"], [
302   _SAVEDLIBS="$LIBS"
303   AC_CHECK_LIB(ldap,main,,,-llber)
304   if test "$ac_cv_lib_ldap_main" = "yes"; then
305     LDAPLIBS="-lldap -llber"\
306     LDAPINCLUDE="-I/usr/include/ldap"
307     AC_SUBST(LDAPLIBS)
308     AC_SUBST(LDAPINCLUDE)
309     AC_CHECK_FUNCS(ldap_set_option)
310     EXTRAS="$EXTRAS check_ldap"
311         AC_CHECK_FUNCS(ldap_init ldap_set_option ldap_get_option ldap_start_tls_s)
312   else
313     AC_MSG_WARN([Skipping LDAP plugin])
314     AC_MSG_WARN([install LDAP libs to compile this plugin (see REQUIREMENTS).])
315   fi
316   LIBS="$_SAVEDLIBS"
319 dnl Check for headers used by check_ide_smart
320 case $host in
321   *linux*)
322     AC_CHECK_HEADER(linux/hdreg.h, FOUNDINCLUDE=yes, FOUNDINCLUDE=no)
323     if test "$FOUNDINCLUDE" = "yes" ; then
324         AC_CHECK_HEADER(linux/types.h, FOUNDINCLUDE=yes, FOUNDINCLUDE=no)
325     fi
326     if test "$FOUNDINCLUDE" = "no" ; then
327         AC_MSG_WARN([Skipping check_ide_smart plugin.])
328         AC_MSG_WARN([check_ide_smart requires linux/hdreg.h and linux/types.h.])
329     fi
330   ;;
331   *netbsd*)
332     AC_CHECK_HEADER(dev/ata/atareg.h, FOUNDINCLUDE=yes, FOUNDINCLUDE=no)
333     if test "$FOUNDINCLUDE" = "yes" ; then
334         AC_CHECK_HEADER(dev/ic/wdcreg.h, FOUNDINCLUDE=yes, FOUNDINCLUDE=no)
335     fi
336     if test "$FOUNDINCLUDE" = "no" ; then
337         AC_MSG_WARN([Skipping check_ide_smart plugin.])
338         AC_MSG_WARN([check_ide_smart requires dev/ata/atareg.h and dev/ic/wdcreg.h])
339     fi
340   ;;
341   *)
342     AC_MSG_WARN([Skipping check_ide_smart plugin.])
343     AC_MSG_WARN([check_ide_smart works only on Linux and NetBSD])
344 esac
346 if test "$FOUNDINCLUDE" = "yes" ; then
347         EXTRAS="$EXTRAS check_ide_smart"
350 dnl Check for mysql libraries
351 np_mysqlclient
352 if test $with_mysql = "no" ; then
353   AC_MSG_WARN([Skipping mysql plugin])
354   AC_MSG_WARN([install mysql client libs to compile this plugin (see REQUIREMENTS).])
355 else
356   EXTRAS="$EXTRAS check_mysql check_mysql_query"
357   MYSQLINCLUDE="$np_mysql_include"
358   MYSQLLIBS="$np_mysql_libs"
359   MYSQLCFLAGS="$np_mysql_cflags"
360   AC_SUBST(MYSQLINCLUDE)
361   AC_SUBST(MYSQLLIBS)
362   AC_SUBST(MYSQLCFLAGS)
365 dnl Check for headers used by check_users
366 AC_CHECK_HEADERS(utmpx.h)
367 AM_CONDITIONAL([HAVE_UTMPX], [test "$ac_cv_header_utmpx_h" = "yes"])
369 dnl Fallback to who(1) if the system doesn't provide an utmpx(5) interface
370 if test "$ac_cv_header_utmpx_h" = "no"
371 then
372         AC_PATH_PROG(PATH_TO_WHO,who)
374         if [$PATH_TO_WHO -q 2>/dev/null | egrep -i "^# users=[0-9]+$" >/dev/null]
375         then
376                 ac_cv_path_to_who="$PATH_TO_WHO -q"
377         else
378                 ac_cv_path_to_who="$PATH_TO_WHO"
379         fi
381         AC_DEFINE_UNQUOTED(WHO_COMMAND,"$ac_cv_path_to_who",
382                 [path and arguments for invoking 'who'])
385 AC_ARG_WITH([ipv6],
386         [AS_HELP_STRING([--with-ipv6], [support IPv6 @<:@default=check@:>@])],
387         [], [with_ipv6=check])
389 dnl Check for AF_INET6 support - unistd.h required for Darwin
390 if test "$with_ipv6" != "no"; then
391         AC_CACHE_CHECK([for IPv6 support], np_cv_sys_ipv6, [
392                 AC_TRY_COMPILE(
393                         [#ifdef HAVE_UNISTD_H
394                         #include <unistd.h>
395                         #endif
396                         #include <netinet/in.h>
397                         #include <sys/socket.h>],
398                         [struct sockaddr_in6 sin6;
399                         void *p;
401                         sin6.sin6_family = AF_INET6;
402                         sin6.sin6_port = 587;
403                         p = &sin6.sin6_addr;],
404                         [np_cv_sys_ipv6=yes],
405                         [np_cv_sys_ipv6=no])
406                 ])
407         if test "$np_cv_sys_ipv6" = "no" -a "$with_ipv6" != "check"; then
408                 AC_MSG_FAILURE([--with-ipv6 was given, but test for IPv6 support failed])
409         fi
410         if test "$np_cv_sys_ipv6" = "yes"; then
411                 AC_DEFINE(USE_IPV6,1,[Enable IPv6 support])
412         fi
413         with_ipv6="$np_cv_sys_ipv6"
417 dnl Checks for Kerberos. Must come before openssl checks for Redhat EL 3
418 AC_CHECK_HEADERS(krb5.h,FOUNDINCLUDE=yes,FOUNDINCLUDE=no)
419 if test "$FOUNDINCLUDE" = "no"; then
420   _SAVEDCPPFLAGS="$CPPFLAGS"
421   CPPFLAGS="$_SAVEDCPPFLAGS -I/usr/kerberos/include"
422   unset ac_cv_header_krb5_h
423   AC_CHECK_HEADERS(krb5.h,
424                    KRB5INCLUDE="-I/usr/kerberos/include"
425                    FOUNDINCLUDE=yes,
426                    FOUNDINCLUDE=no)
428 AC_SUBST(KRBINCLUDE)
429 if test "$FOUNDINCLUDE" = "no"; then
430   CPPFLAGS="$_SAVEDCPPFLAGS"
433 dnl *** The following block comes from wget configure.ac ***
434 dnl Unfortunately, as of this writing (OpenSSL 0.9.6), the libcrypto
435 dnl shared library doesn't record its dependency on libdl, so we
436 dnl need to check for it ourselves so we won't fail to link due to a
437 dnl lack of -ldl.  Most OSes use dlopen(), but HP-UX uses
438 dnl shl_load().
439 AC_CHECK_LIB(dl,dlopen)
440 AC_CHECK_LIB(dl,shl_load)
442 dnl openssl detection/configuration
443 if ! test x"$with_openssl" = x"no"; then
444         dnl Check for OpenSSL location if it wasn't already specified
445         if ! test -d "$with_openssl"; then
446                 for d in $OPENSSL_DIRS; do
447                         if test -x ${d}/bin/openssl || test -x ${d}/sbin/openssl ; then
448                                 with_openssl=$d
449                         fi
450                 done
451         fi
453         _SAVEDCPPFLAGS="$CPPFLAGS"
454         _SAVEDLDFLAGS="$LDFLAGS"
455         dnl Check for OpenSSL header files
456         unset FOUNDINCLUDE
457         if test x"$with_openssl" != x"/usr" ; then
458                 CPPFLAGS="$CPPFLAGS -I$with_openssl/include"
459                 LDFLAGS="$LDFLAGS -L$with_openssl/lib"
460         fi
462         dnl check for openssl in $dir/include/openssl
463         AC_CHECK_HEADERS(openssl/ssl.h openssl/x509.h openssl/rsa.h openssl/pem.h openssl/crypto.h openssl/err.h,
464                          SSLINCLUDE="-I$with_openssl/include"
465                          FOUNDINCLUDE=yes,
466                          FOUNDINCLUDE=no)
467         dnl else check to see if $dir/include has it
468         if test "$FOUNDINCLUDE" = "no"; then
469                 AC_CHECK_HEADERS(ssl.h x509.h rsa.h pem.h crypto.h err.h,
470                                  SSLINCLUDE="-I$with_openssl/include"
471                                  FOUNDINCLUDE=yes,
472                                  FOUNDINCLUDE=no)
473         fi
474         AC_SUBST(SSLINCLUDE)
475         dnl if we didn't find it, reset CPPFLAGS
476         if test "$FOUNDINCLUDE" = "no"; then
477                 CPPFLAGS="$_SAVEDCPPFLAGS"
478                 LDFLAGS="$_SAVEDLDFLAGS"
479         fi
481         dnl Check for crypto lib
482         _SAVEDLIBS="$LIBS"
483         LIBS="-L${with_openssl}/lib"
484         AC_CHECK_LIB(crypto,CRYPTO_lock)
485         if test "$ac_cv_lib_crypto_CRYPTO_lock" = "yes"; then
486                 dnl Check for SSL lib
487                 AC_CHECK_LIB(ssl,main, SSLLIBS="-lssl -lcrypto",,-lcrypto)
488         fi
489         LIBS="$_SAVEDLIBS"
491         dnl test headers and libs to decide whether check_http should use SSL
492         if test "$ac_cv_lib_crypto_CRYPTO_lock" = "yes"; then
493                 if test "$ac_cv_lib_ssl_main" = "yes"; then
494                         if test "$FOUNDINCLUDE" = "yes"; then
495                                 FOUNDOPENSSL="yes"
496                         fi
497                 fi
498         fi
502 dnl check for gnutls if openssl isn't found (or is disabled)
503 if test ! "$FOUNDOPENSSL" = "yes" && test ! "$with_gnutls" = "no"; then
504         if test ! "$with_gnutls" = ""; then
505                 CPPFLAGS="$CPPFLAGS -I${with_gnutls}/include"
506         elif test ! "$LIBGNUTLS_CONFIG" = ""; then
507                 CPPFLAGS="$CPPFLAGS -I`$LIBGNUTLS_CONFIG --prefix`"
508         fi
509         AC_CHECK_HEADERS([gnutls/openssl.h],FOUNDGNUTLS="yes",)
510         if test "$FOUNDGNUTLS" = "yes"; then
511                 AC_CHECK_LIB(gnutls-openssl,main,SSLLIBS="-lgnutls-openssl")
512         fi
514 dnl end check for gnutls
516 if test "$FOUNDOPENSSL" = "yes" || test "$FOUNDGNUTLS" = "yes"; then
517         check_tcp_ssl="check_simap check_spop check_jabber check_nntps check_ssmtp"
518         AC_SUBST(check_tcp_ssl)
519         AC_SUBST(SSLLIBS)
520         AC_DEFINE(HAVE_SSL,1,[Define if SSL libraries are found])
521         if test "$FOUNDOPENSSL" = "yes"; then
522                 AC_DEFINE(USE_OPENSSL,1,[Define if using OpenSSL libraries])
523                 with_openssl="yes"
524                 with_gnutls="no"
525         else
526                 AC_DEFINE(USE_GNUTLS,1,[Define if using gnutls libraries])
527                 with_gnutls="yes"
528                 with_openssl="no"
529         fi
530 else
531         dnl else deliberately disabled or no ssl support available
532         AC_MSG_WARN([OpenSSL or GnuTLS libs could not be found or were disabled])
533         with_openssl="no"
534         with_gnutls="no"
538 dnl Checks for header files.
541 AC_HEADER_TIME
542 AC_HEADER_SYS_WAIT
543 AC_CHECK_HEADERS(signal.h syslog.h uio.h errno.h sys/time.h sys/socket.h sys/un.h sys/poll.h)
544 AC_CHECK_HEADERS(features.h stdarg.h sys/unistd.h ctype.h)
546 dnl Checks for typedefs, structures, and compiler characteristics.
547 AC_C_CONST
548 AC_STRUCT_TM
549 AC_TYPE_PID_T
550 AC_TYPE_SIZE_T
551 AC_TYPE_SIGNAL
553 AC_CACHE_CHECK([for va_copy],ac_cv_HAVE_VA_COPY,[
554 AC_TRY_LINK([#include <stdarg.h>
555 va_list ap1,ap2;], [va_copy(ap1,ap2);],
556 ac_cv_HAVE_VA_COPY=yes,
557 ac_cv_HAVE_VA_COPY=no)])
558 if test x"$ac_cv_HAVE_VA_COPY" = x"yes"; then
559     AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available])
560 else
561     AC_CACHE_CHECK([for __va_copy],ac_cv_HAVE___VA_COPY,[
562     AC_TRY_LINK([#include <stdarg.h>
563     va_list ap1,ap2;], [__va_copy(ap1,ap2);],
564     ac_cv_HAVE___VA_COPY=yes,
565     ac_cv_HAVE___VA_COPY=no)])
566     if test x"$ac_cv_HAVE___VA_COPY" = x"yes"; then
567         AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available])
568     fi
571 AC_TRY_COMPILE([#include <sys/time.h>],
572                [struct timeval *tv;
573                 struct timezone *tz;],
574                AC_DEFINE(HAVE_STRUCT_TIMEVAL,1,[Define if we have a timeval structure])
575                AC_TRY_COMPILE([#include <sys/time.h>],
576                               [struct timeval *tv;
577                                struct timezone *tz;
578                                gettimeofday(tv, tz);],
579                               AC_DEFINE(HAVE_GETTIMEOFDAY,1,[Define if gettimeofday is found]),
580                               AC_DEFINE(NEED_GETTIMEOFDAY,1,[Define if gettimeofday is needed])))
582 dnl Checks for library functions.
583 AC_CHECK_FUNCS(memmove select socket strdup strstr strtol strtoul floor)
584 AC_CHECK_FUNCS(poll)
586 AC_MSG_CHECKING(return type of socket size)
587 AC_TRY_COMPILE([#include <stdlib.h>
588                 #include <sys/types.h>
589                 #include <sys/socket.h>],
590                [int a = send(1, (const void *) buffer, (size_t *) 0, (int *) 0);],
591                ac_cv_socket_size_type=["size_t"]
592                 AC_MSG_RESULT(size_t),
593                ac_cv_socket_size_type=["int"]
594                 AC_MSG_RESULT(int))
596 AC_DEFINE_UNQUOTED(SOCKET_SIZE_TYPE, $ac_cv_socket_size_type ,
597         [Define type of socket size])
600 dnl #### Process table test
602 AC_PATH_PROG(PATH_TO_PS,ps)
604 AC_MSG_CHECKING(for ps syntax)
605 AC_ARG_WITH(ps_command,
606             ACX_HELP_STRING([--with-ps-command=PATH],
607                             [Verbatim command to execute for ps]),
608             PS_COMMAND=$withval)
609 AC_ARG_WITH(ps_format,
610             ACX_HELP_STRING([--with-ps-format=FORMAT],
611                             [Format string for scanning ps output]),
612             PS_FORMAT=$withval)
613 AC_ARG_WITH(ps_cols,
614             ACX_HELP_STRING([--with-ps-cols=NUM],
615                             [Number of columns in ps command]),
616             PS_COLS=$withval)
617 AC_ARG_WITH(ps_varlist,
618             ACX_HELP_STRING([--with-ps-varlist=LIST],
619                             [Variable list for sscanf of 'ps' output]),
620             PS_VARLIST=$withval)
622 if test -n "$PS_COMMAND" && test -n "$PS_FORMAT" && test -n "$PS_COLS" && test -n "$PS_VARLIST"; then
623         ac_cv_ps_command="$PS_COMMAND"
624         ac_cv_ps_format="$PS_FORMAT"
625         ac_cv_ps_varlist="$PS_VARLIST"
626         ac_cv_ps_cols="$PS_COLS"
627         AC_MSG_RESULT([(command-line) $ac_cv_ps_command])
629 dnl Now using the pst3/kmem hack for solaris systems to avoid truncation
630 elif test "$ac_cv_uname_s" = "SunOS"; then
631         #
632         # this is a very, very ugly hack, to hardcode the location for plugins
633         #
634         if test "$libexecdir" = '${exec_prefix}/libexec'; then
635                 if test "$exec_prefix" = "NONE"; then
636                         if test "$prefix" = "NONE"; then
637                                 pst3="$ac_default_prefix/libexec/pst3"
638                         else
639                                 pst3="$prefix/libexec/pst3"
640                         fi
641                 else
642                         pst3="$exec_prefix/libexec/pst3"
643                 fi
644         else
645                 pst3="$libexecdir/pst3"
646         fi
647         ac_cv_ps_command="$pst3"
648         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
649         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
650         ac_cv_ps_cols=9
651         AC_MSG_RESULT([using nagios-plugins internal ps command (pst3) for solaris])
652         if test `isainfo -b` = 64 ; then
653                 pst3_use_64bit=1
654                 AC_MSG_NOTICE([using 64bit pst3])
655         else
656                 AC_MSG_NOTICE([using 32bit pst3])
657         fi
658         EXTRAS_ROOT="$EXTRAS_ROOT pst3"
660         if test "$pst3_use_64bit" = 1; then
661                 dnl Test if we can actually compile code in 64bit
662                 old_cflags=$CFLAGS
663                 CFLAGS="$CFLAGS -m64"
664                 pst3_64bit_working=0
665                 AC_RUN_IFELSE(
666                         [AC_LANG_PROGRAM([], [
667 return sizeof(void*) == 8 ? 0 : 1;
668                         ])
669                 ],[
670                         PST3CFLAGS="-m64"
671                         AC_SUBST(PST3CFLAGS)
672                         pst3_64bit_working=1
673                         AC_MSG_NOTICE([using -m64 for 64bit code])
674                 ],[
675                         pst3_64bit_working=0
676                         AC_MSG_NOTICE([compiler do not like -m64])
677                 ])
678                 CFLAGS=$old_cflags
679                 if test "$pst3_64bit_working" = 0; then
680                         old_cflags=$CFLAGS
681                         CFLAGS="$CFLAGS -xarch=v9"
682                         AC_RUN_IFELSE(
683                                 [AC_LANG_PROGRAM([], [
684 return sizeof(void*) == 8 ? 0 : 1;
685                                 ])
686                         ],[
687                                 PST3CFLAGS="-xarch=v9"
688                                 AC_SUBST(PST3CFLAGS)
689                                 pst3_64bit_working=1
690                                 AC_MSG_NOTICE([using -xarch=v9 for 64bit code])
691                         ],[
692                                 pst3_64bit_working=0
693                                 AC_MSG_NOTICE([compiler do not like -xarch=v9])
694                         ])
695                         CFLAGS=$old_cflags
696                 fi
697                 if test "$pst3_64bit_working" = 0; then
698                         old_cflags=$CFLAGS
699                         CFLAGS="$CFLAGS -xarch=amd64"
700                         AC_RUN_IFELSE(
701                                 [AC_LANG_PROGRAM([], [
702 return sizeof(void*) == 8 ? 0 : 1;
703                                 ])
704                         ],[
705                                 PST3CFLAGS="-xarch=amd64"
706                                 AC_SUBST(PST3CFLAGS)
707                                 pst3_64bit_working=1
708                                 AC_MSG_NOTICE([using -xarch=amd64 for 64bit code])
709                         ],[
710                                 pst3_64bit_working=0
711                                 AC_MSG_NOTICE([compiler do not like -xarch=amd64])
712                         ])
713                         CFLAGS=$old_cflags
714                 fi
715                 if test "$pst3_64bit_working" = 0; then
716                         AC_MSG_ERROR([I don't know how to build a 64-bit object!])
717                 fi
718         fi
720 dnl Removing this for the moment - Ton
721 dnl Using /usr/ucb/ps on Solaris systems, to avoid truncation
722 dnl Limitation that command name is not available
723 dnl elif test "$ac_cv_uname_s" = "SunOS" && /usr/ucb/ps -alxwwn 2>/dev/null | \
724 dnl     egrep -i ["^ *F +UID +PID +PPID +%C +PRI +NI +SZ +RSS +WCHAN +S +TT +TIME +COMMAND"] > /dev/null
725 dnl then
726 dnl     ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procpcpu,&procvsz,&procrss,procstat,&pos]"
727 dnl     ac_cv_ps_command="/usr/ucb/ps -alxwwn"
728 dnl     ac_cv_ps_format=["%*s %d %d %d %d %*d %*d %d %d%*[ 0123456789abcdef]%[OSRZT]%*s %*s %n"]
729 dnl     ac_cv_ps_cols=8
730 dnl     AC_MSG_RESULT([$ac_cv_ps_command])
732 dnl Some gnu/linux systems (debian for one) don't like -axwo and need axwo.
733 dnl so test for this first...
734 elif ps axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
735         egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null
736 then
737         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
738         ac_cv_ps_command="$PATH_TO_PS axwo 'stat uid pid ppid vsz rss pcpu comm args'"
739         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
740         ac_cv_ps_cols=9
741         AC_MSG_RESULT([$ac_cv_ps_command])
743 dnl For OpenBSD 3.2 & 3.3. Must come before ps -weo
744 dnl Should also work for FreeBSD 5.2.1 and 5.3
745 dnl  STAT UCOMM              VSZ   RSS USER      PPID COMMAND
746 elif ps -axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
747         egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null
748 then
749         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
750         ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid pid ppid vsz rss pcpu comm args'"
751         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
752         ac_cv_ps_cols=9
753         AC_MSG_RESULT([$ac_cv_ps_command])
755 dnl Some *BSDs have different format for ps. This is mainly to catch FreeBSD 4.
756 dnl Limitation: Only first 16 chars returned for ucomm field
757 dnl Must come before ps -weo
758 elif ps -axwo 'stat uid pid ppid vsz rss pcpu ucomm command' 2>/dev/null | \
759         egrep -i ["^ *STAT +UID +PID +PPID +VSZ +RSS +%CPU +UCOMM +COMMAND"] > /dev/null
760 then
761         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
762         ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid pid ppid vsz rss pcpu ucomm command'"
763         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
764         ac_cv_ps_cols=9
765         AC_MSG_RESULT([$ac_cv_ps_command])
767 dnl  STAT UCOMM              VSZ   RSS USER       UID  PPID COMMAND
768 elif ps -weo 'stat comm vsz rss user uid pid ppid etime args' 2>/dev/null | \
769         egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[ID]+ +P[PID]+ +[ELAPSD]+ +[RGSCOMDNA]+"] >/dev/null
770 then
771         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procetime,procprog,&pos]"
772         ac_cv_ps_command="$PATH_TO_PS -weo 'stat uid pid ppid vsz rss pcpu etime comm args'"
773         ac_cv_ps_format="%s %d %d %d %d %d %f %s %s %n"
774         ac_cv_ps_cols=10
775         AC_MSG_RESULT([$ac_cv_ps_command])
777 dnl FreeBSD
778 elif ps waxco 'state command vsz rss uid user pid ppid' 2>/dev/null | \
779         egrep -i ["^STAT +COMMAND +VSZ +RSS +UID +USER +PID +PPID"] >/dev/null
780 then
781         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
782         ac_cv_ps_command="$PATH_TO_PS waxco 'state uid pid ppid vsz rss pcpu command command'"
783         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
784         ac_cv_ps_cols=9
785         AC_MSG_RESULT([$ac_cv_ps_command])
787 dnl BSD-like mode in RH 6.1
788 elif ps waxno 'state comm vsz rss uid user pid ppid args' 2>/dev/null | \
789         egrep -i ["^S +COMMAND +VSZ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
790 then
791         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
792         ac_cv_ps_command="$PATH_TO_PS waxno 'state uid pid ppid vsz rss pcpu comm args'"
793         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
794         ac_cv_ps_cols=9
795         AC_MSG_RESULT([$ac_cv_ps_command])
797 dnl SunOS 4.1.3:
798 dnl  F  UID  PID  PPID  CP  PRI  NI  SZ  RSS  WCHAN  STAT  TT  TIME  COMMAND
799 dnl Need the head -1 otherwise test will work because arguments are found
800 elif ps -laxnwww 2>/dev/null | head -1 | \
801         egrep -i ["^ *F(LAGS)? +UID +PID +PPID +CP +PRI +NI +(SZ)|(VSZ)|(SIZE) +RSS +WCHAN +STAT? +TTY? +TIME +COMMAND"] >/dev/null
802 then
803         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]"
804         ac_cv_ps_command="$PATH_TO_PS -laxnwww"
805         ac_cv_ps_format="%*s %d %d %d %*s %*s %*s %d %d %*s %s %*s %*s %n%s"
806         ac_cv_ps_cols=9
807         AC_MSG_RESULT([$ac_cv_ps_command])
809 dnl Debian Linux / procps v1.2.9:
810 dnl  FLAGS   UID   PID  PPID PRI  NI   SIZE   RSS WCHAN       STA TTY TIME COMMAND
811 dnl    100     0     1     0   0   0    776    76  c0131c8c   S  ffff  0:11 init [2]
813 elif ps laxnwww 2>/dev/null | \
814         egrep -i ["^ *F(LAGS)? +UID +PID +PPID +PRI +NI +(VSZ)|(SIZE) +RSS +WCHAN +STAT? TTY +TIME +COMMAND"] >/dev/null
815 then
816         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,procstat,&procvsz,&procrss,&pos,procprog]"
817         ac_cv_ps_command="$PATH_TO_PS laxnwww"
818         ac_cv_ps_format="%*s %d %d %d %*s %*s %d %d %*s %s %*s %*s %n%s"
819         ac_cv_ps_cols=9
820         AC_MSG_RESULT([$ac_cv_ps_command])
822 dnl OpenBSD (needs to come early because -exo appears to work, but does not give all procs)
823 elif ps -axo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
824         egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[PID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null
825 then
826         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
827         ac_cv_ps_command="$PATH_TO_PS -axo 'stat uid pid ppid vsz rss pcpu comm args'"
828         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
829         ac_cv_ps_cols=9
830         AC_MSG_RESULT([$ac_cv_ps_command])
832 dnl Tru64 - needs %*[ +<>] in PS_FORMAT.
833 dnl Has /usr/bin/ps and /sbin/ps - force sbin version
834 dnl Can't use vsize and rssize because comes back with text (eg, 1.5M instead
835 dnl of 1500). Will need big changes to check_procs to support
836 elif /sbin/ps -eo 'stat uid pid ppid pcpu etime comm args' 2>/dev/null | \
837         egrep -i ["^ *S +[UID]+ +[PID]+ +[PID]+ +[%CPU]+ +[ELAPSD]+ +[COMMAND]+ +[COMMAND]+"] > /dev/null
838 then
839         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procpcpu,procetime,procprog,&pos]"
840         ac_cv_ps_command="/sbin/ps -eo 'stat uid pid ppid pcpu etime comm args'"
841         ac_cv_ps_format=["%s%*[ +<>] %d %d %d %f %s %s %n"]
842         ac_cv_ps_cols=8
843         AC_MSG_RESULT([$ac_cv_ps_command])
845 elif ps -eo 's comm vsz rss user uid pid ppid args' 2>/dev/null | \
846         egrep -i ["^S[TAUES]* +C[OMDNA]+ +[VSIZE]+ +U[SER]+ +U[ID]+ +P[PID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null
847 then
848         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
849         ac_cv_ps_command="$PATH_TO_PS -eo 's uid pid ppid vsz rss pcpu comm args'"
850         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
851         ac_cv_ps_cols=9
852         AC_MSG_RESULT([$ac_cv_ps_command])
854 dnl AIX 4.3.3 and 5.1 do not have an rss field
855 elif ps -eo 'stat uid pid ppid vsz pcpu comm args' 2>/dev/null | \
856         egrep -i ["^ *S[TAUES]* +UID +PID +PPID +VSZ +%CPU +COMMAND +COMMAND"] >/dev/null
857 then
858         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procpcpu,procprog,&pos]"
859         ac_cv_ps_command="$PATH_TO_PS -eo 'stat uid pid ppid vsz pcpu comm args'"
860         ac_cv_ps_format="%s %d %d %d %d %f %s %n"
861         ac_cv_ps_cols=8
862         AC_MSG_RESULT([$ac_cv_ps_command - with no RSS])
864 dnl Solaris 2.6
865 elif ps -Ao 's comm vsz rss uid user pid ppid args' 2>/dev/null | \
866         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
867 then
868         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
869         ac_cv_ps_command="$PATH_TO_PS -Ao 's uid pid ppid vsz rss pcpu comm args'"
870         # There must be no space between the %s and %n due to a wierd problem in sscanf where
871         # it will return %n as longer than the line length
872         ac_cv_ps_format="%s %d %d %d %d %d %f %s%n"
873         ac_cv_ps_cols=9
874         AC_MSG_RESULT([$ac_cv_ps_command])
876 elif ps -Ao 'status comm vsz rss uid user pid ppid args' 2>/dev/null | \
877         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
878 then
879         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
880         ac_cv_ps_command="$PATH_TO_PS -Ao 'status uid pid ppid vsz rss pcpu comm args'"
881         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
882         ac_cv_ps_cols=9
883         AC_MSG_RESULT([$ac_cv_ps_command])
885 elif ps -Ao 'state comm vsz rss uid user pid ppid args' 2>/dev/null | \
886         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
887 then
888         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
889         ac_cv_ps_command="$PATH_TO_PS -Ao 'state uid pid ppid vsz rss pcpu comm args'"
890         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
891         ac_cv_ps_cols=9
892         AC_MSG_RESULT([$ac_cv_ps_command])
894 dnl wonder who takes state instead of stat
895 elif ps -ao 'state command vsz rss user pid ppid args' 2>/dev/null | \
896         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
897 then
898         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
899         ac_cv_ps_command="$PATH_TO_PS -ao 'state uid pid ppid vsz rss pcpu command args'"
900         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
901         ac_cv_ps_cols=8
902         AC_MSG_RESULT([$ac_cv_ps_command])
904 dnl IRIX 53
905 elif ps -el 2>/dev/null | \
906         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
907 then
908         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&pos,procprog]"
909         ac_cv_ps_command="$PATH_TO_PS -el (IRIX 53)"
910         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %d %d %*s %*s %*s %n%s"
911         ac_cv_ps_cols=8
912         AC_MSG_RESULT([$ac_cv_ps_command])
914 dnl IRIX 63
915 elif ps -el 2>/dev/null | \
916         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +ADDR +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
917 then
918         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
919         ac_cv_ps_command="$PATH_TO_PS -el (IRIX 63)"
920         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
921         ac_cv_ps_cols=6
922         AC_MSG_RESULT([$ac_cv_ps_command])
924 dnl AIX 4.1:
925 dnl     F S      UID   PID  PPID   C PRI NI ADDR  SZ  RSS   WCHAN    TTY  TIME CMD
926 dnl    303 A        0     0     0 120  16 -- 1c07  20   24              -  0:45 swapper
927 elif ps -el 2>/dev/null | \
928         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +ADDR +SZ +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
929 then
930         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
931         ac_cv_ps_command="$PATH_TO_PS -el (AIX 4.1 and HP-UX)"
932         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
933         ac_cv_ps_cols=6
934         AC_MSG_RESULT([$ac_cv_ps_command])
936 dnl AIX?
937 elif ps glaxen 2>/dev/null | \
938         egrep -i ["^ *F +UID +PID +PPID +PRI +NI +VSZ +RSS +WCHAN +STAT +TTY +TIME +COMMAND"] >/dev/null
939 then
940         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]"
941         ac_cv_ps_command="$PATH_TO_PS glaxen"
942         ac_cv_ps_format="%*s %d %d %d %*s %*s %d %d %*s %s %*s %*s %n%s"
943         ac_cv_ps_cols=8
944         AC_MSG_RESULT([$ac_cv_ps_command])
946 dnl MacOSX / Darwin
947 dnl TODO: MacOSX has commands with spaces which will cause problems to PS_FORMAT
948 dnl Some truncation will happen in UCOMM column
949 dnl STAT      VSZ    RSS   UID  PPID %CPU UCOMM            COMMAND
950 dnl Ss      52756  22496   501     1   6.9 Window Manager   /System/Library/CoreServices/WindowServer -daemon
951 elif ps wwaxo 'state vsz rss uid pid ppid pcpu ucomm command' 2>/dev/null | \
952         egrep -i ["^STAT +VSZ +RSS +UID +PPID +%CPU +UCOMM +COMMAND"] >/dev/null
953 then
954         ac_cv_ps_command="$PATH_TO_PS wwaxo 'state vsz rss uid pid ppid pcpu ucomm command'"
955         ac_cv_ps_varlist="[procstat,&procvsz,&procrss,&procuid,&procpid,&procppid,&procpcpu,procprog,&pos]"
956         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
957         ac_cv_ps_cols=8
958         AC_MSG_RESULT([$ac_cv_ps_command])
960 dnl UnixWare
961 elif ps -Al 2>/dev/null | \
962         egrep -i ["^ *F +S +UID +PID +PPID +CLS +PRI +NI +C +ADDR +SZ +WCHAN +TTY +TIME +COMD"] >/dev/null
963 then
964         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
965         ac_cv_ps_command="$PATH_TO_PS -Al"
966         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
967         ac_cv_ps_cols=8
968         AC_MSG_RESULT([$ac_cv_ps_command])
970 else
971         AC_MSG_WARN([unable to find usable ps syntax - check_procs and check_nagios will not be compiled])
974 if test -n "$ac_cv_ps_varlist" ; then
975         AC_DEFINE_UNQUOTED(PS_VARLIST,$ac_cv_ps_varlist,
976                 [Variable list for sscanf of 'ps' output])
977         AC_DEFINE_UNQUOTED(PS_COMMAND,"$ac_cv_ps_command",
978                 [Verbatim command to execute for ps in check_procs])
979         AC_DEFINE_UNQUOTED(PS_FORMAT,"$ac_cv_ps_format",
980                 [Format string for scanning ps output in check_procs])
981         AC_DEFINE_UNQUOTED(PS_COLS,$ac_cv_ps_cols,
982                 [Number of columns in ps command])
983         EXTRAS="$EXTRAS check_procs check_nagios"
984         if echo "$ac_cv_ps_varlist" | grep "procetime" >/dev/null; then
985                 AC_DEFINE(PS_USES_PROCETIME,"yes",
986                           [Whether the ps utility uses the "procetime" field])
987         fi
990 AC_PATH_PROG(PATH_TO_PING,ping)
991 AC_PATH_PROG(PATH_TO_PING6,ping6)
993 AC_ARG_WITH(ping_command,
994         ACX_HELP_STRING([--with-ping-command=SYNTAX],
995                 [sets syntax for ICMP ping]),
996         with_ping_command=$withval,)
998 AC_MSG_CHECKING(for ICMP ping syntax)
999 ac_cv_ping_packets_first=no
1000 ac_cv_ping_has_timeout=no
1001 if test -n "$with_ping_command"
1002 then
1003         AC_MSG_RESULT([(command-line) $with_ping_command])
1004         if echo "$with_ping_command" | grep '%d.*%d.*%s' >/dev/null
1005         then
1006                 ac_cv_ping_packets_first=yes
1007                 ac_cv_ping_has_timeout=yes
1008         elif echo "$with_ping_command" | grep '%d.*%s.*%d' >/dev/null || \
1009              echo "$with_ping_command" | grep '%s.*%d.*%d' >/dev/null
1010         then
1011                 ac_cv_ping_has_timeout=yes
1012         elif echo "$with_ping_command" | grep '%d.*%s' >/dev/null
1013         then
1014                 ac_cv_ping_packets_first=yes
1015         fi
1017 elif [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
1018         $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
1019         egrep -i "^round-trip|^rtt" >/dev/null
1020 then
1021         with_ping_command="$PATH_TO_PING -n -U -c %d %s"
1022         ac_cv_ping_packets_first=yes
1023         AC_MSG_RESULT([$with_ping_command])
1025 elif $PATH_TO_PING -n -U -w 10 -c 1 127.0.0.1 2>/dev/null | \
1026         egrep -i "^round-trip|^rtt" >/dev/null
1027 then
1028         with_ping_command="$PATH_TO_PING -n -U -w %d -c %d %s"
1029         ac_cv_ping_packets_first=yes
1030   ac_cv_ping_has_timeout=yes
1031         AC_MSG_RESULT([$with_ping_command])
1033 elif $PATH_TO_PING -n -U -c 1 127.0.0.1 2>/dev/null | \
1034         egrep -i "^round-trip|^rtt" >/dev/null
1035 then
1036         with_ping_command="$PATH_TO_PING -n -U -c %d %s"
1037         ac_cv_ping_packets_first=yes
1038         AC_MSG_RESULT([$with_ping_command])
1040 elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \
1041         egrep -i "^round-trip|^rtt" >/dev/null
1042 then
1043         with_ping_command="$PATH_TO_PING -n -c %d %s"
1044         ac_cv_ping_packets_first=yes
1045         AC_MSG_RESULT([$with_ping_command])
1047 elif $PATH_TO_PING -n 127.0.0.1 -c 1 2>/dev/null | \
1048         egrep -i "^round-trip|^rtt" >/dev/null
1049 then
1050         with_ping_command="$PATH_TO_PING -n %s -c %d"
1051         AC_MSG_RESULT([$with_ping_command])
1053 elif $PATH_TO_PING 127.0.0.1 -n 1 2>/dev/null | \
1054         egrep -i "^round-trip|^rtt" >/dev/null
1055 then
1056         with_ping_command="$PATH_TO_PING %s -n %d"
1057         AC_MSG_RESULT([$with_ping_command])
1059 elif $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
1060         egrep -i "^round-trip|^rtt" >/dev/null
1061 then
1062         with_ping_command="$PATH_TO_PING -n -s %s 56 %d"
1063         AC_MSG_RESULT([$with_ping_command])
1065 elif $PATH_TO_PING -n -h 127.0.0.1 -s 56 -c 1 2>/dev/null | \
1066         egrep -i "^round-trip|^rtt" >/dev/null
1067 then
1068         with_ping_command="$PATH_TO_PING -n -h %s -s 56 -c %d"
1069         AC_MSG_RESULT([$with_ping_command])
1071 elif $PATH_TO_PING -n -s 56 -c 1 127.0.0.1 2>/dev/null | \
1072         egrep -i "^round-trip|^rtt" >/dev/null
1073 then
1074         with_ping_command="$PATH_TO_PING -n -s 56 -c %d %s"
1075         ac_cv_ping_packets_first=yes
1076         AC_MSG_RESULT([$with_ping_command])
1078 elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \
1079         egrep -i "^round-trip|^rtt" >/dev/null
1080 then
1081         with_ping_command="$PATH_TO_PING -n -c %d %s"
1082         ac_cv_ping_packets_first=yes
1083         AC_MSG_RESULT([$with_ping_command])
1085 else
1086         AC_MSG_WARN([unable to find usable ping syntax])
1089 AC_DEFINE_UNQUOTED(PING_COMMAND,"$with_ping_command",
1090         [path and args for ICMP ping command])
1092 if test "x$ac_cv_ping_packets_first" != "xno"
1093 then
1094         AC_DEFINE(PING_PACKETS_FIRST,1,
1095                 [Define if packet count must precede host])
1098 if test "x$ac_cv_ping_has_timeout" != "xno"
1099 then
1100         AC_DEFINE(PING_HAS_TIMEOUT,1,
1101                 [Define if ping has its own timeout option that should be set])
1104 AC_ARG_WITH(ping6_command,
1105         ACX_HELP_STRING([--with-ping6-command=SYNTAX],
1106                 [sets syntax for ICMPv6 ping]),
1107         with_ping6_command=$withval,)
1109 if test x"$with_ipv6" != xno ; then
1110 AC_MSG_CHECKING(for ICMPv6 ping syntax)
1111 ac_cv_ping6_packets_first=no
1112 if test -n "$with_ping6_command"
1113 then
1114         AC_MSG_RESULT([(command-line) $with_ping6_command])
1115         if echo "$with_ping6_command" | grep '%d.*%d.*%s' >/dev/null
1116         then
1117                 ac_cv_ping6_packets_first=yes
1118         elif echo "$with_ping6_command" | grep '%d.*%s.*%d' >/dev/null || \
1119              echo "$with_ping6_command" | grep '%s.*%d.*%d' >/dev/null
1120         then
1121                 # Just keep same logic as ping (IPv4) if we ever need ac_cv_ping6_has_timeout
1122                 true
1123         elif echo "$with_ping6_command" | grep '%d.*%s' >/dev/null
1124         then
1125                 ac_cv_ping6_packets_first=yes
1126         fi
1128 elif test "x$PATH_TO_PING6" != "x"; then
1129         if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
1130                 $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \
1131                 egrep -i "^round-trip|^rtt" >/dev/null
1132         then
1133                 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s"
1134                 ac_cv_ping6_packets_first=yes
1135                 AC_MSG_RESULT([$with_ping6_command])
1137         elif $PATH_TO_PING6 -n -U -w 10 -c 1 ::1 2>/dev/null | \
1138                 egrep -i "^round-trip|^rtt" >/dev/null
1139         then
1140                 with_ping6_command="$PATH_TO_PING6 -n -U -w %d -c %d %s"
1141                 ac_cv_ping6_packets_first=yes
1142                 ac_cv_ping_has_timeout=yes
1143                 AC_MSG_RESULT([$with_ping6_command])
1145         elif $PATH_TO_PING6 -n -U -c 1 ::1 2>/dev/null | \
1146                 egrep -i "^round-trip|^rtt" >/dev/null
1147         then
1148                 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s"
1149                 ac_cv_ping6_packets_first=yes
1150                 AC_MSG_RESULT([$with_ping6_command])
1152         elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \
1153                 egrep -i "^round-trip|^rtt" >/dev/null
1154         then
1155                 with_ping6_command="$PATH_TO_PING6 -n -c %d %s"
1156                 ac_cv_ping6_packets_first=yes
1157                 AC_MSG_RESULT([$with_ping6_command])
1159         elif $PATH_TO_PING6 -n ::1 -c 1 2>/dev/null | \
1160                 egrep -i "^round-trip|^rtt" >/dev/null
1161         then
1162                 with_ping6_command="$PATH_TO_PING6 -n %s -c %d"
1163                 AC_MSG_RESULT([$with_ping6_command])
1165         elif $PATH_TO_PING6 ::1 -n 1 2>/dev/null | \
1166                 egrep -i "^round-trip|^rtt" >/dev/null
1167         then
1168                 with_ping6_command="$PATH_TO_PING6 %s -n %d"
1169                 AC_MSG_RESULT([$with_ping6_command])
1171         elif $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \
1172                 egrep -i "^round-trip|^rtt" >/dev/null
1173         then
1174                 with_ping6_command="$PATH_TO_PING6 -n -s %s 56 %d"
1175                 AC_MSG_RESULT([$with_ping6_command])
1177         elif $PATH_TO_PING6 -n -h ::1 -s 56 -c 1 2>/dev/null | \
1178                 egrep -i "^round-trip|^rtt" >/dev/null
1179         then
1180                 with_ping6_command="$PATH_TO_PING6 -n -h %s -s 56 -c %d"
1181                 AC_MSG_RESULT([$with_ping6_command])
1183         elif $PATH_TO_PING6 -n -s 56 -c 1 ::1 2>/dev/null | \
1184                 egrep -i "^round-trip|^rtt" >/dev/null
1185         then
1186                 with_ping6_command="$PATH_TO_PING6 -n -s 56 -c %d %s"
1187                 ac_cv_ping6_packets_first=yes
1188                 AC_MSG_RESULT([$with_ping_command])
1190         elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \
1191                 egrep -i "^round-trip|^rtt" >/dev/null
1192         then
1193                 with_ping6_command="$PATH_TO_PING6 -n -c %d %s"
1194                 ac_cv_ping6_packets_first=yes
1195                 AC_MSG_RESULT([$with_ping6_command])
1197         fi
1199 elif test "x$PATH_TO_PING" != "x"; then
1200         if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
1201                 $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \
1202                 egrep -i "^round-trip|^rtt" >/dev/null
1203         then
1204                 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s"
1205                 ac_cv_ping6_packets_first=yes
1206                 AC_MSG_RESULT([$with_ping6_command])
1208         elif $PATH_TO_PING -A inet6 -n -U -c 1 ::1 2>/dev/null | \
1209                 egrep -i "^round-trip|^rtt" >/dev/null
1210         then
1211                 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s"
1212                 ac_cv_ping6_packets_first=yes
1213                 AC_MSG_RESULT([$with_ping6_command])
1215         elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \
1216                 egrep -i "^round-trip|^rtt" >/dev/null
1217         then
1218                 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s"
1219                 ac_cv_ping6_packets_first=yes
1220                 AC_MSG_RESULT([$with_ping6_command])
1222         elif $PATH_TO_PING -A inet6 -n ::1 -c 1 2>/dev/null | \
1223                 egrep -i "^round-trip|^rtt" >/dev/null
1224         then
1225                 with_ping6_command="$PATH_TO_PING -A inet6 -n %s -c %d"
1226                 AC_MSG_RESULT([$with_ping6_command])
1228         elif $PATH_TO_PING -A inet6 ::1 -n 1 2>/dev/null | \
1229                 egrep -i "^round-trip|^rtt" >/dev/null
1230         then
1231                 with_ping6_command="$PATH_TO_PING -A inet6 %s -n %d"
1232                 AC_MSG_RESULT([$with_ping6_command])
1234         elif $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \
1235                 egrep -i "^round-trip|^rtt" >/dev/null
1236         then
1237                 with_ping6_command="$PATH_TO_PING -A inet6 -n -s %s 56 %d"
1238                 AC_MSG_RESULT([$with_ping6_command])
1240         elif $PATH_TO_PING -A inet6 -n -h ::1 -s 56 -c 1 2>/dev/null | \
1241                 egrep -i "^round-trip|^rtt" >/dev/null
1242         then
1243                 with_ping6_command="$PATH_TO_PING -A inet6 -n -h %s -s 56 -c %d"
1244                 AC_MSG_RESULT([$with_ping6_command])
1246         elif $PATH_TO_PING -A inet6 -n -s 56 -c 1 ::1 2>/dev/null | \
1247                 egrep -i "^round-trip|^rtt" >/dev/null
1248         then
1249                 with_ping6_command="$PATH_TO_PING -A inet6 -n -s 56 -c %d %s"
1250                 ac_cv_ping6_packets_first=yes
1251                 AC_MSG_RESULT([$with_ping_command])
1253         elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \
1254                 egrep -i "^round-trip|^rtt" >/dev/null
1255         then
1256                 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s"
1257                 ac_cv_ping6_packets_first=yes
1258                 AC_MSG_RESULT([$with_ping6_command])
1260         fi
1264 if test "x$with_ping6_command" != "x"; then
1265         AC_DEFINE_UNQUOTED(PING6_COMMAND,"$with_ping6_command",
1266                 [path and args for ICMPv6 ping command])
1267 else
1268         AC_MSG_RESULT([none])
1271 if test "x$ac_cv_ping6_packets_first" != "xno"; then
1272         AC_DEFINE(PING6_PACKETS_FIRST,1,
1273                 [Define if packet count must precede host])
1278 AC_ARG_WITH(nslookup_command,
1279             ACX_HELP_STRING([--with-nslookup-command=PATH],
1280                             [sets path to nslookup executable]),
1281             ac_cv_nslookup_command=$withval)
1282 if test -n "$ac_cv_nslookup_command"; then
1283         AC_MSG_NOTICE([Using specific nslookup at $ac_cv_nslookup_command])
1284 else
1285         AC_PATH_PROG(PATH_TO_NSLOOKUP,nslookup)
1286         if test -n "$PATH_TO_NSLOOKUP"
1287         then
1288                 AC_MSG_CHECKING(for nslookup syntax)
1289                 if $PATH_TO_NSLOOKUP -sil 127.0.0.1 2>&1 | grep ["Invalid option: sil"] >/dev/null
1290                 then
1291                         ac_cv_nslookup_command="$PATH_TO_NSLOOKUP"
1292                         AC_MSG_RESULT([$ac_cv_nslookup_command])
1294                 else
1295                         ac_cv_nslookup_command="$PATH_TO_NSLOOKUP -sil"
1296                         AC_MSG_RESULT([$ac_cv_nslookup_command])
1298                 fi
1299         else
1300                 AC_MSG_WARN([nslookup command not found])
1301         fi
1304 if test -n "$ac_cv_nslookup_command"; then
1305         EXTRAS="$EXTRAS check_dns"
1306         AC_DEFINE_UNQUOTED(NSLOOKUP_COMMAND,"$ac_cv_nslookup_command", [path and args for nslookup])
1309 AC_MSG_CHECKING([for number of online cpus])
1310 AC_TRY_COMPILE([#include <unistd.h>],
1311         [sysconf(_SC_NPROCESSORS_ONLN) > 0;],
1312         AC_DEFINE(HAVE_SYSCONF__SC_NPROCESSORS_ONLN,1,[Define if sysconf returns number of online cpus])
1313         AC_MSG_RESULT([sysconf(_SC_NPROCESSORS_ONLN)]),
1314         AC_MSG_RESULT([cannot calculate])
1315         )
1317 AC_MSG_CHECKING([for number of available cpus])
1318 AC_TRY_COMPILE([#include <unistd.h>],
1319         [sysconf(_SC_NPROCESSORS_CONF) > 0;],
1320         AC_DEFINE(HAVE_SYSCONF__SC_NPROCESSORS_CONF,1,[Define if sysconf returns number of available cpus])
1321         AC_MSG_RESULT([sysconf(_SC_NPROCESSORS_CONF)]),
1322         AC_MSG_RESULT([cannot calculate])
1323         )
1325 AC_PATH_PROG(PATH_TO_UPTIME,uptime)
1326 AC_ARG_WITH(uptime_command,
1327             ACX_HELP_STRING([--with-uptime-command=PATH],
1328                             [sets path to uptime]), PATH_TO_UPTIME=$withval)
1329 AC_DEFINE_UNQUOTED(PATH_TO_UPTIME,"$PATH_TO_UPTIME",[path to uptime binary])
1331 AC_PATH_PROG(PATH_TO_RPCINFO,rpcinfo)
1332 AC_ARG_WITH(rpcinfo_command,
1333             ACX_HELP_STRING([--with-rpcinfo-command=PATH],
1334                             [sets path to rpcinfo]), PATH_TO_RPCINFO=$withval)
1335 AC_DEFINE_UNQUOTED(PATH_TO_RPCINFO,"$PATH_TO_RPCINFO",[path to rpcinfo binary])
1337 AC_PATH_PROG(PATH_TO_LMSTAT,lmstat)
1338 if test -x "$PATH_TO_LMSTAT"
1339 then
1340         AC_DEFINE_UNQUOTED(PATH_TO_LMSTAT,"$PATH_TO_LMSTAT",[path to lmstat])
1341 else
1342         AC_MSG_WARN([Get lmstat from Globetrotter Software to monitor flexlm licenses])
1345 AC_PATH_PROG(PATH_TO_SMBCLIENT,smbclient)
1346 AC_ARG_WITH(smbclient_command,
1347             ACX_HELP_STRING([--with-smbclient-command=PATH],
1348                             [sets path to smbclient]),
1349             PATH_TO_SMBCLIENT=$withval)
1350 if test -n "$PATH_TO_SMBCLIENT"
1351 then
1352         AC_DEFINE_UNQUOTED(PATH_TO_SMBCLIENT,"$PATH_TO_SMBCLIENT",[path to smbclient binary])
1353 else
1354         AC_MSG_WARN([Get smbclient from Samba.org to monitor SMB shares])
1357 AC_PATH_PROG(PATH_TO_SNMPGET,snmpget)
1358 AC_ARG_WITH(snmpget_command,
1359             ACX_HELP_STRING([--with-snmpget-command=PATH],
1360                             [Path to snmpget command]),
1361             PATH_TO_SNMPGET=$withval)
1362 if test -n "$PATH_TO_SNMPGET"
1363 then
1364         AC_DEFINE_UNQUOTED(PATH_TO_SNMPGET,"$PATH_TO_SNMPGET",[path to snmpget binary])
1365         EXTRAS="$EXTRAS check_hpjd check_snmp"
1366 else
1367         AC_MSG_WARN([Get snmpget from http://net-snmp.sourceforge.net to make check_hpjd and check_snmp plugins])
1370 AC_PATH_PROG(PATH_TO_SNMPGETNEXT,snmpgetnext)
1371 AC_ARG_WITH(snmpgetnext_command,
1372             ACX_HELP_STRING([--with-snmpgetnext-command=PATH],
1373                             [Path to snmpgetnext command]),
1374             PATH_TO_SNMPGETNEXT=$withval)
1375 if test -n "$PATH_TO_SNMPGETNEXT"
1376 then
1377         AC_DEFINE_UNQUOTED(PATH_TO_SNMPGETNEXT,"$PATH_TO_SNMPGETNEXT",[path to snmpgetnext binary])
1380 if ( $PERL -M"Net::SNMP 3.6" -e 'exit' 2>/dev/null  )
1381 then
1382         AC_MSG_CHECKING(for Net::SNMP perl module)
1383         AC_MSG_RESULT([found])
1384 else
1385         AC_MSG_WARN([Tried $PERL - install Net::SNMP perl module if you want to use the perl snmp plugins])
1388 AC_PATH_PROG(PATH_TO_QUAKESTAT,quakestat)
1389 AC_PATH_PROG(PATH_TO_QSTAT,qstat)
1390 AC_ARG_WITH(qstat_command,
1391             ACX_HELP_STRING([--with-qstat-command=PATH],
1392                             [Path to qstat command]), PATH_TO_QSTAT=$withval)
1394 if test -x "$PATH_TO_QUAKESTAT"
1395 then
1396         ac_cv_path_to_qstat="$PATH_TO_QUAKESTAT"
1397         EXTRAS="$EXTRAS check_game"
1399 elif test -n "$PATH_TO_QSTAT"
1400 then
1401         ac_cv_path_to_qstat="$PATH_TO_QSTAT"
1402         EXTRAS="$EXTRAS check_game"
1403 else
1404         AC_MSG_WARN([Get qstat from http://www.activesw.com/people/steve/qstat.html in order to make check_game plugin])
1407 if test $ac_cv_path_to_qstat
1408 then
1409         AC_DEFINE_UNQUOTED(PATH_TO_QSTAT,"$ac_cv_path_to_qstat",
1410                 [path to qstat/quakestat])
1413 AC_PATH_PROG(PATH_TO_FPING,fping)
1414 AC_PATH_PROG(PATH_TO_FPING6,fping6)
1416 AC_ARG_WITH(fping_command,
1417             ACX_HELP_STRING([--with-fping-command=PATH],
1418                             [Path to fping command]), PATH_TO_FPING=$withval)
1419 AC_ARG_WITH(fping6_command,
1420             ACX_HELP_STRING([--with-fping6-command=PATH],
1421                             [Path to fping6 command]), PATH_TO_FPING6=$withval)
1423 if test -n "$PATH_TO_FPING"
1424 then
1425         AC_DEFINE_UNQUOTED(PATH_TO_FPING,"$PATH_TO_FPING",[path to fping])
1426         EXTRAS="$EXTRAS check_fping"
1427         if test x"$with_ipv6" != xno && test -n "$PATH_TO_FPING6"; then
1428                 AC_DEFINE_UNQUOTED(PATH_TO_FPING6,"$PATH_TO_FPING6",[path to fping6])
1429         fi
1430 else
1431         AC_MSG_WARN([Get fping from http://www.fping.com in order to make check_fping plugin])
1434 AC_PATH_PROG(PATH_TO_SSH,ssh)
1435 AC_ARG_WITH(ssh_command,
1436             ACX_HELP_STRING([--with-ssh-command=PATH],
1437                             [sets path for ssh]), PATH_TO_SSH=$withval)
1438 if test -n "$PATH_TO_SSH"
1439 then
1440         AC_DEFINE_UNQUOTED(SSH_COMMAND,"$PATH_TO_SSH",[path to ssh binary])
1441         EXTRAS="$EXTRAS check_by_ssh"
1442 else
1443         AC_MSG_WARN([Get ssh in order to make check_by_ssh plugin])
1447 AC_PATH_PROG(PATH_TO_MAILQ,mailq)
1448 AC_ARG_WITH(mailq_command,
1449             ACX_HELP_STRING([--with-mailq-command=PATH],
1450                             [sets path to mailq]), PATH_TO_MAILQ=$withval)
1451 if test -n "$PATH_TO_MAILQ"
1452 then
1453         AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_MAILQ",[path to mailq])
1454 else
1455         AC_MSG_WARN([Could not find mailq or eqivalent])
1458 AC_PATH_PROG(PATH_TO_QMAIL_QSTAT,qmail-qstat)
1459 if test -x "$PATH_TO_QMAIL_QSTAT"
1460 then
1461         AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_QMAIL_QSTAT",[path to qmail-qstat])
1462 else
1463         AC_MSG_WARN([Could not find qmail-qstat or eqivalent])
1466 dnl SWAP info required is amount allocated/available and amount free
1467 dnl The plugin works through all the swap devices and adds up the total swap
1468 dnl available.
1469 AC_PATH_PROG(PATH_TO_SWAP,swap)
1470 if (test -n "$PATH_TO_SWAP")
1471 then
1472 AC_MSG_CHECKING([for $PATH_TO_SWAP format])
1473 if [$PATH_TO_SWAP -l 2>&1 >/dev/null]
1474 then
1475         ac_cv_have_swap=yes
1476         ac_cv_swap_command="$PATH_TO_SWAP -l"
1477         if [$PATH_TO_SWAP -l 2>/dev/null | \
1478                 egrep -i "^lswap +path +pri +swaplo +blocks +free +maxswap" \
1479                 >/dev/null]
1480         then
1481                 ac_cv_swap_format=[" %*d %*s %*d,%*d %*d %*d %f %f"]
1482                 ac_cv_swap_conv=2048
1483                 AC_MSG_RESULT([using IRIX format swap])
1485         elif [$PATH_TO_SWAP -l 2>/dev/null | egrep -i "^path +dev +swaplo +blocks +free" >/dev/null]
1486         then
1487                 ac_cv_swap_format=["%*s %*[0-9,-] %*d %f %f"]
1488                 ac_cv_swap_conv=2048
1489                 AC_MSG_RESULT([using Unixware format swap])
1490         else
1491                 dnl if we don't know what format swap's output is
1492                 dnl we might as well pretend we didn't see it
1493                 ac_cv_have_swap=""
1494                 ac_cv_swap_command=""
1495         fi
1497 dnl end if for PATH_TO_SWAP
1500 AC_PATH_PROG(PATH_TO_SWAPINFO,swapinfo)
1501 if (test -n "$PATH_TO_SWAPINFO")
1502 then
1503 AC_MSG_CHECKING([for $PATH_TO_SWAPINFO format])
1504 if [$PATH_TO_SWAPINFO -k 2>&1 | egrep -i "^Device" >/dev/null]
1505 then
1506         ac_cv_have_swap=yes
1507         ac_cv_swap_command="$PATH_TO_SWAPINFO -k"
1509         if [$PATH_TO_SWAPINFO -k 2>/dev/null | egrep -i "^Device +1K-blocks +Used +Avail" >/dev/null]
1510         then
1511                 ac_cv_swap_format=["%*s %f %*d %f"]
1512                 ac_cv_swap_conv=1024
1513                 AC_MSG_RESULT([using FreeBSD format swapinfo])
1514         fi
1516 elif [$PATH_TO_SWAPINFO -dfM 2>/dev/null | egrep -i "^TYPE +AVAIL +USED +FREE" >/dev/null]
1517 then
1518         ac_cv_have_swap=yes
1519         ac_cv_swap_command="$PATH_TO_SWAPINFO -dfM"
1520         ac_cv_swap_format=["%*s %f %*d %f"]
1521         ac_cv_swap_conv=1024
1522         AC_MSG_RESULT([using HP-UX format swapinfo])
1524 dnl end if for PATH_TO_SWAPINFO
1527 AC_PATH_PROG(PATH_TO_LSPS,lsps)
1528 if (test -n "$PATH_TO_LSPS")
1529 then
1530 AC_MSG_CHECKING([for $PATH_TO_LSPS format])
1531 if [$PATH_TO_LSPS -a 2>/dev/null | egrep -i "^Page Space" > /dev/null]
1532 then
1533         ac_cv_have_swap=yes
1534         ac_cv_swap_command="$PATH_TO_LSPS -a"
1535         ac_cv_swap_format=["%*s %*s %*s %f%*s %f %*s"]
1536         ac_cv_swap_conv=1
1537         AC_MSG_RESULT([using AIX lsps])
1539 dnl end if for PATH_TO_SWAPINFO
1543 dnl test for swapctl system call, both the 2-arg and 3-arg variants
1544 dnl fwict, the 2-arg is an SVR4 standard, whereas the 3-arg is shared
1545 dnl in the various BSD's
1548 AC_CHECK_HEADERS([sys/stat.h sys/param.h])
1549 AC_CHECK_HEADERS([sys/swap.h], [], [], [
1550 #ifdef HAVE_SYS_PARAM_H
1551 #include <sys/param.h>
1552 #endif
1554 AC_CHECK_DECLS([swapctl],,,[
1555                #include <unistd.h>
1556                #include <sys/types.h>
1557                #include <sys/param.h>
1558                #include <sys/stat.h>
1559                #include <sys/swap.h>
1560                ])
1561 AC_CHECK_TYPES([swaptbl_t, swapent_t],,,[
1562                #include <sys/types.h>
1563                #include <sys/param.h>
1564                #include <sys/stat.h>
1565                #include <sys/swap.h>
1566                ])
1567 AC_CHECK_MEMBERS([struct swapent.se_nblks],,,[
1568                  #include <unistd.h>
1569                  #include <sys/types.h>
1570                  #include <sys/param.h>
1571                  #include <sys/stat.h>
1572                  #include <sys/swap.h>
1573                  ])
1575 if test "$ac_cv_have_decl_swapctl" = "yes";
1576 then
1577         EXTRAS="$EXTRAS check_swap"
1578         AC_MSG_CHECKING([for 2-arg (SVR4) swapctl])
1579         if test "$ac_cv_type_swaptbl_t" = "yes" -a \
1580                 "$ac_cv_type_swapent_t" = "yes";
1581         then
1582                 AC_MSG_RESULT([yes])
1583                 ac_cv_check_swap_swapctl_svr4="1";
1584                 AC_DEFINE([CHECK_SWAP_SWAPCTL_SVR4],1,
1585                           [Define if 2-argument SVR4 swapctl exists])
1586         else
1587                 AC_MSG_RESULT([no])
1588                 AC_MSG_CHECKING([for 3-arg (*BSD) swapctl])
1589                 if test "$ac_cv_member_struct_swapent_se_nblks" = "yes";
1590                 then
1591                         AC_MSG_RESULT([yes])
1592                         AC_DEFINE([CHECK_SWAP_SWAPCTL_BSD],1,
1593                                   [Define if 3-argument BSD swapctl exists])
1594                 else
1595                         AC_MSG_RESULT([no])
1596                 fi
1597         fi
1598         AC_MSG_CHECKING([for whether swapctl uses blocks or pages])
1599         if test "$ac_cv_check_swap_swapctl_svr4" = "1";
1600         then
1601                 dnl
1602                 dnl the SVR4 spec returns values in pages
1603                 dnl
1604                 AC_MSG_RESULT([page])
1605                 AC_CHECK_DECLS([sysconf])
1606                 AC_MSG_CHECKING([for system page size])
1607                 if test "$ac_cv_have_decl_sysconf" = "yes";
1608                 then
1609                         AC_MSG_RESULT([determined by sysconf(3)])
1610                         ac_cv_swap_conv="(1048576/sysconf(_SC_PAGESIZE))"
1611                 else
1612                         AC_MSG_WARN([don't know. guessing 4096k])
1613                         ac_cv_swap_conv=256
1614                 fi
1615         else
1616                 dnl
1617                 dnl the BSD spec returns values in blocks
1618                 dnl
1619                 AC_MSG_RESULT([blocks (assuming 512b)])
1620                 ac_cv_swap_conv=2048
1621         fi
1622         AC_DEFINE_UNQUOTED(SWAP_CONVERSION,$ac_cv_swap_conv,
1623                 [Conversion factor to MB])
1626 dnl end tests for the swapctl system calls
1630 if test "x$ac_cv_have_swap" != "x"
1631 then
1632         AC_DEFINE(HAVE_SWAP,1,[Define if swap/swapinfo command is found])
1633         EXTRAS="$EXTRAS check_swap"
1635 if test "x$ac_cv_swap_command" != "x"
1636 then
1637         AC_DEFINE_UNQUOTED(SWAP_COMMAND,"$ac_cv_swap_command",
1638                 [Path to swap/swapinfo binary, with any args])
1639         AC_DEFINE_UNQUOTED(SWAP_FORMAT,"$ac_cv_swap_format",
1640                 [Format string for parsing swap output])
1641         AC_DEFINE_UNQUOTED(SWAP_CONVERSION,$ac_cv_swap_conv,
1642                 [Conversion factor to MB])
1645 AC_ARG_WITH(proc-meminfo,
1646             ACX_HELP_STRING([--with-proc-meminfo=PATH],
1647                             [path to /proc/meminfo or equivalent]),
1648                             ac_cv_proc_meminfo=$withval)
1649 dnl dunno why this does not work below - use hack (kbd)
1650 dnl fine on linux, broken on solaris
1651 dnl if /bin/test -e "/proc/meminfo"
1652 AC_MSG_CHECKING([for /proc/meminfo])
1653 if test -n "$ac_cv_proc_meminfo"; then
1654         AC_MSG_RESULT([(command line) $ac_cv_proc_meminfo])
1655 elif [cat /proc/meminfo > /dev/null 2>&1]; then
1656         AC_MSG_RESULT([found /proc/meminfo])
1657         ac_cv_proc_meminfo="/proc/meminfo"
1658 else
1659         AC_MSG_RESULT([no])
1662 if test -n "$ac_cv_proc_meminfo"; then
1663         AC_DEFINE(HAVE_PROC_MEMINFO,1,[Define if we have /proc/meminfo])
1664         AC_DEFINE_UNQUOTED(PROC_MEMINFO,"$ac_cv_proc_meminfo",[path to /proc/meminfo if name changes])
1665         EXTRAS="$EXTRAS check_swap"
1668 AC_PATH_PROG(PATH_TO_DIG,dig)
1669 AC_ARG_WITH(dig_command,
1670             ACX_HELP_STRING([--with-dig-command=PATH],
1671                             [Path to dig command]), PATH_TO_DIG=$withval)
1672 if test -n "$PATH_TO_DIG"; then
1673         EXTRAS="$EXTRAS check_dig"
1674         AC_DEFINE_UNQUOTED(PATH_TO_DIG,"$PATH_TO_DIG",[Path to dig command, if present])
1677 AC_PATH_PROG(PATH_TO_APTGET,apt-get)
1678 AC_ARG_WITH(apt-get_command,
1679             ACX_HELP_STRING([--with-apt-get-command=PATH],
1680                             [Path to apt-get command]),
1681                             with_apt_get_command=$withval,
1682                             with_apt_get_command=$PATH_TO_APTGET)
1683 AC_DEFINE_UNQUOTED(PATH_TO_APTGET,"$PATH_TO_APTGET",[Path to apt-get command, if present])
1684 if test -n "$PATH_TO_APTGET" ; then
1685         EXTRAS="$EXTRAS check_apt"
1689 if test -f $srcdir/plugins/check_nt.c ; then
1690   EXTRAS="$EXTRAS check_nt"
1694 dnl used in check_dhcp
1695 AC_CHECK_HEADERS(sys/sockio.h)
1697 case $host in
1698         *bsd*)
1699                 AC_DEFINE(__bsd__,1,[bsd specific code in check_dhcp.c])
1700         ;;
1701         *linux*)
1702                 AC_DEFINE(__linux__,1,[linux specific code in check_dhcp.c])
1703         ;;
1704         *sun* | *solaris*)
1705                 AC_DEFINE(__sun__,1,[sun specific code in check_dhcp.c])
1706         ;;
1707         *hpux*)
1708                 AC_DEFINE(__hpux__,1,[hpux specific code in check_dhcp.c])
1709         ;;
1710 esac
1712 AC_SUBST(EXTRAS)
1713 AC_SUBST(EXTRAS_ROOT)
1714 AC_SUBST(EXTRA_NETOBJS)
1715 AC_SUBST(DEPLIBS)
1717 AM_GNU_GETTEXT([external], [need-ngettext])
1718 AM_GNU_GETTEXT_VERSION(0.15)
1720 dnl Check for Redhat spopen problem
1721 dnl Wierd problem where ECHILD is returned from a wait call in error
1722 dnl Only appears to affect nslookup and dig calls. Only affects redhat around
1723 dnl 2.6.9-11 (okay in 2.6.9-5). Redhat investigating root cause
1724 dnl We patch plugins/popen.c
1725 dnl Need to add smp because uname different on those
1726 dnl Can force patch to be applied with --enable-redhat-pthread-workaround
1727 AC_ARG_ENABLE(redhat-pthread-workaround,
1728         AC_HELP_STRING([--enable-redhat-pthread-workaround],
1729                 [force Redhat patch to be applied (default: test system)]),
1730         [ac_cv_enable_redhat_pthread_workaround=$enableval],
1731         [ac_cv_enable_redhat_pthread_workaround=test])
1732 if test "$ac_cv_enable_redhat_pthread_workaround" = "test" ; then
1733         if echo $ac_cv_uname_r | egrep "\.EL(smp)?$" >/dev/null 2>&1 ; then
1734                 AC_MSG_NOTICE([See http://nagiosplugins.org/faq/compile/configure_appears_to_hang if this next part takes a long time])
1735                 AC_MSG_CHECKING(for redhat spopen problem)
1736                 ( cd config_test && make && make test ) > /dev/null 2>&1
1737                 if test $? -eq 0 ; then
1738                         AC_MSG_RESULT(okay)
1739                 else
1740                         AC_MSG_RESULT(error)
1741                         AC_DEFINE(REDHAT_SPOPEN_ERROR, 1, [Workaround on redhat in spopen])
1742                 fi
1743         fi
1744 elif test "$ac_cv_enable_redhat_pthread_workaround" = "yes" ; then
1745         AC_DEFINE(REDHAT_SPOPEN_ERROR, 1, [Forced workaround on redhat in spopen])
1748 dnl Perl modules
1749 AC_ARG_ENABLE(perl-modules,
1750         AC_HELP_STRING([--enable-perl-modules],
1751                 [Enables installation of Nagios::Plugin and its dependencies (default: no)]),
1752         [enable_perl_modules=$enableval],
1753         [enable_perl_modules=no])
1754 if test "$enable_perl_modules" = "yes" ; then
1755   AC_SUBST(PERLMODS_DIR,perlmods)
1758 # From Tap configure
1759 # Checks for libraries
1760 case "$host" in
1761         *-*-*freebsd4*)
1762                 LDFLAGS="$LDFLAGS -pthread"
1763                 HAVE_LIBPTHREAD=1
1764                 ;;
1765         *)
1766                 AC_CHECK_LIB(pthread, main)
1767                 ;;
1768 esac
1770 dnl External libraries - see ACKNOWLEDGEMENTS
1771 gl_INIT
1773 dnl Some helpful common compile errors checked here
1774 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
1775         AC_MSG_ERROR(No ar found for Solaris - is /usr/ccs/bin in PATH?)
1778 AC_OUTPUT(
1779   Makefile
1780   tap/Makefile
1781   lib/Makefile
1782   plugins/Makefile
1783   lib/tests/Makefile
1784   plugins-root/Makefile
1785   plugins-scripts/Makefile
1786   plugins-scripts/subst
1787   plugins-scripts/utils.pm
1788   plugins-scripts/utils.sh
1789   perlmods/Makefile
1790   command.cfg
1791   test.pl
1792   pkg/solaris/pkginfo
1793   po/Makefile.in
1797 dnl the ones below that are commented out need to be cleaned up
1798 dnl in the configure code above to use with_foo instead of ac_cv_foo
1799 dnl if we want them to show up here.  it'd also make the code cleaner.
1800 dnl i'll get to that on another rainy day :) -sf
1801 ACX_FEATURE([with],[apt-get-command])
1802 dnl ACX_FEATURE([with],[dig-command])
1803 dnl ACX_FEATURE([with],[fping-command])
1804 dnl ACX_FEATURE([with],[mailq-command])
1805 dnl ACX_FEATURE([with],[nslookup-command])
1806 ACX_FEATURE([with],[ping6-command])
1807 ACX_FEATURE([with],[ping-command])
1808 dnl ACX_FEATURE([with],[qstat-command])
1809 dnl ACX_FEATURE([with],[rpcinfo-command])
1810 dnl ACX_FEATURE([with],[smbclient-command])
1811 dnl ACX_FEATURE([with],[snmpget-command])
1812 dnl ACX_FEATURE([with],[snmpgetnext-command])
1813 dnl ACX_FEATURE([with],[ssh-command])
1814 dnl ACX_FEATURE([with],[uptime-command])
1816 dnl ACX_FEATURE([with],[proc-meminfo])
1817 dnl ACX_FEATURE([with],[ps-command])
1818 dnl ACX_FEATURE([with],[ps-format])
1819 dnl ACX_FEATURE([with],[ps-cols])
1820 dnl ACX_FEATURE([with],[ps-varlist])
1822 ACX_FEATURE([with],[ipv6])
1823 ACX_FEATURE([with],[mysql])
1824 ACX_FEATURE([with],[openssl])
1825 ACX_FEATURE([with],[gnutls])
1826 ACX_FEATURE([enable],[extra-opts])
1827 ACX_FEATURE([with],[perl])
1828 ACX_FEATURE([enable],[perl-modules])
1829 ACX_FEATURE([with],[cgiurl])
1830 ACX_FEATURE([with],[trusted-path])
1831 ACX_FEATURE([enable],[libtap])