Code

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