Code

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