check_procs: Assume we have stat()
[monitoring-plugins.git] / configure.in
blob43fe4ade9c6a8580413ea4c940a1d1c83179ef2f
1 dnl Process this file with autoconf to produce a configure script.
2 AC_PREREQ(2.59)
3 AC_INIT(nagios-plugins,1.4.16)
4 AC_CONFIG_SRCDIR(NPTest.pm)
5 AC_CONFIG_FILES([gl/Makefile 
6         nagios-plugins.spec])
7 AC_CONFIG_AUX_DIR(build-aux)
8 AM_INIT_AUTOMAKE([1.8.3])
9 AM_CONFIG_HEADER(config.h)
10 AC_CANONICAL_HOST
12 RELEASE=1
13 AC_SUBST(RELEASE)
15 AC_PREFIX_DEFAULT(/usr/local/nagios)
17 dnl Deprecated configure options
20 dnl Append user (-o), group (-g), mode (-m) to install command
21 dnl There is an assumption that this is possible with ./configure's chosen install command
22 extra_install_args=""
23 AC_ARG_WITH(nagios_user,
24         ACX_HELP_STRING([--with-nagios-user=USER],
25                 [Installs executables with this user. Defaults to install user]),
26         extra_install_args="-o $withval")
27 AC_ARG_WITH(nagios_group,
28         ACX_HELP_STRING([--with-nagios-group=GROUP],
29                 [Installs executables with this group. Defaults to install user]),
30         extra_install_args="$extra_install_args -g $withval")
31 AC_ARG_WITH(world_permissions,
32         ACX_HELP_STRING([--without-world-permissions],
33                 [Installs executables without world permissions]))
35 if test "x$with_world_permissions" = xno ; then
36         extra_install_args="$extra_install_args -m 0550"
39 INSTALL="$INSTALL $extra_install_args"
40 INSTALL_STRIP_PROGRAM="$INSTALL_STRIP_PROGRAM $extra_install_args"
41 AC_SUBST(INSTALL)
43 AC_PROG_CC
44 gl_EARLY
45 AC_PROG_GCC_TRADITIONAL
46 AC_PROG_LIBTOOL
48 AM_PROG_CC_C_O
50 AC_FUNC_ERROR_AT_LINE
51 AC_SYS_LARGEFILE
53 ifdef([AC_FUNC_STRTOD],[AC_FUNC_STRTOD],[AM_FUNC_STRTOD])
55 PLUGIN_TEST=`echo $srcdir/plugins/t/*.t|sed -e 's,\.*/plugins/,,g'`
56 AC_SUBST(PLUGIN_TEST)dnl
58 SCRIPT_TEST=`echo $srcdir/plugins-scripts/t/*.t|sed -e 's,\.*/plugins-scripts/,,g'`
59 AC_SUBST(SCRIPT_TEST)dnl
61 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"
62 AC_SUBST(WARRANTY)
64 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"
65 AC_SUBST(SUPPORT)
67 dnl CGIURL has changed for Nagios with 1.0 beta
68 AC_ARG_WITH(cgiurl,
69         ACX_HELP_STRING([--with-cgiurl=DIR],
70                 [sets URL for cgi programs]),
71         with_cgiurl=$withval,
72         with_cgiurl=/nagios/cgi-bin)
73 CGIURL="$with_cgiurl"
74 AC_DEFINE_UNQUOTED(CGIURL,"$CGIURL",[URL of CGI programs])
76 AC_ARG_WITH(trusted_path,
77         ACX_HELP_STRING([--with-trusted-path=PATH],
78                 [sets trusted path for executables called by scripts (default=/bin:/sbin:/usr/bin:/usr/sbin)]),
79         with_trusted_path=$withval,
80         with_trusted_path=/bin:/sbin:/usr/bin:/usr/sbin)
81 AC_SUBST(with_trusted_path)
83 EXTRAS=
84 EXTRAS_ROOT=
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 Check if version file is present
103 AM_CONDITIONAL([RELEASE_PRESENT], [test -f $srcdir/release])
105 # Also read in the version from it
106 if test -f $srcdir/release; then
107         NP_RELEASE="$(<release)"
108 else
109         NP_RELEASE="$PACKAGE_VERSION"
111 AC_SUBST(NP_RELEASE)
113 dnl Checks for programs.
114 AC_PATH_PROG(PYTHON,python)
115 AC_PATH_PROG(SH,sh)
116 AC_PATH_PROG(PERL,perl)
117 AC_PATH_PROG(LIBGNUTLS_CONFIG,libgnutls-config)
118 AC_PATH_PROG(HOSTNAME,hostname)
119 AC_PATH_PROG(BASENAME,basename)
121 dnl allow them to override the path of perl
122 AC_ARG_WITH(perl,
123         ACX_HELP_STRING([--with-perl=PATH],
124                         [sets path to perl executable]),
125                         with_perl=$withval,with_perl=$PERL)
126 AC_SUBST(PERL, $with_perl)
128 dnl openssl/gnutls
129 AC_ARG_WITH(openssl,
130             AC_HELP_STRING([--with-openssl=DIR],
131                            [path to openssl installation]),)
133 AC_ARG_WITH(gnutls,
134             ACX_HELP_STRING([--with-gnutls=PATH],
135                             [path to gnutls installation root]),)
137 dnl you can only have one or the other
138 if test ! "$with_openssl" = "" && test ! "$with_openssl" = "no"; then
139         with_gnutls="no"
141 if test ! "$with_gnutls" = "" && test ! "$with_gnutls" = "no"; then
142         with_openssl="no"
145 dnl list of possible dirs to try to autodetect openssl
146 dnl if $dir/include exists, we consider it found
147 dnl the order should allow locally installed versions to override distros' ones
148 OPENSSL_DIRS="/usr /usr/local /usr/slocal /usr/local/openssl /usr/local/ssl \
149               /opt /opt/openssl"
153 dnl Checks for libraries.
156 AC_CHECK_LIB(dce,main,SOCKETLIBS="$SOCKETLIBS -ldce")
157 AC_CHECK_LIB(nsl,main,SOCKETLIBS="$SOCKETLIBS -lnsl")
158 AC_CHECK_LIB(socket,socket,SOCKETLIBS="$SOCKETLIBS -lsocket")
159 AC_CHECK_LIB(resolv,main,SOCKETLIBS="$SOCKETLIBS -lresolv")
160 AC_SUBST(SOCKETLIBS)
163 dnl check for math-related functions needing -lm
164 AC_CHECK_HEADERS(math.h)
165 AC_CHECK_LIB(m,floor,MATHLIBS="-lm")
166 AC_CHECK_HEADERS(mp.h)
167 AC_CHECK_LIB(bsd,pow,MATHLIBS="$MATHLIBS -lbsd")
168 AC_SUBST(MATHLIBS)
170 dnl Check if we buils local libtap
171 AC_ARG_ENABLE(libtap,
172   AC_HELP_STRING([--enable-libtap],
173                 [Enable built-in libtap for unit-testing (default: autodetect system library).]),
174         [enable_libtap=$enableval],
175         [enable_libtap=no])
176 AM_CONDITIONAL([USE_LIBTAP_LOCAL],[test "$enable_libtap" = "yes"])
178 # If not local, check if we can use the system one
179 if test "$enable_libtap" != "yes" ; then
180         dnl Check for libtap, to run perl-like tests
181         AC_CHECK_LIB(tap, plan_tests,
182                 enable_libtap="yes"
183                 )
186 # Finally, define tests if we use libtap
187 if test "$enable_libtap" = "yes" ; then
188         EXTRA_TEST="test_utils test_disk test_tcp test_cmd test_base64"
189         AC_SUBST(EXTRA_TEST)
192 dnl INI Parsing
193 AC_ARG_ENABLE(extra-opts,
194   AC_HELP_STRING([--enable-extra-opts],
195                 [Enables parsing of plugins ini config files for extra options (default: no)]),
196         [enable_extra_opts=$enableval],
197         [enable_extra_opts=no])
198 AM_CONDITIONAL([USE_PARSE_INI],[test "$enable_extra_opts" = "yes"])
199 if test "$enable_extra_opts" = "yes" ; then
200         AC_DEFINE(NP_EXTRA_OPTS,[1],[Enable INI file parsing.])
201         if test "$enable_libtap" = "yes"; then
202                 EXTRA_TEST="$EXTRA_TEST test_ini1 test_ini3 test_opts1 test_opts2 test_opts3"
203                 AC_SUBST(EXTRA_TEST)
204         fi
207 dnl Check for PostgreSQL libraries
208 _SAVEDLIBS="$LIBS"
209 _SAVEDCPPFLAGS="$CPPFLAGS"
210 AC_ARG_WITH(pgsql,
211         ACX_HELP_STRING([--with-pgsql=DIR],
212                 [sets path to pgsql installation]),
213         PGSQL=$withval,)
214 AC_CHECK_LIB(crypt,main)
215 if test "$ac_cv_lib_crypt_main" = "yes" -a "x$PGSQL" != "xno"; then
216   if test -n "$PGSQL"; then
217     LDFLAGS="$LDFLAGS -L$PGSQL/lib"
218     CPPFLAGS="$CPPFLAGS -I$PGSQL/include"
219   fi
220   AC_CHECK_LIB(pq,PQsetdbLogin,,,-lcrypt)
221   if test "$ac_cv_lib_pq_PQsetdbLogin" = "yes"; then
222     AC_CHECK_HEADERS(pgsql/libpq-fe.h)
223     AC_CHECK_HEADERS(postgresql/libpq-fe.h)
224     AC_CHECK_HEADERS(libpq-fe.h)
225     if [[ -n "$PGSQL" -a "$ac_cv_header_libpq_fe_h" = "yes" ]]; then
226       PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
227       PGINCLUDE="-I$PGSQL/include"
228     elif test  "$ac_cv_header_pgsql_libpq_fe_h" = "yes"; then
229       PGLIBS="-lpq -lcrypt"
230       PGINCLUDE="-I/usr/include/pgsql"
231     elif test  "$ac_cv_header_postgresql_libpq_fe_h" = "yes"; then
232       PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
233       PGINCLUDE="-I/usr/include/postgresql"
234     elif test  "$ac_cv_header_libpq_fe_h" = "yes"; then
235       PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
236       PGINCLUDE="-I$PGSQL/include"
237     fi
238     if test -z "$PGINCLUDE"; then
239       AC_MSG_WARN([Skipping PostgreSQL plugin (check_pgsql)])
240       AC_MSG_WARN([install PostgreSQL headers to compile this plugin (see REQUIREMENTS).])
241     else
242       AC_SUBST(PGLIBS)
243       AC_SUBST(PGINCLUDE)
244       EXTRAS="$EXTRAS check_pgsql"
245     fi
246   else
247     AC_MSG_WARN([Skipping PostgreSQL plugin (check_pgsql)])
248     AC_MSG_WARN([LIBS="$LIBS" CPPFLAGS="$CPPFLAGS"])
249     AC_MSG_WARN([install PostgreSQL libs to compile this plugin (see REQUIREMENTS).])
250   fi
251 else
252   AC_MSG_WARN([Skipping PostgreSQL plugin (check_pgsql)])
253   AC_MSG_WARN([install lib crypt and PostgreSQL libs to compile this plugin (see REQUIREMENTS).])
255 LIBS="$_SAVEDLIBS"
256 CPPFLAGS="$_SAVEDCPPFLAGS"
258 AC_ARG_WITH([dbi], [AS_HELP_STRING([--without-dbi], [Skips the dbi plugin])])
259 dnl Check for DBI libraries
260 AS_IF([test "x$with_dbi" != "xno"], [
261   _SAVEDLIBS="$LIBS"
262   AC_CHECK_LIB(dbi,dbi_initialize)
263   if test "$ac_cv_lib_dbi_dbi_initialize" = "yes"; then
264     EXTRAS="$EXTRAS check_dbi"
265         DBILIBS="-ldbi"
266     AC_SUBST(DBILIBS)
267   else
268     AC_MSG_WARN([Skipping dbi plugin])
269     AC_MSG_WARN([install DBI libs to compile this plugin (see REQUIREMENTS).])
270   fi
271   LIBS="$_SAVEDLIBS"
274 AC_ARG_WITH([radius], [AS_HELP_STRING([--without-radius], [Skips the radius plugin])])
276 dnl Check for radius libraries
277 AS_IF([test "x$with_radius" != "xno"], [
278   _SAVEDLIBS="$LIBS"
279   AC_CHECK_LIB(radiusclient,rc_read_config)
280   if test "$ac_cv_lib_radiusclient_rc_read_config" = "yes"; then
281     EXTRAS="$EXTRAS check_radius"
282         RADIUSLIBS="-lradiusclient"
283     AC_SUBST(RADIUSLIBS)
284   else
285     AC_CHECK_LIB(radiusclient-ng,rc_read_config)
286     if test "$ac_cv_lib_radiusclient_ng_rc_read_config" = "yes"; then
287       EXTRAS="$EXTRAS check_radius"
288           RADIUSLIBS="-lradiusclient-ng"
289       AC_SUBST(RADIUSLIBS)
290     else
291       AC_MSG_WARN([Skipping radius plugin])
292       AC_MSG_WARN([install radius libs to compile this plugin (see REQUIREMENTS).])
293     fi
294   fi
295   LIBS="$_SAVEDLIBS"
298 AC_ARG_WITH([ldap], [AS_HELP_STRING([--without-ldap], [Skips the LDAP plugin])])
300 dnl Check for LDAP libraries
301 AS_IF([test "x$with_ldap" != "xno"], [
302   _SAVEDLIBS="$LIBS"
303   AC_CHECK_LIB(ldap,main,,,-llber)
304   if test "$ac_cv_lib_ldap_main" = "yes"; then
305     LDAPLIBS="-lldap -llber"\
306     LDAPINCLUDE="-I/usr/include/ldap"
307     AC_SUBST(LDAPLIBS)
308     AC_SUBST(LDAPINCLUDE)
309     AC_CHECK_FUNCS(ldap_set_option)
310     EXTRAS="$EXTRAS check_ldap"
311         AC_CHECK_FUNCS(ldap_init ldap_set_option ldap_get_option ldap_start_tls_s)
312   else
313     AC_MSG_WARN([Skipping LDAP plugin])
314     AC_MSG_WARN([install LDAP libs to compile this plugin (see REQUIREMENTS).])
315   fi
316   LIBS="$_SAVEDLIBS"
319 dnl Check for headers used by check_ide_smart
320 AC_CHECK_HEADER(linux/hdreg.h, FOUNDINCLUDE=yes, FOUNDINCLUDE=no)
321 if test "$FOUNDINCLUDE" = "yes" ; then
322         AC_CHECK_HEADER(linux/types.h, FOUNDINCLUDE=yes, FOUNDINCLUDE=no)
325 if test "$FOUNDINCLUDE" = "yes" ; then
326         EXTRAS="$EXTRAS check_ide_smart"
327 else
328         AC_MSG_WARN([Skipping check_ide_smart plugin.])
329         AC_MSG_WARN([check_ide_smart is linux specific. It requires linux/hdreg.h and linux/types.h.])
332 dnl Check for mysql libraries
333 np_mysqlclient
334 if test $with_mysql = "no" ; then
335   AC_MSG_WARN([Skipping mysql plugin])
336   AC_MSG_WARN([install mysql client libs to compile this plugin (see REQUIREMENTS).])
337 else
338   EXTRAS="$EXTRAS check_mysql check_mysql_query"
339   MYSQLINCLUDE="$np_mysql_include"
340   MYSQLLIBS="$np_mysql_libs"
341   MYSQLCFLAGS="$np_mysql_cflags"
342   AC_SUBST(MYSQLINCLUDE)
343   AC_SUBST(MYSQLLIBS)
344   AC_SUBST(MYSQLCFLAGS)
347 AC_ARG_WITH([ipv6],
348         [AS_HELP_STRING([--with-ipv6], [support IPv6 @<:@default=check@:>@])],
349         [], [with_ipv6=check])
351 dnl Check for AF_INET6 support - unistd.h required for Darwin
352 if test "$with_ipv6" != "no"; then
353         AC_CACHE_CHECK([for IPv6 support], np_cv_sys_ipv6, [
354                 AC_TRY_COMPILE(
355                         [#ifdef HAVE_UNISTD_H
356                         #include <unistd.h>
357                         #endif
358                         #include <netinet/in.h>
359                         #include <sys/socket.h>],
360                         [struct sockaddr_in6 sin6;
361                         void *p;
363                         sin6.sin6_family = AF_INET6;
364                         sin6.sin6_port = 587;
365                         p = &sin6.sin6_addr;],
366                         [np_cv_sys_ipv6=yes],
367                         [np_cv_sys_ipv6=no])
368                 ])
369         if test "$np_cv_sys_ipv6" = "no" -a "$with_ipv6" != "check"; then
370                 AC_MSG_FAILURE([--with-ipv6 was given, but test for IPv6 support failed])
371         fi
372         if test "$np_cv_sys_ipv6" = "yes"; then
373                 AC_DEFINE(USE_IPV6,1,[Enable IPv6 support])
374         fi
375         with_ipv6="$np_cv_sys_ipv6"
379 dnl Checks for Kerberos. Must come before openssl checks for Redhat EL 3
380 AC_CHECK_HEADERS(krb5.h,FOUNDINCLUDE=yes,FOUNDINCLUDE=no)
381 if test "$FOUNDINCLUDE" = "no"; then
382   _SAVEDCPPFLAGS="$CPPFLAGS"
383   CPPFLAGS="$_SAVEDCPPFLAGS -I/usr/kerberos/include"
384   unset ac_cv_header_krb5_h
385   AC_CHECK_HEADERS(krb5.h,
386                    KRB5INCLUDE="-I/usr/kerberos/include"
387                    FOUNDINCLUDE=yes,
388                    FOUNDINCLUDE=no)
390 AC_SUBST(KRBINCLUDE)
391 if test "$FOUNDINCLUDE" = "no"; then
392   CPPFLAGS="$_SAVEDCPPFLAGS"
395 dnl *** The following block comes from wget configure.ac ***
396 dnl Unfortunately, as of this writing (OpenSSL 0.9.6), the libcrypto
397 dnl shared library doesn't record its dependency on libdl, so we
398 dnl need to check for it ourselves so we won't fail to link due to a
399 dnl lack of -ldl.  Most OSes use dlopen(), but HP-UX uses
400 dnl shl_load().
401 AC_CHECK_LIB(dl,dlopen)
402 AC_CHECK_LIB(dl,shl_load)
404 dnl openssl detection/configuration
405 if ! test x"$with_openssl" = x"no"; then
406         dnl Check for OpenSSL location if it wasn't already specified
407         if ! test -d "$with_openssl"; then
408                 for d in $OPENSSL_DIRS; do
409                         if test -x ${d}/bin/openssl || test -x ${d}/sbin/openssl ; then
410                                 with_openssl=$d
411                         fi
412                 done
413         fi
415         _SAVEDCPPFLAGS="$CPPFLAGS"
416         _SAVEDLDFLAGS="$LDFLAGS"
417         dnl Check for OpenSSL header files
418         unset FOUNDINCLUDE
419         if test x"$with_openssl" != x"/usr" ; then
420                 CPPFLAGS="$CPPFLAGS -I$with_openssl/include"
421                 LDFLAGS="$LDFLAGS -L$with_openssl/lib"
422         fi
424         dnl check for openssl in $dir/include/openssl
425         AC_CHECK_HEADERS(openssl/ssl.h openssl/x509.h openssl/rsa.h openssl/pem.h openssl/crypto.h openssl/err.h,
426                          SSLINCLUDE="-I$with_openssl/include"
427                          FOUNDINCLUDE=yes,
428                          FOUNDINCLUDE=no)
429         dnl else check to see if $dir/include has it
430         if test "$FOUNDINCLUDE" = "no"; then
431                 AC_CHECK_HEADERS(ssl.h x509.h rsa.h pem.h crypto.h err.h,
432                                  SSLINCLUDE="-I$with_openssl/include"
433                                  FOUNDINCLUDE=yes,
434                                  FOUNDINCLUDE=no)
435         fi
436         AC_SUBST(SSLINCLUDE)
437         dnl if we didn't find it, reset CPPFLAGS
438         if test "$FOUNDINCLUDE" = "no"; then
439                 CPPFLAGS="$_SAVEDCPPFLAGS"
440                 LDFLAGS="$_SAVEDLDFLAGS"
441         fi
443         dnl Check for crypto lib
444         _SAVEDLIBS="$LIBS"
445         LIBS="-L${with_openssl}/lib"
446         AC_CHECK_LIB(crypto,CRYPTO_lock)
447         if test "$ac_cv_lib_crypto_CRYPTO_lock" = "yes"; then
448                 dnl Check for SSL lib
449                 AC_CHECK_LIB(ssl,main, SSLLIBS="-lssl -lcrypto",,-lcrypto)
450         fi
451         LIBS="$_SAVEDLIBS"
453         dnl test headers and libs to decide whether check_http should use SSL
454         if test "$ac_cv_lib_crypto_CRYPTO_lock" = "yes"; then
455                 if test "$ac_cv_lib_ssl_main" = "yes"; then
456                         if test "$FOUNDINCLUDE" = "yes"; then
457                                 FOUNDOPENSSL="yes"
458                         fi
459                 fi
460         fi
464 dnl check for gnutls if openssl isn't found (or is disabled)
465 if test ! "$FOUNDOPENSSL" = "yes" && test ! "$with_gnutls" = "no"; then
466         if test ! "$with_gnutls" = ""; then
467                 CPPFLAGS="$CPPFLAGS -I${with_gnutls}/include"
468         elif test ! "$LIBGNUTLS_CONFIG" = ""; then
469                 CPPFLAGS="$CPPFLAGS -I`$LIBGNUTLS_CONFIG --prefix`"
470         fi
471         AC_CHECK_HEADERS([gnutls/openssl.h],FOUNDGNUTLS="yes",)
472         if test "$FOUNDGNUTLS" = "yes"; then
473                 AC_CHECK_LIB(gnutls-openssl,main,SSLLIBS="-lgnutls-openssl")
474         fi
476 dnl end check for gnutls
478 if test "$FOUNDOPENSSL" = "yes" || test "$FOUNDGNUTLS" = "yes"; then
479         check_tcp_ssl="check_simap check_spop check_jabber check_nntps check_ssmtp"
480         AC_SUBST(check_tcp_ssl)
481         AC_SUBST(SSLLIBS)
482         AC_DEFINE(HAVE_SSL,1,[Define if SSL libraries are found])
483         if test "$FOUNDOPENSSL" = "yes"; then
484                 AC_DEFINE(USE_OPENSSL,1,[Define if using OpenSSL libraries])
485                 with_openssl="yes"
486                 with_gnutls="no"
487         else
488                 AC_DEFINE(USE_GNUTLS,1,[Define if using gnutls libraries])
489                 with_gnutls="yes"
490                 with_openssl="no"
491         fi
492 else
493         dnl else deliberately disabled or no ssl support available
494         AC_MSG_WARN([OpenSSL or GnuTLS libs could not be found or were disabled])
495         with_openssl="no"
496         with_gnutls="no"
500 dnl Checks for header files.
503 AC_HEADER_TIME
504 AC_HEADER_SYS_WAIT
505 AC_CHECK_HEADERS(signal.h syslog.h uio.h errno.h sys/time.h sys/socket.h sys/un.h sys/poll.h)
506 AC_CHECK_HEADERS(features.h stdarg.h sys/unistd.h ctype.h)
508 dnl Checks for typedefs, structures, and compiler characteristics.
509 AC_C_CONST
510 AC_STRUCT_TM
511 AC_TYPE_PID_T
512 AC_TYPE_SIZE_T
513 AC_TYPE_SIGNAL
515 AC_CACHE_CHECK([for va_copy],ac_cv_HAVE_VA_COPY,[
516 AC_TRY_LINK([#include <stdarg.h>
517 va_list ap1,ap2;], [va_copy(ap1,ap2);],
518 ac_cv_HAVE_VA_COPY=yes,
519 ac_cv_HAVE_VA_COPY=no)])
520 if test x"$ac_cv_HAVE_VA_COPY" = x"yes"; then
521     AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available])
522 else
523     AC_CACHE_CHECK([for __va_copy],ac_cv_HAVE___VA_COPY,[
524     AC_TRY_LINK([#include <stdarg.h>
525     va_list ap1,ap2;], [__va_copy(ap1,ap2);],
526     ac_cv_HAVE___VA_COPY=yes,
527     ac_cv_HAVE___VA_COPY=no)])
528     if test x"$ac_cv_HAVE___VA_COPY" = x"yes"; then
529         AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available])
530     fi
533 AC_TRY_COMPILE([#include <sys/time.h>],
534                [struct timeval *tv;
535                 struct timezone *tz;],
536                AC_DEFINE(HAVE_STRUCT_TIMEVAL,1,[Define if we have a timeval structure])
537                AC_TRY_COMPILE([#include <sys/time.h>],
538                               [struct timeval *tv;
539                                struct timezone *tz;
540                                gettimeofday(tv, tz);],
541                               AC_DEFINE(HAVE_GETTIMEOFDAY,1,[Define if gettimeofday is found]),
542                               AC_DEFINE(NEED_GETTIMEOFDAY,1,[Define if gettimeofday is needed])))
544 dnl Checks for library functions.
545 AC_CHECK_FUNCS(memmove select socket strdup strstr strtol strtoul floor)
546 AC_CHECK_FUNCS(poll)
548 AC_MSG_CHECKING(return type of socket size)
549 AC_TRY_COMPILE([#include <stdlib.h>
550                 #include <sys/types.h>
551                 #include <sys/socket.h>],
552                [int a = send(1, (const void *) buffer, (size_t *) 0, (int *) 0);],
553                ac_cv_socket_size_type=["size_t"]
554                 AC_MSG_RESULT(size_t),
555                ac_cv_socket_size_type=["int"]
556                 AC_MSG_RESULT(int))
558 AC_DEFINE_UNQUOTED(SOCKET_SIZE_TYPE, $ac_cv_socket_size_type ,
559         [Define type of socket size])
562 dnl #### Process table test
564 AC_PATH_PROG(PATH_TO_PS,ps)
566 AC_MSG_CHECKING(for ps syntax)
567 AC_ARG_WITH(ps_command,
568             ACX_HELP_STRING([--with-ps-command=PATH],
569                             [Verbatim command to execute for ps]),
570             PS_COMMAND=$withval)
571 AC_ARG_WITH(ps_format,
572             ACX_HELP_STRING([--with-ps-format=FORMAT],
573                             [Format string for scanning ps output]),
574             PS_FORMAT=$withval)
575 AC_ARG_WITH(ps_cols,
576             ACX_HELP_STRING([--with-ps-cols=NUM],
577                             [Number of columns in ps command]),
578             PS_COLS=$withval)
579 AC_ARG_WITH(ps_varlist,
580             ACX_HELP_STRING([--with-ps-varlist=LIST],
581                             [Variable list for sscanf of 'ps' output]),
582             PS_VARLIST=$withval)
584 if test -n "$PS_COMMAND" && test -n "$PS_FORMAT" && test -n "$PS_COLS" && test -n "$PS_VARLIST"; then
585         ac_cv_ps_command="$PS_COMMAND"
586         ac_cv_ps_format="$PS_FORMAT"
587         ac_cv_ps_varlist="$PS_VARLIST"
588         ac_cv_ps_cols="$PS_COLS"
589         AC_MSG_RESULT([(command-line) $ac_cv_ps_command])
591 dnl Now using the pst3/kmem hack for solaris systems to avoid truncation
592 elif test "$ac_cv_uname_s" = "SunOS"; then
593         #
594         # this is a very, very ugly hack, to hardcode the location for plugins
595         #
596         if test "$libexecdir" = '${exec_prefix}/libexec'; then
597                 if test "$exec_prefix" = "NONE"; then
598                         if test "$prefix" = "NONE"; then
599                                 pst3="$ac_default_prefix/libexec/pst3"
600                         else
601                                 pst3="$prefix/libexec/pst3"
602                         fi
603                 else
604                         pst3="$exec_prefix/libexec/pst3"
605                 fi
606         else
607                 pst3="$libexecdir/pst3"
608         fi
609         ac_cv_ps_command="$pst3"
610         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
611         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
612         ac_cv_ps_cols=9
613         AC_MSG_RESULT([using nagios-plugins internal ps command (pst3) for solaris])
614         if test `isainfo -b` = 64 ; then
615                 pst3_use_64bit=1
616                 AC_MSG_NOTICE([using 64bit pst3])
617         else
618                 AC_MSG_NOTICE([using 32bit pst3])
619         fi
620         EXTRAS_ROOT="$EXTRAS_ROOT pst3"
622         if test "$pst3_use_64bit" = 1; then
623                 dnl Test if we can actually compile code in 64bit
624                 old_cflags=$CFLAGS
625                 CFLAGS="$CFLAGS -m64"
626                 pst3_64bit_working=0
627                 AC_RUN_IFELSE(
628                         [AC_LANG_PROGRAM([], [
629 return sizeof(void*) == 8 ? 0 : 1;
630                         ])
631                 ],[
632                         PST3CFLAGS="-m64"
633                         AC_SUBST(PST3CFLAGS)
634                         pst3_64bit_working=1
635                         AC_MSG_NOTICE([using -m64 for 64bit code])
636                 ],[
637                         pst3_64bit_working=0
638                         AC_MSG_NOTICE([compiler do not like -m64])
639                 ])
640                 CFLAGS=$old_cflags
641                 if test "$pst3_64bit_working" = 0; then
642                         old_cflags=$CFLAGS
643                         CFLAGS="$CFLAGS -xarch=v9"
644                         AC_RUN_IFELSE(
645                                 [AC_LANG_PROGRAM([], [
646 return sizeof(void*) == 8 ? 0 : 1;
647                                 ])
648                         ],[
649                                 PST3CFLAGS="-xarch=v9"
650                                 AC_SUBST(PST3CFLAGS)
651                                 pst3_64bit_working=1
652                                 AC_MSG_NOTICE([using -xarch=v9 for 64bit code])
653                         ],[
654                                 pst3_64bit_working=0
655                                 AC_MSG_NOTICE([compiler do not like -xarch=v9])
656                         ])
657                         CFLAGS=$old_cflags
658                 fi
659                 if test "$pst3_64bit_working" = 0; then
660                         old_cflags=$CFLAGS
661                         CFLAGS="$CFLAGS -xarch=amd64"
662                         AC_RUN_IFELSE(
663                                 [AC_LANG_PROGRAM([], [
664 return sizeof(void*) == 8 ? 0 : 1;
665                                 ])
666                         ],[
667                                 PST3CFLAGS="-xarch=amd64"
668                                 AC_SUBST(PST3CFLAGS)
669                                 pst3_64bit_working=1
670                                 AC_MSG_NOTICE([using -xarch=amd64 for 64bit code])
671                         ],[
672                                 pst3_64bit_working=0
673                                 AC_MSG_NOTICE([compiler do not like -xarch=amd64])
674                         ])
675                         CFLAGS=$old_cflags
676                 fi
677                 if test "$pst3_64bit_working" = 0; then
678                         AC_MSG_ERROR([I don't know how to build a 64-bit object!])
679                 fi
680         fi
682 dnl Removing this for the moment - Ton
683 dnl Using /usr/ucb/ps on Solaris systems, to avoid truncation
684 dnl Limitation that command name is not available
685 dnl elif test "$ac_cv_uname_s" = "SunOS" && /usr/ucb/ps -alxwwn 2>/dev/null | \
686 dnl     egrep -i ["^ *F +UID +PID +PPID +%C +PRI +NI +SZ +RSS +WCHAN +S +TT +TIME +COMMAND"] > /dev/null
687 dnl then
688 dnl     ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procpcpu,&procvsz,&procrss,procstat,&pos]"
689 dnl     ac_cv_ps_command="/usr/ucb/ps -alxwwn"
690 dnl     ac_cv_ps_format=["%*s %d %d %d %d %*d %*d %d %d%*[ 0123456789abcdef]%[OSRZT]%*s %*s %n"]
691 dnl     ac_cv_ps_cols=8
692 dnl     AC_MSG_RESULT([$ac_cv_ps_command])
694 dnl Some gnu/linux systems (debian for one) don't like -axwo and need axwo.
695 dnl so test for this first...
696 elif ps axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
697         egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null
698 then
699         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
700         ac_cv_ps_command="$PATH_TO_PS axwo 'stat uid pid ppid vsz rss pcpu comm args'"
701         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
702         ac_cv_ps_cols=9
703         AC_MSG_RESULT([$ac_cv_ps_command])
705 dnl For OpenBSD 3.2 & 3.3. Must come before ps -weo
706 dnl Should also work for FreeBSD 5.2.1 and 5.3
707 dnl  STAT UCOMM              VSZ   RSS USER      PPID COMMAND
708 elif ps -axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
709         egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null
710 then
711         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
712         ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid pid ppid vsz rss pcpu comm args'"
713         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
714         ac_cv_ps_cols=9
715         AC_MSG_RESULT([$ac_cv_ps_command])
717 dnl Some *BSDs have different format for ps. This is mainly to catch FreeBSD 4.
718 dnl Limitation: Only first 16 chars returned for ucomm field
719 dnl Must come before ps -weo
720 elif ps -axwo 'stat uid pid ppid vsz rss pcpu ucomm command' 2>/dev/null | \
721         egrep -i ["^ *STAT +UID +PID +PPID +VSZ +RSS +%CPU +UCOMM +COMMAND"] > /dev/null
722 then
723         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
724         ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid pid ppid vsz rss pcpu ucomm command'"
725         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
726         ac_cv_ps_cols=9
727         AC_MSG_RESULT([$ac_cv_ps_command])
729 dnl  STAT UCOMM              VSZ   RSS USER       UID  PPID COMMAND
730 elif ps -weo 'stat comm vsz rss user uid pid ppid etime args' 2>/dev/null | \
731         egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[ID]+ +P[PID]+ +[ELAPSD]+ +[RGSCOMDNA]+"] >/dev/null
732 then
733         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procetime,procprog,&pos]"
734         ac_cv_ps_command="$PATH_TO_PS -weo 'stat uid pid ppid vsz rss pcpu etime comm args'"
735         ac_cv_ps_format="%s %d %d %d %d %d %f %s %s %n"
736         ac_cv_ps_cols=10
737         AC_MSG_RESULT([$ac_cv_ps_command])
739 dnl FreeBSD
740 elif ps waxco 'state command vsz rss uid user pid ppid' 2>/dev/null | \
741         egrep -i ["^STAT +COMMAND +VSZ +RSS +UID +USER +PID +PPID"] >/dev/null
742 then
743         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
744         ac_cv_ps_command="$PATH_TO_PS waxco 'state uid pid ppid vsz rss pcpu command command'"
745         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
746         ac_cv_ps_cols=9
747         AC_MSG_RESULT([$ac_cv_ps_command])
749 dnl BSD-like mode in RH 6.1
750 elif ps waxno 'state comm vsz rss uid user pid ppid args' 2>/dev/null | \
751         egrep -i ["^S +COMMAND +VSZ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
752 then
753         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
754         ac_cv_ps_command="$PATH_TO_PS waxno 'state uid pid ppid vsz rss pcpu comm args'"
755         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
756         ac_cv_ps_cols=9
757         AC_MSG_RESULT([$ac_cv_ps_command])
759 dnl SunOS 4.1.3:
760 dnl  F  UID  PID  PPID  CP  PRI  NI  SZ  RSS  WCHAN  STAT  TT  TIME  COMMAND
761 dnl Need the head -1 otherwise test will work because arguments are found
762 elif ps -laxnwww 2>/dev/null | head -1 | \
763         egrep -i ["^ *F(LAGS)? +UID +PID +PPID +CP +PRI +NI +(SZ)|(VSZ)|(SIZE) +RSS +WCHAN +STAT? +TTY? +TIME +COMMAND"] >/dev/null
764 then
765         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]"
766         ac_cv_ps_command="$PATH_TO_PS -laxnwww"
767         ac_cv_ps_format="%*s %d %d %d %*s %*s %*s %d %d %*s %s %*s %*s %n%s"
768         ac_cv_ps_cols=9
769         AC_MSG_RESULT([$ac_cv_ps_command])
771 dnl Debian Linux / procps v1.2.9:
772 dnl  FLAGS   UID   PID  PPID PRI  NI   SIZE   RSS WCHAN       STA TTY TIME COMMAND
773 dnl    100     0     1     0   0   0    776    76  c0131c8c   S  ffff  0:11 init [2]
775 elif ps laxnwww 2>/dev/null | \
776         egrep -i ["^ *F(LAGS)? +UID +PID +PPID +PRI +NI +(VSZ)|(SIZE) +RSS +WCHAN +STAT? TTY +TIME +COMMAND"] >/dev/null
777 then
778         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,procstat,&procvsz,&procrss,&pos,procprog]"
779         ac_cv_ps_command="$PATH_TO_PS laxnwww"
780         ac_cv_ps_format="%*s %d %d %d %*s %*s %d %d %*s %s %*s %*s %n%s"
781         ac_cv_ps_cols=9
782         AC_MSG_RESULT([$ac_cv_ps_command])
784 dnl OpenBSD (needs to come early because -exo appears to work, but does not give all procs)
785 elif ps -axo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
786         egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[PID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null
787 then
788         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
789         ac_cv_ps_command="$PATH_TO_PS -axo 'stat uid pid ppid vsz rss pcpu comm args'"
790         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
791         ac_cv_ps_cols=9
792         AC_MSG_RESULT([$ac_cv_ps_command])
794 dnl Tru64 - needs %*[ +<>] in PS_FORMAT.
795 dnl Has /usr/bin/ps and /sbin/ps - force sbin version
796 dnl Can't use vsize and rssize because comes back with text (eg, 1.5M instead
797 dnl of 1500). Will need big changes to check_procs to support
798 elif /sbin/ps -eo 'stat uid pid ppid pcpu etime comm args' 2>/dev/null | \
799         egrep -i ["^ *S +[UID]+ +[PID]+ +[PID]+ +[%CPU]+ +[ELAPSD]+ +[COMMAND]+ +[COMMAND]+"] > /dev/null
800 then
801         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procpcpu,procetime,procprog,&pos]"
802         ac_cv_ps_command="/sbin/ps -eo 'stat uid pid ppid pcpu etime comm args'"
803         ac_cv_ps_format=["%s%*[ +<>] %d %d %d %f %s %s %n"]
804         ac_cv_ps_cols=8
805         AC_MSG_RESULT([$ac_cv_ps_command])
807 elif ps -eo 's comm vsz rss user uid pid ppid args' 2>/dev/null | \
808         egrep -i ["^S[TAUES]* +C[OMDNA]+ +[VSIZE]+ +U[SER]+ +U[ID]+ +P[PID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null
809 then
810         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
811         ac_cv_ps_command="$PATH_TO_PS -eo 's uid pid ppid vsz rss pcpu comm args'"
812         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
813         ac_cv_ps_cols=9
814         AC_MSG_RESULT([$ac_cv_ps_command])
816 dnl AIX 4.3.3 and 5.1 do not have an rss field
817 elif ps -eo 'stat uid pid ppid vsz pcpu comm args' 2>/dev/null | \
818         egrep -i ["^ *S[TAUES]* +UID +PID +PPID +VSZ +%CPU +COMMAND +COMMAND"] >/dev/null
819 then
820         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procpcpu,procprog,&pos]"
821         ac_cv_ps_command="$PATH_TO_PS -eo 'stat uid pid ppid vsz pcpu comm args'"
822         ac_cv_ps_format="%s %d %d %d %d %f %s %n"
823         ac_cv_ps_cols=8
824         AC_MSG_RESULT([$ac_cv_ps_command - with no RSS])
826 dnl Solaris 2.6
827 elif ps -Ao 's comm vsz rss uid user pid ppid args' 2>/dev/null | \
828         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
829 then
830         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
831         ac_cv_ps_command="$PATH_TO_PS -Ao 's uid pid ppid vsz rss pcpu comm args'"
832         # There must be no space between the %s and %n due to a wierd problem in sscanf where
833         # it will return %n as longer than the line length
834         ac_cv_ps_format="%s %d %d %d %d %d %f %s%n"
835         ac_cv_ps_cols=9
836         AC_MSG_RESULT([$ac_cv_ps_command])
838 elif ps -Ao 'status comm vsz rss uid user pid ppid args' 2>/dev/null | \
839         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
840 then
841         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
842         ac_cv_ps_command="$PATH_TO_PS -Ao 'status uid pid ppid vsz rss pcpu comm args'"
843         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
844         ac_cv_ps_cols=9
845         AC_MSG_RESULT([$ac_cv_ps_command])
847 elif ps -Ao 'state comm vsz rss uid user pid ppid args' 2>/dev/null | \
848         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
849 then
850         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
851         ac_cv_ps_command="$PATH_TO_PS -Ao 'state uid pid ppid vsz rss pcpu comm args'"
852         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
853         ac_cv_ps_cols=9
854         AC_MSG_RESULT([$ac_cv_ps_command])
856 dnl wonder who takes state instead of stat
857 elif ps -ao 'state command vsz rss user pid ppid args' 2>/dev/null | \
858         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
859 then
860         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
861         ac_cv_ps_command="$PATH_TO_PS -ao 'state uid pid ppid vsz rss pcpu command args'"
862         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
863         ac_cv_ps_cols=8
864         AC_MSG_RESULT([$ac_cv_ps_command])
866 dnl IRIX 53
867 elif ps -el 2>/dev/null | \
868         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
869 then
870         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&pos,procprog]"
871         ac_cv_ps_command="$PATH_TO_PS -el (IRIX 53)"
872         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %d %d %*s %*s %*s %n%s"
873         ac_cv_ps_cols=8
874         AC_MSG_RESULT([$ac_cv_ps_command])
876 dnl IRIX 63
877 elif ps -el 2>/dev/null | \
878         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +ADDR +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
879 then
880         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
881         ac_cv_ps_command="$PATH_TO_PS -el (IRIX 63)"
882         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
883         ac_cv_ps_cols=6
884         AC_MSG_RESULT([$ac_cv_ps_command])
886 dnl AIX 4.1:
887 dnl     F S      UID   PID  PPID   C PRI NI ADDR  SZ  RSS   WCHAN    TTY  TIME CMD
888 dnl    303 A        0     0     0 120  16 -- 1c07  20   24              -  0:45 swapper
889 elif ps -el 2>/dev/null | \
890         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +ADDR +SZ +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
891 then
892         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
893         ac_cv_ps_command="$PATH_TO_PS -el (AIX 4.1 and HP-UX)"
894         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
895         ac_cv_ps_cols=6
896         AC_MSG_RESULT([$ac_cv_ps_command])
898 dnl AIX?
899 elif ps glaxen 2>/dev/null | \
900         egrep -i ["^ *F +UID +PID +PPID +PRI +NI +VSZ +RSS +WCHAN +STAT +TTY +TIME +COMMAND"] >/dev/null
901 then
902         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]"
903         ac_cv_ps_command="$PATH_TO_PS glaxen"
904         ac_cv_ps_format="%*s %d %d %d %*s %*s %d %d %*s %s %*s %*s %n%s"
905         ac_cv_ps_cols=8
906         AC_MSG_RESULT([$ac_cv_ps_command])
908 dnl MacOSX / Darwin
909 dnl TODO: MacOSX has commands with spaces which will cause problems to PS_FORMAT
910 dnl Some truncation will happen in UCOMM column
911 dnl STAT      VSZ    RSS   UID  PPID %CPU UCOMM            COMMAND
912 dnl Ss      52756  22496   501     1   6.9 Window Manager   /System/Library/CoreServices/WindowServer -daemon
913 elif ps wwaxo 'state vsz rss uid pid ppid pcpu ucomm command' 2>/dev/null | \
914         egrep -i ["^STAT +VSZ +RSS +UID +PPID +%CPU +UCOMM +COMMAND"] >/dev/null
915 then
916         ac_cv_ps_command="$PATH_TO_PS wwaxo 'state vsz rss uid pid ppid pcpu ucomm command'"
917         ac_cv_ps_varlist="[procstat,&procvsz,&procrss,&procuid,&procpid,&procppid,&procpcpu,procprog,&pos]"
918         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
919         ac_cv_ps_cols=8
920         AC_MSG_RESULT([$ac_cv_ps_command])
922 dnl UnixWare
923 elif ps -Al 2>/dev/null | \
924         egrep -i ["^ *F +S +UID +PID +PPID +CLS +PRI +NI +C +ADDR +SZ +WCHAN +TTY +TIME +COMD"] >/dev/null
925 then
926         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
927         ac_cv_ps_command="$PATH_TO_PS -Al"
928         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
929         ac_cv_ps_cols=8
930         AC_MSG_RESULT([$ac_cv_ps_command])
932 else
933         AC_MSG_WARN([unable to find usable ps syntax - check_procs and check_nagios will not be compiled])
936 if test -n "$ac_cv_ps_varlist" ; then
937         AC_DEFINE_UNQUOTED(PS_VARLIST,$ac_cv_ps_varlist,
938                 [Variable list for sscanf of 'ps' output])
939         AC_DEFINE_UNQUOTED(PS_COMMAND,"$ac_cv_ps_command",
940                 [Verbatim command to execute for ps in check_procs])
941         AC_DEFINE_UNQUOTED(PS_FORMAT,"$ac_cv_ps_format",
942                 [Format string for scanning ps output in check_procs])
943         AC_DEFINE_UNQUOTED(PS_COLS,$ac_cv_ps_cols,
944                 [Number of columns in ps command])
945         EXTRAS="$EXTRAS check_procs check_nagios"
946         if echo "$ac_cv_ps_varlist" | grep "procetime" >/dev/null; then
947                 AC_DEFINE(PS_USES_PROCETIME,"yes",
948                           [Whether the ps utility uses the "procetime" field])
949         fi
952 AC_PATH_PROG(PATH_TO_PING,ping)
953 AC_PATH_PROG(PATH_TO_PING6,ping6)
955 AC_ARG_WITH(ping_command,
956         ACX_HELP_STRING([--with-ping-command=SYNTAX],
957                 [sets syntax for ICMP ping]),
958         with_ping_command=$withval,)
960 AC_MSG_CHECKING(for ICMP ping syntax)
961 ac_cv_ping_packets_first=no
962 ac_cv_ping_has_timeout=no
963 if test -n "$with_ping_command"
964 then
965         AC_MSG_RESULT([(command-line) $with_ping_command])
966         if echo "$with_ping_command" | grep '%d.*%d.*%s' >/dev/null
967         then
968                 ac_cv_ping_packets_first=yes
969                 ac_cv_ping_has_timeout=yes
970         elif echo "$with_ping_command" | grep '%d.*%s.*%d' >/dev/null || \
971              echo "$with_ping_command" | grep '%s.*%d.*%d' >/dev/null
972         then
973                 ac_cv_ping_has_timeout=yes
974         elif echo "$with_ping_command" | grep '%d.*%s' >/dev/null
975         then
976                 ac_cv_ping_packets_first=yes
977         fi
979 elif [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
980         $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
981         egrep -i "^round-trip|^rtt" >/dev/null
982 then
983         with_ping_command="$PATH_TO_PING -n -U -c %d %s"
984         ac_cv_ping_packets_first=yes
985         AC_MSG_RESULT([$with_ping_command])
987 elif $PATH_TO_PING -n -U -w 10 -c 1 127.0.0.1 2>/dev/null | \
988         egrep -i "^round-trip|^rtt" >/dev/null
989 then
990         with_ping_command="$PATH_TO_PING -n -U -w %d -c %d %s"
991         ac_cv_ping_packets_first=yes
992   ac_cv_ping_has_timeout=yes
993         AC_MSG_RESULT([$with_ping_command])
995 elif $PATH_TO_PING -n -U -c 1 127.0.0.1 2>/dev/null | \
996         egrep -i "^round-trip|^rtt" >/dev/null
997 then
998         with_ping_command="$PATH_TO_PING -n -U -c %d %s"
999         ac_cv_ping_packets_first=yes
1000         AC_MSG_RESULT([$with_ping_command])
1002 elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \
1003         egrep -i "^round-trip|^rtt" >/dev/null
1004 then
1005         with_ping_command="$PATH_TO_PING -n -c %d %s"
1006         ac_cv_ping_packets_first=yes
1007         AC_MSG_RESULT([$with_ping_command])
1009 elif $PATH_TO_PING -n 127.0.0.1 -c 1 2>/dev/null | \
1010         egrep -i "^round-trip|^rtt" >/dev/null
1011 then
1012         with_ping_command="$PATH_TO_PING -n %s -c %d"
1013         AC_MSG_RESULT([$with_ping_command])
1015 elif $PATH_TO_PING 127.0.0.1 -n 1 2>/dev/null | \
1016         egrep -i "^round-trip|^rtt" >/dev/null
1017 then
1018         with_ping_command="$PATH_TO_PING %s -n %d"
1019         AC_MSG_RESULT([$with_ping_command])
1021 elif $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
1022         egrep -i "^round-trip|^rtt" >/dev/null
1023 then
1024         with_ping_command="$PATH_TO_PING -n -s %s 56 %d"
1025         AC_MSG_RESULT([$with_ping_command])
1027 elif $PATH_TO_PING -n -h 127.0.0.1 -s 56 -c 1 2>/dev/null | \
1028         egrep -i "^round-trip|^rtt" >/dev/null
1029 then
1030         with_ping_command="$PATH_TO_PING -n -h %s -s 56 -c %d"
1031         AC_MSG_RESULT([$with_ping_command])
1033 elif $PATH_TO_PING -n -s 56 -c 1 127.0.0.1 2>/dev/null | \
1034         egrep -i "^round-trip|^rtt" >/dev/null
1035 then
1036         with_ping_command="$PATH_TO_PING -n -s 56 -c %d %s"
1037         ac_cv_ping_packets_first=yes
1038         AC_MSG_RESULT([$with_ping_command])
1040 elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \
1041         egrep -i "^round-trip|^rtt" >/dev/null
1042 then
1043         with_ping_command="$PATH_TO_PING -n -c %d %s"
1044         ac_cv_ping_packets_first=yes
1045         AC_MSG_RESULT([$with_ping_command])
1047 else
1048         AC_MSG_WARN([unable to find usable ping syntax])
1051 AC_DEFINE_UNQUOTED(PING_COMMAND,"$with_ping_command",
1052         [path and args for ICMP ping command])
1054 if test "x$ac_cv_ping_packets_first" != "xno"
1055 then
1056         AC_DEFINE(PING_PACKETS_FIRST,1,
1057                 [Define if packet count must precede host])
1060 if test "x$ac_cv_ping_has_timeout" != "xno"
1061 then
1062         AC_DEFINE(PING_HAS_TIMEOUT,1,
1063                 [Define if ping has its own timeout option that should be set])
1066 AC_ARG_WITH(ping6_command,
1067         ACX_HELP_STRING([--with-ping6-command=SYNTAX],
1068                 [sets syntax for ICMPv6 ping]),
1069         with_ping6_command=$withval,)
1071 if test x"$with_ipv6" != xno ; then
1072 AC_MSG_CHECKING(for ICMPv6 ping syntax)
1073 ac_cv_ping6_packets_first=no
1074 if test -n "$with_ping6_command"
1075 then
1076         AC_MSG_RESULT([(command-line) $with_ping6_command])
1077         if echo "$with_ping6_command" | grep '%d.*%d.*%s' >/dev/null
1078         then
1079                 ac_cv_ping6_packets_first=yes
1080         elif echo "$with_ping6_command" | grep '%d.*%s.*%d' >/dev/null || \
1081              echo "$with_ping6_command" | grep '%s.*%d.*%d' >/dev/null
1082         then
1083                 # Just keep same logic as ping (IPv4) if we ever need ac_cv_ping6_has_timeout
1084                 true
1085         elif echo "$with_ping6_command" | grep '%d.*%s' >/dev/null
1086         then
1087                 ac_cv_ping6_packets_first=yes
1088         fi
1090 elif test "x$PATH_TO_PING6" != "x"; then
1091         if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
1092                 $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \
1093                 egrep -i "^round-trip|^rtt" >/dev/null
1094         then
1095                 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s"
1096                 ac_cv_ping6_packets_first=yes
1097                 AC_MSG_RESULT([$with_ping6_command])
1099         elif $PATH_TO_PING6 -n -U -w 10 -c 1 ::1 2>/dev/null | \
1100                 egrep -i "^round-trip|^rtt" >/dev/null
1101         then
1102                 with_ping6_command="$PATH_TO_PING6 -n -U -w %d -c %d %s"
1103                 ac_cv_ping6_packets_first=yes
1104                 ac_cv_ping_has_timeout=yes
1105                 AC_MSG_RESULT([$with_ping6_command])
1107         elif $PATH_TO_PING6 -n -U -c 1 ::1 2>/dev/null | \
1108                 egrep -i "^round-trip|^rtt" >/dev/null
1109         then
1110                 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s"
1111                 ac_cv_ping6_packets_first=yes
1112                 AC_MSG_RESULT([$with_ping6_command])
1114         elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \
1115                 egrep -i "^round-trip|^rtt" >/dev/null
1116         then
1117                 with_ping6_command="$PATH_TO_PING6 -n -c %d %s"
1118                 ac_cv_ping6_packets_first=yes
1119                 AC_MSG_RESULT([$with_ping6_command])
1121         elif $PATH_TO_PING6 -n ::1 -c 1 2>/dev/null | \
1122                 egrep -i "^round-trip|^rtt" >/dev/null
1123         then
1124                 with_ping6_command="$PATH_TO_PING6 -n %s -c %d"
1125                 AC_MSG_RESULT([$with_ping6_command])
1127         elif $PATH_TO_PING6 ::1 -n 1 2>/dev/null | \
1128                 egrep -i "^round-trip|^rtt" >/dev/null
1129         then
1130                 with_ping6_command="$PATH_TO_PING6 %s -n %d"
1131                 AC_MSG_RESULT([$with_ping6_command])
1133         elif $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \
1134                 egrep -i "^round-trip|^rtt" >/dev/null
1135         then
1136                 with_ping6_command="$PATH_TO_PING6 -n -s %s 56 %d"
1137                 AC_MSG_RESULT([$with_ping6_command])
1139         elif $PATH_TO_PING6 -n -h ::1 -s 56 -c 1 2>/dev/null | \
1140                 egrep -i "^round-trip|^rtt" >/dev/null
1141         then
1142                 with_ping6_command="$PATH_TO_PING6 -n -h %s -s 56 -c %d"
1143                 AC_MSG_RESULT([$with_ping6_command])
1145         elif $PATH_TO_PING6 -n -s 56 -c 1 ::1 2>/dev/null | \
1146                 egrep -i "^round-trip|^rtt" >/dev/null
1147         then
1148                 with_ping6_command="$PATH_TO_PING6 -n -s 56 -c %d %s"
1149                 ac_cv_ping6_packets_first=yes
1150                 AC_MSG_RESULT([$with_ping_command])
1152         elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \
1153                 egrep -i "^round-trip|^rtt" >/dev/null
1154         then
1155                 with_ping6_command="$PATH_TO_PING6 -n -c %d %s"
1156                 ac_cv_ping6_packets_first=yes
1157                 AC_MSG_RESULT([$with_ping6_command])
1159         fi
1161 elif test "x$PATH_TO_PING" != "x"; then
1162         if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
1163                 $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \
1164                 egrep -i "^round-trip|^rtt" >/dev/null
1165         then
1166                 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s"
1167                 ac_cv_ping6_packets_first=yes
1168                 AC_MSG_RESULT([$with_ping6_command])
1170         elif $PATH_TO_PING -A inet6 -n -U -c 1 ::1 2>/dev/null | \
1171                 egrep -i "^round-trip|^rtt" >/dev/null
1172         then
1173                 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s"
1174                 ac_cv_ping6_packets_first=yes
1175                 AC_MSG_RESULT([$with_ping6_command])
1177         elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \
1178                 egrep -i "^round-trip|^rtt" >/dev/null
1179         then
1180                 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s"
1181                 ac_cv_ping6_packets_first=yes
1182                 AC_MSG_RESULT([$with_ping6_command])
1184         elif $PATH_TO_PING -A inet6 -n ::1 -c 1 2>/dev/null | \
1185                 egrep -i "^round-trip|^rtt" >/dev/null
1186         then
1187                 with_ping6_command="$PATH_TO_PING -A inet6 -n %s -c %d"
1188                 AC_MSG_RESULT([$with_ping6_command])
1190         elif $PATH_TO_PING -A inet6 ::1 -n 1 2>/dev/null | \
1191                 egrep -i "^round-trip|^rtt" >/dev/null
1192         then
1193                 with_ping6_command="$PATH_TO_PING -A inet6 %s -n %d"
1194                 AC_MSG_RESULT([$with_ping6_command])
1196         elif $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \
1197                 egrep -i "^round-trip|^rtt" >/dev/null
1198         then
1199                 with_ping6_command="$PATH_TO_PING -A inet6 -n -s %s 56 %d"
1200                 AC_MSG_RESULT([$with_ping6_command])
1202         elif $PATH_TO_PING -A inet6 -n -h ::1 -s 56 -c 1 2>/dev/null | \
1203                 egrep -i "^round-trip|^rtt" >/dev/null
1204         then
1205                 with_ping6_command="$PATH_TO_PING -A inet6 -n -h %s -s 56 -c %d"
1206                 AC_MSG_RESULT([$with_ping6_command])
1208         elif $PATH_TO_PING -A inet6 -n -s 56 -c 1 ::1 2>/dev/null | \
1209                 egrep -i "^round-trip|^rtt" >/dev/null
1210         then
1211                 with_ping6_command="$PATH_TO_PING -A inet6 -n -s 56 -c %d %s"
1212                 ac_cv_ping6_packets_first=yes
1213                 AC_MSG_RESULT([$with_ping_command])
1215         elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \
1216                 egrep -i "^round-trip|^rtt" >/dev/null
1217         then
1218                 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s"
1219                 ac_cv_ping6_packets_first=yes
1220                 AC_MSG_RESULT([$with_ping6_command])
1222         fi
1226 if test "x$with_ping6_command" != "x"; then
1227         AC_DEFINE_UNQUOTED(PING6_COMMAND,"$with_ping6_command",
1228                 [path and args for ICMPv6 ping command])
1229 else
1230         AC_MSG_RESULT([none])
1233 if test "x$ac_cv_ping6_packets_first" != "xno"; then
1234         AC_DEFINE(PING6_PACKETS_FIRST,1,
1235                 [Define if packet count must precede host])
1240 AC_ARG_WITH(nslookup_command,
1241             ACX_HELP_STRING([--with-nslookup-command=PATH],
1242                             [sets path to nslookup executable]),
1243             ac_cv_nslookup_command=$withval)
1244 if test -n "$ac_cv_nslookup_command"; then
1245         AC_MSG_NOTICE([Using specific nslookup at $ac_cv_nslookup_command])
1246 else
1247         AC_PATH_PROG(PATH_TO_NSLOOKUP,nslookup)
1248         if test -n "$PATH_TO_NSLOOKUP"
1249         then
1250                 AC_MSG_CHECKING(for nslookup syntax)
1251                 if $PATH_TO_NSLOOKUP -sil 127.0.0.1 2>&1 | grep ["Invalid option: sil"] >/dev/null
1252                 then
1253                         ac_cv_nslookup_command="$PATH_TO_NSLOOKUP"
1254                         AC_MSG_RESULT([$ac_cv_nslookup_command])
1256                 else
1257                         ac_cv_nslookup_command="$PATH_TO_NSLOOKUP -sil"
1258                         AC_MSG_RESULT([$ac_cv_nslookup_command])
1260                 fi
1261         else
1262                 AC_MSG_WARN([nslookup command not found])
1263         fi
1266 if test -n "$ac_cv_nslookup_command"; then
1267         EXTRAS="$EXTRAS check_dns"
1268         AC_DEFINE_UNQUOTED(NSLOOKUP_COMMAND,"$ac_cv_nslookup_command", [path and args for nslookup])
1271 AC_MSG_CHECKING([for number of cpus])
1272 AC_TRY_COMPILE([#include <unistd.h>],
1273         [sysconf(_SC_NPROCESSORS_CONF) > 0;],
1274         AC_DEFINE(HAVE_SYSCONF__SC_NPROCESSORS_CONF,1,[Define if sysconf returns number of cpus])
1275         AC_MSG_RESULT([sysconf(_SC_NPROCESSORS_CONF)]),
1276         AC_MSG_RESULT([cannot calculate])
1277         )
1279 AC_PATH_PROG(PATH_TO_UPTIME,uptime)
1280 AC_ARG_WITH(uptime_command,
1281             ACX_HELP_STRING([--with-uptime-command=PATH],
1282                             [sets path to uptime]), PATH_TO_UPTIME=$withval)
1283 AC_DEFINE_UNQUOTED(PATH_TO_UPTIME,"$PATH_TO_UPTIME",[path to uptime binary])
1285 AC_PATH_PROG(PATH_TO_RPCINFO,rpcinfo)
1286 AC_ARG_WITH(rpcinfo_command,
1287             ACX_HELP_STRING([--with-rpcinfo-command=PATH],
1288                             [sets path to rpcinfo]), PATH_TO_RPCINFO=$withval)
1289 AC_DEFINE_UNQUOTED(PATH_TO_RPCINFO,"$PATH_TO_RPCINFO",[path to rpcinfo binary])
1291 AC_PATH_PROG(PATH_TO_LMSTAT,lmstat)
1292 if test -x "$PATH_TO_LMSTAT"
1293 then
1294         AC_DEFINE_UNQUOTED(PATH_TO_LMSTAT,"$PATH_TO_LMSTAT",[path to lmstat])
1295 else
1296         AC_MSG_WARN([Get lmstat from Globetrotter Software to monitor flexlm licenses])
1299 AC_PATH_PROG(PATH_TO_SMBCLIENT,smbclient)
1300 AC_ARG_WITH(smbclient_command,
1301             ACX_HELP_STRING([--with-smbclient-command=PATH],
1302                             [sets path to smbclient]),
1303             PATH_TO_SMBCLIENT=$withval)
1304 if test -n "$PATH_TO_SMBCLIENT"
1305 then
1306         AC_DEFINE_UNQUOTED(PATH_TO_SMBCLIENT,"$PATH_TO_SMBCLIENT",[path to smbclient binary])
1307 else
1308         AC_MSG_WARN([Get smbclient from Samba.org to monitor SMB shares])
1312 AC_PATH_PROG(PATH_TO_WHO,who)
1314 if [$PATH_TO_WHO -q 2>/dev/null | egrep -i "^# users=[0-9]+$" >/dev/null]
1315 then
1316         ac_cv_path_to_who="$PATH_TO_WHO -q"
1317 else
1318         ac_cv_path_to_who="$PATH_TO_WHO"
1321 AC_DEFINE_UNQUOTED(WHO_COMMAND,"$ac_cv_path_to_who",
1322         [path and arguments for invoking 'who'])
1324 AC_PATH_PROG(PATH_TO_SNMPGET,snmpget)
1325 AC_ARG_WITH(snmpget_command,
1326             ACX_HELP_STRING([--with-snmpget-command=PATH],
1327                             [Path to snmpget command]),
1328             PATH_TO_SNMPGET=$withval)
1329 if test -n "$PATH_TO_SNMPGET"
1330 then
1331         AC_DEFINE_UNQUOTED(PATH_TO_SNMPGET,"$PATH_TO_SNMPGET",[path to snmpget binary])
1332         EXTRAS="$EXTRAS check_hpjd check_snmp"
1333 else
1334         AC_MSG_WARN([Get snmpget from http://net-snmp.sourceforge.net to make check_hpjd and check_snmp plugins])
1337 AC_PATH_PROG(PATH_TO_SNMPGETNEXT,snmpgetnext)
1338 AC_ARG_WITH(snmpgetnext_command,
1339             ACX_HELP_STRING([--with-snmpgetnext-command=PATH],
1340                             [Path to snmpgetnext command]),
1341             PATH_TO_SNMPGETNEXT=$withval)
1342 if test -n "$PATH_TO_SNMPGETNEXT"
1343 then
1344         AC_DEFINE_UNQUOTED(PATH_TO_SNMPGETNEXT,"$PATH_TO_SNMPGETNEXT",[path to snmpgetnext binary])
1347 if ( $PERL -M"Net::SNMP 3.6" -e 'exit' 2>/dev/null  )
1348 then
1349         AC_MSG_CHECKING(for Net::SNMP perl module)
1350         AC_MSG_RESULT([found])
1351 else
1352         AC_MSG_WARN([Tried $PERL - install Net::SNMP perl module if you want to use the perl snmp plugins])
1355 AC_PATH_PROG(PATH_TO_QUAKESTAT,quakestat)
1356 AC_PATH_PROG(PATH_TO_QSTAT,qstat)
1357 AC_ARG_WITH(qstat_command,
1358             ACX_HELP_STRING([--with-qstat-command=PATH],
1359                             [Path to qstat command]), PATH_TO_QSTAT=$withval)
1361 if test -x "$PATH_TO_QUAKESTAT"
1362 then
1363         ac_cv_path_to_qstat="$PATH_TO_QUAKESTAT"
1364         EXTRAS="$EXTRAS check_game"
1366 elif test -n "$PATH_TO_QSTAT"
1367 then
1368         ac_cv_path_to_qstat="$PATH_TO_QSTAT"
1369         EXTRAS="$EXTRAS check_game"
1370 else
1371         AC_MSG_WARN([Get qstat from http://www.activesw.com/people/steve/qstat.html in order to make check_game plugin])
1374 if test $ac_cv_path_to_qstat
1375 then
1376         AC_DEFINE_UNQUOTED(PATH_TO_QSTAT,"$ac_cv_path_to_qstat",
1377                 [path to qstat/quakestat])
1380 AC_PATH_PROG(PATH_TO_FPING,fping)
1381 AC_PATH_PROG(PATH_TO_FPING6,fping6)
1383 AC_ARG_WITH(fping_command,
1384             ACX_HELP_STRING([--with-fping-command=PATH],
1385                             [Path to fping command]), PATH_TO_FPING=$withval)
1386 AC_ARG_WITH(fping6_command,
1387             ACX_HELP_STRING([--with-fping6-command=PATH],
1388                             [Path to fping6 command]), PATH_TO_FPING6=$withval)
1390 if test -n "$PATH_TO_FPING"
1391 then
1392         AC_DEFINE_UNQUOTED(PATH_TO_FPING,"$PATH_TO_FPING",[path to fping])
1393         EXTRAS="$EXTRAS check_fping"
1394         if test x"$with_ipv6" != xno && test -n "$PATH_TO_FPING6"; then
1395                 AC_DEFINE_UNQUOTED(PATH_TO_FPING6,"$PATH_TO_FPING6",[path to fping6])
1396         fi
1397 else
1398         AC_MSG_WARN([Get fping from http://www.fping.com in order to make check_fping plugin])
1401 AC_PATH_PROG(PATH_TO_SSH,ssh)
1402 AC_ARG_WITH(ssh_command,
1403             ACX_HELP_STRING([--with-ssh-command=PATH],
1404                             [sets path for ssh]), PATH_TO_SSH=$withval)
1405 if test -n "$PATH_TO_SSH"
1406 then
1407         AC_DEFINE_UNQUOTED(SSH_COMMAND,"$PATH_TO_SSH",[path to ssh binary])
1408         EXTRAS="$EXTRAS check_by_ssh"
1409 else
1410         AC_MSG_WARN([Get ssh in order to make check_by_ssh plugin])
1414 AC_PATH_PROG(PATH_TO_MAILQ,mailq)
1415 AC_ARG_WITH(mailq_command,
1416             ACX_HELP_STRING([--with-mailq-command=PATH],
1417                             [sets path to mailq]), PATH_TO_MAILQ=$withval)
1418 if test -n "$PATH_TO_MAILQ"
1419 then
1420         AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_MAILQ",[path to mailq])
1421 else
1422         AC_MSG_WARN([Could not find mailq or eqivalent])
1425 AC_PATH_PROG(PATH_TO_QMAIL_QSTAT,qmail-qstat)
1426 if test -x "$PATH_TO_QMAIL_QSTAT"
1427 then
1428         AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_QMAIL_QSTAT",[path to qmail-qstat])
1429 else
1430         AC_MSG_WARN([Could not find qmail-qstat or eqivalent])
1433 dnl SWAP info required is amount allocated/available and amount free
1434 dnl The plugin works through all the swap devices and adds up the total swap
1435 dnl available.
1436 AC_PATH_PROG(PATH_TO_SWAP,swap)
1437 if (test -n "$PATH_TO_SWAP")
1438 then
1439 AC_MSG_CHECKING([for $PATH_TO_SWAP format])
1440 if [$PATH_TO_SWAP -l 2>&1 >/dev/null]
1441 then
1442         ac_cv_have_swap=yes
1443         ac_cv_swap_command="$PATH_TO_SWAP -l"
1444         if [$PATH_TO_SWAP -l 2>/dev/null | \
1445                 egrep -i "^lswap +path +pri +swaplo +blocks +free +maxswap" \
1446                 >/dev/null]
1447         then
1448                 ac_cv_swap_format=[" %*d %*s %*d,%*d %*d %*d %f %f"]
1449                 ac_cv_swap_conv=2048
1450                 AC_MSG_RESULT([using IRIX format swap])
1452         elif [$PATH_TO_SWAP -l 2>/dev/null | egrep -i "^path +dev +swaplo +blocks +free" >/dev/null]
1453         then
1454                 ac_cv_swap_format=["%*s %*[0-9,-] %*d %f %f"]
1455                 ac_cv_swap_conv=2048
1456                 AC_MSG_RESULT([using Unixware format swap])
1457         else
1458                 dnl if we don't know what format swap's output is
1459                 dnl we might as well pretend we didn't see it
1460                 ac_cv_have_swap=""
1461                 ac_cv_swap_command=""
1462         fi
1464 dnl end if for PATH_TO_SWAP
1467 AC_PATH_PROG(PATH_TO_SWAPINFO,swapinfo)
1468 if (test -n "$PATH_TO_SWAPINFO")
1469 then
1470 AC_MSG_CHECKING([for $PATH_TO_SWAPINFO format])
1471 if [$PATH_TO_SWAPINFO -k 2>&1 | egrep -i "^Device" >/dev/null]
1472 then
1473         ac_cv_have_swap=yes
1474         ac_cv_swap_command="$PATH_TO_SWAPINFO -k"
1476         if [$PATH_TO_SWAPINFO -k 2>/dev/null | egrep -i "^Device +1K-blocks +Used +Avail" >/dev/null]
1477         then
1478                 ac_cv_swap_format=["%*s %f %*d %f"]
1479                 ac_cv_swap_conv=1024
1480                 AC_MSG_RESULT([using FreeBSD format swapinfo])
1481         fi
1483 elif [$PATH_TO_SWAPINFO -dfM 2>/dev/null | egrep -i "^TYPE +AVAIL +USED +FREE" >/dev/null]
1484 then
1485         ac_cv_have_swap=yes
1486         ac_cv_swap_command="$PATH_TO_SWAPINFO -dfM"
1487         ac_cv_swap_format=["%*s %f %*d %f"]
1488         ac_cv_swap_conv=1024
1489         AC_MSG_RESULT([using HP-UX format swapinfo])
1491 dnl end if for PATH_TO_SWAPINFO
1494 AC_PATH_PROG(PATH_TO_LSPS,lsps)
1495 if (test -n "$PATH_TO_LSPS")
1496 then
1497 AC_MSG_CHECKING([for $PATH_TO_LSPS format])
1498 if [$PATH_TO_LSPS -a 2>/dev/null | egrep -i "^Page Space" > /dev/null]
1499 then
1500         ac_cv_have_swap=yes
1501         ac_cv_swap_command="$PATH_TO_LSPS -a"
1502         ac_cv_swap_format=["%*s %*s %*s %f%*s %f %*s"]
1503         ac_cv_swap_conv=1
1504         AC_MSG_RESULT([using AIX lsps])
1506 dnl end if for PATH_TO_SWAPINFO
1510 dnl test for swapctl system call, both the 2-arg and 3-arg variants
1511 dnl fwict, the 2-arg is an SVR4 standard, whereas the 3-arg is shared
1512 dnl in the various BSD's
1515 AC_CHECK_HEADERS([sys/stat.h sys/param.h])
1516 AC_CHECK_HEADERS([sys/swap.h], [], [], [
1517 #ifdef HAVE_SYS_PARAM_H
1518 #include <sys/param.h>
1519 #endif
1521 AC_CHECK_DECLS([swapctl],,,[
1522                #include <unistd.h>
1523                #include <sys/types.h>
1524                #include <sys/param.h>
1525                #include <sys/stat.h>
1526                #include <sys/swap.h>
1527                ])
1528 AC_CHECK_TYPES([swaptbl_t, swapent_t],,,[
1529                #include <sys/types.h>
1530                #include <sys/param.h>
1531                #include <sys/stat.h>
1532                #include <sys/swap.h>
1533                ])
1534 AC_CHECK_MEMBERS([struct swapent.se_nblks],,,[
1535                  #include <unistd.h>
1536                  #include <sys/types.h>
1537                  #include <sys/param.h>
1538                  #include <sys/stat.h>
1539                  #include <sys/swap.h>
1540                  ])
1542 if test "$ac_cv_have_decl_swapctl" = "yes";
1543 then
1544         EXTRAS="$EXTRAS check_swap"
1545         AC_MSG_CHECKING([for 2-arg (SVR4) swapctl])
1546         if test "$ac_cv_type_swaptbl_t" = "yes" -a \
1547                 "$ac_cv_type_swapent_t" = "yes";
1548         then
1549                 AC_MSG_RESULT([yes])
1550                 ac_cv_check_swap_swapctl_svr4="1";
1551                 AC_DEFINE([CHECK_SWAP_SWAPCTL_SVR4],1,
1552                           [Define if 2-argument SVR4 swapctl exists])
1553         else
1554                 AC_MSG_RESULT([no])
1555                 AC_MSG_CHECKING([for 3-arg (*BSD) swapctl])
1556                 if test "$ac_cv_member_struct_swapent_se_nblks" = "yes";
1557                 then
1558                         AC_MSG_RESULT([yes])
1559                         AC_DEFINE([CHECK_SWAP_SWAPCTL_BSD],1,
1560                                   [Define if 3-argument BSD swapctl exists])
1561                 else
1562                         AC_MSG_RESULT([no])
1563                 fi
1564         fi
1565         AC_MSG_CHECKING([for whether swapctl uses blocks or pages])
1566         if test "$ac_cv_check_swap_swapctl_svr4" = "1";
1567         then
1568                 dnl
1569                 dnl the SVR4 spec returns values in pages
1570                 dnl
1571                 AC_MSG_RESULT([page])
1572                 AC_CHECK_DECLS([sysconf])
1573                 AC_MSG_CHECKING([for system page size])
1574                 if test "$ac_cv_have_decl_sysconf" = "yes";
1575                 then
1576                         AC_MSG_RESULT([determined by sysconf(3)])
1577                         ac_cv_swap_conv="(1048576/sysconf(_SC_PAGESIZE))"
1578                 else
1579                         AC_MSG_WARN([don't know. guessing 4096k])
1580                         ac_cv_swap_conv=256
1581                 fi
1582         else
1583                 dnl
1584                 dnl the BSD spec returns values in blocks
1585                 dnl
1586                 AC_MSG_RESULT([blocks (assuming 512b)])
1587                 ac_cv_swap_conv=2048
1588         fi
1589         AC_DEFINE_UNQUOTED(SWAP_CONVERSION,$ac_cv_swap_conv,
1590                 [Conversion factor to MB])
1593 dnl end tests for the swapctl system calls
1597 if test "x$ac_cv_have_swap" != "x"
1598 then
1599         AC_DEFINE(HAVE_SWAP,1,[Define if swap/swapinfo command is found])
1600         EXTRAS="$EXTRAS check_swap"
1602 if test "x$ac_cv_swap_command" != "x"
1603 then
1604         AC_DEFINE_UNQUOTED(SWAP_COMMAND,"$ac_cv_swap_command",
1605                 [Path to swap/swapinfo binary, with any args])
1606         AC_DEFINE_UNQUOTED(SWAP_FORMAT,"$ac_cv_swap_format",
1607                 [Format string for parsing swap output])
1608         AC_DEFINE_UNQUOTED(SWAP_CONVERSION,$ac_cv_swap_conv,
1609                 [Conversion factor to MB])
1612 AC_ARG_WITH(proc-meminfo,
1613             ACX_HELP_STRING([--with-proc-meminfo=PATH],
1614                             [path to /proc/meminfo or equivalent]),
1615                             ac_cv_proc_meminfo=$withval)
1616 dnl dunno why this does not work below - use hack (kbd)
1617 dnl fine on linux, broken on solaris
1618 dnl if /bin/test -e "/proc/meminfo"
1619 AC_MSG_CHECKING([for /proc/meminfo])
1620 if test -n "$ac_cv_proc_meminfo"; then
1621         AC_MSG_RESULT([(command line) $ac_cv_proc_meminfo])
1622 elif [cat /proc/meminfo > /dev/null 2>&1]; then
1623         AC_MSG_RESULT([found /proc/meminfo])
1624         ac_cv_proc_meminfo="/proc/meminfo"
1625 else
1626         AC_MSG_RESULT([no])
1629 if test -n "$ac_cv_proc_meminfo"; then
1630         AC_DEFINE(HAVE_PROC_MEMINFO,1,[Define if we have /proc/meminfo])
1631         AC_DEFINE_UNQUOTED(PROC_MEMINFO,"$ac_cv_proc_meminfo",[path to /proc/meminfo if name changes])
1632         EXTRAS="$EXTRAS check_swap"
1635 AC_PATH_PROG(PATH_TO_DIG,dig)
1636 AC_ARG_WITH(dig_command,
1637             ACX_HELP_STRING([--with-dig-command=PATH],
1638                             [Path to dig command]), PATH_TO_DIG=$withval)
1639 if test -n "$PATH_TO_DIG"; then
1640         EXTRAS="$EXTRAS check_dig"
1641         AC_DEFINE_UNQUOTED(PATH_TO_DIG,"$PATH_TO_DIG",[Path to dig command, if present])
1644 AC_PATH_PROG(PATH_TO_APTGET,apt-get)
1645 AC_ARG_WITH(apt-get_command,
1646             ACX_HELP_STRING([--with-apt-get-command=PATH],
1647                             [Path to apt-get command]),
1648                             with_apt_get_command=$withval,
1649                             with_apt_get_command=$PATH_TO_APTGET)
1650 AC_DEFINE_UNQUOTED(PATH_TO_APTGET,"$PATH_TO_APTGET",[Path to apt-get command, if present])
1651 if test -n "$PATH_TO_APTGET" ; then
1652         EXTRAS="$EXTRAS check_apt"
1656 if test -f $srcdir/plugins/check_nt.c ; then
1657   EXTRAS="$EXTRAS check_nt"
1661 dnl used in check_dhcp
1662 AC_CHECK_HEADERS(sys/sockio.h)
1664 case $host in
1665         *bsd*)
1666                 AC_DEFINE(__bsd__,1,[bsd specific code in check_dhcp.c])
1667         ;;
1668         *linux*)
1669                 AC_DEFINE(__linux__,1,[linux specific code in check_dhcp.c])
1670         ;;
1671         *sun* | *solaris*)
1672                 AC_DEFINE(__sun__,1,[sun specific code in check_dhcp.c])
1673         ;;
1674         *hpux*)
1675                 AC_DEFINE(__hpux__,1,[hpux specific code in check_dhcp.c])
1676         ;;
1677 esac
1679 AC_SUBST(EXTRAS)
1680 AC_SUBST(EXTRAS_ROOT)
1681 AC_SUBST(EXTRA_NETOBJS)
1682 AC_SUBST(DEPLIBS)
1684 AM_GNU_GETTEXT([external], [need-ngettext])
1685 AM_GNU_GETTEXT_VERSION(0.15)
1687 dnl Check for Redhat spopen problem
1688 dnl Wierd problem where ECHILD is returned from a wait call in error
1689 dnl Only appears to affect nslookup and dig calls. Only affects redhat around
1690 dnl 2.6.9-11 (okay in 2.6.9-5). Redhat investigating root cause
1691 dnl We patch plugins/popen.c
1692 dnl Need to add smp because uname different on those
1693 dnl Can force patch to be applied with --enable-redhat-pthread-workaround
1694 AC_ARG_ENABLE(redhat-pthread-workaround,
1695         AC_HELP_STRING([--enable-redhat-pthread-workaround],
1696                 [force Redhat patch to be applied (default: test system)]),
1697         [ac_cv_enable_redhat_pthread_workaround=$enableval],
1698         [ac_cv_enable_redhat_pthread_workaround=test])
1699 if test "$ac_cv_enable_redhat_pthread_workaround" = "test" ; then
1700         if echo $ac_cv_uname_r | egrep "\.EL(smp)?$" >/dev/null 2>&1 ; then
1701                 AC_MSG_NOTICE([See http://nagiosplugins.org/faq/compile/configure_appears_to_hang if this next part takes a long time])
1702                 AC_MSG_CHECKING(for redhat spopen problem)
1703                 ( cd config_test && make && make test ) > /dev/null 2>&1
1704                 if test $? -eq 0 ; then
1705                         AC_MSG_RESULT(okay)
1706                 else
1707                         AC_MSG_RESULT(error)
1708                         AC_DEFINE(REDHAT_SPOPEN_ERROR, 1, [Workaround on redhat in spopen])
1709                 fi
1710         fi
1711 elif test "$ac_cv_enable_redhat_pthread_workaround" = "yes" ; then
1712         AC_DEFINE(REDHAT_SPOPEN_ERROR, 1, [Forced workaround on redhat in spopen])
1715 dnl Perl modules
1716 AC_ARG_ENABLE(perl-modules,
1717         AC_HELP_STRING([--enable-perl-modules],
1718                 [Enables installation of Nagios::Plugin and its dependencies (default: no)]),
1719         [enable_perl_modules=$enableval],
1720         [enable_perl_modules=no])
1721 if test "$enable_perl_modules" = "yes" ; then
1722   AC_SUBST(PERLMODS_DIR,perlmods)
1725 # From Tap configure
1726 # Checks for libraries
1727 case "$host" in
1728         *-*-*freebsd4*)
1729                 LDFLAGS="$LDFLAGS -pthread"
1730                 HAVE_LIBPTHREAD=1
1731                 ;;
1732         *)
1733                 AC_CHECK_LIB(pthread, main)
1734                 ;;
1735 esac
1737 dnl External libraries - see ACKNOWLEDGEMENTS
1738 gl_INIT
1740 dnl Some helpful common compile errors checked here
1741 if test "$ac_cv_uname_s" = 'SunOS' -a \( "x$ac_cv_prog_ac_ct_AR" = "x" -o "$ac_cv_prog_ac_ct_AR" = 'false' \) ; then
1742         AC_MSG_ERROR(No ar found for Solaris - is /usr/ccs/bin in PATH?)
1745 AC_OUTPUT(
1746   Makefile
1747   tap/Makefile
1748   lib/Makefile
1749   plugins/Makefile
1750   lib/tests/Makefile
1751   plugins-root/Makefile
1752   plugins-scripts/Makefile
1753   plugins-scripts/subst
1754   plugins-scripts/utils.pm
1755   plugins-scripts/utils.sh
1756   perlmods/Makefile
1757   command.cfg
1758   test.pl
1759   pkg/solaris/pkginfo
1760   po/Makefile.in
1764 dnl the ones below that are commented out need to be cleaned up
1765 dnl in the configure code above to use with_foo instead of ac_cv_foo
1766 dnl if we want them to show up here.  it'd also make the code cleaner.
1767 dnl i'll get to that on another rainy day :) -sf
1768 ACX_FEATURE([with],[apt-get-command])
1769 dnl ACX_FEATURE([with],[dig-command])
1770 dnl ACX_FEATURE([with],[fping-command])
1771 dnl ACX_FEATURE([with],[mailq-command])
1772 dnl ACX_FEATURE([with],[nslookup-command])
1773 ACX_FEATURE([with],[ping6-command])
1774 ACX_FEATURE([with],[ping-command])
1775 dnl ACX_FEATURE([with],[qstat-command])
1776 dnl ACX_FEATURE([with],[rpcinfo-command])
1777 dnl ACX_FEATURE([with],[smbclient-command])
1778 dnl ACX_FEATURE([with],[snmpget-command])
1779 dnl ACX_FEATURE([with],[snmpgetnext-command])
1780 dnl ACX_FEATURE([with],[ssh-command])
1781 dnl ACX_FEATURE([with],[uptime-command])
1783 dnl ACX_FEATURE([with],[proc-meminfo])
1784 dnl ACX_FEATURE([with],[ps-command])
1785 dnl ACX_FEATURE([with],[ps-format])
1786 dnl ACX_FEATURE([with],[ps-cols])
1787 dnl ACX_FEATURE([with],[ps-varlist])
1789 ACX_FEATURE([with],[ipv6])
1790 ACX_FEATURE([with],[mysql])
1791 ACX_FEATURE([with],[openssl])
1792 ACX_FEATURE([with],[gnutls])
1793 ACX_FEATURE([enable],[extra-opts])
1794 ACX_FEATURE([with],[perl])
1795 ACX_FEATURE([enable],[perl-modules])
1796 ACX_FEATURE([with],[cgiurl])
1797 ACX_FEATURE([with],[trusted-path])
1798 ACX_FEATURE([enable],[libtap])