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