Code

Fix compile problems on Solaris for pst3 and ssl libs
[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                 LDFLAGS="$LDFLAGS -L$with_openssl/lib"
448         fi
450         dnl check for openssl in $dir/include/openssl
451         AC_CHECK_HEADERS(openssl/ssl.h openssl/x509.h openssl/rsa.h openssl/pem.h openssl/crypto.h openssl/err.h,
452                          SSLINCLUDE="-I$with_openssl/include"
453                          FOUNDINCLUDE=yes,
454                          FOUNDINCLUDE=no)
455         dnl else check to see if $dir/include has it
456         if test "$FOUNDINCLUDE" = "no"; then
457                 AC_CHECK_HEADERS(ssl.h x509.h rsa.h pem.h crypto.h err.h,
458                                  SSLINCLUDE="-I$with_openssl/include"
459                                  FOUNDINCLUDE=yes,
460                                  FOUNDINCLUDE=no)
461         fi
462         AC_SUBST(SSLINCLUDE)
463         dnl if we didn't find it, reset CPPFLAGS
464         if test "$FOUNDINCLUDE" = "no"; then
465                 CPPFLAGS="$_SAVEDCPPFLAGS"
466                 LDFLAGS="$_SAVEDLDFLAGS"
467         fi
469         dnl Check for crypto lib
470         _SAVEDLIBS="$LIBS"
471         LIBS="-L${with_openssl}/lib"
472         AC_CHECK_LIB(crypto,CRYPTO_lock)
473         if test "$ac_cv_lib_crypto_CRYPTO_lock" = "yes"; then
474                 dnl Check for SSL lib
475                 AC_CHECK_LIB(ssl,main, SSLLIBS="-lssl -lcrypto",,-lcrypto)
476         fi
477         LIBS="$_SAVEDLIBS"
479         dnl test headers and libs to decide whether check_http should use SSL
480         if test "$ac_cv_lib_crypto_CRYPTO_lock" = "yes"; then
481                 if test "$ac_cv_lib_ssl_main" = "yes"; then
482                         if test "$FOUNDINCLUDE" = "yes"; then
483                                 FOUNDOPENSSL="yes"
484                         fi
485                 fi
486         fi
487 fi
490 dnl check for gnutls if openssl isn't found (or is disabled)
491 if test ! "$FOUNDOPENSSL" = "yes" && test ! "$with_gnutls" = "no"; then
492         if test ! "$with_gnutls" = ""; then
493                 CPPFLAGS="$CPPFLAGS -I${with_gnutls}/include"
494         elif test ! "$LIBGNUTLS_CONFIG" = ""; then
495                 CPPFLAGS="$CPPFLAGS -I`$LIBGNUTLS_CONFIG --prefix`"
496         fi
497         AC_CHECK_HEADERS([gnutls/openssl.h],FOUNDGNUTLS="yes",)
498         if test "$FOUNDGNUTLS" = "yes"; then
499                 AC_CHECK_LIB(gnutls-openssl,main,SSLLIBS="-lgnutls-openssl")
500         fi
501 fi
502 dnl end check for gnutls
504 if test "$FOUNDOPENSSL" = "yes" || test "$FOUNDGNUTLS" = "yes"; then
505         check_tcp_ssl="check_simap check_spop check_jabber check_nntps check_ssmtp"
506         AC_SUBST(check_tcp_ssl)
507         AC_SUBST(SSLLIBS)
508         AC_DEFINE(HAVE_SSL,1,[Define if SSL libraries are found])
509         if test "$FOUNDOPENSSL" = "yes"; then
510                 AC_DEFINE(USE_OPENSSL,1,[Define if using OpenSSL libraries])
511                 with_openssl="yes"
512                 with_gnutls="no"
513         else
514                 AC_DEFINE(USE_GNUTLS,1,[Define if using gnutls libraries])
515                 with_gnutls="yes"
516                 with_openssl="no"
517         fi
518 else
519         dnl else deliberately disabled or no ssl support available
520         AC_MSG_WARN([OpenSSL or GnuTLS libs could not be found or were disabled])
521         with_openssl="no"
522         with_gnutls="no"
523 fi
525 dnl
526 dnl Checks for header files.
527 dnl
529 AC_HEADER_STDC
530 AC_HEADER_TIME
531 AC_HEADER_SYS_WAIT
532 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)
533 AC_CHECK_HEADERS(features.h stdarg.h sys/unistd.h ctype.h stdlib.h)
534 AC_CHECK_HEADERS(regex.h,FOUNDREGEX=yes,FOUNDREGEX=no)
536 dnl Checks for typedefs, structures, and compiler characteristics.
537 AC_C_CONST
538 AC_STRUCT_TM
539 AC_TYPE_PID_T
540 AC_TYPE_SIZE_T
541 AC_TYPE_SIGNAL
543 AC_CACHE_CHECK([for va_copy],ac_cv_HAVE_VA_COPY,[
544 AC_TRY_LINK([#include <stdarg.h>
545 va_list ap1,ap2;], [va_copy(ap1,ap2);],
546 ac_cv_HAVE_VA_COPY=yes,
547 ac_cv_HAVE_VA_COPY=no)])
548 if test x"$ac_cv_HAVE_VA_COPY" = x"yes"; then
549     AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available])
550 else    
551     AC_CACHE_CHECK([for __va_copy],ac_cv_HAVE___VA_COPY,[
552     AC_TRY_LINK([#include <stdarg.h>
553     va_list ap1,ap2;], [__va_copy(ap1,ap2);],
554     ac_cv_HAVE___VA_COPY=yes,
555     ac_cv_HAVE___VA_COPY=no)])
556     if test x"$ac_cv_HAVE___VA_COPY" = x"yes"; then
557         AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available])
558     fi
559 fi
561 AC_CHECK_FUNCS(vsnprintf snprintf asprintf vasprintf)
562 AC_CACHE_CHECK([for C99 vsnprintf],ac_cv_HAVE_C99_VSNPRINTF,[
563 AC_TRY_RUN([
564 #include <sys/types.h>
565 #include <stdarg.h>
566 void foo(const char *format, ...) { 
567        va_list ap;
568        int len;
569        char buf[5];
571        va_start(ap, format);
572        len = vsnprintf(buf, 0, format, ap);
573        va_end(ap);
574        if (len != 5) exit(1);
576        va_start(ap, format);
577        len = vsnprintf(0, 0, format, ap);
578        va_end(ap);
579        if (len != 5) exit(1);
581        if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
583        exit(0);
585 main() { foo("hello"); }
586 ],
587 ac_cv_HAVE_C99_VSNPRINTF=yes,ac_cv_HAVE_C99_VSNPRINTF=no,ac_cv_HAVE_C99_VSNPRINTF=cross)])
588 if test x"$ac_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
589     AC_DEFINE(HAVE_C99_VSNPRINTF,1,[Define if system has C99 compatible vsnprintf])
590 fi
592 AC_TRY_COMPILE([#include <sys/time.h>],
593                [struct timeval *tv;
594                 struct timezone *tz;],
595                AC_DEFINE(HAVE_STRUCT_TIMEVAL,1,[Define if we have a timeval structure])
596                AC_TRY_COMPILE([#include <sys/time.h>],
597                               [struct timeval *tv;
598                                struct timezone *tz;
599                                gettimeofday(tv, tz);],
600                               AC_DEFINE(HAVE_GETTIMEOFDAY,1,[Define if gettimeofday is found]),
601                               AC_DEFINE(NEED_GETTIMEOFDAY,1,[Define if gettimeofday is needed])))
603 dnl Checks for library functions.
604 AC_CHECK_FUNCS(memmove select socket strdup strstr strtod strtol strtoul floor)
605 AC_CHECK_FUNCS(basename poll)
607 AC_MSG_CHECKING(return type of socket size)
608 AC_TRY_COMPILE([#include <stdlib.h>
609                 #include <sys/types.h>
610                 #include <sys/socket.h>],
611                [int a = send(1, (const void *) buffer, (size_t *) 0, (int *) 0);],
612                ac_cv_socket_size_type=["size_t"]
613                 AC_MSG_RESULT(size_t),
614                ac_cv_socket_size_type=["int"]
615                 AC_MSG_RESULT(int))
617 AC_DEFINE_UNQUOTED(SOCKET_SIZE_TYPE, $ac_cv_socket_size_type ,
618         [Define type of socket size])
620 AC_ARG_WITH(proc-loadavg,
621             ACX_HELP_STRING([--with-proc-loadavg=PATH],
622                             [path to /proc/loadavg or equivalent]),
623             ac_cv_proc_loadavg=$withval)
624 AC_MSG_CHECKING([for /proc/loadavg])
625 if test -n "$ac_cv_proc_loadavg"; then
626   AC_MSG_RESULT([(command line) $ac_cv_proc_loadavg])
627 elif test -f "/proc/loadavg"; then
628   AC_MSG_RESULT([found /proc/loadavg])
629   ac_cv_proc_loadavg="/proc/loadavg"
630 else
631   AC_MSG_RESULT([no])
632 fi
634 if test -n "$ac_cv_proc_loadavg"; then
635   AC_DEFINE(HAVE_PROC_LOADAVG,1,[Define if /proc/loadavg or similar exists])
636   AC_DEFINE_UNQUOTED(PROC_LOADAVG,"/proc/loadavg",[Location of /proc/loadavg])
637 fi
639 dnl #### Process table test
641 AC_PATH_PROG(PATH_TO_PS,ps)
643 AC_MSG_CHECKING(for ps syntax)
644 AC_ARG_WITH(ps_command,
645             ACX_HELP_STRING([--with-ps-command=PATH], 
646                             [Verbatim command to execute for ps]),
647             PS_COMMAND=$withval)
648 AC_ARG_WITH(ps_format,
649             ACX_HELP_STRING([--with-ps-format=FORMAT],
650                             [Format string for scanning ps output]),
651             PS_FORMAT=$withval)
652 AC_ARG_WITH(ps_cols,
653             ACX_HELP_STRING([--with-ps-cols=NUM], 
654                             [Number of columns in ps command]),
655             PS_COLS=$withval)
656 AC_ARG_WITH(ps_varlist,
657             ACX_HELP_STRING([--with-ps-varlist=LIST],
658                             [Variable list for sscanf of 'ps' output]),
659             PS_VARLIST=$withval)
661 if test -n "$PS_COMMAND" && test -n "$PS_FORMAT" && test -n "$PS_COLS" && test -n "$PS_VARLIST"; then 
662         ac_cv_ps_command="$PS_COMMAND"
663         ac_cv_ps_format="$PS_FORMAT"
664         ac_cv_ps_varlist="$PS_VARLIST"
665         ac_cv_ps_cols="$PS_COLS"
666         AC_MSG_RESULT([(command-line) $ac_cv_ps_command])
668 dnl Now using the pst3/kmem hack for solaris systems to avoid truncation
669 elif test "$ac_cv_uname_s" = "SunOS"; then
670         #
671         # this is a very, very ugly hack, to hardcode the location for plugins
672         #
673         if test "$libexecdir" = '${exec_prefix}/libexec'; then
674                 if test "$exec_prefix" = "NONE"; then
675                         if test "$prefix" = "NONE"; then
676                                 pst3="$ac_default_prefix/libexec/pst3"
677                         else
678                                 pst3="$prefix/libexec/pst3"
679                         fi
680                 else
681                         pst3="$exec_prefix/libexec/pst3"
682                 fi
683         else
684                 pst3="$libexecdir/pst3"
685         fi
686         ac_cv_ps_command="$pst3"
687         ac_cv_ps_format="%s %d %d %d %d %f %s %n"
688         ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
689         ac_cv_ps_cols=8
690         AC_MSG_RESULT([using nagios-plugins internal ps for solaris])
691         EXTRAS_ROOT="$EXTRAS_ROOT pst3"
693 dnl Some gnu/linux systems (debian for one) don't like -axwo and need axwo.
694 dnl so test for this first...
695 elif ps axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
696         egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null
697 then
698         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
699         ac_cv_ps_command="$PATH_TO_PS axwo 'stat uid pid ppid vsz rss pcpu comm args'"
700         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
701         ac_cv_ps_cols=9
702         AC_MSG_RESULT([$ac_cv_ps_command])
704 dnl For OpenBSD 3.2 & 3.3. Must come before ps -weo
705 dnl Should also work for FreeBSD 5.2.1 and 5.3
706 dnl  STAT UCOMM              VSZ   RSS USER      PPID COMMAND
707 elif ps -axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
708         egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null
709 then
710         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
711         ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid pid ppid vsz rss pcpu comm args'"
712         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
713         ac_cv_ps_cols=9
714         AC_MSG_RESULT([$ac_cv_ps_command])
716 dnl Some *BSDs have different format for ps. This is mainly to catch FreeBSD 4. 
717 dnl Limitation: Only first 16 chars returned for ucomm field
718 dnl Must come before ps -weo
719 elif ps -axwo 'stat uid pid ppid vsz rss pcpu ucomm command' 2>/dev/null | \
720         egrep -i ["^ *STAT +UID +PID +PPID +VSZ +RSS +%CPU +UCOMM +COMMAND"] > /dev/null
721 then
722         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
723         ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid pid ppid vsz rss pcpu ucomm command'"
724         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
725         ac_cv_ps_cols=9
726         AC_MSG_RESULT([$ac_cv_ps_command])
728 dnl  STAT UCOMM              VSZ   RSS USER       UID  PPID COMMAND
729 elif ps -weo 'stat comm vsz rss user uid pid ppid etime args' 2>/dev/null | \
730         egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[ID]+ +P[PID]+ +[ELAPSD]+ +[RGSCOMDNA]+"] >/dev/null
731 then
732         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procetime,procprog,&pos]"
733         ac_cv_ps_command="$PATH_TO_PS -weo 'stat uid pid ppid vsz rss pcpu etime comm args'"
734         ac_cv_ps_format="%s %d %d %d %d %d %f %s %s %n"
735         ac_cv_ps_cols=10
736         AC_MSG_RESULT([$ac_cv_ps_command])
738 dnl FreeBSD
739 elif ps waxco 'state command vsz rss uid user pid ppid' 2>/dev/null | \
740         egrep -i ["^STAT +COMMAND +VSZ +RSS +UID +USER +PID +PPID"] >/dev/null
741 then
742         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
743         ac_cv_ps_command="$PATH_TO_PS waxco 'state uid pid ppid vsz rss pcpu command command'"
744         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
745         ac_cv_ps_cols=9
746         AC_MSG_RESULT([$ac_cv_ps_command])
748 dnl BSD-like mode in RH 6.1
749 elif ps waxno 'state comm vsz rss uid user pid ppid args' 2>/dev/null | \
750         egrep -i ["^S +COMMAND +VSZ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
751 then
752         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
753         ac_cv_ps_command="$PATH_TO_PS waxno 'state uid pid ppid vsz rss pcpu comm args'"
754         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
755         ac_cv_ps_cols=9
756         AC_MSG_RESULT([$ac_cv_ps_command])
758 dnl SunOS 4.1.3:
759 dnl  F  UID  PID  PPID  CP  PRI  NI  SZ  RSS  WCHAN  STAT  TT  TIME  COMMAND
760 dnl Need the head -1 otherwise test will work because arguments are found
761 elif ps -laxnwww 2>/dev/null | head -1 | \
762         egrep -i ["^ *F(LAGS)? +UID +PID +PPID +CP +PRI +NI +(SZ)|(VSZ)|(SIZE) +RSS +WCHAN +STAT? +TTY? +TIME +COMMAND"] >/dev/null
763 then
764         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]"
765         ac_cv_ps_command="$PATH_TO_PS -laxnwww"
766         ac_cv_ps_format="%*s %d %d %d %*s %*s %*s %d %d %*s %s %*s %*s %n%s"
767         ac_cv_ps_cols=9
768         AC_MSG_RESULT([$ac_cv_ps_command])
770 dnl Debian Linux / procps v1.2.9:
771 dnl  FLAGS   UID   PID  PPID PRI  NI   SIZE   RSS WCHAN       STA TTY TIME COMMAND
772 dnl    100     0     1     0   0   0    776    76  c0131c8c   S  ffff  0:11 init [2]
773 dnl
774 elif ps laxnwww 2>/dev/null | \
775         egrep -i ["^ *F(LAGS)? +UID +PID +PPID +PRI +NI +(VSZ)|(SIZE) +RSS +WCHAN +STAT? TTY +TIME +COMMAND"] >/dev/null
776 then
777         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,procstat,&procvsz,&procrss,&pos,procprog]"
778         ac_cv_ps_command="$PATH_TO_PS laxnwww"
779         ac_cv_ps_format="%*s %d %d %d %*s %*s %d %d %*s %s %*s %*s %n%s"
780         ac_cv_ps_cols=9
781         AC_MSG_RESULT([$ac_cv_ps_command])
783 dnl OpenBSD (needs to come early because -exo appears to work, but does not give all procs)
784 elif ps -axo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
785         egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[PID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null
786 then
787         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
788         ac_cv_ps_command="$PATH_TO_PS -axo 'stat uid pid ppid vsz rss pcpu comm args'"
789         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
790         ac_cv_ps_cols=9
791         AC_MSG_RESULT([$ac_cv_ps_command])
793 dnl Tru64 - needs %*[ +<>] in PS_FORMAT. 
794 dnl Has /usr/bin/ps and /sbin/ps - force sbin version
795 dnl Can't use vsize and rssize because comes back with text (eg, 1.5M instead 
796 dnl of 1500). Will need big changes to check_procs to support
797 elif /sbin/ps -eo 'stat uid pid ppid pcpu etime comm args' 2>/dev/null | \
798         egrep -i ["^ *S +[UID]+ +[PID]+ +[PID]+ +[%CPU]+ +[ELAPSD]+ +[COMMAND]+ +[COMMAND]+"] > /dev/null
799 then
800         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procpcpu,procetime,procprog,&pos]"
801         ac_cv_ps_command="/sbin/ps -eo 'stat uid pid ppid pcpu etime comm args'"
802         ac_cv_ps_format=["%s%*[ +<>] %d %d %d %f %s %s %n"]
803         ac_cv_ps_cols=8
804         AC_MSG_RESULT([$ac_cv_ps_command])
806 elif ps -eo 's comm vsz rss user uid pid ppid args' 2>/dev/null | \
807         egrep -i ["^S[TAUES]* +C[OMDNA]+ +[VSIZE]+ +U[SER]+ +U[ID]+ +P[PID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null
808 then
809         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
810         ac_cv_ps_command="$PATH_TO_PS -eo 's uid pid ppid vsz rss pcpu comm args'"
811         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
812         ac_cv_ps_cols=9
813         AC_MSG_RESULT([$ac_cv_ps_command])
815 dnl AIX 4.3.3 and 5.1 do not have an rss field
816 elif ps -eo 'stat uid pid ppid vsz pcpu comm args' 2>/dev/null | \
817         egrep -i ["^ *S[TAUES]* +UID +PID +PPID +VSZ +%CPU +COMMAND +COMMAND"] >/dev/null
818 then
819         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procpcpu,procprog,&pos]"
820         ac_cv_ps_command="$PATH_TO_PS -eo 'stat uid pid ppid vsz pcpu comm args'"
821         ac_cv_ps_format="%s %d %d %d %d %f %s %n"
822         ac_cv_ps_cols=8
823         AC_MSG_RESULT([$ac_cv_ps_command - with no RSS])
825 dnl Solaris 2.6
826 elif ps -Ao 's comm vsz rss uid user pid ppid args' 2>/dev/null | \
827         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
828 then
829         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
830         ac_cv_ps_command="$PATH_TO_PS -Ao 's uid pid ppid vsz rss pcpu comm args'"
831         # There must be no space between the %s and %n due to a wierd problem in sscanf where
832         # it will return %n as longer than the line length
833         ac_cv_ps_format="%s %d %d %d %d %d %f %s%n"
834         ac_cv_ps_cols=9
835         AC_MSG_RESULT([$ac_cv_ps_command])
837 elif ps -Ao 'status comm vsz rss uid user pid ppid args' 2>/dev/null | \
838         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
839 then
840         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
841         ac_cv_ps_command="$PATH_TO_PS -Ao 'status uid pid ppid vsz rss pcpu comm args'"
842         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
843         ac_cv_ps_cols=9
844         AC_MSG_RESULT([$ac_cv_ps_command])
846 elif ps -Ao 'state comm vsz rss uid user pid ppid args' 2>/dev/null | \
847         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
848 then
849         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
850         ac_cv_ps_command="$PATH_TO_PS -Ao 'state uid pid ppid vsz rss pcpu comm args'"
851         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
852         ac_cv_ps_cols=9
853         AC_MSG_RESULT([$ac_cv_ps_command])
855 dnl wonder who takes state instead of stat
856 elif ps -ao 'state command vsz rss user pid ppid args' 2>/dev/null | \
857         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
858 then
859         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
860         ac_cv_ps_command="$PATH_TO_PS -ao 'state uid pid ppid vsz rss pcpu command args'"
861         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
862         ac_cv_ps_cols=8
863         AC_MSG_RESULT([$ac_cv_ps_command])
865 dnl IRIX 53
866 elif ps -el 2>/dev/null | \
867         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
868 then
869         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&pos,procprog]"
870         ac_cv_ps_command="$PATH_TO_PS -el (IRIX 53)"
871         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %d %d %*s %*s %*s %n%s"
872         ac_cv_ps_cols=8
873         AC_MSG_RESULT([$ac_cv_ps_command])
875 dnl IRIX 63
876 elif ps -el 2>/dev/null | \
877         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +ADDR +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
878 then
879         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
880         ac_cv_ps_command="$PATH_TO_PS -el (IRIX 63)"
881         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
882         ac_cv_ps_cols=6
883         AC_MSG_RESULT([$ac_cv_ps_command])
885 dnl AIX 4.1:
886 dnl     F S      UID   PID  PPID   C PRI NI ADDR  SZ  RSS   WCHAN    TTY  TIME CMD
887 dnl    303 A        0     0     0 120  16 -- 1c07  20   24              -  0:45 swapper
888 elif ps -el 2>/dev/null | \
889         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +ADDR +SZ +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
890 then
891         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
892         ac_cv_ps_command="$PATH_TO_PS -el (AIX 4.1 and HP-UX)"
893         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
894         ac_cv_ps_cols=6
895         AC_MSG_RESULT([$ac_cv_ps_command])
897 dnl AIX?
898 elif ps glaxen 2>/dev/null | \
899         egrep -i ["^ *F +UID +PID +PPID +PRI +NI +VSZ +RSS +WCHAN +STAT +TTY +TIME +COMMAND"] >/dev/null
900 then
901         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]"
902         ac_cv_ps_command="$PATH_TO_PS glaxen"
903         ac_cv_ps_format="%*s %d %d %d %*s %*s %d %d %*s %s %*s %*s %n%s"
904         ac_cv_ps_cols=8
905         AC_MSG_RESULT([$ac_cv_ps_command])
907 dnl MacOSX / Darwin
908 dnl TODO: MacOSX has commands with spaces which will cause problems to PS_FORMAT
909 dnl Some truncation will happen in UCOMM column
910 dnl STAT      VSZ    RSS   UID  PPID %CPU UCOMM            COMMAND
911 dnl Ss      52756  22496   501     1   6.9 Window Manager   /System/Library/CoreServices/WindowServer -daemon
912 elif ps wwaxo 'state vsz rss uid pid ppid pcpu ucomm command' 2>/dev/null | \
913         egrep -i ["^STAT +VSZ +RSS +UID +PPID +%CPU +UCOMM +COMMAND"] >/dev/null
914 then
915         ac_cv_ps_command="$PATH_TO_PS wwaxo 'state vsz rss uid pid ppid pcpu ucomm command'"
916         ac_cv_ps_varlist="[procstat,&procvsz,&procrss,&procuid,&procpid,&procppid,&procpcpu,procprog,&pos]"
917         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
918         ac_cv_ps_cols=8
919         AC_MSG_RESULT([$ac_cv_ps_command])
921 dnl UnixWare 
922 elif ps -Al 2>/dev/null | \
923         egrep -i ["^ *F +S +UID +PID +PPID +CLS +PRI +NI +C +ADDR +SZ +WCHAN +TTY +TIME +COMD"] >/dev/null
924 then
925         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
926         ac_cv_ps_command="$PATH_TO_PS -Al"
927         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
928         ac_cv_ps_cols=8
929         AC_MSG_RESULT([$ac_cv_ps_command])
931 else
932         AC_MSG_WARN([unable to find usable ps syntax - check_procs and check_nagios will not be compiled])
933 fi
935 if test -n "$ac_cv_ps_varlist" ; then
936         AC_DEFINE_UNQUOTED(PS_VARLIST,$ac_cv_ps_varlist,
937                 [Variable list for sscanf of 'ps' output])
938         AC_DEFINE_UNQUOTED(PS_COMMAND,"$ac_cv_ps_command",
939                 [Verbatim command to execute for ps in check_procs])
940         AC_DEFINE_UNQUOTED(PS_FORMAT,"$ac_cv_ps_format",
941                 [Format string for scanning ps output in check_procs])
942         AC_DEFINE_UNQUOTED(PS_COLS,$ac_cv_ps_cols,
943                 [Number of columns in ps command])
944         EXTRAS="$EXTRAS check_procs check_nagios"
945         if echo "$ac_cv_ps_varlist" | grep -q "procetime"; then
946                 AC_DEFINE(PS_USES_PROCETIME,"yes",
947                           [Whether the ps utility uses the "procetime" field])
948         fi
949 fi
951 AC_PATH_PROG(PATH_TO_PING,ping)
952 AC_PATH_PROG(PATH_TO_PING6,ping6)
954 AC_ARG_WITH(ping_command,
955         ACX_HELP_STRING([--with-ping-command=SYNTAX],
956                 [sets syntax for ICMP ping]),
957         with_ping_command=$withval,)
959 AC_MSG_CHECKING(for ICMP ping syntax)
960 ac_cv_ping_packets_first=no
961 ac_cv_ping_has_timeout=no
962 if test -n "$with_ping_command"
963 then
964         AC_MSG_RESULT([(command-line) $with_ping_command])
965         if test -n "$ac_cv_ping_packets_first"
966         then
967                 ac_cv_ping_packets_first=yes
968                 ac_cv_ping_has_timeout=yes
969         fi
971 elif [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
972         $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
973         egrep -i "^round-trip|^rtt" >/dev/null
974 then
975         with_ping_command="$PATH_TO_PING -n -U -c %d %s"
976         ac_cv_ping_packets_first=yes
977         AC_MSG_RESULT([$with_ping_command])
979 elif $PATH_TO_PING -n -U -w 10 -c 1 127.0.0.1 2>/dev/null | \
980         egrep -i "^round-trip|^rtt" >/dev/null
981 then
982         with_ping_command="$PATH_TO_PING -n -U -w %d -c %d %s"
983         ac_cv_ping_packets_first=yes
984   ac_cv_ping_has_timeout=yes
985         AC_MSG_RESULT([$with_ping_command])
987 elif $PATH_TO_PING -n -U -c 1 127.0.0.1 2>/dev/null | \
988         egrep -i "^round-trip|^rtt" >/dev/null
989 then
990         with_ping_command="$PATH_TO_PING -n -U -c %d %s"
991         ac_cv_ping_packets_first=yes
992         AC_MSG_RESULT([$with_ping_command])
994 elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \
995         egrep -i "^round-trip|^rtt" >/dev/null
996 then
997         with_ping_command="$PATH_TO_PING -n -c %d %s"
998         ac_cv_ping_packets_first=yes
999         AC_MSG_RESULT([$with_ping_command])
1001 elif $PATH_TO_PING -n 127.0.0.1 -c 1 2>/dev/null | \
1002         egrep -i "^round-trip|^rtt" >/dev/null
1003 then
1004         with_ping_command="$PATH_TO_PING -n %s -c %d"
1005         AC_MSG_RESULT([$with_ping_command])
1007 elif $PATH_TO_PING 127.0.0.1 -n 1 2>/dev/null | \
1008         egrep -i "^round-trip|^rtt" >/dev/null
1009 then
1010         with_ping_command="$PATH_TO_PING %s -n %d"
1011         AC_MSG_RESULT([$with_ping_command])
1013 elif $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
1014         egrep -i "^round-trip|^rtt" >/dev/null
1015 then
1016         with_ping_command="$PATH_TO_PING -n -s %s 56 %d"
1017         AC_MSG_RESULT([$with_ping_command])
1019 elif $PATH_TO_PING -n -h 127.0.0.1 -s 56 -c 1 2>/dev/null | \
1020         egrep -i "^round-trip|^rtt" >/dev/null
1021 then
1022         with_ping_command="$PATH_TO_PING -n -h %s -s 56 -c %d"
1023         AC_MSG_RESULT([$with_ping_command])
1025 elif $PATH_TO_PING -n -s 56 -c 1 127.0.0.1 2>/dev/null | \
1026         egrep -i "^round-trip|^rtt" >/dev/null
1027 then
1028         with_ping_command="$PATH_TO_PING -n -s 56 -c %d %s"
1029         ac_cv_ping_packets_first=yes
1030         AC_MSG_RESULT([$with_ping_command])
1032 elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \
1033         egrep -i "^round-trip|^rtt" >/dev/null
1034 then
1035         with_ping_command="$PATH_TO_PING -n -c %d %s"
1036         ac_cv_ping_packets_first=yes
1037         AC_MSG_RESULT([$with_ping_command])
1039 else
1040         AC_MSG_WARN([unable to find usable ping syntax])
1041 fi
1043 AC_DEFINE_UNQUOTED(PING_COMMAND,"$with_ping_command",
1044         [path and args for ICMP ping command])
1046 if test "x$ac_cv_ping_packets_first" != "xno"
1047 then
1048         AC_DEFINE(PING_PACKETS_FIRST,1,
1049                 [Define if packet count must precede host])
1050 fi
1052 if test "x$ac_cv_ping_has_timeout" != "xno"
1053 then
1054         AC_DEFINE(PING_HAS_TIMEOUT,1,
1055                 [Define if ping has its own timeout option that should be set])
1056 fi
1058 AC_ARG_WITH(ping6_command,
1059         ACX_HELP_STRING([--with-ping6-command=SYNTAX],
1060                 [sets syntax for ICMPv6 ping]),
1061         with_ping6_command=$withval,)
1063 if test x"$with_ipv6" != xno ; then
1064 AC_MSG_CHECKING(for ICMPv6 ping syntax)
1065 ac_cv_ping6_packets_first=no
1066 if test -n "$with_ping6_command"
1067 then
1068         AC_MSG_RESULT([(command-line) $with_ping6_command])
1069         if test -n "$ac_cv_ping6_packets_first"
1070         then
1071                 ac_cv_ping6_packets_first=yes
1072         fi
1074 elif test "x$PATH_TO_PING6" != "x"; then
1075         if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
1076                 $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \
1077                 egrep -i "^round-trip|^rtt" >/dev/null
1078         then
1079                 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s"
1080                 ac_cv_ping6_packets_first=yes
1081                 AC_MSG_RESULT([$with_ping6_command])
1083         elif $PATH_TO_PING6 -n -U -w 10 -c 1 ::1 2>/dev/null | \
1084                 egrep -i "^round-trip|^rtt" >/dev/null
1085         then
1086                 with_ping6_command="$PATH_TO_PING6 -n -U -w %d -c %d %s"
1087                 ac_cv_ping6_packets_first=yes
1088                 ac_cv_ping_has_timeout=yes
1089                 AC_MSG_RESULT([$with_ping6_command])
1091         elif $PATH_TO_PING6 -n -U -c 1 ::1 2>/dev/null | \
1092                 egrep -i "^round-trip|^rtt" >/dev/null
1093         then
1094                 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s"
1095                 ac_cv_ping6_packets_first=yes
1096                 AC_MSG_RESULT([$with_ping6_command])
1098         elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \
1099                 egrep -i "^round-trip|^rtt" >/dev/null
1100         then
1101                 with_ping6_command="$PATH_TO_PING6 -n -c %d %s"
1102                 ac_cv_ping6_packets_first=yes
1103                 AC_MSG_RESULT([$with_ping6_command])
1105         elif $PATH_TO_PING6 -n ::1 -c 1 2>/dev/null | \
1106                 egrep -i "^round-trip|^rtt" >/dev/null
1107         then
1108                 with_ping6_command="$PATH_TO_PING6 -n %s -c %d"
1109                 AC_MSG_RESULT([$with_ping6_command])
1111         elif $PATH_TO_PING6 ::1 -n 1 2>/dev/null | \
1112                 egrep -i "^round-trip|^rtt" >/dev/null
1113         then
1114                 with_ping6_command="$PATH_TO_PING6 %s -n %d"
1115                 AC_MSG_RESULT([$with_ping6_command])
1117         elif $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \
1118                 egrep -i "^round-trip|^rtt" >/dev/null
1119         then
1120                 with_ping6_command="$PATH_TO_PING6 -n -s %s 56 %d"
1121                 AC_MSG_RESULT([$with_ping6_command])
1123         elif $PATH_TO_PING6 -n -h ::1 -s 56 -c 1 2>/dev/null | \
1124                 egrep -i "^round-trip|^rtt" >/dev/null
1125         then
1126                 with_ping6_command="$PATH_TO_PING6 -n -h %s -s 56 -c %d"
1127                 AC_MSG_RESULT([$with_ping6_command])
1129         elif $PATH_TO_PING6 -n -s 56 -c 1 ::1 2>/dev/null | \
1130                 egrep -i "^round-trip|^rtt" >/dev/null
1131         then
1132                 with_ping6_command="$PATH_TO_PING6 -n -s 56 -c %d %s"
1133                 ac_cv_ping6_packets_first=yes
1134                 AC_MSG_RESULT([$with_ping_command])
1136         elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \
1137                 egrep -i "^round-trip|^rtt" >/dev/null
1138         then
1139                 with_ping6_command="$PATH_TO_PING6 -n -c %d %s"
1140                 ac_cv_ping6_packets_first=yes
1141                 AC_MSG_RESULT([$with_ping6_command])
1143         fi
1145 elif test "x$PATH_TO_PING" != "x"; then
1146         if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
1147                 $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \
1148                 egrep -i "^round-trip|^rtt" >/dev/null
1149         then
1150                 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s"
1151                 ac_cv_ping6_packets_first=yes
1152                 AC_MSG_RESULT([$with_ping6_command])
1154         elif $PATH_TO_PING -A inet6 -n -U -c 1 ::1 2>/dev/null | \
1155                 egrep -i "^round-trip|^rtt" >/dev/null
1156         then
1157                 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s"
1158                 ac_cv_ping6_packets_first=yes
1159                 AC_MSG_RESULT([$with_ping6_command])
1161         elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \
1162                 egrep -i "^round-trip|^rtt" >/dev/null
1163         then
1164                 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s"
1165                 ac_cv_ping6_packets_first=yes
1166                 AC_MSG_RESULT([$with_ping6_command])
1168         elif $PATH_TO_PING -A inet6 -n ::1 -c 1 2>/dev/null | \
1169                 egrep -i "^round-trip|^rtt" >/dev/null
1170         then
1171                 with_ping6_command="$PATH_TO_PING -A inet6 -n %s -c %d"
1172                 AC_MSG_RESULT([$with_ping6_command])
1174         elif $PATH_TO_PING -A inet6 ::1 -n 1 2>/dev/null | \
1175                 egrep -i "^round-trip|^rtt" >/dev/null
1176         then
1177                 with_ping6_command="$PATH_TO_PING -A inet6 %s -n %d"
1178                 AC_MSG_RESULT([$with_ping6_command])
1180         elif $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \
1181                 egrep -i "^round-trip|^rtt" >/dev/null
1182         then
1183                 with_ping6_command="$PATH_TO_PING -A inet6 -n -s %s 56 %d"
1184                 AC_MSG_RESULT([$with_ping6_command])
1186         elif $PATH_TO_PING -A inet6 -n -h ::1 -s 56 -c 1 2>/dev/null | \
1187                 egrep -i "^round-trip|^rtt" >/dev/null
1188         then
1189                 with_ping6_command="$PATH_TO_PING -A inet6 -n -h %s -s 56 -c %d"
1190                 AC_MSG_RESULT([$with_ping6_command])
1192         elif $PATH_TO_PING -A inet6 -n -s 56 -c 1 ::1 2>/dev/null | \
1193                 egrep -i "^round-trip|^rtt" >/dev/null
1194         then
1195                 with_ping6_command="$PATH_TO_PING -A inet6 -n -s 56 -c %d %s"
1196                 ac_cv_ping6_packets_first=yes
1197                 AC_MSG_RESULT([$with_ping_command])
1199         elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \
1200                 egrep -i "^round-trip|^rtt" >/dev/null
1201         then
1202                 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s"
1203                 ac_cv_ping6_packets_first=yes
1204                 AC_MSG_RESULT([$with_ping6_command])
1206         fi
1208 fi
1210 if test "x$with_ping6_command" != "x"; then
1211         AC_DEFINE_UNQUOTED(PING6_COMMAND,"$with_ping6_command",
1212                 [path and args for ICMPv6 ping command])
1213 else
1214         AC_MSG_RESULT([none])
1215 fi
1217 if test "x$ac_cv_ping6_packets_first" != "xno"; then
1218         AC_DEFINE(PING6_PACKETS_FIRST,1,
1219                 [Define if packet count must precede host])
1220 fi
1221 fi
1224 AC_ARG_WITH(nslookup_command,
1225             ACX_HELP_STRING([--with-nslookup-command=PATH],
1226                             [sets path to nslookup executable]),
1227             ac_cv_nslookup_command=$withval)
1228 if test -n "$ac_cv_nslookup_command"; then
1229         AC_MSG_NOTICE([Using specific nslookup at $ac_cv_nslookup_command])
1230 else
1231         AC_PATH_PROG(PATH_TO_NSLOOKUP,nslookup)
1232         if test -n "$PATH_TO_NSLOOKUP"
1233         then
1234                 AC_MSG_CHECKING(for nslookup syntax)
1235                 if $PATH_TO_NSLOOKUP -sil 127.0.0.1 2>&1 | grep ["Invalid option: sil"] >/dev/null
1236                 then
1237                         ac_cv_nslookup_command="$PATH_TO_NSLOOKUP"
1238                         AC_MSG_RESULT([$ac_cv_nslookup_command])
1240                 else
1241                         ac_cv_nslookup_command="$PATH_TO_NSLOOKUP -sil"
1242                         AC_MSG_RESULT([$ac_cv_nslookup_command])
1244                 fi
1245         else
1246                 AC_MSG_WARN([nslookup command not found])
1247         fi
1248 fi
1250 if test -n "$ac_cv_nslookup_command"; then
1251         EXTRAS="$EXTRAS check_dns"
1252         AC_DEFINE_UNQUOTED(NSLOOKUP_COMMAND,"$ac_cv_nslookup_command", [path and args for nslookup])
1253 fi
1255 AC_PATH_PROG(PATH_TO_UPTIME,uptime)
1256 AC_ARG_WITH(uptime_command,
1257             ACX_HELP_STRING([--with-uptime-command=PATH],
1258                             [sets path to uptime]), PATH_TO_UPTIME=$withval)
1259 AC_DEFINE_UNQUOTED(PATH_TO_UPTIME,"$PATH_TO_UPTIME",[path to uptime binary])
1261 AC_PATH_PROG(PATH_TO_RPCINFO,rpcinfo)
1262 AC_ARG_WITH(rpcinfo_command,
1263             ACX_HELP_STRING([--with-rpcinfo-command=PATH],
1264                             [sets path to rpcinfo]), PATH_TO_RPCINFO=$withval)
1265 AC_DEFINE_UNQUOTED(PATH_TO_RPCINFO,"$PATH_TO_RPCINFO",[path to rpcinfo binary])
1267 AC_PATH_PROG(PATH_TO_LMSTAT,lmstat)
1268 if test -x "$PATH_TO_LMSTAT"
1269 then
1270         AC_DEFINE_UNQUOTED(PATH_TO_LMSTAT,"$PATH_TO_LMSTAT",[path to lmstat])
1271 else
1272         AC_MSG_WARN([Get lmstat from Globetrotter Software to monitor flexlm licenses])
1273 fi
1275 AC_PATH_PROG(PATH_TO_SMBCLIENT,smbclient)
1276 AC_ARG_WITH(smbclient_command,
1277             ACX_HELP_STRING([--with-smbclient-command=PATH],
1278                             [sets path to smbclient]), 
1279             PATH_TO_SMBCLIENT=$withval)
1280 if test -n "$PATH_TO_SMBCLIENT"
1281 then
1282         AC_DEFINE_UNQUOTED(PATH_TO_SMBCLIENT,"$PATH_TO_SMBCLIENT",[path to smbclient binary])
1283 else
1284         AC_MSG_WARN([Get smbclient from Samba.org to monitor SMB shares])
1285 fi
1288 AC_PATH_PROG(PATH_TO_WHO,who)
1290 if [$PATH_TO_WHO -q 2>/dev/null | egrep -i "^# users=[0-9]+$" >/dev/null]
1291 then
1292         ac_cv_path_to_who="$PATH_TO_WHO -q"
1293 else
1294         ac_cv_path_to_who="$PATH_TO_WHO"
1295 fi
1297 AC_DEFINE_UNQUOTED(WHO_COMMAND,"$ac_cv_path_to_who",
1298         [path and arguments for invoking 'who'])
1300 AC_PATH_PROG(PATH_TO_SNMPGET,snmpget)
1301 AC_ARG_WITH(snmpget_command,
1302             ACX_HELP_STRING([--with-snmpget-command=PATH],
1303                             [Path to snmpget command]),
1304             PATH_TO_SNMPGET=$withval)
1305 if test -n "$PATH_TO_SNMPGET"
1306 then
1307         AC_DEFINE_UNQUOTED(PATH_TO_SNMPGET,"$PATH_TO_SNMPGET",[path to snmpget binary])
1308         EXTRAS="$EXTRAS check_hpjd check_snmp"
1309 else
1310         AC_MSG_WARN([Get snmpget from http://net-snmp.sourceforge.net to make check_hpjd and check_snmp plugins])
1311 fi
1313 AC_PATH_PROG(PATH_TO_SNMPGETNEXT,snmpgetnext)
1314 AC_ARG_WITH(snmpgetnext_command,
1315             ACX_HELP_STRING([--with-snmpgetnext-command=PATH],
1316                             [Path to snmpgetnext command]),
1317             PATH_TO_SNMPGETNEXT=$withval)
1318 if test -n "$PATH_TO_SNMPGETNEXT"
1319 then
1320         AC_DEFINE_UNQUOTED(PATH_TO_SNMPGETNEXT,"$PATH_TO_SNMPGETNEXT",[path to snmpgetnext binary])
1321 fi
1323 if ( $PERL -M"Net::SNMP 3.6" -e 'exit' 2>/dev/null  )
1324 then
1325         AC_MSG_CHECKING(for Net::SNMP perl module)
1326         AC_MSG_RESULT([found])
1327 else
1328         AC_MSG_WARN([Tried $PERL - install Net::SNMP perl module if you want to use the perl snmp plugins])
1329 fi
1331 AC_PATH_PROG(PATH_TO_QUAKESTAT,quakestat)
1332 AC_PATH_PROG(PATH_TO_QSTAT,qstat)
1333 AC_ARG_WITH(qstat_command,
1334             ACX_HELP_STRING([--with-qstat-command=PATH], 
1335                             [Path to qstat command]), PATH_TO_QSTAT=$withval)
1337 if test -x "$PATH_TO_QUAKESTAT"
1338 then
1339         ac_cv_path_to_qstat="$PATH_TO_QUAKESTAT"
1340         EXTRAS="$EXTRAS check_game"
1342 elif test -n "$PATH_TO_QSTAT"
1343 then
1344         ac_cv_path_to_qstat="$PATH_TO_QSTAT"
1345         EXTRAS="$EXTRAS check_game"
1346 else
1347         AC_MSG_WARN([Get qstat from http://www.activesw.com/people/steve/qstat.html in order to make check_game plugin])
1348 fi
1350 if test $ac_cv_path_to_qstat 
1351 then
1352         AC_DEFINE_UNQUOTED(PATH_TO_QSTAT,"$ac_cv_path_to_qstat",
1353                 [path to qstat/quakestat])
1354 fi
1356 AC_PATH_PROG(PATH_TO_FPING,fping)
1357 AC_ARG_WITH(fping_command,
1358             ACX_HELP_STRING([--with-fping-command=PATH],
1359                             [Path to fping command]), PATH_TO_FPING=$withval)
1360 if test -n "$PATH_TO_FPING"
1361 then
1362         AC_DEFINE_UNQUOTED(PATH_TO_FPING,"$PATH_TO_FPING",[path to fping])
1363         EXTRAS="$EXTRAS check_fping"
1364 else
1365         AC_MSG_WARN([Get fping from http://www.fping.com in order to make check_fping plugin])
1366 fi
1368 AC_PATH_PROG(PATH_TO_SSH,ssh)
1369 AC_ARG_WITH(ssh_command,
1370             ACX_HELP_STRING([--with-ssh-command=PATH],
1371                             [sets path for ssh]), PATH_TO_SSH=$withval)
1372 if test -n "$PATH_TO_SSH"
1373 then
1374         AC_DEFINE_UNQUOTED(SSH_COMMAND,"$PATH_TO_SSH",[path to ssh binary])
1375         EXTRAS="$EXTRAS check_by_ssh"
1376 else
1377         AC_MSG_WARN([Get ssh in order to make check_by_ssh plugin])
1378 fi
1381 AC_PATH_PROG(PATH_TO_MAILQ,mailq)
1382 AC_ARG_WITH(mailq_command,
1383             ACX_HELP_STRING([--with-mailq-command=PATH],
1384                             [sets path to mailq]), PATH_TO_MAILQ=$withval)
1385 if test -n "$PATH_TO_MAILQ"
1386 then
1387         AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_MAILQ",[path to mailq])
1388 else
1389         AC_MSG_WARN([Could not find mailq or eqivalent])
1390 fi
1392 AC_PATH_PROG(PATH_TO_QMAIL_QSTAT,qmail-qstat)
1393 if test -x "$PATH_TO_QMAIL_QSTAT"
1394 then
1395         AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_QMAIL_QSTAT",[path to qmail-qstat])
1396 else
1397         AC_MSG_WARN([Could not find qmail-qstat or eqivalent])
1398 fi
1400 dnl SWAP info required is amount allocated/available and amount free
1401 dnl The plugin works through all the swap devices and adds up the total swap
1402 dnl available.
1403 AC_PATH_PROG(PATH_TO_SWAP,swap)
1404 if (test -n "$PATH_TO_SWAP")
1405 then
1406 AC_MSG_CHECKING([for $PATH_TO_SWAP format])
1407 if [$PATH_TO_SWAP -l 2>&1 >/dev/null]
1408 then
1409         ac_cv_have_swap=yes
1410         ac_cv_swap_command="$PATH_TO_SWAP -l"
1411         if [$PATH_TO_SWAP -l 2>/dev/null | \
1412                 egrep -i "^lswap +path +pri +swaplo +blocks +free +maxswap" \
1413                 >/dev/null]
1414         then
1415                 ac_cv_swap_format=[" %*d %*s %*d,%*d %*d %*d %f %f"]
1416                 ac_cv_swap_conv=2048
1417                 AC_MSG_RESULT([using IRIX format swap])
1419         elif [$PATH_TO_SWAP -l 2>/dev/null | egrep -i "^path +dev +swaplo +blocks +free" >/dev/null]
1420         then
1421                 ac_cv_swap_format=["%*s %*[0-9,-] %*d %f %f"]
1422                 ac_cv_swap_conv=2048
1423                 AC_MSG_RESULT([using Unixware format swap])
1424         else
1425                 dnl if we don't know what format swap's output is
1426                 dnl we might as well pretend we didn't see it
1427                 ac_cv_have_swap=""
1428                 ac_cv_swap_command=""
1429         fi
1430 fi
1431 dnl end if for PATH_TO_SWAP
1432 fi
1434 AC_PATH_PROG(PATH_TO_SWAPINFO,swapinfo)
1435 if (test -n "$PATH_TO_SWAPINFO")
1436 then
1437 AC_MSG_CHECKING([for $PATH_TO_SWAPINFO format])
1438 if [$PATH_TO_SWAPINFO -k 2>&1 | egrep -i "^Device" >/dev/null]
1439 then
1440         ac_cv_have_swap=yes
1441         ac_cv_swap_command="$PATH_TO_SWAPINFO -k"
1443         if [$PATH_TO_SWAPINFO -k 2>/dev/null | egrep -i "^Device +1K-blocks +Used +Avail" >/dev/null]
1444         then
1445                 ac_cv_swap_format=["%*s %f %*d %f"]
1446                 ac_cv_swap_conv=1024
1447                 AC_MSG_RESULT([using FreeBSD format swapinfo])
1448         fi
1450 elif [$PATH_TO_SWAPINFO -dfM 2>/dev/null | egrep -i "^TYPE +AVAIL +USED +FREE" >/dev/null]
1451 then
1452         ac_cv_have_swap=yes
1453         ac_cv_swap_command="$PATH_TO_SWAPINFO -dfM",
1454         ac_cv_swap_format=["%*s %f %*d %f"]
1455         ac_cv_swap_conv=1024
1456         AC_MSG_RESULT([using HP-UX format swapinfo])
1457 fi
1458 dnl end if for PATH_TO_SWAPINFO
1459 fi
1461 AC_PATH_PROG(PATH_TO_LSPS,lsps)
1462 if (test -n "$PATH_TO_LSPS")
1463 then
1464 AC_MSG_CHECKING([for $PATH_TO_LSPS format])
1465 if [$PATH_TO_LSPS -a 2>/dev/null | egrep -i "^Page Space" > /dev/null]
1466 then
1467         ac_cv_have_swap=yes
1468         ac_cv_swap_command="$PATH_TO_LSPS -a"
1469         ac_cv_swap_format=["%*s %*s %*s %f%*s %f %*s"]
1470         ac_cv_swap_conv=1
1471         AC_MSG_RESULT([using AIX lsps])
1472 fi
1473 dnl end if for PATH_TO_SWAPINFO
1474 fi
1476 dnl
1477 dnl test for swapctl system call, both the 2-arg and 3-arg variants
1478 dnl fwict, the 2-arg is an SVR4 standard, whereas the 3-arg is shared
1479 dnl in the various BSD's
1480 dnl
1482 AC_CHECK_HEADERS([sys/stat.h sys/param.h])
1483 AC_CHECK_HEADERS([sys/swap.h], [], [], [
1484 #ifdef HAVE_SYS_PARAM_H
1485 #include <sys/param.h>
1486 #endif
1487 ])
1488 AC_CHECK_DECLS([swapctl],,,[
1489                #include <unistd.h>
1490                #include <sys/types.h>
1491                #include <sys/param.h>
1492                #include <sys/stat.h>
1493                #include <sys/swap.h>
1494                ])
1495 AC_CHECK_TYPES([swaptbl_t, swapent_t],,,[
1496                #include <sys/types.h>
1497                #include <sys/param.h>
1498                #include <sys/stat.h>
1499                #include <sys/swap.h>
1500                ])
1501 AC_CHECK_MEMBERS([struct swapent.se_nblks],,,[
1502                #include <unistd.h>
1503                #include <sys/types.h>
1504                #include <sys/param.h>
1505                #include <sys/stat.h>
1506                #include <sys/swap.h>
1507                ])
1509 if test "$ac_cv_have_decl_swapctl" = "yes"; 
1510 then
1511         EXTRAS="$EXTRAS check_swap"
1512         AC_MSG_CHECKING([for 2-arg (SVR4) swapctl])
1513         if test "$ac_cv_type_swaptbl_t" = "yes" -a \
1514                 "$ac_cv_type_swapent_t" = "yes"; 
1515         then
1516                 AC_MSG_RESULT([yes])
1517                 ac_cv_check_swap_swapctl_svr4="1";
1518                 AC_DEFINE([CHECK_SWAP_SWAPCTL_SVR4],1,
1519                           [Define if 2-argument SVR4 swapctl exists])
1520         else
1521                 AC_MSG_RESULT([no])
1522                 AC_MSG_CHECKING([for 3-arg (*BSD) swapctl])
1523                 if test "$ac_cv_member_struct_swapent_se_nblks" = "yes"; 
1524                 then
1525                         AC_MSG_RESULT([yes])
1526                         AC_DEFINE([CHECK_SWAP_SWAPCTL_BSD],1,
1527                                   [Define if 3-argument BSD swapctl exists])
1528                 else
1529                         AC_MSG_RESULT([no])
1530                 fi
1531         fi
1532         AC_MSG_CHECKING([for whether swapctl uses blocks or pages])
1533         if test "$ac_cv_check_swap_swapctl_svr4" = "1";
1534         then
1535                 dnl
1536                 dnl the SVR4 spec returns values in pages
1537                 dnl
1538                 AC_MSG_RESULT([page])
1539                 AC_CHECK_DECLS([sysconf])
1540                 AC_MSG_CHECKING([for system page size])
1541                 if test "$ac_cv_have_decl_sysconf" = "yes";
1542                 then
1543                         AC_MSG_RESULT([determined by sysconf(3)])
1544                         ac_cv_swap_conv="(1048576/sysconf(_SC_PAGESIZE))"
1545                 else
1546                         AC_MSG_WARN([don't know. guessing 4096k])
1547                         ac_cv_swap_conv=256
1548                 fi
1549         else
1550                 dnl
1551                 dnl the BSD spec returns values in blocks
1552                 dnl
1553                 AC_MSG_RESULT([blocks (assuming 512b)])
1554                 ac_cv_swap_conv=2048
1555         fi
1556         AC_DEFINE_UNQUOTED(SWAP_CONVERSION,$ac_cv_swap_conv,
1557                 [Conversion factor to MB])
1558 fi
1559 dnl
1560 dnl end tests for the swapctl system calls
1561 dnl
1564 if test "x$ac_cv_have_swap" != "x" 
1565 then
1566         AC_DEFINE(HAVE_SWAP,1,[Define if swap/swapinfo command is found])
1567         EXTRAS="$EXTRAS check_swap"
1568 fi
1569 if test "x$ac_cv_swap_command" != "x" 
1570 then
1571         AC_DEFINE_UNQUOTED(SWAP_COMMAND,"$ac_cv_swap_command",
1572                 [Path to swap/swapinfo binary, with any args])
1573         AC_DEFINE_UNQUOTED(SWAP_FORMAT,"$ac_cv_swap_format",
1574                 [Format string for parsing swap output])
1575         AC_DEFINE_UNQUOTED(SWAP_CONVERSION,$ac_cv_swap_conv,
1576                 [Conversion factor to MB])
1577 fi
1579 AC_ARG_WITH(proc-meminfo,
1580             ACX_HELP_STRING([--with-proc-meminfo=PATH],
1581                             [path to /proc/meminfo or equivalent]),
1582                             ac_cv_proc_meminfo=$withval)
1583 dnl dunno why this does not work below - use hack (kbd)
1584 dnl fine on linux, broken on solaris
1585 dnl if /bin/test -e "/proc/meminfo"
1586 AC_MSG_CHECKING([for /proc/meminfo])
1587 if test -n "$ac_cv_proc_meminfo"; then
1588         AC_MSG_RESULT([(command line) $ac_cv_proc_meminfo])
1589 elif [cat /proc/meminfo > /dev/null 2>&1]; then
1590         AC_MSG_RESULT([found /proc/meminfo])
1591         ac_cv_proc_meminfo="/proc/meminfo"
1592 else
1593         AC_MSG_RESULT([no])
1594 fi
1596 if test -n "$ac_cv_proc_meminfo"; then
1597         AC_DEFINE(HAVE_PROC_MEMINFO,1,[Define if we have /proc/meminfo])
1598         AC_DEFINE_UNQUOTED(PROC_MEMINFO,"$ac_cv_proc_meminfo",[path to /proc/meminfo if name changes])
1599         EXTRAS="$EXTRAS check_swap"
1600 fi
1602 AC_PATH_PROG(PATH_TO_DIG,dig)
1603 AC_ARG_WITH(dig_command,
1604             ACX_HELP_STRING([--with-dig-command=PATH],
1605                             [Path to dig command]), PATH_TO_DIG=$withval)
1606 if test -n "$PATH_TO_DIG"; then
1607         EXTRAS="$EXTRAS check_dig"
1608         AC_DEFINE_UNQUOTED(PATH_TO_DIG,"$PATH_TO_DIG",[Path to dig command, if present])
1609 fi
1611 AC_PATH_PROG(PATH_TO_APTGET,apt-get)
1612 AC_ARG_WITH(apt-get_command,
1613             ACX_HELP_STRING([--with-apt-get-command=PATH],
1614                             [Path to apt-get command]), 
1615                             with_apt_get_command=$withval,
1616                             with_apt_get_command=$PATH_TO_APTGET)
1617 AC_DEFINE_UNQUOTED(PATH_TO_APTGET,"$PATH_TO_APTGET",[Path to apt-get command, if present])
1618 # check_apt needs regex support
1619 if test -n "$PATH_TO_APTGET" && test "$FOUNDREGEX" = "yes"; 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([no-libtool], [need-ngettext])
1665 AM_GNU_GETTEXT_VERSION(0.11.5)
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   intl/Makefile
1713   po/Makefile.in 
1717 dnl the ones below that are commented out need to be cleaned up 
1718 dnl in the configure code above to use with_foo instead of ac_cv_foo
1719 dnl if we want them to show up here.  it'd also make the code cleaner.
1720 dnl i'll get to that on another rainy day :) -sf
1721 ACX_FEATURE([with],[apt-get-command])
1722 dnl ACX_FEATURE([with],[dig-command])
1723 dnl ACX_FEATURE([with],[fping-command])
1724 dnl ACX_FEATURE([with],[mailq-command])
1725 dnl ACX_FEATURE([with],[nslookup-command])
1726 ACX_FEATURE([with],[ping6-command])
1727 ACX_FEATURE([with],[ping-command])
1728 dnl ACX_FEATURE([with],[qstat-command])
1729 dnl ACX_FEATURE([with],[rpcinfo-command])
1730 dnl ACX_FEATURE([with],[smbclient-command])
1731 dnl ACX_FEATURE([with],[snmpget-command])
1732 dnl ACX_FEATURE([with],[snmpgetnext-command])
1733 dnl ACX_FEATURE([with],[ssh-command])
1734 dnl ACX_FEATURE([with],[uptime-command])
1736 dnl ACX_FEATURE([with],[proc-loadavg])
1737 dnl ACX_FEATURE([with],[proc-meminfo])
1738 dnl ACX_FEATURE([with],[ps-command])
1739 dnl ACX_FEATURE([with],[ps-format])
1740 dnl ACX_FEATURE([with],[ps-cols])
1741 dnl ACX_FEATURE([with],[ps-varlist])
1743 ACX_FEATURE([with],[lwres])
1744 ACX_FEATURE([with],[ipv6])
1745 ACX_FEATURE([with],[mysql])
1746 ACX_FEATURE([with],[openssl])
1747 ACX_FEATURE([with],[gnutls])
1748 ACX_FEATURE([enable],[emulate-getaddrinfo])
1749 ACX_FEATURE([with],[perl])
1750 ACX_FEATURE([with],[cgiurl])
1751 ACX_FEATURE([with],[nagios-user])
1752 ACX_FEATURE([with],[nagios-group])
1753 ACX_FEATURE([with],[trusted-path])