Code

Updated link to sfsnapshotgit
[nagiosplug.git] / configure.in
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"
36 fi
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"
109 fi
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"
139 fi
140 if test ! "$with_gnutls" = "" && test ! "$with_gnutls" = "no"; then
141         with_openssl="no"
142 fi
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"
151 dnl
152 dnl Checks for libraries.
153 dnl
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)
161 dnl
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                 )
181 fi
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)
187 fi
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
202 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).])
251 fi
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
272 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).])
289 fi
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)
296 fi
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.])
303 fi
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)
318 fi
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"
349 fi
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)
362 fi
363 AC_SUBST(KRBINCLUDE)
364 if test "$FOUNDINCLUDE" = "no"; then
365   CPPFLAGS="$_SAVEDCPPFLAGS"
366 fi
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
434 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
448 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"
470 fi
472 dnl
473 dnl Checks for header files.
474 dnl
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
504 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                 PST3CFLAGS="-m64"
589                 AC_SUBST(PST3CFLAGS)
590                 AC_MSG_NOTICE([using 64bit pst3])       
591         else
592                 AC_MSG_NOTICE([using 32bit pst3])
593         fi
594         EXTRAS_ROOT="$EXTRAS_ROOT pst3"
596 dnl Removing this for the moment - Ton
597 dnl Using /usr/ucb/ps on Solaris systems, to avoid truncation
598 dnl Limitation that command name is not available
599 dnl elif test "$ac_cv_uname_s" = "SunOS" && /usr/ucb/ps -alxwwn 2>/dev/null | \
600 dnl     egrep -i ["^ *F +UID +PID +PPID +%C +PRI +NI +SZ +RSS +WCHAN +S +TT +TIME +COMMAND"] > /dev/null
601 dnl then
602 dnl     ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procpcpu,&procvsz,&procrss,procstat,&pos]"
603 dnl     ac_cv_ps_command="/usr/ucb/ps -alxwwn"
604 dnl     ac_cv_ps_format=["%*s %d %d %d %d %*d %*d %d %d%*[ 0123456789abcdef]%[OSRZT]%*s %*s %n"]
605 dnl     ac_cv_ps_cols=8
606 dnl     AC_MSG_RESULT([$ac_cv_ps_command])
608 dnl Some gnu/linux systems (debian for one) don't like -axwo and need axwo.
609 dnl so test for this first...
610 elif ps axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
611         egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null
612 then
613         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
614         ac_cv_ps_command="$PATH_TO_PS axwo 'stat uid pid ppid vsz rss pcpu comm args'"
615         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
616         ac_cv_ps_cols=9
617         AC_MSG_RESULT([$ac_cv_ps_command])
619 dnl For OpenBSD 3.2 & 3.3. Must come before ps -weo
620 dnl Should also work for FreeBSD 5.2.1 and 5.3
621 dnl  STAT UCOMM              VSZ   RSS USER      PPID COMMAND
622 elif ps -axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
623         egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null
624 then
625         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
626         ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid pid ppid vsz rss pcpu comm args'"
627         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
628         ac_cv_ps_cols=9
629         AC_MSG_RESULT([$ac_cv_ps_command])
631 dnl Some *BSDs have different format for ps. This is mainly to catch FreeBSD 4.
632 dnl Limitation: Only first 16 chars returned for ucomm field
633 dnl Must come before ps -weo
634 elif ps -axwo 'stat uid pid ppid vsz rss pcpu ucomm command' 2>/dev/null | \
635         egrep -i ["^ *STAT +UID +PID +PPID +VSZ +RSS +%CPU +UCOMM +COMMAND"] > /dev/null
636 then
637         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
638         ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid pid ppid vsz rss pcpu ucomm command'"
639         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
640         ac_cv_ps_cols=9
641         AC_MSG_RESULT([$ac_cv_ps_command])
643 dnl  STAT UCOMM              VSZ   RSS USER       UID  PPID COMMAND
644 elif ps -weo 'stat comm vsz rss user uid pid ppid etime args' 2>/dev/null | \
645         egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[ID]+ +P[PID]+ +[ELAPSD]+ +[RGSCOMDNA]+"] >/dev/null
646 then
647         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procetime,procprog,&pos]"
648         ac_cv_ps_command="$PATH_TO_PS -weo 'stat uid pid ppid vsz rss pcpu etime comm args'"
649         ac_cv_ps_format="%s %d %d %d %d %d %f %s %s %n"
650         ac_cv_ps_cols=10
651         AC_MSG_RESULT([$ac_cv_ps_command])
653 dnl FreeBSD
654 elif ps waxco 'state command vsz rss uid user pid ppid' 2>/dev/null | \
655         egrep -i ["^STAT +COMMAND +VSZ +RSS +UID +USER +PID +PPID"] >/dev/null
656 then
657         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
658         ac_cv_ps_command="$PATH_TO_PS waxco 'state uid pid ppid vsz rss pcpu command command'"
659         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
660         ac_cv_ps_cols=9
661         AC_MSG_RESULT([$ac_cv_ps_command])
663 dnl BSD-like mode in RH 6.1
664 elif ps waxno 'state comm vsz rss uid user pid ppid args' 2>/dev/null | \
665         egrep -i ["^S +COMMAND +VSZ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
666 then
667         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
668         ac_cv_ps_command="$PATH_TO_PS waxno 'state uid pid ppid vsz rss pcpu comm args'"
669         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
670         ac_cv_ps_cols=9
671         AC_MSG_RESULT([$ac_cv_ps_command])
673 dnl SunOS 4.1.3:
674 dnl  F  UID  PID  PPID  CP  PRI  NI  SZ  RSS  WCHAN  STAT  TT  TIME  COMMAND
675 dnl Need the head -1 otherwise test will work because arguments are found
676 elif ps -laxnwww 2>/dev/null | head -1 | \
677         egrep -i ["^ *F(LAGS)? +UID +PID +PPID +CP +PRI +NI +(SZ)|(VSZ)|(SIZE) +RSS +WCHAN +STAT? +TTY? +TIME +COMMAND"] >/dev/null
678 then
679         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]"
680         ac_cv_ps_command="$PATH_TO_PS -laxnwww"
681         ac_cv_ps_format="%*s %d %d %d %*s %*s %*s %d %d %*s %s %*s %*s %n%s"
682         ac_cv_ps_cols=9
683         AC_MSG_RESULT([$ac_cv_ps_command])
685 dnl Debian Linux / procps v1.2.9:
686 dnl  FLAGS   UID   PID  PPID PRI  NI   SIZE   RSS WCHAN       STA TTY TIME COMMAND
687 dnl    100     0     1     0   0   0    776    76  c0131c8c   S  ffff  0:11 init [2]
688 dnl
689 elif ps laxnwww 2>/dev/null | \
690         egrep -i ["^ *F(LAGS)? +UID +PID +PPID +PRI +NI +(VSZ)|(SIZE) +RSS +WCHAN +STAT? TTY +TIME +COMMAND"] >/dev/null
691 then
692         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,procstat,&procvsz,&procrss,&pos,procprog]"
693         ac_cv_ps_command="$PATH_TO_PS laxnwww"
694         ac_cv_ps_format="%*s %d %d %d %*s %*s %d %d %*s %s %*s %*s %n%s"
695         ac_cv_ps_cols=9
696         AC_MSG_RESULT([$ac_cv_ps_command])
698 dnl OpenBSD (needs to come early because -exo appears to work, but does not give all procs)
699 elif ps -axo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
700         egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[PID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null
701 then
702         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
703         ac_cv_ps_command="$PATH_TO_PS -axo 'stat uid pid ppid vsz rss pcpu comm args'"
704         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
705         ac_cv_ps_cols=9
706         AC_MSG_RESULT([$ac_cv_ps_command])
708 dnl Tru64 - needs %*[ +<>] in PS_FORMAT.
709 dnl Has /usr/bin/ps and /sbin/ps - force sbin version
710 dnl Can't use vsize and rssize because comes back with text (eg, 1.5M instead
711 dnl of 1500). Will need big changes to check_procs to support
712 elif /sbin/ps -eo 'stat uid pid ppid pcpu etime comm args' 2>/dev/null | \
713         egrep -i ["^ *S +[UID]+ +[PID]+ +[PID]+ +[%CPU]+ +[ELAPSD]+ +[COMMAND]+ +[COMMAND]+"] > /dev/null
714 then
715         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procpcpu,procetime,procprog,&pos]"
716         ac_cv_ps_command="/sbin/ps -eo 'stat uid pid ppid pcpu etime comm args'"
717         ac_cv_ps_format=["%s%*[ +<>] %d %d %d %f %s %s %n"]
718         ac_cv_ps_cols=8
719         AC_MSG_RESULT([$ac_cv_ps_command])
721 elif ps -eo 's comm vsz rss user uid pid ppid args' 2>/dev/null | \
722         egrep -i ["^S[TAUES]* +C[OMDNA]+ +[VSIZE]+ +U[SER]+ +U[ID]+ +P[PID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null
723 then
724         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
725         ac_cv_ps_command="$PATH_TO_PS -eo 's uid pid ppid vsz rss pcpu comm args'"
726         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
727         ac_cv_ps_cols=9
728         AC_MSG_RESULT([$ac_cv_ps_command])
730 dnl AIX 4.3.3 and 5.1 do not have an rss field
731 elif ps -eo 'stat uid pid ppid vsz pcpu comm args' 2>/dev/null | \
732         egrep -i ["^ *S[TAUES]* +UID +PID +PPID +VSZ +%CPU +COMMAND +COMMAND"] >/dev/null
733 then
734         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procpcpu,procprog,&pos]"
735         ac_cv_ps_command="$PATH_TO_PS -eo 'stat uid pid ppid vsz pcpu comm args'"
736         ac_cv_ps_format="%s %d %d %d %d %f %s %n"
737         ac_cv_ps_cols=8
738         AC_MSG_RESULT([$ac_cv_ps_command - with no RSS])
740 dnl Solaris 2.6
741 elif ps -Ao 's comm vsz rss uid user pid ppid args' 2>/dev/null | \
742         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
743 then
744         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
745         ac_cv_ps_command="$PATH_TO_PS -Ao 's uid pid ppid vsz rss pcpu comm args'"
746         # There must be no space between the %s and %n due to a wierd problem in sscanf where
747         # it will return %n as longer than the line length
748         ac_cv_ps_format="%s %d %d %d %d %d %f %s%n"
749         ac_cv_ps_cols=9
750         AC_MSG_RESULT([$ac_cv_ps_command])
752 elif ps -Ao 'status comm vsz rss uid user pid ppid args' 2>/dev/null | \
753         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
754 then
755         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
756         ac_cv_ps_command="$PATH_TO_PS -Ao 'status uid pid ppid vsz rss pcpu comm args'"
757         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
758         ac_cv_ps_cols=9
759         AC_MSG_RESULT([$ac_cv_ps_command])
761 elif ps -Ao 'state comm vsz rss uid user pid ppid args' 2>/dev/null | \
762         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
763 then
764         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
765         ac_cv_ps_command="$PATH_TO_PS -Ao 'state uid pid ppid vsz rss pcpu comm args'"
766         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
767         ac_cv_ps_cols=9
768         AC_MSG_RESULT([$ac_cv_ps_command])
770 dnl wonder who takes state instead of stat
771 elif ps -ao 'state command vsz rss user pid ppid args' 2>/dev/null | \
772         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
773 then
774         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
775         ac_cv_ps_command="$PATH_TO_PS -ao 'state uid pid ppid vsz rss pcpu command args'"
776         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
777         ac_cv_ps_cols=8
778         AC_MSG_RESULT([$ac_cv_ps_command])
780 dnl IRIX 53
781 elif ps -el 2>/dev/null | \
782         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
783 then
784         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&pos,procprog]"
785         ac_cv_ps_command="$PATH_TO_PS -el (IRIX 53)"
786         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %d %d %*s %*s %*s %n%s"
787         ac_cv_ps_cols=8
788         AC_MSG_RESULT([$ac_cv_ps_command])
790 dnl IRIX 63
791 elif ps -el 2>/dev/null | \
792         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +ADDR +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
793 then
794         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
795         ac_cv_ps_command="$PATH_TO_PS -el (IRIX 63)"
796         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
797         ac_cv_ps_cols=6
798         AC_MSG_RESULT([$ac_cv_ps_command])
800 dnl AIX 4.1:
801 dnl     F S      UID   PID  PPID   C PRI NI ADDR  SZ  RSS   WCHAN    TTY  TIME CMD
802 dnl    303 A        0     0     0 120  16 -- 1c07  20   24              -  0:45 swapper
803 elif ps -el 2>/dev/null | \
804         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +ADDR +SZ +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
805 then
806         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
807         ac_cv_ps_command="$PATH_TO_PS -el (AIX 4.1 and HP-UX)"
808         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
809         ac_cv_ps_cols=6
810         AC_MSG_RESULT([$ac_cv_ps_command])
812 dnl AIX?
813 elif ps glaxen 2>/dev/null | \
814         egrep -i ["^ *F +UID +PID +PPID +PRI +NI +VSZ +RSS +WCHAN +STAT +TTY +TIME +COMMAND"] >/dev/null
815 then
816         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]"
817         ac_cv_ps_command="$PATH_TO_PS glaxen"
818         ac_cv_ps_format="%*s %d %d %d %*s %*s %d %d %*s %s %*s %*s %n%s"
819         ac_cv_ps_cols=8
820         AC_MSG_RESULT([$ac_cv_ps_command])
822 dnl MacOSX / Darwin
823 dnl TODO: MacOSX has commands with spaces which will cause problems to PS_FORMAT
824 dnl Some truncation will happen in UCOMM column
825 dnl STAT      VSZ    RSS   UID  PPID %CPU UCOMM            COMMAND
826 dnl Ss      52756  22496   501     1   6.9 Window Manager   /System/Library/CoreServices/WindowServer -daemon
827 elif ps wwaxo 'state vsz rss uid pid ppid pcpu ucomm command' 2>/dev/null | \
828         egrep -i ["^STAT +VSZ +RSS +UID +PPID +%CPU +UCOMM +COMMAND"] >/dev/null
829 then
830         ac_cv_ps_command="$PATH_TO_PS wwaxo 'state vsz rss uid pid ppid pcpu ucomm command'"
831         ac_cv_ps_varlist="[procstat,&procvsz,&procrss,&procuid,&procpid,&procppid,&procpcpu,procprog,&pos]"
832         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
833         ac_cv_ps_cols=8
834         AC_MSG_RESULT([$ac_cv_ps_command])
836 dnl UnixWare
837 elif ps -Al 2>/dev/null | \
838         egrep -i ["^ *F +S +UID +PID +PPID +CLS +PRI +NI +C +ADDR +SZ +WCHAN +TTY +TIME +COMD"] >/dev/null
839 then
840         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
841         ac_cv_ps_command="$PATH_TO_PS -Al"
842         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
843         ac_cv_ps_cols=8
844         AC_MSG_RESULT([$ac_cv_ps_command])
846 else
847         AC_MSG_WARN([unable to find usable ps syntax - check_procs and check_nagios will not be compiled])
848 fi
850 if test -n "$ac_cv_ps_varlist" ; then
851         AC_DEFINE_UNQUOTED(PS_VARLIST,$ac_cv_ps_varlist,
852                 [Variable list for sscanf of 'ps' output])
853         AC_DEFINE_UNQUOTED(PS_COMMAND,"$ac_cv_ps_command",
854                 [Verbatim command to execute for ps in check_procs])
855         AC_DEFINE_UNQUOTED(PS_FORMAT,"$ac_cv_ps_format",
856                 [Format string for scanning ps output in check_procs])
857         AC_DEFINE_UNQUOTED(PS_COLS,$ac_cv_ps_cols,
858                 [Number of columns in ps command])
859         EXTRAS="$EXTRAS check_procs check_nagios"
860         if echo "$ac_cv_ps_varlist" | grep "procetime" >/dev/null; then
861                 AC_DEFINE(PS_USES_PROCETIME,"yes",
862                           [Whether the ps utility uses the "procetime" field])
863         fi
864 fi
866 AC_PATH_PROG(PATH_TO_PING,ping)
867 AC_PATH_PROG(PATH_TO_PING6,ping6)
869 AC_ARG_WITH(ping_command,
870         ACX_HELP_STRING([--with-ping-command=SYNTAX],
871                 [sets syntax for ICMP ping]),
872         with_ping_command=$withval,)
874 AC_MSG_CHECKING(for ICMP ping syntax)
875 ac_cv_ping_packets_first=no
876 ac_cv_ping_has_timeout=no
877 if test -n "$with_ping_command"
878 then
879         AC_MSG_RESULT([(command-line) $with_ping_command])
880         if test -n "$ac_cv_ping_packets_first"
881         then
882                 ac_cv_ping_packets_first=yes
883                 ac_cv_ping_has_timeout=yes
884         fi
886 elif [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
887         $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
888         egrep -i "^round-trip|^rtt" >/dev/null
889 then
890         with_ping_command="$PATH_TO_PING -n -U -c %d %s"
891         ac_cv_ping_packets_first=yes
892         AC_MSG_RESULT([$with_ping_command])
894 elif $PATH_TO_PING -n -U -w 10 -c 1 127.0.0.1 2>/dev/null | \
895         egrep -i "^round-trip|^rtt" >/dev/null
896 then
897         with_ping_command="$PATH_TO_PING -n -U -w %d -c %d %s"
898         ac_cv_ping_packets_first=yes
899   ac_cv_ping_has_timeout=yes
900         AC_MSG_RESULT([$with_ping_command])
902 elif $PATH_TO_PING -n -U -c 1 127.0.0.1 2>/dev/null | \
903         egrep -i "^round-trip|^rtt" >/dev/null
904 then
905         with_ping_command="$PATH_TO_PING -n -U -c %d %s"
906         ac_cv_ping_packets_first=yes
907         AC_MSG_RESULT([$with_ping_command])
909 elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \
910         egrep -i "^round-trip|^rtt" >/dev/null
911 then
912         with_ping_command="$PATH_TO_PING -n -c %d %s"
913         ac_cv_ping_packets_first=yes
914         AC_MSG_RESULT([$with_ping_command])
916 elif $PATH_TO_PING -n 127.0.0.1 -c 1 2>/dev/null | \
917         egrep -i "^round-trip|^rtt" >/dev/null
918 then
919         with_ping_command="$PATH_TO_PING -n %s -c %d"
920         AC_MSG_RESULT([$with_ping_command])
922 elif $PATH_TO_PING 127.0.0.1 -n 1 2>/dev/null | \
923         egrep -i "^round-trip|^rtt" >/dev/null
924 then
925         with_ping_command="$PATH_TO_PING %s -n %d"
926         AC_MSG_RESULT([$with_ping_command])
928 elif $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
929         egrep -i "^round-trip|^rtt" >/dev/null
930 then
931         with_ping_command="$PATH_TO_PING -n -s %s 56 %d"
932         AC_MSG_RESULT([$with_ping_command])
934 elif $PATH_TO_PING -n -h 127.0.0.1 -s 56 -c 1 2>/dev/null | \
935         egrep -i "^round-trip|^rtt" >/dev/null
936 then
937         with_ping_command="$PATH_TO_PING -n -h %s -s 56 -c %d"
938         AC_MSG_RESULT([$with_ping_command])
940 elif $PATH_TO_PING -n -s 56 -c 1 127.0.0.1 2>/dev/null | \
941         egrep -i "^round-trip|^rtt" >/dev/null
942 then
943         with_ping_command="$PATH_TO_PING -n -s 56 -c %d %s"
944         ac_cv_ping_packets_first=yes
945         AC_MSG_RESULT([$with_ping_command])
947 elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \
948         egrep -i "^round-trip|^rtt" >/dev/null
949 then
950         with_ping_command="$PATH_TO_PING -n -c %d %s"
951         ac_cv_ping_packets_first=yes
952         AC_MSG_RESULT([$with_ping_command])
954 else
955         AC_MSG_WARN([unable to find usable ping syntax])
956 fi
958 AC_DEFINE_UNQUOTED(PING_COMMAND,"$with_ping_command",
959         [path and args for ICMP ping command])
961 if test "x$ac_cv_ping_packets_first" != "xno"
962 then
963         AC_DEFINE(PING_PACKETS_FIRST,1,
964                 [Define if packet count must precede host])
965 fi
967 if test "x$ac_cv_ping_has_timeout" != "xno"
968 then
969         AC_DEFINE(PING_HAS_TIMEOUT,1,
970                 [Define if ping has its own timeout option that should be set])
971 fi
973 AC_ARG_WITH(ping6_command,
974         ACX_HELP_STRING([--with-ping6-command=SYNTAX],
975                 [sets syntax for ICMPv6 ping]),
976         with_ping6_command=$withval,)
978 if test x"$with_ipv6" != xno ; then
979 AC_MSG_CHECKING(for ICMPv6 ping syntax)
980 ac_cv_ping6_packets_first=no
981 if test -n "$with_ping6_command"
982 then
983         AC_MSG_RESULT([(command-line) $with_ping6_command])
984         if test -n "$ac_cv_ping6_packets_first"
985         then
986                 ac_cv_ping6_packets_first=yes
987         fi
989 elif test "x$PATH_TO_PING6" != "x"; then
990         if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
991                 $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \
992                 egrep -i "^round-trip|^rtt" >/dev/null
993         then
994                 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s"
995                 ac_cv_ping6_packets_first=yes
996                 AC_MSG_RESULT([$with_ping6_command])
998         elif $PATH_TO_PING6 -n -U -w 10 -c 1 ::1 2>/dev/null | \
999                 egrep -i "^round-trip|^rtt" >/dev/null
1000         then
1001                 with_ping6_command="$PATH_TO_PING6 -n -U -w %d -c %d %s"
1002                 ac_cv_ping6_packets_first=yes
1003                 ac_cv_ping_has_timeout=yes
1004                 AC_MSG_RESULT([$with_ping6_command])
1006         elif $PATH_TO_PING6 -n -U -c 1 ::1 2>/dev/null | \
1007                 egrep -i "^round-trip|^rtt" >/dev/null
1008         then
1009                 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s"
1010                 ac_cv_ping6_packets_first=yes
1011                 AC_MSG_RESULT([$with_ping6_command])
1013         elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \
1014                 egrep -i "^round-trip|^rtt" >/dev/null
1015         then
1016                 with_ping6_command="$PATH_TO_PING6 -n -c %d %s"
1017                 ac_cv_ping6_packets_first=yes
1018                 AC_MSG_RESULT([$with_ping6_command])
1020         elif $PATH_TO_PING6 -n ::1 -c 1 2>/dev/null | \
1021                 egrep -i "^round-trip|^rtt" >/dev/null
1022         then
1023                 with_ping6_command="$PATH_TO_PING6 -n %s -c %d"
1024                 AC_MSG_RESULT([$with_ping6_command])
1026         elif $PATH_TO_PING6 ::1 -n 1 2>/dev/null | \
1027                 egrep -i "^round-trip|^rtt" >/dev/null
1028         then
1029                 with_ping6_command="$PATH_TO_PING6 %s -n %d"
1030                 AC_MSG_RESULT([$with_ping6_command])
1032         elif $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \
1033                 egrep -i "^round-trip|^rtt" >/dev/null
1034         then
1035                 with_ping6_command="$PATH_TO_PING6 -n -s %s 56 %d"
1036                 AC_MSG_RESULT([$with_ping6_command])
1038         elif $PATH_TO_PING6 -n -h ::1 -s 56 -c 1 2>/dev/null | \
1039                 egrep -i "^round-trip|^rtt" >/dev/null
1040         then
1041                 with_ping6_command="$PATH_TO_PING6 -n -h %s -s 56 -c %d"
1042                 AC_MSG_RESULT([$with_ping6_command])
1044         elif $PATH_TO_PING6 -n -s 56 -c 1 ::1 2>/dev/null | \
1045                 egrep -i "^round-trip|^rtt" >/dev/null
1046         then
1047                 with_ping6_command="$PATH_TO_PING6 -n -s 56 -c %d %s"
1048                 ac_cv_ping6_packets_first=yes
1049                 AC_MSG_RESULT([$with_ping_command])
1051         elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \
1052                 egrep -i "^round-trip|^rtt" >/dev/null
1053         then
1054                 with_ping6_command="$PATH_TO_PING6 -n -c %d %s"
1055                 ac_cv_ping6_packets_first=yes
1056                 AC_MSG_RESULT([$with_ping6_command])
1058         fi
1060 elif test "x$PATH_TO_PING" != "x"; then
1061         if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
1062                 $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \
1063                 egrep -i "^round-trip|^rtt" >/dev/null
1064         then
1065                 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s"
1066                 ac_cv_ping6_packets_first=yes
1067                 AC_MSG_RESULT([$with_ping6_command])
1069         elif $PATH_TO_PING -A inet6 -n -U -c 1 ::1 2>/dev/null | \
1070                 egrep -i "^round-trip|^rtt" >/dev/null
1071         then
1072                 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s"
1073                 ac_cv_ping6_packets_first=yes
1074                 AC_MSG_RESULT([$with_ping6_command])
1076         elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \
1077                 egrep -i "^round-trip|^rtt" >/dev/null
1078         then
1079                 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s"
1080                 ac_cv_ping6_packets_first=yes
1081                 AC_MSG_RESULT([$with_ping6_command])
1083         elif $PATH_TO_PING -A inet6 -n ::1 -c 1 2>/dev/null | \
1084                 egrep -i "^round-trip|^rtt" >/dev/null
1085         then
1086                 with_ping6_command="$PATH_TO_PING -A inet6 -n %s -c %d"
1087                 AC_MSG_RESULT([$with_ping6_command])
1089         elif $PATH_TO_PING -A inet6 ::1 -n 1 2>/dev/null | \
1090                 egrep -i "^round-trip|^rtt" >/dev/null
1091         then
1092                 with_ping6_command="$PATH_TO_PING -A inet6 %s -n %d"
1093                 AC_MSG_RESULT([$with_ping6_command])
1095         elif $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \
1096                 egrep -i "^round-trip|^rtt" >/dev/null
1097         then
1098                 with_ping6_command="$PATH_TO_PING -A inet6 -n -s %s 56 %d"
1099                 AC_MSG_RESULT([$with_ping6_command])
1101         elif $PATH_TO_PING -A inet6 -n -h ::1 -s 56 -c 1 2>/dev/null | \
1102                 egrep -i "^round-trip|^rtt" >/dev/null
1103         then
1104                 with_ping6_command="$PATH_TO_PING -A inet6 -n -h %s -s 56 -c %d"
1105                 AC_MSG_RESULT([$with_ping6_command])
1107         elif $PATH_TO_PING -A inet6 -n -s 56 -c 1 ::1 2>/dev/null | \
1108                 egrep -i "^round-trip|^rtt" >/dev/null
1109         then
1110                 with_ping6_command="$PATH_TO_PING -A inet6 -n -s 56 -c %d %s"
1111                 ac_cv_ping6_packets_first=yes
1112                 AC_MSG_RESULT([$with_ping_command])
1114         elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \
1115                 egrep -i "^round-trip|^rtt" >/dev/null
1116         then
1117                 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s"
1118                 ac_cv_ping6_packets_first=yes
1119                 AC_MSG_RESULT([$with_ping6_command])
1121         fi
1123 fi
1125 if test "x$with_ping6_command" != "x"; then
1126         AC_DEFINE_UNQUOTED(PING6_COMMAND,"$with_ping6_command",
1127                 [path and args for ICMPv6 ping command])
1128 else
1129         AC_MSG_RESULT([none])
1130 fi
1132 if test "x$ac_cv_ping6_packets_first" != "xno"; then
1133         AC_DEFINE(PING6_PACKETS_FIRST,1,
1134                 [Define if packet count must precede host])
1135 fi
1136 fi
1139 AC_ARG_WITH(nslookup_command,
1140             ACX_HELP_STRING([--with-nslookup-command=PATH],
1141                             [sets path to nslookup executable]),
1142             ac_cv_nslookup_command=$withval)
1143 if test -n "$ac_cv_nslookup_command"; then
1144         AC_MSG_NOTICE([Using specific nslookup at $ac_cv_nslookup_command])
1145 else
1146         AC_PATH_PROG(PATH_TO_NSLOOKUP,nslookup)
1147         if test -n "$PATH_TO_NSLOOKUP"
1148         then
1149                 AC_MSG_CHECKING(for nslookup syntax)
1150                 if $PATH_TO_NSLOOKUP -sil 127.0.0.1 2>&1 | grep ["Invalid option: sil"] >/dev/null
1151                 then
1152                         ac_cv_nslookup_command="$PATH_TO_NSLOOKUP"
1153                         AC_MSG_RESULT([$ac_cv_nslookup_command])
1155                 else
1156                         ac_cv_nslookup_command="$PATH_TO_NSLOOKUP -sil"
1157                         AC_MSG_RESULT([$ac_cv_nslookup_command])
1159                 fi
1160         else
1161                 AC_MSG_WARN([nslookup command not found])
1162         fi
1163 fi
1165 if test -n "$ac_cv_nslookup_command"; then
1166         EXTRAS="$EXTRAS check_dns"
1167         AC_DEFINE_UNQUOTED(NSLOOKUP_COMMAND,"$ac_cv_nslookup_command", [path and args for nslookup])
1168 fi
1170 AC_MSG_CHECKING([for number of cpus])
1171 AC_TRY_COMPILE([#include <unistd.h>],
1172         [sysconf(_SC_NPROCESSORS_CONF) > 0;],
1173         AC_DEFINE(HAVE_SYSCONF__SC_NPROCESSORS_CONF,1,[Define if sysconf returns number of cpus])
1174         AC_MSG_RESULT([sysconf(_SC_NPROCESSORS_CONF)]),
1175         AC_MSG_RESULT([cannot calculate])
1176         )
1178 AC_PATH_PROG(PATH_TO_UPTIME,uptime)
1179 AC_ARG_WITH(uptime_command,
1180             ACX_HELP_STRING([--with-uptime-command=PATH],
1181                             [sets path to uptime]), PATH_TO_UPTIME=$withval)
1182 AC_DEFINE_UNQUOTED(PATH_TO_UPTIME,"$PATH_TO_UPTIME",[path to uptime binary])
1184 AC_PATH_PROG(PATH_TO_RPCINFO,rpcinfo)
1185 AC_ARG_WITH(rpcinfo_command,
1186             ACX_HELP_STRING([--with-rpcinfo-command=PATH],
1187                             [sets path to rpcinfo]), PATH_TO_RPCINFO=$withval)
1188 AC_DEFINE_UNQUOTED(PATH_TO_RPCINFO,"$PATH_TO_RPCINFO",[path to rpcinfo binary])
1190 AC_PATH_PROG(PATH_TO_LMSTAT,lmstat)
1191 if test -x "$PATH_TO_LMSTAT"
1192 then
1193         AC_DEFINE_UNQUOTED(PATH_TO_LMSTAT,"$PATH_TO_LMSTAT",[path to lmstat])
1194 else
1195         AC_MSG_WARN([Get lmstat from Globetrotter Software to monitor flexlm licenses])
1196 fi
1198 AC_PATH_PROG(PATH_TO_SMBCLIENT,smbclient)
1199 AC_ARG_WITH(smbclient_command,
1200             ACX_HELP_STRING([--with-smbclient-command=PATH],
1201                             [sets path to smbclient]),
1202             PATH_TO_SMBCLIENT=$withval)
1203 if test -n "$PATH_TO_SMBCLIENT"
1204 then
1205         AC_DEFINE_UNQUOTED(PATH_TO_SMBCLIENT,"$PATH_TO_SMBCLIENT",[path to smbclient binary])
1206 else
1207         AC_MSG_WARN([Get smbclient from Samba.org to monitor SMB shares])
1208 fi
1211 AC_PATH_PROG(PATH_TO_WHO,who)
1213 if [$PATH_TO_WHO -q 2>/dev/null | egrep -i "^# users=[0-9]+$" >/dev/null]
1214 then
1215         ac_cv_path_to_who="$PATH_TO_WHO -q"
1216 else
1217         ac_cv_path_to_who="$PATH_TO_WHO"
1218 fi
1220 AC_DEFINE_UNQUOTED(WHO_COMMAND,"$ac_cv_path_to_who",
1221         [path and arguments for invoking 'who'])
1223 AC_PATH_PROG(PATH_TO_SNMPGET,snmpget)
1224 AC_ARG_WITH(snmpget_command,
1225             ACX_HELP_STRING([--with-snmpget-command=PATH],
1226                             [Path to snmpget command]),
1227             PATH_TO_SNMPGET=$withval)
1228 if test -n "$PATH_TO_SNMPGET"
1229 then
1230         AC_DEFINE_UNQUOTED(PATH_TO_SNMPGET,"$PATH_TO_SNMPGET",[path to snmpget binary])
1231         EXTRAS="$EXTRAS check_hpjd check_snmp"
1232 else
1233         AC_MSG_WARN([Get snmpget from http://net-snmp.sourceforge.net to make check_hpjd and check_snmp plugins])
1234 fi
1236 AC_PATH_PROG(PATH_TO_SNMPGETNEXT,snmpgetnext)
1237 AC_ARG_WITH(snmpgetnext_command,
1238             ACX_HELP_STRING([--with-snmpgetnext-command=PATH],
1239                             [Path to snmpgetnext command]),
1240             PATH_TO_SNMPGETNEXT=$withval)
1241 if test -n "$PATH_TO_SNMPGETNEXT"
1242 then
1243         AC_DEFINE_UNQUOTED(PATH_TO_SNMPGETNEXT,"$PATH_TO_SNMPGETNEXT",[path to snmpgetnext binary])
1244 fi
1246 if ( $PERL -M"Net::SNMP 3.6" -e 'exit' 2>/dev/null  )
1247 then
1248         AC_MSG_CHECKING(for Net::SNMP perl module)
1249         AC_MSG_RESULT([found])
1250 else
1251         AC_MSG_WARN([Tried $PERL - install Net::SNMP perl module if you want to use the perl snmp plugins])
1252 fi
1254 AC_PATH_PROG(PATH_TO_QUAKESTAT,quakestat)
1255 AC_PATH_PROG(PATH_TO_QSTAT,qstat)
1256 AC_ARG_WITH(qstat_command,
1257             ACX_HELP_STRING([--with-qstat-command=PATH],
1258                             [Path to qstat command]), PATH_TO_QSTAT=$withval)
1260 if test -x "$PATH_TO_QUAKESTAT"
1261 then
1262         ac_cv_path_to_qstat="$PATH_TO_QUAKESTAT"
1263         EXTRAS="$EXTRAS check_game"
1265 elif test -n "$PATH_TO_QSTAT"
1266 then
1267         ac_cv_path_to_qstat="$PATH_TO_QSTAT"
1268         EXTRAS="$EXTRAS check_game"
1269 else
1270         AC_MSG_WARN([Get qstat from http://www.activesw.com/people/steve/qstat.html in order to make check_game plugin])
1271 fi
1273 if test $ac_cv_path_to_qstat
1274 then
1275         AC_DEFINE_UNQUOTED(PATH_TO_QSTAT,"$ac_cv_path_to_qstat",
1276                 [path to qstat/quakestat])
1277 fi
1279 AC_PATH_PROG(PATH_TO_FPING,fping)
1280 AC_ARG_WITH(fping_command,
1281             ACX_HELP_STRING([--with-fping-command=PATH],
1282                             [Path to fping command]), PATH_TO_FPING=$withval)
1283 if test -n "$PATH_TO_FPING"
1284 then
1285         AC_DEFINE_UNQUOTED(PATH_TO_FPING,"$PATH_TO_FPING",[path to fping])
1286         EXTRAS="$EXTRAS check_fping"
1287 else
1288         AC_MSG_WARN([Get fping from http://www.fping.com in order to make check_fping plugin])
1289 fi
1291 AC_PATH_PROG(PATH_TO_SSH,ssh)
1292 AC_ARG_WITH(ssh_command,
1293             ACX_HELP_STRING([--with-ssh-command=PATH],
1294                             [sets path for ssh]), PATH_TO_SSH=$withval)
1295 if test -n "$PATH_TO_SSH"
1296 then
1297         AC_DEFINE_UNQUOTED(SSH_COMMAND,"$PATH_TO_SSH",[path to ssh binary])
1298         EXTRAS="$EXTRAS check_by_ssh"
1299 else
1300         AC_MSG_WARN([Get ssh in order to make check_by_ssh plugin])
1301 fi
1304 AC_PATH_PROG(PATH_TO_MAILQ,mailq)
1305 AC_ARG_WITH(mailq_command,
1306             ACX_HELP_STRING([--with-mailq-command=PATH],
1307                             [sets path to mailq]), PATH_TO_MAILQ=$withval)
1308 if test -n "$PATH_TO_MAILQ"
1309 then
1310         AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_MAILQ",[path to mailq])
1311 else
1312         AC_MSG_WARN([Could not find mailq or eqivalent])
1313 fi
1315 AC_PATH_PROG(PATH_TO_QMAIL_QSTAT,qmail-qstat)
1316 if test -x "$PATH_TO_QMAIL_QSTAT"
1317 then
1318         AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_QMAIL_QSTAT",[path to qmail-qstat])
1319 else
1320         AC_MSG_WARN([Could not find qmail-qstat or eqivalent])
1321 fi
1323 dnl SWAP info required is amount allocated/available and amount free
1324 dnl The plugin works through all the swap devices and adds up the total swap
1325 dnl available.
1326 AC_PATH_PROG(PATH_TO_SWAP,swap)
1327 if (test -n "$PATH_TO_SWAP")
1328 then
1329 AC_MSG_CHECKING([for $PATH_TO_SWAP format])
1330 if [$PATH_TO_SWAP -l 2>&1 >/dev/null]
1331 then
1332         ac_cv_have_swap=yes
1333         ac_cv_swap_command="$PATH_TO_SWAP -l"
1334         if [$PATH_TO_SWAP -l 2>/dev/null | \
1335                 egrep -i "^lswap +path +pri +swaplo +blocks +free +maxswap" \
1336                 >/dev/null]
1337         then
1338                 ac_cv_swap_format=[" %*d %*s %*d,%*d %*d %*d %f %f"]
1339                 ac_cv_swap_conv=2048
1340                 AC_MSG_RESULT([using IRIX format swap])
1342         elif [$PATH_TO_SWAP -l 2>/dev/null | egrep -i "^path +dev +swaplo +blocks +free" >/dev/null]
1343         then
1344                 ac_cv_swap_format=["%*s %*[0-9,-] %*d %f %f"]
1345                 ac_cv_swap_conv=2048
1346                 AC_MSG_RESULT([using Unixware format swap])
1347         else
1348                 dnl if we don't know what format swap's output is
1349                 dnl we might as well pretend we didn't see it
1350                 ac_cv_have_swap=""
1351                 ac_cv_swap_command=""
1352         fi
1353 fi
1354 dnl end if for PATH_TO_SWAP
1355 fi
1357 AC_PATH_PROG(PATH_TO_SWAPINFO,swapinfo)
1358 if (test -n "$PATH_TO_SWAPINFO")
1359 then
1360 AC_MSG_CHECKING([for $PATH_TO_SWAPINFO format])
1361 if [$PATH_TO_SWAPINFO -k 2>&1 | egrep -i "^Device" >/dev/null]
1362 then
1363         ac_cv_have_swap=yes
1364         ac_cv_swap_command="$PATH_TO_SWAPINFO -k"
1366         if [$PATH_TO_SWAPINFO -k 2>/dev/null | egrep -i "^Device +1K-blocks +Used +Avail" >/dev/null]
1367         then
1368                 ac_cv_swap_format=["%*s %f %*d %f"]
1369                 ac_cv_swap_conv=1024
1370                 AC_MSG_RESULT([using FreeBSD format swapinfo])
1371         fi
1373 elif [$PATH_TO_SWAPINFO -dfM 2>/dev/null | egrep -i "^TYPE +AVAIL +USED +FREE" >/dev/null]
1374 then
1375         ac_cv_have_swap=yes
1376         ac_cv_swap_command="$PATH_TO_SWAPINFO -dfM"
1377         ac_cv_swap_format=["%*s %f %*d %f"]
1378         ac_cv_swap_conv=1024
1379         AC_MSG_RESULT([using HP-UX format swapinfo])
1380 fi
1381 dnl end if for PATH_TO_SWAPINFO
1382 fi
1384 AC_PATH_PROG(PATH_TO_LSPS,lsps)
1385 if (test -n "$PATH_TO_LSPS")
1386 then
1387 AC_MSG_CHECKING([for $PATH_TO_LSPS format])
1388 if [$PATH_TO_LSPS -a 2>/dev/null | egrep -i "^Page Space" > /dev/null]
1389 then
1390         ac_cv_have_swap=yes
1391         ac_cv_swap_command="$PATH_TO_LSPS -a"
1392         ac_cv_swap_format=["%*s %*s %*s %f%*s %f %*s"]
1393         ac_cv_swap_conv=1
1394         AC_MSG_RESULT([using AIX lsps])
1395 fi
1396 dnl end if for PATH_TO_SWAPINFO
1397 fi
1399 dnl
1400 dnl test for swapctl system call, both the 2-arg and 3-arg variants
1401 dnl fwict, the 2-arg is an SVR4 standard, whereas the 3-arg is shared
1402 dnl in the various BSD's
1403 dnl
1405 AC_CHECK_HEADERS([sys/stat.h sys/param.h])
1406 AC_CHECK_HEADERS([sys/swap.h], [], [], [
1407 #ifdef HAVE_SYS_PARAM_H
1408 #include <sys/param.h>
1409 #endif
1410 ])
1411 AC_CHECK_DECLS([swapctl],,,[
1412                #include <unistd.h>
1413                #include <sys/types.h>
1414                #include <sys/param.h>
1415                #include <sys/stat.h>
1416                #include <sys/swap.h>
1417                ])
1418 AC_CHECK_TYPES([swaptbl_t, swapent_t],,,[
1419                #include <sys/types.h>
1420                #include <sys/param.h>
1421                #include <sys/stat.h>
1422                #include <sys/swap.h>
1423                ])
1424 AC_CHECK_MEMBERS([struct swapent.se_nblks],,,[
1425                #include <unistd.h>
1426                #include <sys/types.h>
1427                #include <sys/param.h>
1428                #include <sys/stat.h>
1429                #include <sys/swap.h>
1430                ])
1432 if test "$ac_cv_have_decl_swapctl" = "yes";
1433 then
1434         EXTRAS="$EXTRAS check_swap"
1435         AC_MSG_CHECKING([for 2-arg (SVR4) swapctl])
1436         if test "$ac_cv_type_swaptbl_t" = "yes" -a \
1437                 "$ac_cv_type_swapent_t" = "yes";
1438         then
1439                 AC_MSG_RESULT([yes])
1440                 ac_cv_check_swap_swapctl_svr4="1";
1441                 AC_DEFINE([CHECK_SWAP_SWAPCTL_SVR4],1,
1442                           [Define if 2-argument SVR4 swapctl exists])
1443         else
1444                 AC_MSG_RESULT([no])
1445                 AC_MSG_CHECKING([for 3-arg (*BSD) swapctl])
1446                 if test "$ac_cv_member_struct_swapent_se_nblks" = "yes";
1447                 then
1448                         AC_MSG_RESULT([yes])
1449                         AC_DEFINE([CHECK_SWAP_SWAPCTL_BSD],1,
1450                                   [Define if 3-argument BSD swapctl exists])
1451                 else
1452                         AC_MSG_RESULT([no])
1453                 fi
1454         fi
1455         AC_MSG_CHECKING([for whether swapctl uses blocks or pages])
1456         if test "$ac_cv_check_swap_swapctl_svr4" = "1";
1457         then
1458                 dnl
1459                 dnl the SVR4 spec returns values in pages
1460                 dnl
1461                 AC_MSG_RESULT([page])
1462                 AC_CHECK_DECLS([sysconf])
1463                 AC_MSG_CHECKING([for system page size])
1464                 if test "$ac_cv_have_decl_sysconf" = "yes";
1465                 then
1466                         AC_MSG_RESULT([determined by sysconf(3)])
1467                         ac_cv_swap_conv="(1048576/sysconf(_SC_PAGESIZE))"
1468                 else
1469                         AC_MSG_WARN([don't know. guessing 4096k])
1470                         ac_cv_swap_conv=256
1471                 fi
1472         else
1473                 dnl
1474                 dnl the BSD spec returns values in blocks
1475                 dnl
1476                 AC_MSG_RESULT([blocks (assuming 512b)])
1477                 ac_cv_swap_conv=2048
1478         fi
1479         AC_DEFINE_UNQUOTED(SWAP_CONVERSION,$ac_cv_swap_conv,
1480                 [Conversion factor to MB])
1481 fi
1482 dnl
1483 dnl end tests for the swapctl system calls
1484 dnl
1487 if test "x$ac_cv_have_swap" != "x"
1488 then
1489         AC_DEFINE(HAVE_SWAP,1,[Define if swap/swapinfo command is found])
1490         EXTRAS="$EXTRAS check_swap"
1491 fi
1492 if test "x$ac_cv_swap_command" != "x"
1493 then
1494         AC_DEFINE_UNQUOTED(SWAP_COMMAND,"$ac_cv_swap_command",
1495                 [Path to swap/swapinfo binary, with any args])
1496         AC_DEFINE_UNQUOTED(SWAP_FORMAT,"$ac_cv_swap_format",
1497                 [Format string for parsing swap output])
1498         AC_DEFINE_UNQUOTED(SWAP_CONVERSION,$ac_cv_swap_conv,
1499                 [Conversion factor to MB])
1500 fi
1502 AC_ARG_WITH(proc-meminfo,
1503             ACX_HELP_STRING([--with-proc-meminfo=PATH],
1504                             [path to /proc/meminfo or equivalent]),
1505                             ac_cv_proc_meminfo=$withval)
1506 dnl dunno why this does not work below - use hack (kbd)
1507 dnl fine on linux, broken on solaris
1508 dnl if /bin/test -e "/proc/meminfo"
1509 AC_MSG_CHECKING([for /proc/meminfo])
1510 if test -n "$ac_cv_proc_meminfo"; then
1511         AC_MSG_RESULT([(command line) $ac_cv_proc_meminfo])
1512 elif [cat /proc/meminfo > /dev/null 2>&1]; then
1513         AC_MSG_RESULT([found /proc/meminfo])
1514         ac_cv_proc_meminfo="/proc/meminfo"
1515 else
1516         AC_MSG_RESULT([no])
1517 fi
1519 if test -n "$ac_cv_proc_meminfo"; then
1520         AC_DEFINE(HAVE_PROC_MEMINFO,1,[Define if we have /proc/meminfo])
1521         AC_DEFINE_UNQUOTED(PROC_MEMINFO,"$ac_cv_proc_meminfo",[path to /proc/meminfo if name changes])
1522         EXTRAS="$EXTRAS check_swap"
1523 fi
1525 AC_PATH_PROG(PATH_TO_DIG,dig)
1526 AC_ARG_WITH(dig_command,
1527             ACX_HELP_STRING([--with-dig-command=PATH],
1528                             [Path to dig command]), PATH_TO_DIG=$withval)
1529 if test -n "$PATH_TO_DIG"; then
1530         EXTRAS="$EXTRAS check_dig"
1531         AC_DEFINE_UNQUOTED(PATH_TO_DIG,"$PATH_TO_DIG",[Path to dig command, if present])
1532 fi
1534 AC_PATH_PROG(PATH_TO_APTGET,apt-get)
1535 AC_ARG_WITH(apt-get_command,
1536             ACX_HELP_STRING([--with-apt-get-command=PATH],
1537                             [Path to apt-get command]),
1538                             with_apt_get_command=$withval,
1539                             with_apt_get_command=$PATH_TO_APTGET)
1540 AC_DEFINE_UNQUOTED(PATH_TO_APTGET,"$PATH_TO_APTGET",[Path to apt-get command, if present])
1541 if test -n "$PATH_TO_APTGET" ; then
1542         EXTRAS="$EXTRAS check_apt"
1543 fi
1546 if test -f $srcdir/plugins/check_nt.c ; then
1547   EXTRAS="$EXTRAS check_nt"
1548 fi
1551 dnl used in check_dhcp
1552 AC_CHECK_HEADERS(sys/sockio.h)
1554 case $host in
1555         *bsd*)
1556                 AC_DEFINE(__bsd__,1,[bsd specific code in check_dhcp.c])
1557         ;;
1558         *linux*)
1559                 AC_DEFINE(__linux__,1,[linux specific code in check_dhcp.c])
1560         ;;
1561         *sun* | *solaris*)
1562                 AC_DEFINE(__sun__,1,[sun specific code in check_dhcp.c])
1563         ;;
1564         *hpux*)
1565                 AC_DEFINE(__hpux__,1,[hpux specific code in check_dhcp.c])
1566         ;;
1567 esac
1569 AC_SUBST(EXTRAS)
1570 AC_SUBST(EXTRAS_ROOT)
1571 AC_SUBST(EXTRA_NETOBJS)
1572 AC_SUBST(DEPLIBS)
1574 AM_GNU_GETTEXT([external], [need-ngettext])
1575 AM_GNU_GETTEXT_VERSION(0.15)
1577 dnl Check for Redhat spopen problem
1578 dnl Wierd problem where ECHILD is returned from a wait call in error
1579 dnl Only appears to affect nslookup and dig calls. Only affects redhat around
1580 dnl 2.6.9-11 (okay in 2.6.9-5). Redhat investigating root cause
1581 dnl We patch plugins/popen.c
1582 dnl Need to add smp because uname different on those
1583 dnl Can force patch to be applied with --enable-redhat-pthread-workaround
1584 AC_ARG_ENABLE(redhat-pthread-workaround,
1585         AC_HELP_STRING([--enable-redhat-pthread-workaround],
1586                 [force Redhat patch to be applied (default: test system)]),
1587         [ac_cv_enable_redhat_pthread_workaround=$enableval],
1588         [ac_cv_enable_redhat_pthread_workaround=test])
1589 if test "$ac_cv_enable_redhat_pthread_workaround" = "test" ; then
1590         if echo $ac_cv_uname_r | egrep "\.EL(smp)?$" >/dev/null 2>&1 ; then
1591                 AC_MSG_NOTICE([See http://nagiosplugins.org/faq/compile/configure_appears_to_hang if this next part takes a long time])
1592                 AC_MSG_CHECKING(for redhat spopen problem)
1593                 ( cd config_test && make && make test ) > /dev/null 2>&1
1594                 if test $? -eq 0 ; then
1595                         AC_MSG_RESULT(okay)
1596                 else
1597                         AC_MSG_RESULT(error)
1598                         AC_DEFINE(REDHAT_SPOPEN_ERROR, 1, [Workaround on redhat in spopen])
1599                 fi
1600         fi
1601 elif test "$ac_cv_enable_redhat_pthread_workaround" = "yes" ; then
1602         AC_DEFINE(REDHAT_SPOPEN_ERROR, 1, [Forced workaround on redhat in spopen])
1603 fi
1605 dnl Perl modules
1606 AC_ARG_ENABLE(perl-modules,
1607         AC_HELP_STRING([--enable-perl-modules],
1608                 [Enables installation of Nagios::Plugin and its dependencies (default: no)]),
1609         [enable_perl_modules=$enableval],
1610         [enable_perl_modules=no])
1611 if test "$enable_perl_modules" = "yes" ; then
1612   AC_SUBST(PERLMODS_DIR,perlmods)
1613 fi
1615 # From Tap configure
1616 # Checks for libraries
1617 case "$host" in
1618         *-*-*freebsd4*)
1619                 LDFLAGS="$LDFLAGS -pthread"
1620                 HAVE_LIBPTHREAD=1
1621                 ;;
1622         *)
1623                 AC_CHECK_LIB(pthread, main)
1624                 ;;
1625 esac
1627 dnl External libraries - see ACKNOWLEDGEMENTS
1628 gl_INIT
1630 dnl Some helpful common compile errors checked here
1631 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
1632         AC_MSG_ERROR(No ar found for Solaris - is /usr/ccs/bin in PATH?)
1633 fi
1635 AC_OUTPUT(
1636   Makefile
1637   tap/Makefile
1638   lib/Makefile
1639   plugins/Makefile
1640   lib/tests/Makefile
1641   plugins-root/Makefile
1642   plugins-scripts/Makefile
1643   plugins-scripts/subst
1644   plugins-scripts/utils.pm
1645   plugins-scripts/utils.sh
1646   perlmods/Makefile
1647   command.cfg
1648   test.pl
1649   pkg/solaris/pkginfo
1650   po/Makefile.in
1654 dnl the ones below that are commented out need to be cleaned up
1655 dnl in the configure code above to use with_foo instead of ac_cv_foo
1656 dnl if we want them to show up here.  it'd also make the code cleaner.
1657 dnl i'll get to that on another rainy day :) -sf
1658 ACX_FEATURE([with],[apt-get-command])
1659 dnl ACX_FEATURE([with],[dig-command])
1660 dnl ACX_FEATURE([with],[fping-command])
1661 dnl ACX_FEATURE([with],[mailq-command])
1662 dnl ACX_FEATURE([with],[nslookup-command])
1663 ACX_FEATURE([with],[ping6-command])
1664 ACX_FEATURE([with],[ping-command])
1665 dnl ACX_FEATURE([with],[qstat-command])
1666 dnl ACX_FEATURE([with],[rpcinfo-command])
1667 dnl ACX_FEATURE([with],[smbclient-command])
1668 dnl ACX_FEATURE([with],[snmpget-command])
1669 dnl ACX_FEATURE([with],[snmpgetnext-command])
1670 dnl ACX_FEATURE([with],[ssh-command])
1671 dnl ACX_FEATURE([with],[uptime-command])
1673 dnl ACX_FEATURE([with],[proc-meminfo])
1674 dnl ACX_FEATURE([with],[ps-command])
1675 dnl ACX_FEATURE([with],[ps-format])
1676 dnl ACX_FEATURE([with],[ps-cols])
1677 dnl ACX_FEATURE([with],[ps-varlist])
1679 ACX_FEATURE([with],[ipv6])
1680 ACX_FEATURE([with],[mysql])
1681 ACX_FEATURE([with],[openssl])
1682 ACX_FEATURE([with],[gnutls])
1683 ACX_FEATURE([enable],[extra-opts])
1684 ACX_FEATURE([with],[perl])
1685 ACX_FEATURE([enable],[perl-modules])
1686 ACX_FEATURE([with],[cgiurl])
1687 ACX_FEATURE([with],[trusted-path])
1688 ACX_FEATURE([enable],[libtap])