Code

0fba2d39ddd55125da2109c991aba0195bd7d960
[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
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])
41 dnl AM_WITH_REGEX
43 PLUGIN_TEST=`echo $srcdir/plugins/t/*.t|sed -e 's,\.*/plugins/,,g'`
44 AC_SUBST(PLUGIN_TEST)dnl
46 SCRIPT_TEST=`echo $srcdir/plugins-scripts/t/*.t|sed -e 's,\.*/plugins-scripts/,,g'`
47 AC_SUBST(SCRIPT_TEST)dnl
49 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"
50 AC_SUBST(WARRANTY)
52 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"
53 AC_SUBST(SUPPORT)
55 dnl CGIURL has changed for Nagios with 1.0 beta
56 AC_ARG_WITH(cgiurl,
57         ACX_HELP_STRING([--with-cgiurl=DIR],
58                 [sets URL for cgi programs]),
59         with_cgiurl=$withval,
60         with_cgiurl=/nagios/cgi-bin)
61 CGIURL="$with_cgiurl"
62 AC_DEFINE_UNQUOTED(CGIURL,"$CGIURL",[URL of CGI programs])
64 AC_ARG_WITH(nagios_user,
65         ACX_HELP_STRING([--with-nagios-user=USER],
66                 [set user name to run nagios]),
67         with_nagios_user=$withval,
68         with_nagios_user=nagios)
69 AC_ARG_WITH(nagios_group,
70         ACX_HELP_STRING([--with-nagios-group=GROUP],
71                 [set group name to run nagios]),
72         with_nagios_group=$withval,
73         with_nagios_group=nagios)
74 AC_SUBST(with_nagios_user)
75 AC_SUBST(with_nagios_group)
76 INSTALL_OPTS="-o $with_nagios_user -g $with_nagios_group"
77 AC_SUBST(INSTALL_OPTS)
79 AC_ARG_WITH(trusted_path,
80         ACX_HELP_STRING([--with-trusted-path=PATH],
81                 [sets trusted path for executables called by scripts (default=/bin:/sbin:/usr/bin:/usr/sbin)]),
82         with_trusted_path=$withval,
83         with_trusted_path=/bin:/sbin:/usr/bin:/usr/sbin)
84 AC_SUBST(with_trusted_path)
86 EXTRAS=
87 EXTRAS_ROOT=
88 dnl PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/etc:/usr/local/bin:/usr/local/sbin:$PATH
90 LDFLAGS="$LDFLAGS -L."
92 ac_cv_uname_m=`uname -m`
93 ac_cv_uname_s=`uname -s`
94 ac_cv_uname_r=`uname -r`
95 ac_cv_uname_v=`uname -v`
97 PKG_ARCH=`uname -p`
98 REV_DATESTAMP=`date '+%Y.%m.%d.%H.%M'`
99 REV_TIMESTAMP=`date '+%Y%m%d%H%M%S'`
101 AC_SUBST(PKG_ARCH)
102 AC_SUBST(REV_DATESTAMP)
103 AC_SUBST(REV_TIMESTAMP)
105 dnl Checks for programs.
106 AC_PATH_PROG(PYTHON,python)
107 AC_PATH_PROG(SH,sh)
108 AC_PATH_PROG(PERL,perl)
109 AC_PATH_PROG(LIBGNUTLS_CONFIG,libgnutls-config)
110 AC_PATH_PROG(HOSTNAME,hostname)
111 AC_PATH_PROG(BASENAME,basename)
113 dnl allow them to override the path of perl
114 AC_ARG_WITH(perl,
115         ACX_HELP_STRING([--with-perl=PATH],
116                         [sets path to perl executable]),
117                         with_perl=$withval,with_perl=$PERL)
118 AC_SUBST(PERL, $with_perl)
120 dnl openssl/gnutls
121 AC_ARG_WITH(openssl,
122             AC_HELP_STRING([--with-openssl=DIR], 
123                            [path to openssl installation]),)
125 AC_ARG_WITH(gnutls,
126             ACX_HELP_STRING([--with-gnutls=PATH],
127                             [path to gnutls installation root]),)
129 dnl you can only have one or the other
130 if test ! "$with_openssl" = "" && test ! "$with_openssl" = "no"; then
131         with_gnutls="no"
132 fi
133 if test ! "$with_gnutls" = "" && test ! "$with_gnutls" = "no"; then
134         with_openssl="no"
135 fi
137 dnl list of possible dirs to try to autodetect openssl
138 dnl if $dir/include exists, we consider it found
139 dnl the order should allow locally installed versions to override distros' ones
140 OPENSSL_DIRS="/usr /usr/local /usr/slocal /usr/local/openssl /usr/local/ssl \
141               /opt /opt/openssl"
143 dnl
144 dnl Check for miscellaneous stuff
145 dnl 
147 case $host_vender-$host_os in
148 sun*)
149         AC_DEFINE(__EXTENSIONS__,1,[Sun's netdb.h needs this for getaddrinfo])
150         ;;
151 osf*)
152         AC_DEFINE(_OSF_SOURCE,1,[OSF needs this for getaddrinfo])
153         ;;
154 esac
156 dnl
157 dnl Checks for libraries.
158 dnl
160 AC_CHECK_LIB(dce,main,SOCKETLIBS="$SOCKETLIBS -ldce")
161 AC_CHECK_LIB(nsl,main,SOCKETLIBS="$SOCKETLIBS -lnsl")
162 AC_CHECK_LIB(socket,socket,SOCKETLIBS="$SOCKETLIBS -lsocket")
163 AC_CHECK_LIB(resolv,main,SOCKETLIBS="$SOCKETLIBS -lresolv")
164 AC_SUBST(SOCKETLIBS)
166 dnl
167 dnl check for math-related functions needing -lm
168 AC_CHECK_HEADERS(math.h)
169 AC_CHECK_LIB(m,floor,MATHLIBS="-lm")
170 AC_SUBST(MATHLIBS)
172 dnl Check for libtap, to run perl-like tests
173 AC_CHECK_LIB(tap, plan_tests, 
174         EXTRA_TEST=test_utils
175         AC_SUBST(EXTRA_TEST)
176         )
178 dnl Check for PostgreSQL libraries
179 _SAVEDLIBS="$LIBS"
180 _SAVEDCPPFLAGS="$CPPFLAGS"
181 AC_ARG_WITH(pgsql,
182         ACX_HELP_STRING([--with-pgsql=DIR],
183                 [sets path to pgsql installation]),
184         PGSQL=$withval,)
185 AC_CHECK_LIB(crypt,main)
186 if test "$ac_cv_lib_crypt_main" = "yes"; then
187   if test -n "$PGSQL"; then
188     LDFLAGS="$LDFLAGS -L$PGSQL/lib"
189     CPPFLAGS="$CPPFLAGS -I$PGSQL/include"
190   fi
191   AC_CHECK_LIB(pq,PQsetdbLogin,,,-lcrypt)
192   if test "$ac_cv_lib_pq_PQsetdbLogin" = "yes"; then
193     AC_CHECK_HEADERS(pgsql/libpq-fe.h)
194     AC_CHECK_HEADERS(postgresql/libpq-fe.h)
195     AC_CHECK_HEADERS(libpq-fe.h)
196     if [[ -n "$PGSQL" -a "$ac_cv_header_libpq_fe_h" = "yes" ]]; then
197       PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
198       PGINCLUDE="-I$PGSQL/include"
199     elif test  "$ac_cv_header_pgsql_libpq_fe_h" = "yes"; then
200       PGLIBS="-lpq -lcrypt"
201       PGINCLUDE="-I/usr/include/pgsql"
202     elif test  "$ac_cv_header_postgresql_libpq_fe_h" = "yes"; then
203       PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
204       PGINCLUDE="-I/usr/include/postgresql"
205     elif test  "$ac_cv_header_libpq_fe_h" = "yes"; then
206       PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
207       PGINCLUDE="-I$PGSQL/include"
208     fi
209     if test -z "$PGINCLUDE"; then
210       AC_MSG_WARN([Skipping PostgreSQL plugin (check_pgsql)])
211       AC_MSG_WARN([install PostgreSQL headers to compile this plugin (see REQUIREMENTS).])
212     else
213       AC_SUBST(PGLIBS)
214       AC_SUBST(PGINCLUDE)
215       EXTRAS="$EXTRAS check_pgsql"
216     fi
217   else
218     AC_MSG_WARN([Skipping PostgreSQL plugin (check_pgsql)])
219     AC_MSG_WARN([LIBS="$LIBS" CPPFLAGS="$CPPFLAGS"])
220     AC_MSG_WARN([install PostgreSQL libs to compile this plugin (see REQUIREMENTS).])
221   fi
222 else
223   AC_MSG_WARN([Skipping PostgreSQL plugin (check_pgsql)])
224   AC_MSG_WARN([install lib crypt and PostgreSQL libs to compile this plugin (see REQUIREMENTS).])
225 fi
226 LIBS="$_SAVEDLIBS"
227 CPPFLAGS="$_SAVEDCPPFLAGS"
229 dnl Check for radius libraries
230 _SAVEDLIBS="$LIBS"
231 AC_CHECK_LIB(radiusclient,rc_read_config)
232 if test "$ac_cv_lib_radiusclient_rc_read_config" = "yes"; then
233   EXTRAS="$EXTRAS check_radius"
234         RADIUSLIBS="-lradiusclient"
235   AC_SUBST(RADIUSLIBS)
236 else
237   AC_MSG_WARN([Skipping radius plugin])
238   AC_MSG_WARN([install radius libs to compile this plugin (see REQUIREMENTS).])
239 fi
240 LIBS="$_SAVEDLIBS"
242 dnl Check for LDAP libraries
243 _SAVEDLIBS="$LIBS"
244 AC_CHECK_LIB(ldap,main,,,-llber)
245 if test "$ac_cv_lib_ldap_main" = "yes"; then
246   LDAPLIBS="-lldap -llber"\
247   LDAPINCLUDE="-I/usr/include/ldap"
248   AC_SUBST(LDAPLIBS)
249   AC_SUBST(LDAPINCLUDE)
250   AC_CHECK_FUNCS(ldap_set_option)
251   EXTRAS="$EXTRAS check_ldap"
252         AC_CHECK_FUNCS(ldap_init ldap_set_option ldap_get_option ldap_start_tls_s)
253 else
254   AC_MSG_WARN([Skipping LDAP plugin])
255   AC_MSG_WARN([install LDAP libs to compile this plugin (see REQUIREMENTS).])
256 fi
257 LIBS="$_SAVEDLIBS"
259 dnl Check for mysql libraries
260 AC_ARG_WITH(mysql,
261         ACX_HELP_STRING([--with-mysql=DIR],
262                 [Compiles mysql plugins. Expects DIR/bin/mysql_config]),
263         with_mysql=$withval,
264         with_mysql=no)
265 if test $with_mysql != "no" ; then
266   if test -x $with_mysql/bin/mysql_config ; then
267     MYSQLCONFIG="$with_mysql/bin/mysql_config"
268   else
269     AC_PATH_PROG(MYSQLCONFIG, mysql_config)
270   fi
271   if test -z "$MYSQLCONFIG"; then
272     with_mysql="not found"
273     AC_MSG_WARN([Skipping mysql plugin])
274     AC_MSG_WARN([install mysql client libs to compile this plugin (see REQUIREMENTS).])
275   else
276     with_mysql=$MYSQLCONFIG
277     EXTRAS="$EXTRAS check_mysql check_mysql_query"
278     MYSQLINCLUDE=`$MYSQLCONFIG --include`
279     MYSQLLIBS=`$MYSQLCONFIG --libs`
280     MYSQLCFLAGS=`$MYSQLCONFIG --cflags`
281     AC_SUBST(MYSQLINCLUDE)
282     AC_SUBST(MYSQLLIBS)
283     AC_SUBST(MYSQLCFLAGS)
284   fi
285 fi
287 AC_CHECK_HEADERS(unistd.h)
289 dnl Check for AF_INET6 support - unistd.h required for Darwin
290 AC_CACHE_CHECK([for IPv6 support], with_ipv6, [
291         AC_TRY_COMPILE([#ifdef HAVE_UNISTD_H
292                         #include <unistd.h>
293                         #endif
294                         #include <netinet/in.h>
295                         #include <sys/socket.h>],
296                         [struct sockaddr_in6 sin6;
297                         void *p;
299                         sin6.sin6_family = AF_INET6;
300                         sin6.sin6_port = 587;
301                         p = &sin6.sin6_addr;],
302                         [with_ipv6=yes], 
303                         [with_ipv6=no])
304         ])
306 if test x"$with_ipv6" != xno ; then
307         AC_DEFINE(USE_IPV6,1,[Enable IPv6 support])
308 fi
310 dnl #########################################################################
311 dnl Check if Posix getaddrinfo() is available.  It is also possible to use
312 dnl the version from the lwres library distributed with BIND.
313 dnl #########################################################################
314 AC_ARG_ENABLE([emulate-getaddrinfo],
315               ACX_HELP_STRING([--enable-emulate-getaddrinfo],
316                              [enable getaddrinfo emulation (default=no)]),
317               ,
318               enable_emulate_getaddrinfo=no)
320 AC_ARG_WITH(lwres,
321             ACX_HELP_STRING([--with-lwres=DIR],
322                            [use lwres library for getaddrinfo (default=no)]),
323             ,
324             with_lwres=no)
326 dnl ## enable force to test getaddrinfo.c
327 if test x$enable_emulate_getaddrinfo = xforce ; then
328         enable_emulate_getaddrinfo=yes
329         have_getaddrinfo=no
330 else
332 have_getaddrinfo=no
333 if test x$with_lwres != xno ; then
334         if test "$with_lwres" != yes ; then
335                    CPPFLAGS="-I${with_lwres}/include $CPPFLAGS"
336                    LDFLAGS="-L${with_lwres}/lib $LDFLAGS"
337         fi
338         AC_CHECK_HEADERS(lwres/netdb.h, ,
339                         [AC_MSG_ERROR([cannot find <lwres/netdb.h>])])
340         AC_CHECK_LIB(lwres, lwres_getaddrinfo, ,
341                      [AC_MSG_ERROR([cannot find the lwres library])],
342                      -lnsl -lpthread)
343         have_getaddrinfo=yes
344 fi
346 if test x$have_getaddrinfo != xyes ; then
347         AC_SEARCH_LIBS(getaddrinfo, socket resolv bind nsl c_r cr, have_getaddrinfo=yes)
348 fi
350 dnl # Special nonsense for systems that actually have getaddrinfo but
351 dnl # redefine the name to something else, e.g. OSF
352 if test x$have_getaddrinfo != xyes ; then
353         AC_MSG_CHECKING(if getaddrinfo is redefined in netdb.h)
354         AC_TRY_LINK([
355 #               include <netdb.h>
356         ], [
357                 struct addrinfo hints, *res;
358                 int err;
360                 err = getaddrinfo ("host", "service", &hints, &res);
361         ], [
362                 have_getaddrinfo=yes
363                 AC_MSG_RESULT(yes)
364         ], [AC_MSG_RESULT(no)])
365 fi
367 fi
369 if test x$have_getaddrinfo != xno ; then
370         if test x$enable_emulate_getaddrinfo != xno ; then
371                 AC_MSG_ERROR([getaddrinfo found but emulate-getaddrinfo was enabled])
372         fi
373         AC_DEFINE(HAVE_GETADDRINFO, 1,
374                   [Does system provide RFC 2553/Posix getaddrinfo?])
375 else
376         if test x$enable_emulate_getaddrinfo != xyes ; then
377 dnl                AC_MSG_ERROR([getaddrinfo not found: try --with-lwres or --enable-emulate-getaddrinfo])
378                enable_emulate_getaddrinfo=yes
379                AC_MSG_WARN([enabling getaddrinfo emulation])
380         fi
381         EXTRA_NETOBJS="$EXTRA_NETOBJS getaddrinfo.o"
382 fi
384 if test x"$enable_emulate_getaddrinfo" != xno ; then
385     have_resolver=no
387   dnl  Try for getipnodebyname
388     AC_SEARCH_LIBS(getipnodebyname, resolv bind nsl c_r cr, have_resolver=yes)
389     if test x"$have_resolver" != xno ; then
390          AC_DEFINE(HAVE_GETIPNODEBYNAME, 1,
391                    [Set when getipnodebyname is available])
392     fi
394   dnl  Try for gethostbyname_r
395     if test x"$have_resolver" = xno ; then
396         AC_SEARCH_LIBS(gethostbyname_r, resolv bind nsl c_r cr,
397                        [have_resolver=yes
398                         ACX_WHICH_GETHOSTBYNAME_R])
399     fi
401   dnl  Try for gethostbyname
402     if test x"$have_resolver" = xno ; then
403         if test x"$enable_pthreads" != xno ; then
404             AC_MSG_WARN([using threads but cannot find gethostbyname_r or getipnodebyname])
405         fi
406         AC_SEARCH_LIBS(gethostbyname, resolv bind nsl, ,
407                        [AC_MSG_ERROR([cannot find gethostbyname])])
408     fi
409     EXTRA_NETOBJS="$EXTRA_NETOBJS gethostbyname.o"
411 fi
413 dnl Checks for Kerberos. Must come before openssl checks for Redhat EL 3
414 AC_CHECK_HEADERS(krb5.h,FOUNDINCLUDE=yes,FOUNDINCLUDE=no)
415 if test "$FOUNDINCLUDE" = "no"; then
416   _SAVEDCPPFLAGS="$CPPFLAGS"
417   CPPFLAGS="$_SAVEDCPPFLAGS -I/usr/kerberos/include"
418   unset ac_cv_header_krb5_h
419   AC_CHECK_HEADERS(krb5.h,
420                    KRB5INCLUDE="-I/usr/kerberos/include"
421                    FOUNDINCLUDE=yes,
422                    FOUNDINCLUDE=no)
423 fi
424 AC_SUBST(KRBINCLUDE)
425 if test "$FOUNDINCLUDE" = "no"; then
426   CPPFLAGS="$_SAVEDCPPFLAGS"
427 fi
430 dnl openssl detection/configuration
431 if ! test x"$with_openssl" = x"no"; then
432         dnl Check for OpenSSL location if it wasn't already specified
433         if ! test -d "$with_openssl"; then
434                 for d in $OPENSSL_DIRS; do
435                         if test -x ${d}/bin/openssl || test -x ${d}/sbin/openssl ; then
436                                 with_openssl=$d
437                         fi
438                 done
439         fi
441         _SAVEDCPPFLAGS="$CPPFLAGS"
442         _SAVEDLDFLAGS="$LDFLAGS"
443         dnl Check for OpenSSL header files
444         unset FOUNDINCLUDE
445         if test x"$with_openssl" != x"/usr" ; then
446                 CPPFLAGS="$CPPFLAGS -I$with_openssl/include"
447                 # Need both to find ssl libraries and to load at runtime
448                 LDFLAGS="$LDFLAGS -L$with_openssl/lib -R$with_openssl/lib"
449         fi
451         dnl check for openssl in $dir/include/openssl
452         AC_CHECK_HEADERS(openssl/ssl.h openssl/x509.h openssl/rsa.h openssl/pem.h openssl/crypto.h openssl/err.h,
453                          SSLINCLUDE="-I$with_openssl/include"
454                          FOUNDINCLUDE=yes,
455                          FOUNDINCLUDE=no)
456         dnl else check to see if $dir/include has it
457         if test "$FOUNDINCLUDE" = "no"; then
458                 AC_CHECK_HEADERS(ssl.h x509.h rsa.h pem.h crypto.h err.h,
459                                  SSLINCLUDE="-I$with_openssl/include"
460                                  FOUNDINCLUDE=yes,
461                                  FOUNDINCLUDE=no)
462         fi
463         AC_SUBST(SSLINCLUDE)
464         dnl if we didn't find it, reset CPPFLAGS
465         if test "$FOUNDINCLUDE" = "no"; then
466                 CPPFLAGS="$_SAVEDCPPFLAGS"
467                 LDFLAGS="$_SAVEDLDFLAGS"
468         fi
470         dnl Check for crypto lib
471         _SAVEDLIBS="$LIBS"
472         LIBS="-L${with_openssl}/lib"
473         AC_CHECK_LIB(crypto,CRYPTO_lock)
474         if test "$ac_cv_lib_crypto_CRYPTO_lock" = "yes"; then
475                 dnl Check for SSL lib
476                 AC_CHECK_LIB(ssl,main, SSLLIBS="-lssl -lcrypto",,-lcrypto)
477         fi
478         LIBS="$_SAVEDLIBS"
480         dnl test headers and libs to decide whether check_http should use SSL
481         if test "$ac_cv_lib_crypto_CRYPTO_lock" = "yes"; then
482                 if test "$ac_cv_lib_ssl_main" = "yes"; then
483                         if test "$FOUNDINCLUDE" = "yes"; then
484                                 FOUNDOPENSSL="yes"
485                         fi
486                 fi
487         fi
488 fi
491 dnl check for gnutls if openssl isn't found (or is disabled)
492 if test ! "$FOUNDOPENSSL" = "yes" && test ! "$with_gnutls" = "no"; then
493         if test ! "$with_gnutls" = ""; then
494                 CPPFLAGS="$CPPFLAGS -I${with_gnutls}/include"
495         elif test ! "$LIBGNUTLS_CONFIG" = ""; then
496                 CPPFLAGS="$CPPFLAGS -I`$LIBGNUTLS_CONFIG --prefix`"
497         fi
498         AC_CHECK_HEADERS([gnutls/openssl.h],FOUNDGNUTLS="yes",)
499         if test "$FOUNDGNUTLS" = "yes"; then
500                 AC_CHECK_LIB(gnutls-openssl,main,SSLLIBS="-lgnutls-openssl")
501         fi
502 fi
503 dnl end check for gnutls
505 if test "$FOUNDOPENSSL" = "yes" || test "$FOUNDGNUTLS" = "yes"; then
506         check_tcp_ssl="check_simap check_spop check_jabber check_nntps check_ssmtp"
507         AC_SUBST(check_tcp_ssl)
508         AC_SUBST(SSLLIBS)
509         AC_DEFINE(HAVE_SSL,1,[Define if SSL libraries are found])
510         if test "$FOUNDOPENSSL" = "yes"; then
511                 AC_DEFINE(USE_OPENSSL,1,[Define if using OpenSSL libraries])
512                 with_openssl="yes"
513                 with_gnutls="no"
514         else
515                 AC_DEFINE(USE_GNUTLS,1,[Define if using gnutls libraries])
516                 with_gnutls="yes"
517                 with_openssl="no"
518         fi
519 else
520         dnl else deliberately disabled or no ssl support available
521         AC_MSG_WARN([OpenSSL or GnuTLS libs could not be found or were disabled])
522         with_openssl="no"
523         with_gnutls="no"
524 fi
526 dnl
527 dnl Checks for header files.
528 dnl
530 AC_HEADER_STDC
531 AC_HEADER_TIME
532 AC_HEADER_SYS_WAIT
533 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)
534 AC_CHECK_HEADERS(features.h stdarg.h sys/unistd.h ctype.h stdlib.h)
535 AC_CHECK_HEADERS(regex.h,FOUNDREGEX=yes,FOUNDREGEX=no)
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 # check_apt needs regex support
1620 if test -n "$PATH_TO_APTGET" && test "$FOUNDREGEX" = "yes"; then
1621         EXTRAS="$EXTRAS check_apt"
1622 fi
1625 if test -f plugins/check_nt.c ; then
1626   EXTRAS="$EXTRAS check_nt"
1627 elif test -f ../plugins/check_nt.c ; then
1628   EXTRAS="$EXTRAS check_nt"
1629 fi
1631 AC_MSG_CHECKING(for va_list)
1632 AC_TRY_COMPILE([#ifdef __STDC__
1633                 #include <stdio.h>
1634                 #include <stdlib.h>
1635                 #include <stdarg.h>
1636                 #else
1637                 #include <sys/types.h>
1638                 #include <stdio.h>
1639                 #include <varargs.h>
1640                 #endif],
1641                 [va_list args;],
1642                 [AC_MSG_RESULT(yes)],
1643                 [NEED_VA_LIST=-DNEED_VA_LIST AC_SUBST(NEED_VA_LIST) AC_MSG_RESULT(no)])
1645 case $host in
1646         *bsd*)
1647                 AC_DEFINE(__bsd__,1,[bsd specific code in check_dhcp.c])
1648         ;;
1649         *linux*)
1650                 AC_DEFINE(__linux__,1,[sun specific code in check_dhcp.c])
1651         ;;
1652         *sun* | solaris*)
1653                 AC_DEFINE(__sun__,1,[sun specific code in check_dhcp.c])
1654         ;;
1655         *hpux*)  
1656                 AC_DEFINE(__hpux__,1,[hpux specific code in check_dhcp.c])
1657         ;;
1658 esac
1660 AC_SUBST(EXTRAS)
1661 AC_SUBST(EXTRAS_ROOT)
1662 AC_SUBST(EXTRA_NETOBJS)
1663 AC_SUBST(DEPLIBS)
1665 AM_GNU_GETTEXT([no-libtool], [need-ngettext])
1666 AM_GNU_GETTEXT_VERSION(0.11.5)
1668 dnl Check for Redhat spopen problem
1669 dnl Wierd problem where ECHILD is returned from a wait call in error
1670 dnl Only appears to affect nslookup and dig calls. Only affects redhat around
1671 dnl 2.6.9-11 (okay in 2.6.9-5). Redhat investigating root cause
1672 dnl We patch plugins/popen.c
1673 dnl Need to add smp because uname different on those
1674 dnl Can force patch to be applied with --enable-redhat-pthread-workaround
1675 AC_ARG_ENABLE(redhat-pthread-workaround, 
1676         AC_HELP_STRING([--enable-redhat-pthread-workaround], 
1677                 [force Redhat patch to be applied (default: test system)]),
1678         [ac_cv_enable_redhat_pthread_workaround=$enableval],
1679         [ac_cv_enable_redhat_pthread_workaround=test])
1680 if test "$ac_cv_enable_redhat_pthread_workaround" = "test" ; then
1681         if echo $ac_cv_uname_r | egrep "\.EL(smp)?$" >/dev/null 2>&1 ; then
1682                 AC_MSG_CHECKING(for redhat spopen problem)
1683                 ( cd config_test && make && make test ) > /dev/null 2>&1
1684                 if test $? -eq 0 ; then
1685                         AC_MSG_RESULT(okay)
1686                 else
1687                         AC_MSG_RESULT(error)
1688                         AC_DEFINE(REDHAT_SPOPEN_ERROR, 1, [Workaround on redhat in spopen])
1689                 fi
1690         fi
1691 elif test "$ac_cv_enable_redhat_pthread_workaround" = "yes" ; then
1692         AC_DEFINE(REDHAT_SPOPEN_ERROR, 1, [Forced workaround on redhat in spopen])
1693 fi
1695 dnl External libraries - see ACKNOWLEDGEMENTS
1696 np_COREUTILS
1697 np_CURL
1699 AC_OUTPUT(
1700   Makefile 
1701   lib/Makefile 
1702   m4/Makefile 
1703   plugins/Makefile 
1704   plugins/tests/Makefile
1705   plugins-root/Makefile
1706   plugins-scripts/Makefile 
1707   plugins-scripts/subst 
1708   plugins-scripts/utils.pm 
1709   plugins-scripts/utils.sh 
1710   command.cfg 
1711   test.pl 
1712   pkg/solaris/pkginfo 
1713   intl/Makefile
1714   po/Makefile.in 
1718 dnl the ones below that are commented out need to be cleaned up 
1719 dnl in the configure code above to use with_foo instead of ac_cv_foo
1720 dnl if we want them to show up here.  it'd also make the code cleaner.
1721 dnl i'll get to that on another rainy day :) -sf
1722 ACX_FEATURE([with],[apt-get-command])
1723 dnl ACX_FEATURE([with],[dig-command])
1724 dnl ACX_FEATURE([with],[fping-command])
1725 dnl ACX_FEATURE([with],[mailq-command])
1726 dnl ACX_FEATURE([with],[nslookup-command])
1727 ACX_FEATURE([with],[ping6-command])
1728 ACX_FEATURE([with],[ping-command])
1729 dnl ACX_FEATURE([with],[qstat-command])
1730 dnl ACX_FEATURE([with],[rpcinfo-command])
1731 dnl ACX_FEATURE([with],[smbclient-command])
1732 dnl ACX_FEATURE([with],[snmpget-command])
1733 dnl ACX_FEATURE([with],[snmpgetnext-command])
1734 dnl ACX_FEATURE([with],[ssh-command])
1735 dnl ACX_FEATURE([with],[uptime-command])
1737 dnl ACX_FEATURE([with],[proc-loadavg])
1738 dnl ACX_FEATURE([with],[proc-meminfo])
1739 dnl ACX_FEATURE([with],[ps-command])
1740 dnl ACX_FEATURE([with],[ps-format])
1741 dnl ACX_FEATURE([with],[ps-cols])
1742 dnl ACX_FEATURE([with],[ps-varlist])
1744 ACX_FEATURE([with],[lwres])
1745 ACX_FEATURE([with],[ipv6])
1746 ACX_FEATURE([with],[mysql])
1747 ACX_FEATURE([with],[openssl])
1748 ACX_FEATURE([with],[gnutls])
1749 ACX_FEATURE([enable],[emulate-getaddrinfo])
1750 ACX_FEATURE([with],[perl])
1751 ACX_FEATURE([with],[cgiurl])
1752 ACX_FEATURE([with],[nagios-user])
1753 ACX_FEATURE([with],[nagios-group])
1754 ACX_FEATURE([with],[trusted-path])