Code

Default to search path for mysql_config
[nagiosplug.git] / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2 AC_REVISION ($Revision$)
3 AC_PREREQ(2.58)
4 AC_INIT(nagios-plugins,1.4.3)
5 AC_CONFIG_SRCDIR(NPTest.pm)
6 AM_INIT_AUTOMAKE([1.8.3])
7 AM_CONFIG_HEADER(config.h)
8 AC_CANONICAL_HOST
10 RELEASE=1
11 AC_SUBST(RELEASE)
13 AC_PREFIX_DEFAULT(/usr/local/nagios)
15 dnl Deprecated configure options
17 dnl Figure out how to invoke "install" and what install options to use.
18 AC_PROG_INSTALL
19 AC_SUBST(INSTALL)
21 dnl Must come very early on due to coreutils requirement
22 dnl Takes care of AC_GNU_SOURCE, AC_AIX and AC_MINIX
23 gl_USE_SYSTEM_EXTENSIONS
25 AC_PROG_CC
26 AC_PROG_CPP
27 AC_PROG_GCC_TRADITIONAL
28 AC_PROG_LIBTOOL
30 AC_PROG_MAKE_SET
31 AC_PROG_AWK
33 AC_FUNC_MALLOC
34 AC_FUNC_REALLOC
35 AC_FUNC_ERROR_AT_LINE
37 AC_CONFIG_LIBOBJ_DIR(lib)
38 AC_FUNC_GETLOADAVG([lib])
40 ifdef([AC_FUNC_STRTOD],[AC_FUNC_STRTOD],[AM_FUNC_STRTOD])
42 PLUGIN_TEST=`echo $srcdir/plugins/t/*.t|sed -e 's,\.*/plugins/,,g'`
43 AC_SUBST(PLUGIN_TEST)dnl
45 SCRIPT_TEST=`echo $srcdir/plugins-scripts/t/*.t|sed -e 's,\.*/plugins-scripts/,,g'`
46 AC_SUBST(SCRIPT_TEST)dnl
48 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"
49 AC_SUBST(WARRANTY)
51 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"
52 AC_SUBST(SUPPORT)
54 dnl CGIURL has changed for Nagios with 1.0 beta
55 AC_ARG_WITH(cgiurl,
56         ACX_HELP_STRING([--with-cgiurl=DIR],
57                 [sets URL for cgi programs]),
58         with_cgiurl=$withval,
59         with_cgiurl=/nagios/cgi-bin)
60 CGIURL="$with_cgiurl"
61 AC_DEFINE_UNQUOTED(CGIURL,"$CGIURL",[URL of CGI programs])
63 AC_ARG_WITH(nagios_user,
64         ACX_HELP_STRING([--with-nagios-user=USER],
65                 [set user name to run nagios]),
66         with_nagios_user=$withval,
67         with_nagios_user=nagios)
68 AC_ARG_WITH(nagios_group,
69         ACX_HELP_STRING([--with-nagios-group=GROUP],
70                 [set group name to run nagios]),
71         with_nagios_group=$withval,
72         with_nagios_group=nagios)
73 AC_SUBST(with_nagios_user)
74 AC_SUBST(with_nagios_group)
75 INSTALL_OPTS="-o $with_nagios_user -g $with_nagios_group"
76 AC_SUBST(INSTALL_OPTS)
78 AC_ARG_WITH(trusted_path,
79         ACX_HELP_STRING([--with-trusted-path=PATH],
80                 [sets trusted path for executables called by scripts (default=/bin:/sbin:/usr/bin:/usr/sbin)]),
81         with_trusted_path=$withval,
82         with_trusted_path=/bin:/sbin:/usr/bin:/usr/sbin)
83 AC_SUBST(with_trusted_path)
85 EXTRAS=
86 EXTRAS_ROOT=
87 dnl PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/etc:/usr/local/bin:/usr/local/sbin:$PATH
89 LDFLAGS="$LDFLAGS -L."
91 ac_cv_uname_m=`uname -m`
92 ac_cv_uname_s=`uname -s`
93 ac_cv_uname_r=`uname -r`
94 ac_cv_uname_v=`uname -v`
96 PKG_ARCH=`uname -p`
97 REV_DATESTAMP=`date '+%Y.%m.%d.%H.%M'`
98 REV_TIMESTAMP=`date '+%Y%m%d%H%M%S'`
100 AC_SUBST(PKG_ARCH)
101 AC_SUBST(REV_DATESTAMP)
102 AC_SUBST(REV_TIMESTAMP)
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"
131 fi
132 if test ! "$with_gnutls" = "" && test ! "$with_gnutls" = "no"; then
133         with_openssl="no"
134 fi
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"
142 dnl
143 dnl Check for miscellaneous stuff
144 dnl 
146 case $host_vender-$host_os in
147 osf*)
148         AC_DEFINE(_OSF_SOURCE,1,[OSF needs this for getaddrinfo])
149         ;;
150 esac
152 dnl
153 dnl Checks for libraries.
154 dnl
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)
162 dnl
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_SUBST(MATHLIBS)
168 dnl Check for libtap, to run perl-like tests
169 AC_CHECK_LIB(tap, plan_tests, 
170         EXTRA_TEST=test_utils
171         AC_SUBST(EXTRA_TEST)
172         )
174 dnl Check for PostgreSQL libraries
175 _SAVEDLIBS="$LIBS"
176 _SAVEDCPPFLAGS="$CPPFLAGS"
177 AC_ARG_WITH(pgsql,
178         ACX_HELP_STRING([--with-pgsql=DIR],
179                 [sets path to pgsql installation]),
180         PGSQL=$withval,)
181 AC_CHECK_LIB(crypt,main)
182 if test "$ac_cv_lib_crypt_main" = "yes"; then
183   if test -n "$PGSQL"; then
184     LDFLAGS="$LDFLAGS -L$PGSQL/lib"
185     CPPFLAGS="$CPPFLAGS -I$PGSQL/include"
186   fi
187   AC_CHECK_LIB(pq,PQsetdbLogin,,,-lcrypt)
188   if test "$ac_cv_lib_pq_PQsetdbLogin" = "yes"; then
189     AC_CHECK_HEADERS(pgsql/libpq-fe.h)
190     AC_CHECK_HEADERS(postgresql/libpq-fe.h)
191     AC_CHECK_HEADERS(libpq-fe.h)
192     if [[ -n "$PGSQL" -a "$ac_cv_header_libpq_fe_h" = "yes" ]]; then
193       PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
194       PGINCLUDE="-I$PGSQL/include"
195     elif test  "$ac_cv_header_pgsql_libpq_fe_h" = "yes"; then
196       PGLIBS="-lpq -lcrypt"
197       PGINCLUDE="-I/usr/include/pgsql"
198     elif test  "$ac_cv_header_postgresql_libpq_fe_h" = "yes"; then
199       PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
200       PGINCLUDE="-I/usr/include/postgresql"
201     elif test  "$ac_cv_header_libpq_fe_h" = "yes"; then
202       PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
203       PGINCLUDE="-I$PGSQL/include"
204     fi
205     if test -z "$PGINCLUDE"; then
206       AC_MSG_WARN([Skipping PostgreSQL plugin (check_pgsql)])
207       AC_MSG_WARN([install PostgreSQL headers to compile this plugin (see REQUIREMENTS).])
208     else
209       AC_SUBST(PGLIBS)
210       AC_SUBST(PGINCLUDE)
211       EXTRAS="$EXTRAS check_pgsql"
212     fi
213   else
214     AC_MSG_WARN([Skipping PostgreSQL plugin (check_pgsql)])
215     AC_MSG_WARN([LIBS="$LIBS" CPPFLAGS="$CPPFLAGS"])
216     AC_MSG_WARN([install PostgreSQL libs to compile this plugin (see REQUIREMENTS).])
217   fi
218 else
219   AC_MSG_WARN([Skipping PostgreSQL plugin (check_pgsql)])
220   AC_MSG_WARN([install lib crypt and PostgreSQL libs to compile this plugin (see REQUIREMENTS).])
221 fi
222 LIBS="$_SAVEDLIBS"
223 CPPFLAGS="$_SAVEDCPPFLAGS"
225 dnl Check for radius libraries
226 _SAVEDLIBS="$LIBS"
227 AC_CHECK_LIB(radiusclient,rc_read_config)
228 if test "$ac_cv_lib_radiusclient_rc_read_config" = "yes"; then
229   EXTRAS="$EXTRAS check_radius"
230         RADIUSLIBS="-lradiusclient"
231   AC_SUBST(RADIUSLIBS)
232 else
233   AC_MSG_WARN([Skipping radius plugin])
234   AC_MSG_WARN([install radius libs to compile this plugin (see REQUIREMENTS).])
235 fi
236 LIBS="$_SAVEDLIBS"
238 dnl Check for LDAP libraries
239 _SAVEDLIBS="$LIBS"
240 AC_CHECK_LIB(ldap,main,,,-llber)
241 if test "$ac_cv_lib_ldap_main" = "yes"; then
242   LDAPLIBS="-lldap -llber"\
243   LDAPINCLUDE="-I/usr/include/ldap"
244   AC_SUBST(LDAPLIBS)
245   AC_SUBST(LDAPINCLUDE)
246   AC_CHECK_FUNCS(ldap_set_option)
247   EXTRAS="$EXTRAS check_ldap"
248         AC_CHECK_FUNCS(ldap_init ldap_set_option ldap_get_option ldap_start_tls_s)
249 else
250   AC_MSG_WARN([Skipping LDAP plugin])
251   AC_MSG_WARN([install LDAP libs to compile this plugin (see REQUIREMENTS).])
252 fi
253 LIBS="$_SAVEDLIBS"
255 dnl Check for mysql libraries
256 dnl Default is to search path for mysql_config
257 AC_ARG_WITH(mysql,
258         ACX_HELP_STRING([--with-mysql=DIR],
259                 [Compiles mysql plugins. Expects DIR/bin/mysql_config]),
260         with_mysql=$withval,
261         with_mysql=yes)
262 if test $with_mysql != "no" ; then
263   if test -x $with_mysql/bin/mysql_config ; then
264     MYSQLCONFIG="$with_mysql/bin/mysql_config"
265   else
266     AC_PATH_PROG(MYSQLCONFIG, mysql_config)
267   fi
268   if test -z "$MYSQLCONFIG"; then
269     with_mysql="not found"
270     AC_MSG_WARN([Skipping mysql plugin])
271     AC_MSG_WARN([install mysql client libs to compile this plugin (see REQUIREMENTS).])
272   else
273     with_mysql=$MYSQLCONFIG
274     EXTRAS="$EXTRAS check_mysql check_mysql_query"
275     MYSQLINCLUDE=`$MYSQLCONFIG --include`
276     # Mysql 3 does not support --include. --cflags should be sufficient
277     if test $? -ne 0 ; then
278       MYSQLINCLUDE=""
279     fi
280     MYSQLLIBS=`$MYSQLCONFIG --libs`
281     MYSQLCFLAGS=`$MYSQLCONFIG --cflags`
282     AC_SUBST(MYSQLINCLUDE)
283     AC_SUBST(MYSQLLIBS)
284     AC_SUBST(MYSQLCFLAGS)
285   fi
286 fi
288 AC_CHECK_HEADERS(unistd.h)
290 dnl Check for AF_INET6 support - unistd.h required for Darwin
291 AC_CACHE_CHECK([for IPv6 support], with_ipv6, [
292         AC_TRY_COMPILE([#ifdef HAVE_UNISTD_H
293                         #include <unistd.h>
294                         #endif
295                         #include <netinet/in.h>
296                         #include <sys/socket.h>],
297                         [struct sockaddr_in6 sin6;
298                         void *p;
300                         sin6.sin6_family = AF_INET6;
301                         sin6.sin6_port = 587;
302                         p = &sin6.sin6_addr;],
303                         [with_ipv6=yes], 
304                         [with_ipv6=no])
305         ])
307 if test x"$with_ipv6" != xno ; then
308         AC_DEFINE(USE_IPV6,1,[Enable IPv6 support])
309 fi
311 dnl #########################################################################
312 dnl Check if Posix getaddrinfo() is available.  It is also possible to use
313 dnl the version from the lwres library distributed with BIND.
314 dnl #########################################################################
315 AC_ARG_ENABLE([emulate-getaddrinfo],
316               ACX_HELP_STRING([--enable-emulate-getaddrinfo],
317                              [enable getaddrinfo emulation (default=no)]),
318               ,
319               enable_emulate_getaddrinfo=no)
321 AC_ARG_WITH(lwres,
322             ACX_HELP_STRING([--with-lwres=DIR],
323                            [use lwres library for getaddrinfo (default=no)]),
324             ,
325             with_lwres=no)
327 dnl ## enable force to test getaddrinfo.c
328 if test x$enable_emulate_getaddrinfo = xforce ; then
329         enable_emulate_getaddrinfo=yes
330         have_getaddrinfo=no
331 else
333 have_getaddrinfo=no
334 if test x$with_lwres != xno ; then
335         if test "$with_lwres" != yes ; then
336                    CPPFLAGS="-I${with_lwres}/include $CPPFLAGS"
337                    LDFLAGS="-L${with_lwres}/lib $LDFLAGS"
338         fi
339         AC_CHECK_HEADERS(lwres/netdb.h, ,
340                         [AC_MSG_ERROR([cannot find <lwres/netdb.h>])])
341         AC_CHECK_LIB(lwres, lwres_getaddrinfo, ,
342                      [AC_MSG_ERROR([cannot find the lwres library])],
343                      -lnsl -lpthread)
344         have_getaddrinfo=yes
345 fi
347 if test x$have_getaddrinfo != xyes ; then
348         AC_SEARCH_LIBS(getaddrinfo, socket resolv bind nsl c_r cr, have_getaddrinfo=yes)
349 fi
351 dnl # Special nonsense for systems that actually have getaddrinfo but
352 dnl # redefine the name to something else, e.g. OSF
353 if test x$have_getaddrinfo != xyes ; then
354         AC_MSG_CHECKING(if getaddrinfo is redefined in netdb.h)
355         AC_TRY_LINK([
356 #               include <netdb.h>
357         ], [
358                 struct addrinfo hints, *res;
359                 int err;
361                 err = getaddrinfo ("host", "service", &hints, &res);
362         ], [
363                 have_getaddrinfo=yes
364                 AC_MSG_RESULT(yes)
365         ], [AC_MSG_RESULT(no)])
366 fi
368 fi
370 if test x$have_getaddrinfo != xno ; then
371         if test x$enable_emulate_getaddrinfo != xno ; then
372                 AC_MSG_ERROR([getaddrinfo found but emulate-getaddrinfo was enabled])
373         fi
374         AC_DEFINE(HAVE_GETADDRINFO, 1,
375                   [Does system provide RFC 2553/Posix getaddrinfo?])
376 else
377         if test x$enable_emulate_getaddrinfo != xyes ; then
378 dnl                AC_MSG_ERROR([getaddrinfo not found: try --with-lwres or --enable-emulate-getaddrinfo])
379                enable_emulate_getaddrinfo=yes
380                AC_MSG_WARN([enabling getaddrinfo emulation])
381         fi
382         EXTRA_NETOBJS="$EXTRA_NETOBJS getaddrinfo.o"
383 fi
385 if test x"$enable_emulate_getaddrinfo" != xno ; then
386     have_resolver=no
388   dnl  Try for getipnodebyname
389     AC_SEARCH_LIBS(getipnodebyname, resolv bind nsl c_r cr, have_resolver=yes)
390     if test x"$have_resolver" != xno ; then
391          AC_DEFINE(HAVE_GETIPNODEBYNAME, 1,
392                    [Set when getipnodebyname is available])
393     fi
395   dnl  Try for gethostbyname_r
396     if test x"$have_resolver" = xno ; then
397         AC_SEARCH_LIBS(gethostbyname_r, resolv bind nsl c_r cr,
398                        [have_resolver=yes
399                         ACX_WHICH_GETHOSTBYNAME_R])
400     fi
402   dnl  Try for gethostbyname
403     if test x"$have_resolver" = xno ; then
404         if test x"$enable_pthreads" != xno ; then
405             AC_MSG_WARN([using threads but cannot find gethostbyname_r or getipnodebyname])
406         fi
407         AC_SEARCH_LIBS(gethostbyname, resolv bind nsl, ,
408                        [AC_MSG_ERROR([cannot find gethostbyname])])
409     fi
410     EXTRA_NETOBJS="$EXTRA_NETOBJS gethostbyname.o"
412 fi
414 dnl Checks for Kerberos. Must come before openssl checks for Redhat EL 3
415 AC_CHECK_HEADERS(krb5.h,FOUNDINCLUDE=yes,FOUNDINCLUDE=no)
416 if test "$FOUNDINCLUDE" = "no"; then
417   _SAVEDCPPFLAGS="$CPPFLAGS"
418   CPPFLAGS="$_SAVEDCPPFLAGS -I/usr/kerberos/include"
419   unset ac_cv_header_krb5_h
420   AC_CHECK_HEADERS(krb5.h,
421                    KRB5INCLUDE="-I/usr/kerberos/include"
422                    FOUNDINCLUDE=yes,
423                    FOUNDINCLUDE=no)
424 fi
425 AC_SUBST(KRBINCLUDE)
426 if test "$FOUNDINCLUDE" = "no"; then
427   CPPFLAGS="$_SAVEDCPPFLAGS"
428 fi
431 dnl openssl detection/configuration
432 if ! test x"$with_openssl" = x"no"; then
433         dnl Check for OpenSSL location if it wasn't already specified
434         if ! test -d "$with_openssl"; then
435                 for d in $OPENSSL_DIRS; do
436                         if test -x ${d}/bin/openssl || test -x ${d}/sbin/openssl ; then
437                                 with_openssl=$d
438                         fi
439                 done
440         fi
442         _SAVEDCPPFLAGS="$CPPFLAGS"
443         _SAVEDLDFLAGS="$LDFLAGS"
444         dnl Check for OpenSSL header files
445         unset FOUNDINCLUDE
446         if test x"$with_openssl" != x"/usr" ; then
447                 CPPFLAGS="$CPPFLAGS -I$with_openssl/include"
448                 # Need both to find ssl libraries and to load at runtime
449                 LDFLAGS="$LDFLAGS -L$with_openssl/lib -R$with_openssl/lib"
450         fi
452         dnl check for openssl in $dir/include/openssl
453         AC_CHECK_HEADERS(openssl/ssl.h openssl/x509.h openssl/rsa.h openssl/pem.h openssl/crypto.h openssl/err.h,
454                          SSLINCLUDE="-I$with_openssl/include"
455                          FOUNDINCLUDE=yes,
456                          FOUNDINCLUDE=no)
457         dnl else check to see if $dir/include has it
458         if test "$FOUNDINCLUDE" = "no"; then
459                 AC_CHECK_HEADERS(ssl.h x509.h rsa.h pem.h crypto.h err.h,
460                                  SSLINCLUDE="-I$with_openssl/include"
461                                  FOUNDINCLUDE=yes,
462                                  FOUNDINCLUDE=no)
463         fi
464         AC_SUBST(SSLINCLUDE)
465         dnl if we didn't find it, reset CPPFLAGS
466         if test "$FOUNDINCLUDE" = "no"; then
467                 CPPFLAGS="$_SAVEDCPPFLAGS"
468                 LDFLAGS="$_SAVEDLDFLAGS"
469         fi
471         dnl Check for crypto lib
472         _SAVEDLIBS="$LIBS"
473         LIBS="-L${with_openssl}/lib"
474         AC_CHECK_LIB(crypto,CRYPTO_lock)
475         if test "$ac_cv_lib_crypto_CRYPTO_lock" = "yes"; then
476                 dnl Check for SSL lib
477                 AC_CHECK_LIB(ssl,main, SSLLIBS="-lssl -lcrypto",,-lcrypto)
478         fi
479         LIBS="$_SAVEDLIBS"
481         dnl test headers and libs to decide whether check_http should use SSL
482         if test "$ac_cv_lib_crypto_CRYPTO_lock" = "yes"; then
483                 if test "$ac_cv_lib_ssl_main" = "yes"; then
484                         if test "$FOUNDINCLUDE" = "yes"; then
485                                 FOUNDOPENSSL="yes"
486                         fi
487                 fi
488         fi
489 fi
492 dnl check for gnutls if openssl isn't found (or is disabled)
493 if test ! "$FOUNDOPENSSL" = "yes" && test ! "$with_gnutls" = "no"; then
494         if test ! "$with_gnutls" = ""; then
495                 CPPFLAGS="$CPPFLAGS -I${with_gnutls}/include"
496         elif test ! "$LIBGNUTLS_CONFIG" = ""; then
497                 CPPFLAGS="$CPPFLAGS -I`$LIBGNUTLS_CONFIG --prefix`"
498         fi
499         AC_CHECK_HEADERS([gnutls/openssl.h],FOUNDGNUTLS="yes",)
500         if test "$FOUNDGNUTLS" = "yes"; then
501                 AC_CHECK_LIB(gnutls-openssl,main,SSLLIBS="-lgnutls-openssl")
502         fi
503 fi
504 dnl end check for gnutls
506 if test "$FOUNDOPENSSL" = "yes" || test "$FOUNDGNUTLS" = "yes"; then
507         check_tcp_ssl="check_simap check_spop check_jabber check_nntps check_ssmtp"
508         AC_SUBST(check_tcp_ssl)
509         AC_SUBST(SSLLIBS)
510         AC_DEFINE(HAVE_SSL,1,[Define if SSL libraries are found])
511         if test "$FOUNDOPENSSL" = "yes"; then
512                 AC_DEFINE(USE_OPENSSL,1,[Define if using OpenSSL libraries])
513                 with_openssl="yes"
514                 with_gnutls="no"
515         else
516                 AC_DEFINE(USE_GNUTLS,1,[Define if using gnutls libraries])
517                 with_gnutls="yes"
518                 with_openssl="no"
519         fi
520 else
521         dnl else deliberately disabled or no ssl support available
522         AC_MSG_WARN([OpenSSL or GnuTLS libs could not be found or were disabled])
523         with_openssl="no"
524         with_gnutls="no"
525 fi
527 dnl
528 dnl Checks for header files.
529 dnl
531 AC_HEADER_STDC
532 AC_HEADER_TIME
533 AC_HEADER_SYS_WAIT
534 AC_CHECK_HEADERS(signal.h strings.h string.h syslog.h uio.h errno.h sys/types.h sys/time.h sys/socket.h sys/loadavg.h sys/un.h sys/poll.h)
535 AC_CHECK_HEADERS(features.h stdarg.h sys/unistd.h ctype.h stdlib.h)
537 dnl Checks for typedefs, structures, and compiler characteristics.
538 AC_C_CONST
539 AC_STRUCT_TM
540 AC_TYPE_PID_T
541 AC_TYPE_SIZE_T
542 AC_TYPE_SIGNAL
544 AC_CACHE_CHECK([for va_copy],ac_cv_HAVE_VA_COPY,[
545 AC_TRY_LINK([#include <stdarg.h>
546 va_list ap1,ap2;], [va_copy(ap1,ap2);],
547 ac_cv_HAVE_VA_COPY=yes,
548 ac_cv_HAVE_VA_COPY=no)])
549 if test x"$ac_cv_HAVE_VA_COPY" = x"yes"; then
550     AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available])
551 else    
552     AC_CACHE_CHECK([for __va_copy],ac_cv_HAVE___VA_COPY,[
553     AC_TRY_LINK([#include <stdarg.h>
554     va_list ap1,ap2;], [__va_copy(ap1,ap2);],
555     ac_cv_HAVE___VA_COPY=yes,
556     ac_cv_HAVE___VA_COPY=no)])
557     if test x"$ac_cv_HAVE___VA_COPY" = x"yes"; then
558         AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available])
559     fi
560 fi
562 AC_CHECK_FUNCS(vsnprintf snprintf asprintf vasprintf)
563 AC_CACHE_CHECK([for C99 vsnprintf],ac_cv_HAVE_C99_VSNPRINTF,[
564 AC_TRY_RUN([
565 #include <sys/types.h>
566 #include <stdarg.h>
567 void foo(const char *format, ...) { 
568        va_list ap;
569        int len;
570        char buf[5];
572        va_start(ap, format);
573        len = vsnprintf(buf, 0, format, ap);
574        va_end(ap);
575        if (len != 5) exit(1);
577        va_start(ap, format);
578        len = vsnprintf(0, 0, format, ap);
579        va_end(ap);
580        if (len != 5) exit(1);
582        if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
584        exit(0);
586 main() { foo("hello"); }
587 ],
588 ac_cv_HAVE_C99_VSNPRINTF=yes,ac_cv_HAVE_C99_VSNPRINTF=no,ac_cv_HAVE_C99_VSNPRINTF=cross)])
589 if test x"$ac_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
590     AC_DEFINE(HAVE_C99_VSNPRINTF,1,[Define if system has C99 compatible vsnprintf])
591 fi
593 AC_TRY_COMPILE([#include <sys/time.h>],
594                [struct timeval *tv;
595                 struct timezone *tz;],
596                AC_DEFINE(HAVE_STRUCT_TIMEVAL,1,[Define if we have a timeval structure])
597                AC_TRY_COMPILE([#include <sys/time.h>],
598                               [struct timeval *tv;
599                                struct timezone *tz;
600                                gettimeofday(tv, tz);],
601                               AC_DEFINE(HAVE_GETTIMEOFDAY,1,[Define if gettimeofday is found]),
602                               AC_DEFINE(NEED_GETTIMEOFDAY,1,[Define if gettimeofday is needed])))
604 dnl Checks for library functions.
605 AC_CHECK_FUNCS(memmove select socket strdup strstr strtod strtol strtoul floor)
606 AC_CHECK_FUNCS(basename poll)
608 AC_MSG_CHECKING(return type of socket size)
609 AC_TRY_COMPILE([#include <stdlib.h>
610                 #include <sys/types.h>
611                 #include <sys/socket.h>],
612                [int a = send(1, (const void *) buffer, (size_t *) 0, (int *) 0);],
613                ac_cv_socket_size_type=["size_t"]
614                 AC_MSG_RESULT(size_t),
615                ac_cv_socket_size_type=["int"]
616                 AC_MSG_RESULT(int))
618 AC_DEFINE_UNQUOTED(SOCKET_SIZE_TYPE, $ac_cv_socket_size_type ,
619         [Define type of socket size])
621 AC_ARG_WITH(proc-loadavg,
622             ACX_HELP_STRING([--with-proc-loadavg=PATH],
623                             [path to /proc/loadavg or equivalent]),
624             ac_cv_proc_loadavg=$withval)
625 AC_MSG_CHECKING([for /proc/loadavg])
626 if test -n "$ac_cv_proc_loadavg"; then
627   AC_MSG_RESULT([(command line) $ac_cv_proc_loadavg])
628 elif test -f "/proc/loadavg"; then
629   AC_MSG_RESULT([found /proc/loadavg])
630   ac_cv_proc_loadavg="/proc/loadavg"
631 else
632   AC_MSG_RESULT([no])
633 fi
635 if test -n "$ac_cv_proc_loadavg"; then
636   AC_DEFINE(HAVE_PROC_LOADAVG,1,[Define if /proc/loadavg or similar exists])
637   AC_DEFINE_UNQUOTED(PROC_LOADAVG,"/proc/loadavg",[Location of /proc/loadavg])
638 fi
640 dnl #### Process table test
642 AC_PATH_PROG(PATH_TO_PS,ps)
644 AC_MSG_CHECKING(for ps syntax)
645 AC_ARG_WITH(ps_command,
646             ACX_HELP_STRING([--with-ps-command=PATH], 
647                             [Verbatim command to execute for ps]),
648             PS_COMMAND=$withval)
649 AC_ARG_WITH(ps_format,
650             ACX_HELP_STRING([--with-ps-format=FORMAT],
651                             [Format string for scanning ps output]),
652             PS_FORMAT=$withval)
653 AC_ARG_WITH(ps_cols,
654             ACX_HELP_STRING([--with-ps-cols=NUM], 
655                             [Number of columns in ps command]),
656             PS_COLS=$withval)
657 AC_ARG_WITH(ps_varlist,
658             ACX_HELP_STRING([--with-ps-varlist=LIST],
659                             [Variable list for sscanf of 'ps' output]),
660             PS_VARLIST=$withval)
662 if test -n "$PS_COMMAND" && test -n "$PS_FORMAT" && test -n "$PS_COLS" && test -n "$PS_VARLIST"; then 
663         ac_cv_ps_command="$PS_COMMAND"
664         ac_cv_ps_format="$PS_FORMAT"
665         ac_cv_ps_varlist="$PS_VARLIST"
666         ac_cv_ps_cols="$PS_COLS"
667         AC_MSG_RESULT([(command-line) $ac_cv_ps_command])
669 dnl Now using the pst3/kmem hack for solaris systems to avoid truncation
670 elif test "$ac_cv_uname_s" = "SunOS"; then
671         #
672         # this is a very, very ugly hack, to hardcode the location for plugins
673         #
674         if test "$libexecdir" = '${exec_prefix}/libexec'; then
675                 if test "$exec_prefix" = "NONE"; then
676                         if test "$prefix" = "NONE"; then
677                                 pst3="$ac_default_prefix/libexec/pst3"
678                         else
679                                 pst3="$prefix/libexec/pst3"
680                         fi
681                 else
682                         pst3="$exec_prefix/libexec/pst3"
683                 fi
684         else
685                 pst3="$libexecdir/pst3"
686         fi
687         ac_cv_ps_command="$pst3"
688         ac_cv_ps_format="%s %d %d %d %d %f %s %n"
689         ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
690         ac_cv_ps_cols=8
691         AC_MSG_RESULT([using nagios-plugins internal ps for solaris])
692         EXTRAS_ROOT="$EXTRAS_ROOT pst3"
694 dnl Some gnu/linux systems (debian for one) don't like -axwo and need axwo.
695 dnl so test for this first...
696 elif ps axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
697         egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null
698 then
699         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
700         ac_cv_ps_command="$PATH_TO_PS axwo 'stat uid pid ppid vsz rss pcpu comm args'"
701         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
702         ac_cv_ps_cols=9
703         AC_MSG_RESULT([$ac_cv_ps_command])
705 dnl For OpenBSD 3.2 & 3.3. Must come before ps -weo
706 dnl Should also work for FreeBSD 5.2.1 and 5.3
707 dnl  STAT UCOMM              VSZ   RSS USER      PPID COMMAND
708 elif ps -axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
709         egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null
710 then
711         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
712         ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid pid ppid vsz rss pcpu comm args'"
713         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
714         ac_cv_ps_cols=9
715         AC_MSG_RESULT([$ac_cv_ps_command])
717 dnl Some *BSDs have different format for ps. This is mainly to catch FreeBSD 4. 
718 dnl Limitation: Only first 16 chars returned for ucomm field
719 dnl Must come before ps -weo
720 elif ps -axwo 'stat uid pid ppid vsz rss pcpu ucomm command' 2>/dev/null | \
721         egrep -i ["^ *STAT +UID +PID +PPID +VSZ +RSS +%CPU +UCOMM +COMMAND"] > /dev/null
722 then
723         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
724         ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid pid ppid vsz rss pcpu ucomm command'"
725         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
726         ac_cv_ps_cols=9
727         AC_MSG_RESULT([$ac_cv_ps_command])
729 dnl  STAT UCOMM              VSZ   RSS USER       UID  PPID COMMAND
730 elif ps -weo 'stat comm vsz rss user uid pid ppid etime args' 2>/dev/null | \
731         egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[ID]+ +P[PID]+ +[ELAPSD]+ +[RGSCOMDNA]+"] >/dev/null
732 then
733         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procetime,procprog,&pos]"
734         ac_cv_ps_command="$PATH_TO_PS -weo 'stat uid pid ppid vsz rss pcpu etime comm args'"
735         ac_cv_ps_format="%s %d %d %d %d %d %f %s %s %n"
736         ac_cv_ps_cols=10
737         AC_MSG_RESULT([$ac_cv_ps_command])
739 dnl FreeBSD
740 elif ps waxco 'state command vsz rss uid user pid ppid' 2>/dev/null | \
741         egrep -i ["^STAT +COMMAND +VSZ +RSS +UID +USER +PID +PPID"] >/dev/null
742 then
743         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
744         ac_cv_ps_command="$PATH_TO_PS waxco 'state uid pid ppid vsz rss pcpu command command'"
745         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
746         ac_cv_ps_cols=9
747         AC_MSG_RESULT([$ac_cv_ps_command])
749 dnl BSD-like mode in RH 6.1
750 elif ps waxno 'state comm vsz rss uid user pid ppid args' 2>/dev/null | \
751         egrep -i ["^S +COMMAND +VSZ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
752 then
753         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
754         ac_cv_ps_command="$PATH_TO_PS waxno 'state uid pid ppid vsz rss pcpu comm args'"
755         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
756         ac_cv_ps_cols=9
757         AC_MSG_RESULT([$ac_cv_ps_command])
759 dnl SunOS 4.1.3:
760 dnl  F  UID  PID  PPID  CP  PRI  NI  SZ  RSS  WCHAN  STAT  TT  TIME  COMMAND
761 dnl Need the head -1 otherwise test will work because arguments are found
762 elif ps -laxnwww 2>/dev/null | head -1 | \
763         egrep -i ["^ *F(LAGS)? +UID +PID +PPID +CP +PRI +NI +(SZ)|(VSZ)|(SIZE) +RSS +WCHAN +STAT? +TTY? +TIME +COMMAND"] >/dev/null
764 then
765         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]"
766         ac_cv_ps_command="$PATH_TO_PS -laxnwww"
767         ac_cv_ps_format="%*s %d %d %d %*s %*s %*s %d %d %*s %s %*s %*s %n%s"
768         ac_cv_ps_cols=9
769         AC_MSG_RESULT([$ac_cv_ps_command])
771 dnl Debian Linux / procps v1.2.9:
772 dnl  FLAGS   UID   PID  PPID PRI  NI   SIZE   RSS WCHAN       STA TTY TIME COMMAND
773 dnl    100     0     1     0   0   0    776    76  c0131c8c   S  ffff  0:11 init [2]
774 dnl
775 elif ps laxnwww 2>/dev/null | \
776         egrep -i ["^ *F(LAGS)? +UID +PID +PPID +PRI +NI +(VSZ)|(SIZE) +RSS +WCHAN +STAT? TTY +TIME +COMMAND"] >/dev/null
777 then
778         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,procstat,&procvsz,&procrss,&pos,procprog]"
779         ac_cv_ps_command="$PATH_TO_PS laxnwww"
780         ac_cv_ps_format="%*s %d %d %d %*s %*s %d %d %*s %s %*s %*s %n%s"
781         ac_cv_ps_cols=9
782         AC_MSG_RESULT([$ac_cv_ps_command])
784 dnl OpenBSD (needs to come early because -exo appears to work, but does not give all procs)
785 elif ps -axo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
786         egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[PID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null
787 then
788         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
789         ac_cv_ps_command="$PATH_TO_PS -axo 'stat uid pid ppid vsz rss pcpu comm args'"
790         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
791         ac_cv_ps_cols=9
792         AC_MSG_RESULT([$ac_cv_ps_command])
794 dnl Tru64 - needs %*[ +<>] in PS_FORMAT. 
795 dnl Has /usr/bin/ps and /sbin/ps - force sbin version
796 dnl Can't use vsize and rssize because comes back with text (eg, 1.5M instead 
797 dnl of 1500). Will need big changes to check_procs to support
798 elif /sbin/ps -eo 'stat uid pid ppid pcpu etime comm args' 2>/dev/null | \
799         egrep -i ["^ *S +[UID]+ +[PID]+ +[PID]+ +[%CPU]+ +[ELAPSD]+ +[COMMAND]+ +[COMMAND]+"] > /dev/null
800 then
801         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procpcpu,procetime,procprog,&pos]"
802         ac_cv_ps_command="/sbin/ps -eo 'stat uid pid ppid pcpu etime comm args'"
803         ac_cv_ps_format=["%s%*[ +<>] %d %d %d %f %s %s %n"]
804         ac_cv_ps_cols=8
805         AC_MSG_RESULT([$ac_cv_ps_command])
807 elif ps -eo 's comm vsz rss user uid pid ppid args' 2>/dev/null | \
808         egrep -i ["^S[TAUES]* +C[OMDNA]+ +[VSIZE]+ +U[SER]+ +U[ID]+ +P[PID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null
809 then
810         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
811         ac_cv_ps_command="$PATH_TO_PS -eo 's uid pid ppid vsz rss pcpu comm args'"
812         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
813         ac_cv_ps_cols=9
814         AC_MSG_RESULT([$ac_cv_ps_command])
816 dnl AIX 4.3.3 and 5.1 do not have an rss field
817 elif ps -eo 'stat uid pid ppid vsz pcpu comm args' 2>/dev/null | \
818         egrep -i ["^ *S[TAUES]* +UID +PID +PPID +VSZ +%CPU +COMMAND +COMMAND"] >/dev/null
819 then
820         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procpcpu,procprog,&pos]"
821         ac_cv_ps_command="$PATH_TO_PS -eo 'stat uid pid ppid vsz pcpu comm args'"
822         ac_cv_ps_format="%s %d %d %d %d %f %s %n"
823         ac_cv_ps_cols=8
824         AC_MSG_RESULT([$ac_cv_ps_command - with no RSS])
826 dnl Solaris 2.6
827 elif ps -Ao 's comm vsz rss uid user pid ppid args' 2>/dev/null | \
828         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
829 then
830         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
831         ac_cv_ps_command="$PATH_TO_PS -Ao 's uid pid ppid vsz rss pcpu comm args'"
832         # There must be no space between the %s and %n due to a wierd problem in sscanf where
833         # it will return %n as longer than the line length
834         ac_cv_ps_format="%s %d %d %d %d %d %f %s%n"
835         ac_cv_ps_cols=9
836         AC_MSG_RESULT([$ac_cv_ps_command])
838 elif ps -Ao 'status comm vsz rss uid user pid ppid args' 2>/dev/null | \
839         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
840 then
841         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
842         ac_cv_ps_command="$PATH_TO_PS -Ao 'status uid pid ppid vsz rss pcpu comm args'"
843         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
844         ac_cv_ps_cols=9
845         AC_MSG_RESULT([$ac_cv_ps_command])
847 elif ps -Ao 'state comm vsz rss uid user pid ppid args' 2>/dev/null | \
848         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
849 then
850         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
851         ac_cv_ps_command="$PATH_TO_PS -Ao 'state uid pid ppid vsz rss pcpu comm args'"
852         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
853         ac_cv_ps_cols=9
854         AC_MSG_RESULT([$ac_cv_ps_command])
856 dnl wonder who takes state instead of stat
857 elif ps -ao 'state command vsz rss user pid ppid args' 2>/dev/null | \
858         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
859 then
860         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
861         ac_cv_ps_command="$PATH_TO_PS -ao 'state uid pid ppid vsz rss pcpu command args'"
862         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
863         ac_cv_ps_cols=8
864         AC_MSG_RESULT([$ac_cv_ps_command])
866 dnl IRIX 53
867 elif ps -el 2>/dev/null | \
868         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
869 then
870         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&pos,procprog]"
871         ac_cv_ps_command="$PATH_TO_PS -el (IRIX 53)"
872         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %d %d %*s %*s %*s %n%s"
873         ac_cv_ps_cols=8
874         AC_MSG_RESULT([$ac_cv_ps_command])
876 dnl IRIX 63
877 elif ps -el 2>/dev/null | \
878         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +ADDR +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
879 then
880         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
881         ac_cv_ps_command="$PATH_TO_PS -el (IRIX 63)"
882         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
883         ac_cv_ps_cols=6
884         AC_MSG_RESULT([$ac_cv_ps_command])
886 dnl AIX 4.1:
887 dnl     F S      UID   PID  PPID   C PRI NI ADDR  SZ  RSS   WCHAN    TTY  TIME CMD
888 dnl    303 A        0     0     0 120  16 -- 1c07  20   24              -  0:45 swapper
889 elif ps -el 2>/dev/null | \
890         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +ADDR +SZ +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
891 then
892         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
893         ac_cv_ps_command="$PATH_TO_PS -el (AIX 4.1 and HP-UX)"
894         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
895         ac_cv_ps_cols=6
896         AC_MSG_RESULT([$ac_cv_ps_command])
898 dnl AIX?
899 elif ps glaxen 2>/dev/null | \
900         egrep -i ["^ *F +UID +PID +PPID +PRI +NI +VSZ +RSS +WCHAN +STAT +TTY +TIME +COMMAND"] >/dev/null
901 then
902         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]"
903         ac_cv_ps_command="$PATH_TO_PS glaxen"
904         ac_cv_ps_format="%*s %d %d %d %*s %*s %d %d %*s %s %*s %*s %n%s"
905         ac_cv_ps_cols=8
906         AC_MSG_RESULT([$ac_cv_ps_command])
908 dnl MacOSX / Darwin
909 dnl TODO: MacOSX has commands with spaces which will cause problems to PS_FORMAT
910 dnl Some truncation will happen in UCOMM column
911 dnl STAT      VSZ    RSS   UID  PPID %CPU UCOMM            COMMAND
912 dnl Ss      52756  22496   501     1   6.9 Window Manager   /System/Library/CoreServices/WindowServer -daemon
913 elif ps wwaxo 'state vsz rss uid pid ppid pcpu ucomm command' 2>/dev/null | \
914         egrep -i ["^STAT +VSZ +RSS +UID +PPID +%CPU +UCOMM +COMMAND"] >/dev/null
915 then
916         ac_cv_ps_command="$PATH_TO_PS wwaxo 'state vsz rss uid pid ppid pcpu ucomm command'"
917         ac_cv_ps_varlist="[procstat,&procvsz,&procrss,&procuid,&procpid,&procppid,&procpcpu,procprog,&pos]"
918         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
919         ac_cv_ps_cols=8
920         AC_MSG_RESULT([$ac_cv_ps_command])
922 dnl UnixWare 
923 elif ps -Al 2>/dev/null | \
924         egrep -i ["^ *F +S +UID +PID +PPID +CLS +PRI +NI +C +ADDR +SZ +WCHAN +TTY +TIME +COMD"] >/dev/null
925 then
926         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
927         ac_cv_ps_command="$PATH_TO_PS -Al"
928         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
929         ac_cv_ps_cols=8
930         AC_MSG_RESULT([$ac_cv_ps_command])
932 else
933         AC_MSG_WARN([unable to find usable ps syntax - check_procs and check_nagios will not be compiled])
934 fi
936 if test -n "$ac_cv_ps_varlist" ; then
937         AC_DEFINE_UNQUOTED(PS_VARLIST,$ac_cv_ps_varlist,
938                 [Variable list for sscanf of 'ps' output])
939         AC_DEFINE_UNQUOTED(PS_COMMAND,"$ac_cv_ps_command",
940                 [Verbatim command to execute for ps in check_procs])
941         AC_DEFINE_UNQUOTED(PS_FORMAT,"$ac_cv_ps_format",
942                 [Format string for scanning ps output in check_procs])
943         AC_DEFINE_UNQUOTED(PS_COLS,$ac_cv_ps_cols,
944                 [Number of columns in ps command])
945         EXTRAS="$EXTRAS check_procs check_nagios"
946         if echo "$ac_cv_ps_varlist" | grep -q "procetime"; then
947                 AC_DEFINE(PS_USES_PROCETIME,"yes",
948                           [Whether the ps utility uses the "procetime" field])
949         fi
950 fi
952 AC_PATH_PROG(PATH_TO_PING,ping)
953 AC_PATH_PROG(PATH_TO_PING6,ping6)
955 AC_ARG_WITH(ping_command,
956         ACX_HELP_STRING([--with-ping-command=SYNTAX],
957                 [sets syntax for ICMP ping]),
958         with_ping_command=$withval,)
960 AC_MSG_CHECKING(for ICMP ping syntax)
961 ac_cv_ping_packets_first=no
962 ac_cv_ping_has_timeout=no
963 if test -n "$with_ping_command"
964 then
965         AC_MSG_RESULT([(command-line) $with_ping_command])
966         if test -n "$ac_cv_ping_packets_first"
967         then
968                 ac_cv_ping_packets_first=yes
969                 ac_cv_ping_has_timeout=yes
970         fi
972 elif [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
973         $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
974         egrep -i "^round-trip|^rtt" >/dev/null
975 then
976         with_ping_command="$PATH_TO_PING -n -U -c %d %s"
977         ac_cv_ping_packets_first=yes
978         AC_MSG_RESULT([$with_ping_command])
980 elif $PATH_TO_PING -n -U -w 10 -c 1 127.0.0.1 2>/dev/null | \
981         egrep -i "^round-trip|^rtt" >/dev/null
982 then
983         with_ping_command="$PATH_TO_PING -n -U -w %d -c %d %s"
984         ac_cv_ping_packets_first=yes
985   ac_cv_ping_has_timeout=yes
986         AC_MSG_RESULT([$with_ping_command])
988 elif $PATH_TO_PING -n -U -c 1 127.0.0.1 2>/dev/null | \
989         egrep -i "^round-trip|^rtt" >/dev/null
990 then
991         with_ping_command="$PATH_TO_PING -n -U -c %d %s"
992         ac_cv_ping_packets_first=yes
993         AC_MSG_RESULT([$with_ping_command])
995 elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \
996         egrep -i "^round-trip|^rtt" >/dev/null
997 then
998         with_ping_command="$PATH_TO_PING -n -c %d %s"
999         ac_cv_ping_packets_first=yes
1000         AC_MSG_RESULT([$with_ping_command])
1002 elif $PATH_TO_PING -n 127.0.0.1 -c 1 2>/dev/null | \
1003         egrep -i "^round-trip|^rtt" >/dev/null
1004 then
1005         with_ping_command="$PATH_TO_PING -n %s -c %d"
1006         AC_MSG_RESULT([$with_ping_command])
1008 elif $PATH_TO_PING 127.0.0.1 -n 1 2>/dev/null | \
1009         egrep -i "^round-trip|^rtt" >/dev/null
1010 then
1011         with_ping_command="$PATH_TO_PING %s -n %d"
1012         AC_MSG_RESULT([$with_ping_command])
1014 elif $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
1015         egrep -i "^round-trip|^rtt" >/dev/null
1016 then
1017         with_ping_command="$PATH_TO_PING -n -s %s 56 %d"
1018         AC_MSG_RESULT([$with_ping_command])
1020 elif $PATH_TO_PING -n -h 127.0.0.1 -s 56 -c 1 2>/dev/null | \
1021         egrep -i "^round-trip|^rtt" >/dev/null
1022 then
1023         with_ping_command="$PATH_TO_PING -n -h %s -s 56 -c %d"
1024         AC_MSG_RESULT([$with_ping_command])
1026 elif $PATH_TO_PING -n -s 56 -c 1 127.0.0.1 2>/dev/null | \
1027         egrep -i "^round-trip|^rtt" >/dev/null
1028 then
1029         with_ping_command="$PATH_TO_PING -n -s 56 -c %d %s"
1030         ac_cv_ping_packets_first=yes
1031         AC_MSG_RESULT([$with_ping_command])
1033 elif $PATH_TO_PING -n -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 -c %d %s"
1037         ac_cv_ping_packets_first=yes
1038         AC_MSG_RESULT([$with_ping_command])
1040 else
1041         AC_MSG_WARN([unable to find usable ping syntax])
1042 fi
1044 AC_DEFINE_UNQUOTED(PING_COMMAND,"$with_ping_command",
1045         [path and args for ICMP ping command])
1047 if test "x$ac_cv_ping_packets_first" != "xno"
1048 then
1049         AC_DEFINE(PING_PACKETS_FIRST,1,
1050                 [Define if packet count must precede host])
1051 fi
1053 if test "x$ac_cv_ping_has_timeout" != "xno"
1054 then
1055         AC_DEFINE(PING_HAS_TIMEOUT,1,
1056                 [Define if ping has its own timeout option that should be set])
1057 fi
1059 AC_ARG_WITH(ping6_command,
1060         ACX_HELP_STRING([--with-ping6-command=SYNTAX],
1061                 [sets syntax for ICMPv6 ping]),
1062         with_ping6_command=$withval,)
1064 if test x"$with_ipv6" != xno ; then
1065 AC_MSG_CHECKING(for ICMPv6 ping syntax)
1066 ac_cv_ping6_packets_first=no
1067 if test -n "$with_ping6_command"
1068 then
1069         AC_MSG_RESULT([(command-line) $with_ping6_command])
1070         if test -n "$ac_cv_ping6_packets_first"
1071         then
1072                 ac_cv_ping6_packets_first=yes
1073         fi
1075 elif test "x$PATH_TO_PING6" != "x"; then
1076         if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
1077                 $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \
1078                 egrep -i "^round-trip|^rtt" >/dev/null
1079         then
1080                 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s"
1081                 ac_cv_ping6_packets_first=yes
1082                 AC_MSG_RESULT([$with_ping6_command])
1084         elif $PATH_TO_PING6 -n -U -w 10 -c 1 ::1 2>/dev/null | \
1085                 egrep -i "^round-trip|^rtt" >/dev/null
1086         then
1087                 with_ping6_command="$PATH_TO_PING6 -n -U -w %d -c %d %s"
1088                 ac_cv_ping6_packets_first=yes
1089                 ac_cv_ping_has_timeout=yes
1090                 AC_MSG_RESULT([$with_ping6_command])
1092         elif $PATH_TO_PING6 -n -U -c 1 ::1 2>/dev/null | \
1093                 egrep -i "^round-trip|^rtt" >/dev/null
1094         then
1095                 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s"
1096                 ac_cv_ping6_packets_first=yes
1097                 AC_MSG_RESULT([$with_ping6_command])
1099         elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \
1100                 egrep -i "^round-trip|^rtt" >/dev/null
1101         then
1102                 with_ping6_command="$PATH_TO_PING6 -n -c %d %s"
1103                 ac_cv_ping6_packets_first=yes
1104                 AC_MSG_RESULT([$with_ping6_command])
1106         elif $PATH_TO_PING6 -n ::1 -c 1 2>/dev/null | \
1107                 egrep -i "^round-trip|^rtt" >/dev/null
1108         then
1109                 with_ping6_command="$PATH_TO_PING6 -n %s -c %d"
1110                 AC_MSG_RESULT([$with_ping6_command])
1112         elif $PATH_TO_PING6 ::1 -n 1 2>/dev/null | \
1113                 egrep -i "^round-trip|^rtt" >/dev/null
1114         then
1115                 with_ping6_command="$PATH_TO_PING6 %s -n %d"
1116                 AC_MSG_RESULT([$with_ping6_command])
1118         elif $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \
1119                 egrep -i "^round-trip|^rtt" >/dev/null
1120         then
1121                 with_ping6_command="$PATH_TO_PING6 -n -s %s 56 %d"
1122                 AC_MSG_RESULT([$with_ping6_command])
1124         elif $PATH_TO_PING6 -n -h ::1 -s 56 -c 1 2>/dev/null | \
1125                 egrep -i "^round-trip|^rtt" >/dev/null
1126         then
1127                 with_ping6_command="$PATH_TO_PING6 -n -h %s -s 56 -c %d"
1128                 AC_MSG_RESULT([$with_ping6_command])
1130         elif $PATH_TO_PING6 -n -s 56 -c 1 ::1 2>/dev/null | \
1131                 egrep -i "^round-trip|^rtt" >/dev/null
1132         then
1133                 with_ping6_command="$PATH_TO_PING6 -n -s 56 -c %d %s"
1134                 ac_cv_ping6_packets_first=yes
1135                 AC_MSG_RESULT([$with_ping_command])
1137         elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \
1138                 egrep -i "^round-trip|^rtt" >/dev/null
1139         then
1140                 with_ping6_command="$PATH_TO_PING6 -n -c %d %s"
1141                 ac_cv_ping6_packets_first=yes
1142                 AC_MSG_RESULT([$with_ping6_command])
1144         fi
1146 elif test "x$PATH_TO_PING" != "x"; then
1147         if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
1148                 $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \
1149                 egrep -i "^round-trip|^rtt" >/dev/null
1150         then
1151                 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s"
1152                 ac_cv_ping6_packets_first=yes
1153                 AC_MSG_RESULT([$with_ping6_command])
1155         elif $PATH_TO_PING -A inet6 -n -U -c 1 ::1 2>/dev/null | \
1156                 egrep -i "^round-trip|^rtt" >/dev/null
1157         then
1158                 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s"
1159                 ac_cv_ping6_packets_first=yes
1160                 AC_MSG_RESULT([$with_ping6_command])
1162         elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \
1163                 egrep -i "^round-trip|^rtt" >/dev/null
1164         then
1165                 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s"
1166                 ac_cv_ping6_packets_first=yes
1167                 AC_MSG_RESULT([$with_ping6_command])
1169         elif $PATH_TO_PING -A inet6 -n ::1 -c 1 2>/dev/null | \
1170                 egrep -i "^round-trip|^rtt" >/dev/null
1171         then
1172                 with_ping6_command="$PATH_TO_PING -A inet6 -n %s -c %d"
1173                 AC_MSG_RESULT([$with_ping6_command])
1175         elif $PATH_TO_PING -A inet6 ::1 -n 1 2>/dev/null | \
1176                 egrep -i "^round-trip|^rtt" >/dev/null
1177         then
1178                 with_ping6_command="$PATH_TO_PING -A inet6 %s -n %d"
1179                 AC_MSG_RESULT([$with_ping6_command])
1181         elif $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \
1182                 egrep -i "^round-trip|^rtt" >/dev/null
1183         then
1184                 with_ping6_command="$PATH_TO_PING -A inet6 -n -s %s 56 %d"
1185                 AC_MSG_RESULT([$with_ping6_command])
1187         elif $PATH_TO_PING -A inet6 -n -h ::1 -s 56 -c 1 2>/dev/null | \
1188                 egrep -i "^round-trip|^rtt" >/dev/null
1189         then
1190                 with_ping6_command="$PATH_TO_PING -A inet6 -n -h %s -s 56 -c %d"
1191                 AC_MSG_RESULT([$with_ping6_command])
1193         elif $PATH_TO_PING -A inet6 -n -s 56 -c 1 ::1 2>/dev/null | \
1194                 egrep -i "^round-trip|^rtt" >/dev/null
1195         then
1196                 with_ping6_command="$PATH_TO_PING -A inet6 -n -s 56 -c %d %s"
1197                 ac_cv_ping6_packets_first=yes
1198                 AC_MSG_RESULT([$with_ping_command])
1200         elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \
1201                 egrep -i "^round-trip|^rtt" >/dev/null
1202         then
1203                 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s"
1204                 ac_cv_ping6_packets_first=yes
1205                 AC_MSG_RESULT([$with_ping6_command])
1207         fi
1209 fi
1211 if test "x$with_ping6_command" != "x"; then
1212         AC_DEFINE_UNQUOTED(PING6_COMMAND,"$with_ping6_command",
1213                 [path and args for ICMPv6 ping command])
1214 else
1215         AC_MSG_RESULT([none])
1216 fi
1218 if test "x$ac_cv_ping6_packets_first" != "xno"; then
1219         AC_DEFINE(PING6_PACKETS_FIRST,1,
1220                 [Define if packet count must precede host])
1221 fi
1222 fi
1225 AC_ARG_WITH(nslookup_command,
1226             ACX_HELP_STRING([--with-nslookup-command=PATH],
1227                             [sets path to nslookup executable]),
1228             ac_cv_nslookup_command=$withval)
1229 if test -n "$ac_cv_nslookup_command"; then
1230         AC_MSG_NOTICE([Using specific nslookup at $ac_cv_nslookup_command])
1231 else
1232         AC_PATH_PROG(PATH_TO_NSLOOKUP,nslookup)
1233         if test -n "$PATH_TO_NSLOOKUP"
1234         then
1235                 AC_MSG_CHECKING(for nslookup syntax)
1236                 if $PATH_TO_NSLOOKUP -sil 127.0.0.1 2>&1 | grep ["Invalid option: sil"] >/dev/null
1237                 then
1238                         ac_cv_nslookup_command="$PATH_TO_NSLOOKUP"
1239                         AC_MSG_RESULT([$ac_cv_nslookup_command])
1241                 else
1242                         ac_cv_nslookup_command="$PATH_TO_NSLOOKUP -sil"
1243                         AC_MSG_RESULT([$ac_cv_nslookup_command])
1245                 fi
1246         else
1247                 AC_MSG_WARN([nslookup command not found])
1248         fi
1249 fi
1251 if test -n "$ac_cv_nslookup_command"; then
1252         EXTRAS="$EXTRAS check_dns"
1253         AC_DEFINE_UNQUOTED(NSLOOKUP_COMMAND,"$ac_cv_nslookup_command", [path and args for nslookup])
1254 fi
1256 AC_PATH_PROG(PATH_TO_UPTIME,uptime)
1257 AC_ARG_WITH(uptime_command,
1258             ACX_HELP_STRING([--with-uptime-command=PATH],
1259                             [sets path to uptime]), PATH_TO_UPTIME=$withval)
1260 AC_DEFINE_UNQUOTED(PATH_TO_UPTIME,"$PATH_TO_UPTIME",[path to uptime binary])
1262 AC_PATH_PROG(PATH_TO_RPCINFO,rpcinfo)
1263 AC_ARG_WITH(rpcinfo_command,
1264             ACX_HELP_STRING([--with-rpcinfo-command=PATH],
1265                             [sets path to rpcinfo]), PATH_TO_RPCINFO=$withval)
1266 AC_DEFINE_UNQUOTED(PATH_TO_RPCINFO,"$PATH_TO_RPCINFO",[path to rpcinfo binary])
1268 AC_PATH_PROG(PATH_TO_LMSTAT,lmstat)
1269 if test -x "$PATH_TO_LMSTAT"
1270 then
1271         AC_DEFINE_UNQUOTED(PATH_TO_LMSTAT,"$PATH_TO_LMSTAT",[path to lmstat])
1272 else
1273         AC_MSG_WARN([Get lmstat from Globetrotter Software to monitor flexlm licenses])
1274 fi
1276 AC_PATH_PROG(PATH_TO_SMBCLIENT,smbclient)
1277 AC_ARG_WITH(smbclient_command,
1278             ACX_HELP_STRING([--with-smbclient-command=PATH],
1279                             [sets path to smbclient]), 
1280             PATH_TO_SMBCLIENT=$withval)
1281 if test -n "$PATH_TO_SMBCLIENT"
1282 then
1283         AC_DEFINE_UNQUOTED(PATH_TO_SMBCLIENT,"$PATH_TO_SMBCLIENT",[path to smbclient binary])
1284 else
1285         AC_MSG_WARN([Get smbclient from Samba.org to monitor SMB shares])
1286 fi
1289 AC_PATH_PROG(PATH_TO_WHO,who)
1291 if [$PATH_TO_WHO -q 2>/dev/null | egrep -i "^# users=[0-9]+$" >/dev/null]
1292 then
1293         ac_cv_path_to_who="$PATH_TO_WHO -q"
1294 else
1295         ac_cv_path_to_who="$PATH_TO_WHO"
1296 fi
1298 AC_DEFINE_UNQUOTED(WHO_COMMAND,"$ac_cv_path_to_who",
1299         [path and arguments for invoking 'who'])
1301 AC_PATH_PROG(PATH_TO_SNMPGET,snmpget)
1302 AC_ARG_WITH(snmpget_command,
1303             ACX_HELP_STRING([--with-snmpget-command=PATH],
1304                             [Path to snmpget command]),
1305             PATH_TO_SNMPGET=$withval)
1306 if test -n "$PATH_TO_SNMPGET"
1307 then
1308         AC_DEFINE_UNQUOTED(PATH_TO_SNMPGET,"$PATH_TO_SNMPGET",[path to snmpget binary])
1309         EXTRAS="$EXTRAS check_hpjd check_snmp"
1310 else
1311         AC_MSG_WARN([Get snmpget from http://net-snmp.sourceforge.net to make check_hpjd and check_snmp plugins])
1312 fi
1314 AC_PATH_PROG(PATH_TO_SNMPGETNEXT,snmpgetnext)
1315 AC_ARG_WITH(snmpgetnext_command,
1316             ACX_HELP_STRING([--with-snmpgetnext-command=PATH],
1317                             [Path to snmpgetnext command]),
1318             PATH_TO_SNMPGETNEXT=$withval)
1319 if test -n "$PATH_TO_SNMPGETNEXT"
1320 then
1321         AC_DEFINE_UNQUOTED(PATH_TO_SNMPGETNEXT,"$PATH_TO_SNMPGETNEXT",[path to snmpgetnext binary])
1322 fi
1324 if ( $PERL -M"Net::SNMP 3.6" -e 'exit' 2>/dev/null  )
1325 then
1326         AC_MSG_CHECKING(for Net::SNMP perl module)
1327         AC_MSG_RESULT([found])
1328 else
1329         AC_MSG_WARN([Tried $PERL - install Net::SNMP perl module if you want to use the perl snmp plugins])
1330 fi
1332 AC_PATH_PROG(PATH_TO_QUAKESTAT,quakestat)
1333 AC_PATH_PROG(PATH_TO_QSTAT,qstat)
1334 AC_ARG_WITH(qstat_command,
1335             ACX_HELP_STRING([--with-qstat-command=PATH], 
1336                             [Path to qstat command]), PATH_TO_QSTAT=$withval)
1338 if test -x "$PATH_TO_QUAKESTAT"
1339 then
1340         ac_cv_path_to_qstat="$PATH_TO_QUAKESTAT"
1341         EXTRAS="$EXTRAS check_game"
1343 elif test -n "$PATH_TO_QSTAT"
1344 then
1345         ac_cv_path_to_qstat="$PATH_TO_QSTAT"
1346         EXTRAS="$EXTRAS check_game"
1347 else
1348         AC_MSG_WARN([Get qstat from http://www.activesw.com/people/steve/qstat.html in order to make check_game plugin])
1349 fi
1351 if test $ac_cv_path_to_qstat 
1352 then
1353         AC_DEFINE_UNQUOTED(PATH_TO_QSTAT,"$ac_cv_path_to_qstat",
1354                 [path to qstat/quakestat])
1355 fi
1357 AC_PATH_PROG(PATH_TO_FPING,fping)
1358 AC_ARG_WITH(fping_command,
1359             ACX_HELP_STRING([--with-fping-command=PATH],
1360                             [Path to fping command]), PATH_TO_FPING=$withval)
1361 if test -n "$PATH_TO_FPING"
1362 then
1363         AC_DEFINE_UNQUOTED(PATH_TO_FPING,"$PATH_TO_FPING",[path to fping])
1364         EXTRAS="$EXTRAS check_fping"
1365 else
1366         AC_MSG_WARN([Get fping from http://www.fping.com in order to make check_fping plugin])
1367 fi
1369 AC_PATH_PROG(PATH_TO_SSH,ssh)
1370 AC_ARG_WITH(ssh_command,
1371             ACX_HELP_STRING([--with-ssh-command=PATH],
1372                             [sets path for ssh]), PATH_TO_SSH=$withval)
1373 if test -n "$PATH_TO_SSH"
1374 then
1375         AC_DEFINE_UNQUOTED(SSH_COMMAND,"$PATH_TO_SSH",[path to ssh binary])
1376         EXTRAS="$EXTRAS check_by_ssh"
1377 else
1378         AC_MSG_WARN([Get ssh in order to make check_by_ssh plugin])
1379 fi
1382 AC_PATH_PROG(PATH_TO_MAILQ,mailq)
1383 AC_ARG_WITH(mailq_command,
1384             ACX_HELP_STRING([--with-mailq-command=PATH],
1385                             [sets path to mailq]), PATH_TO_MAILQ=$withval)
1386 if test -n "$PATH_TO_MAILQ"
1387 then
1388         AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_MAILQ",[path to mailq])
1389 else
1390         AC_MSG_WARN([Could not find mailq or eqivalent])
1391 fi
1393 AC_PATH_PROG(PATH_TO_QMAIL_QSTAT,qmail-qstat)
1394 if test -x "$PATH_TO_QMAIL_QSTAT"
1395 then
1396         AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_QMAIL_QSTAT",[path to qmail-qstat])
1397 else
1398         AC_MSG_WARN([Could not find qmail-qstat or eqivalent])
1399 fi
1401 dnl SWAP info required is amount allocated/available and amount free
1402 dnl The plugin works through all the swap devices and adds up the total swap
1403 dnl available.
1404 AC_PATH_PROG(PATH_TO_SWAP,swap)
1405 if (test -n "$PATH_TO_SWAP")
1406 then
1407 AC_MSG_CHECKING([for $PATH_TO_SWAP format])
1408 if [$PATH_TO_SWAP -l 2>&1 >/dev/null]
1409 then
1410         ac_cv_have_swap=yes
1411         ac_cv_swap_command="$PATH_TO_SWAP -l"
1412         if [$PATH_TO_SWAP -l 2>/dev/null | \
1413                 egrep -i "^lswap +path +pri +swaplo +blocks +free +maxswap" \
1414                 >/dev/null]
1415         then
1416                 ac_cv_swap_format=[" %*d %*s %*d,%*d %*d %*d %f %f"]
1417                 ac_cv_swap_conv=2048
1418                 AC_MSG_RESULT([using IRIX format swap])
1420         elif [$PATH_TO_SWAP -l 2>/dev/null | egrep -i "^path +dev +swaplo +blocks +free" >/dev/null]
1421         then
1422                 ac_cv_swap_format=["%*s %*[0-9,-] %*d %f %f"]
1423                 ac_cv_swap_conv=2048
1424                 AC_MSG_RESULT([using Unixware format swap])
1425         else
1426                 dnl if we don't know what format swap's output is
1427                 dnl we might as well pretend we didn't see it
1428                 ac_cv_have_swap=""
1429                 ac_cv_swap_command=""
1430         fi
1431 fi
1432 dnl end if for PATH_TO_SWAP
1433 fi
1435 AC_PATH_PROG(PATH_TO_SWAPINFO,swapinfo)
1436 if (test -n "$PATH_TO_SWAPINFO")
1437 then
1438 AC_MSG_CHECKING([for $PATH_TO_SWAPINFO format])
1439 if [$PATH_TO_SWAPINFO -k 2>&1 | egrep -i "^Device" >/dev/null]
1440 then
1441         ac_cv_have_swap=yes
1442         ac_cv_swap_command="$PATH_TO_SWAPINFO -k"
1444         if [$PATH_TO_SWAPINFO -k 2>/dev/null | egrep -i "^Device +1K-blocks +Used +Avail" >/dev/null]
1445         then
1446                 ac_cv_swap_format=["%*s %f %*d %f"]
1447                 ac_cv_swap_conv=1024
1448                 AC_MSG_RESULT([using FreeBSD format swapinfo])
1449         fi
1451 elif [$PATH_TO_SWAPINFO -dfM 2>/dev/null | egrep -i "^TYPE +AVAIL +USED +FREE" >/dev/null]
1452 then
1453         ac_cv_have_swap=yes
1454         ac_cv_swap_command="$PATH_TO_SWAPINFO -dfM",
1455         ac_cv_swap_format=["%*s %f %*d %f"]
1456         ac_cv_swap_conv=1024
1457         AC_MSG_RESULT([using HP-UX format swapinfo])
1458 fi
1459 dnl end if for PATH_TO_SWAPINFO
1460 fi
1462 AC_PATH_PROG(PATH_TO_LSPS,lsps)
1463 if (test -n "$PATH_TO_LSPS")
1464 then
1465 AC_MSG_CHECKING([for $PATH_TO_LSPS format])
1466 if [$PATH_TO_LSPS -a 2>/dev/null | egrep -i "^Page Space" > /dev/null]
1467 then
1468         ac_cv_have_swap=yes
1469         ac_cv_swap_command="$PATH_TO_LSPS -a"
1470         ac_cv_swap_format=["%*s %*s %*s %f%*s %f %*s"]
1471         ac_cv_swap_conv=1
1472         AC_MSG_RESULT([using AIX lsps])
1473 fi
1474 dnl end if for PATH_TO_SWAPINFO
1475 fi
1477 dnl
1478 dnl test for swapctl system call, both the 2-arg and 3-arg variants
1479 dnl fwict, the 2-arg is an SVR4 standard, whereas the 3-arg is shared
1480 dnl in the various BSD's
1481 dnl
1483 AC_CHECK_HEADERS([sys/stat.h sys/param.h])
1484 AC_CHECK_HEADERS([sys/swap.h], [], [], [
1485 #ifdef HAVE_SYS_PARAM_H
1486 #include <sys/param.h>
1487 #endif
1488 ])
1489 AC_CHECK_DECLS([swapctl],,,[
1490                #include <unistd.h>
1491                #include <sys/types.h>
1492                #include <sys/param.h>
1493                #include <sys/stat.h>
1494                #include <sys/swap.h>
1495                ])
1496 AC_CHECK_TYPES([swaptbl_t, swapent_t],,,[
1497                #include <sys/types.h>
1498                #include <sys/param.h>
1499                #include <sys/stat.h>
1500                #include <sys/swap.h>
1501                ])
1502 AC_CHECK_MEMBERS([struct swapent.se_nblks],,,[
1503                #include <unistd.h>
1504                #include <sys/types.h>
1505                #include <sys/param.h>
1506                #include <sys/stat.h>
1507                #include <sys/swap.h>
1508                ])
1510 if test "$ac_cv_have_decl_swapctl" = "yes"; 
1511 then
1512         EXTRAS="$EXTRAS check_swap"
1513         AC_MSG_CHECKING([for 2-arg (SVR4) swapctl])
1514         if test "$ac_cv_type_swaptbl_t" = "yes" -a \
1515                 "$ac_cv_type_swapent_t" = "yes"; 
1516         then
1517                 AC_MSG_RESULT([yes])
1518                 ac_cv_check_swap_swapctl_svr4="1";
1519                 AC_DEFINE([CHECK_SWAP_SWAPCTL_SVR4],1,
1520                           [Define if 2-argument SVR4 swapctl exists])
1521         else
1522                 AC_MSG_RESULT([no])
1523                 AC_MSG_CHECKING([for 3-arg (*BSD) swapctl])
1524                 if test "$ac_cv_member_struct_swapent_se_nblks" = "yes"; 
1525                 then
1526                         AC_MSG_RESULT([yes])
1527                         AC_DEFINE([CHECK_SWAP_SWAPCTL_BSD],1,
1528                                   [Define if 3-argument BSD swapctl exists])
1529                 else
1530                         AC_MSG_RESULT([no])
1531                 fi
1532         fi
1533         AC_MSG_CHECKING([for whether swapctl uses blocks or pages])
1534         if test "$ac_cv_check_swap_swapctl_svr4" = "1";
1535         then
1536                 dnl
1537                 dnl the SVR4 spec returns values in pages
1538                 dnl
1539                 AC_MSG_RESULT([page])
1540                 AC_CHECK_DECLS([sysconf])
1541                 AC_MSG_CHECKING([for system page size])
1542                 if test "$ac_cv_have_decl_sysconf" = "yes";
1543                 then
1544                         AC_MSG_RESULT([determined by sysconf(3)])
1545                         ac_cv_swap_conv="(1048576/sysconf(_SC_PAGESIZE))"
1546                 else
1547                         AC_MSG_WARN([don't know. guessing 4096k])
1548                         ac_cv_swap_conv=256
1549                 fi
1550         else
1551                 dnl
1552                 dnl the BSD spec returns values in blocks
1553                 dnl
1554                 AC_MSG_RESULT([blocks (assuming 512b)])
1555                 ac_cv_swap_conv=2048
1556         fi
1557         AC_DEFINE_UNQUOTED(SWAP_CONVERSION,$ac_cv_swap_conv,
1558                 [Conversion factor to MB])
1559 fi
1560 dnl
1561 dnl end tests for the swapctl system calls
1562 dnl
1565 if test "x$ac_cv_have_swap" != "x" 
1566 then
1567         AC_DEFINE(HAVE_SWAP,1,[Define if swap/swapinfo command is found])
1568         EXTRAS="$EXTRAS check_swap"
1569 fi
1570 if test "x$ac_cv_swap_command" != "x" 
1571 then
1572         AC_DEFINE_UNQUOTED(SWAP_COMMAND,"$ac_cv_swap_command",
1573                 [Path to swap/swapinfo binary, with any args])
1574         AC_DEFINE_UNQUOTED(SWAP_FORMAT,"$ac_cv_swap_format",
1575                 [Format string for parsing swap output])
1576         AC_DEFINE_UNQUOTED(SWAP_CONVERSION,$ac_cv_swap_conv,
1577                 [Conversion factor to MB])
1578 fi
1580 AC_ARG_WITH(proc-meminfo,
1581             ACX_HELP_STRING([--with-proc-meminfo=PATH],
1582                             [path to /proc/meminfo or equivalent]),
1583                             ac_cv_proc_meminfo=$withval)
1584 dnl dunno why this does not work below - use hack (kbd)
1585 dnl fine on linux, broken on solaris
1586 dnl if /bin/test -e "/proc/meminfo"
1587 AC_MSG_CHECKING([for /proc/meminfo])
1588 if test -n "$ac_cv_proc_meminfo"; then
1589         AC_MSG_RESULT([(command line) $ac_cv_proc_meminfo])
1590 elif [cat /proc/meminfo > /dev/null 2>&1]; then
1591         AC_MSG_RESULT([found /proc/meminfo])
1592         ac_cv_proc_meminfo="/proc/meminfo"
1593 else
1594         AC_MSG_RESULT([no])
1595 fi
1597 if test -n "$ac_cv_proc_meminfo"; then
1598         AC_DEFINE(HAVE_PROC_MEMINFO,1,[Define if we have /proc/meminfo])
1599         AC_DEFINE_UNQUOTED(PROC_MEMINFO,"$ac_cv_proc_meminfo",[path to /proc/meminfo if name changes])
1600         EXTRAS="$EXTRAS check_swap"
1601 fi
1603 AC_PATH_PROG(PATH_TO_DIG,dig)
1604 AC_ARG_WITH(dig_command,
1605             ACX_HELP_STRING([--with-dig-command=PATH],
1606                             [Path to dig command]), PATH_TO_DIG=$withval)
1607 if test -n "$PATH_TO_DIG"; then
1608         EXTRAS="$EXTRAS check_dig"
1609         AC_DEFINE_UNQUOTED(PATH_TO_DIG,"$PATH_TO_DIG",[Path to dig command, if present])
1610 fi
1612 AC_PATH_PROG(PATH_TO_APTGET,apt-get)
1613 AC_ARG_WITH(apt-get_command,
1614             ACX_HELP_STRING([--with-apt-get-command=PATH],
1615                             [Path to apt-get command]), 
1616                             with_apt_get_command=$withval,
1617                             with_apt_get_command=$PATH_TO_APTGET)
1618 AC_DEFINE_UNQUOTED(PATH_TO_APTGET,"$PATH_TO_APTGET",[Path to apt-get command, if present])
1619 if test -n "$PATH_TO_APTGET" ; then
1620         EXTRAS="$EXTRAS check_apt"
1621 fi
1624 if test -f plugins/check_nt.c ; then
1625   EXTRAS="$EXTRAS check_nt"
1626 elif test -f ../plugins/check_nt.c ; then
1627   EXTRAS="$EXTRAS check_nt"
1628 fi
1630 AC_MSG_CHECKING(for va_list)
1631 AC_TRY_COMPILE([#ifdef __STDC__
1632                 #include <stdio.h>
1633                 #include <stdlib.h>
1634                 #include <stdarg.h>
1635                 #else
1636                 #include <sys/types.h>
1637                 #include <stdio.h>
1638                 #include <varargs.h>
1639                 #endif],
1640                 [va_list args;],
1641                 [AC_MSG_RESULT(yes)],
1642                 [NEED_VA_LIST=-DNEED_VA_LIST AC_SUBST(NEED_VA_LIST) AC_MSG_RESULT(no)])
1644 case $host in
1645         *bsd*)
1646                 AC_DEFINE(__bsd__,1,[bsd specific code in check_dhcp.c])
1647         ;;
1648         *linux*)
1649                 AC_DEFINE(__linux__,1,[sun specific code in check_dhcp.c])
1650         ;;
1651         *sun* | solaris*)
1652                 AC_DEFINE(__sun__,1,[sun specific code in check_dhcp.c])
1653         ;;
1654         *hpux*)  
1655                 AC_DEFINE(__hpux__,1,[hpux specific code in check_dhcp.c])
1656         ;;
1657 esac
1659 AC_SUBST(EXTRAS)
1660 AC_SUBST(EXTRAS_ROOT)
1661 AC_SUBST(EXTRA_NETOBJS)
1662 AC_SUBST(DEPLIBS)
1664 AM_GNU_GETTEXT([external], [need-ngettext])
1665 AM_GNU_GETTEXT_VERSION(0.13.1)
1667 dnl Check for Redhat spopen problem
1668 dnl Wierd problem where ECHILD is returned from a wait call in error
1669 dnl Only appears to affect nslookup and dig calls. Only affects redhat around
1670 dnl 2.6.9-11 (okay in 2.6.9-5). Redhat investigating root cause
1671 dnl We patch plugins/popen.c
1672 dnl Need to add smp because uname different on those
1673 dnl Can force patch to be applied with --enable-redhat-pthread-workaround
1674 AC_ARG_ENABLE(redhat-pthread-workaround, 
1675         AC_HELP_STRING([--enable-redhat-pthread-workaround], 
1676                 [force Redhat patch to be applied (default: test system)]),
1677         [ac_cv_enable_redhat_pthread_workaround=$enableval],
1678         [ac_cv_enable_redhat_pthread_workaround=test])
1679 if test "$ac_cv_enable_redhat_pthread_workaround" = "test" ; then
1680         if echo $ac_cv_uname_r | egrep "\.EL(smp)?$" >/dev/null 2>&1 ; then
1681                 AC_MSG_CHECKING(for redhat spopen problem)
1682                 ( cd config_test && make && make test ) > /dev/null 2>&1
1683                 if test $? -eq 0 ; then
1684                         AC_MSG_RESULT(okay)
1685                 else
1686                         AC_MSG_RESULT(error)
1687                         AC_DEFINE(REDHAT_SPOPEN_ERROR, 1, [Workaround on redhat in spopen])
1688                 fi
1689         fi
1690 elif test "$ac_cv_enable_redhat_pthread_workaround" = "yes" ; then
1691         AC_DEFINE(REDHAT_SPOPEN_ERROR, 1, [Forced workaround on redhat in spopen])
1692 fi
1694 dnl External libraries - see ACKNOWLEDGEMENTS
1695 np_COREUTILS
1696 np_CURL
1698 AC_OUTPUT(
1699   Makefile 
1700   lib/Makefile 
1701   m4/Makefile 
1702   plugins/Makefile 
1703   plugins/tests/Makefile
1704   plugins-root/Makefile
1705   plugins-scripts/Makefile 
1706   plugins-scripts/subst 
1707   plugins-scripts/utils.pm 
1708   plugins-scripts/utils.sh 
1709   command.cfg 
1710   test.pl 
1711   pkg/solaris/pkginfo 
1712   po/Makefile.in 
1716 dnl the ones below that are commented out need to be cleaned up 
1717 dnl in the configure code above to use with_foo instead of ac_cv_foo
1718 dnl if we want them to show up here.  it'd also make the code cleaner.
1719 dnl i'll get to that on another rainy day :) -sf
1720 ACX_FEATURE([with],[apt-get-command])
1721 dnl ACX_FEATURE([with],[dig-command])
1722 dnl ACX_FEATURE([with],[fping-command])
1723 dnl ACX_FEATURE([with],[mailq-command])
1724 dnl ACX_FEATURE([with],[nslookup-command])
1725 ACX_FEATURE([with],[ping6-command])
1726 ACX_FEATURE([with],[ping-command])
1727 dnl ACX_FEATURE([with],[qstat-command])
1728 dnl ACX_FEATURE([with],[rpcinfo-command])
1729 dnl ACX_FEATURE([with],[smbclient-command])
1730 dnl ACX_FEATURE([with],[snmpget-command])
1731 dnl ACX_FEATURE([with],[snmpgetnext-command])
1732 dnl ACX_FEATURE([with],[ssh-command])
1733 dnl ACX_FEATURE([with],[uptime-command])
1735 dnl ACX_FEATURE([with],[proc-loadavg])
1736 dnl ACX_FEATURE([with],[proc-meminfo])
1737 dnl ACX_FEATURE([with],[ps-command])
1738 dnl ACX_FEATURE([with],[ps-format])
1739 dnl ACX_FEATURE([with],[ps-cols])
1740 dnl ACX_FEATURE([with],[ps-varlist])
1742 ACX_FEATURE([with],[lwres])
1743 ACX_FEATURE([with],[ipv6])
1744 ACX_FEATURE([with],[mysql])
1745 ACX_FEATURE([with],[openssl])
1746 ACX_FEATURE([with],[gnutls])
1747 ACX_FEATURE([enable],[emulate-getaddrinfo])
1748 ACX_FEATURE([with],[perl])
1749 ACX_FEATURE([with],[cgiurl])
1750 ACX_FEATURE([with],[nagios-user])
1751 ACX_FEATURE([with],[nagios-group])
1752 ACX_FEATURE([with],[trusted-path])