Code

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