Code

d02d7f85beafe3c993eea023a5473fae09c69a08
[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 echo "$with_ping_command" | grep '%d.*%d.*%s' >/dev/null
881         then
882                 ac_cv_ping_packets_first=yes
883                 ac_cv_ping_has_timeout=yes
884         elif echo "$with_ping_command" | grep '%d.*%s.*%d' >/dev/null || \
885              echo "$with_ping_command" | grep '%s.*%d.*%d' >/dev/null
886         then
887                 ac_cv_ping_has_timeout=yes
888         elif echo "$with_ping_command" | grep '%d.*%s' >/dev/null
889         then
890                 ac_cv_ping_packets_first=yes
891         fi
893 elif [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
894         $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
895         egrep -i "^round-trip|^rtt" >/dev/null
896 then
897         with_ping_command="$PATH_TO_PING -n -U -c %d %s"
898         ac_cv_ping_packets_first=yes
899         AC_MSG_RESULT([$with_ping_command])
901 elif $PATH_TO_PING -n -U -w 10 -c 1 127.0.0.1 2>/dev/null | \
902         egrep -i "^round-trip|^rtt" >/dev/null
903 then
904         with_ping_command="$PATH_TO_PING -n -U -w %d -c %d %s"
905         ac_cv_ping_packets_first=yes
906   ac_cv_ping_has_timeout=yes
907         AC_MSG_RESULT([$with_ping_command])
909 elif $PATH_TO_PING -n -U -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 -U -c %d %s"
913         ac_cv_ping_packets_first=yes
914         AC_MSG_RESULT([$with_ping_command])
916 elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \
917         egrep -i "^round-trip|^rtt" >/dev/null
918 then
919         with_ping_command="$PATH_TO_PING -n -c %d %s"
920         ac_cv_ping_packets_first=yes
921         AC_MSG_RESULT([$with_ping_command])
923 elif $PATH_TO_PING -n 127.0.0.1 -c 1 2>/dev/null | \
924         egrep -i "^round-trip|^rtt" >/dev/null
925 then
926         with_ping_command="$PATH_TO_PING -n %s -c %d"
927         AC_MSG_RESULT([$with_ping_command])
929 elif $PATH_TO_PING 127.0.0.1 -n 1 2>/dev/null | \
930         egrep -i "^round-trip|^rtt" >/dev/null
931 then
932         with_ping_command="$PATH_TO_PING %s -n %d"
933         AC_MSG_RESULT([$with_ping_command])
935 elif $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
936         egrep -i "^round-trip|^rtt" >/dev/null
937 then
938         with_ping_command="$PATH_TO_PING -n -s %s 56 %d"
939         AC_MSG_RESULT([$with_ping_command])
941 elif $PATH_TO_PING -n -h 127.0.0.1 -s 56 -c 1 2>/dev/null | \
942         egrep -i "^round-trip|^rtt" >/dev/null
943 then
944         with_ping_command="$PATH_TO_PING -n -h %s -s 56 -c %d"
945         AC_MSG_RESULT([$with_ping_command])
947 elif $PATH_TO_PING -n -s 56 -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 -s 56 -c %d %s"
951         ac_cv_ping_packets_first=yes
952         AC_MSG_RESULT([$with_ping_command])
954 elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \
955         egrep -i "^round-trip|^rtt" >/dev/null
956 then
957         with_ping_command="$PATH_TO_PING -n -c %d %s"
958         ac_cv_ping_packets_first=yes
959         AC_MSG_RESULT([$with_ping_command])
961 else
962         AC_MSG_WARN([unable to find usable ping syntax])
963 fi
965 AC_DEFINE_UNQUOTED(PING_COMMAND,"$with_ping_command",
966         [path and args for ICMP ping command])
968 if test "x$ac_cv_ping_packets_first" != "xno"
969 then
970         AC_DEFINE(PING_PACKETS_FIRST,1,
971                 [Define if packet count must precede host])
972 fi
974 if test "x$ac_cv_ping_has_timeout" != "xno"
975 then
976         AC_DEFINE(PING_HAS_TIMEOUT,1,
977                 [Define if ping has its own timeout option that should be set])
978 fi
980 AC_ARG_WITH(ping6_command,
981         ACX_HELP_STRING([--with-ping6-command=SYNTAX],
982                 [sets syntax for ICMPv6 ping]),
983         with_ping6_command=$withval,)
985 if test x"$with_ipv6" != xno ; then
986 AC_MSG_CHECKING(for ICMPv6 ping syntax)
987 ac_cv_ping6_packets_first=no
988 if test -n "$with_ping6_command"
989 then
990         AC_MSG_RESULT([(command-line) $with_ping6_command])
991         if echo "$with_ping6_command" | grep '%d.*%d.*%s' >/dev/null
992         then
993                 ac_cv_ping6_packets_first=yes
994         elif echo "$with_ping6_command" | grep '%d.*%s.*%d' >/dev/null || \
995              echo "$with_ping6_command" | grep '%s.*%d.*%d' >/dev/null
996         then
997                 # Just keep same logic as ping (IPv4) if we ever need ac_cv_ping6_has_timeout
998                 true
999         elif echo "$with_ping6_command" | grep '%d.*%s' >/dev/null
1000         then
1001                 ac_cv_ping6_packets_first=yes
1002         fi
1004 elif test "x$PATH_TO_PING6" != "x"; then
1005         if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
1006                 $PATH_TO_PING6 -n -s ::1 56 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 -U -w 10 -c 1 ::1 2>/dev/null | \
1014                 egrep -i "^round-trip|^rtt" >/dev/null
1015         then
1016                 with_ping6_command="$PATH_TO_PING6 -n -U -w %d -c %d %s"
1017                 ac_cv_ping6_packets_first=yes
1018                 ac_cv_ping_has_timeout=yes
1019                 AC_MSG_RESULT([$with_ping6_command])
1021         elif $PATH_TO_PING6 -n -U -c 1 ::1 2>/dev/null | \
1022                 egrep -i "^round-trip|^rtt" >/dev/null
1023         then
1024                 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s"
1025                 ac_cv_ping6_packets_first=yes
1026                 AC_MSG_RESULT([$with_ping6_command])
1028         elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \
1029                 egrep -i "^round-trip|^rtt" >/dev/null
1030         then
1031                 with_ping6_command="$PATH_TO_PING6 -n -c %d %s"
1032                 ac_cv_ping6_packets_first=yes
1033                 AC_MSG_RESULT([$with_ping6_command])
1035         elif $PATH_TO_PING6 -n ::1 -c 1 2>/dev/null | \
1036                 egrep -i "^round-trip|^rtt" >/dev/null
1037         then
1038                 with_ping6_command="$PATH_TO_PING6 -n %s -c %d"
1039                 AC_MSG_RESULT([$with_ping6_command])
1041         elif $PATH_TO_PING6 ::1 -n 1 2>/dev/null | \
1042                 egrep -i "^round-trip|^rtt" >/dev/null
1043         then
1044                 with_ping6_command="$PATH_TO_PING6 %s -n %d"
1045                 AC_MSG_RESULT([$with_ping6_command])
1047         elif $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \
1048                 egrep -i "^round-trip|^rtt" >/dev/null
1049         then
1050                 with_ping6_command="$PATH_TO_PING6 -n -s %s 56 %d"
1051                 AC_MSG_RESULT([$with_ping6_command])
1053         elif $PATH_TO_PING6 -n -h ::1 -s 56 -c 1 2>/dev/null | \
1054                 egrep -i "^round-trip|^rtt" >/dev/null
1055         then
1056                 with_ping6_command="$PATH_TO_PING6 -n -h %s -s 56 -c %d"
1057                 AC_MSG_RESULT([$with_ping6_command])
1059         elif $PATH_TO_PING6 -n -s 56 -c 1 ::1 2>/dev/null | \
1060                 egrep -i "^round-trip|^rtt" >/dev/null
1061         then
1062                 with_ping6_command="$PATH_TO_PING6 -n -s 56 -c %d %s"
1063                 ac_cv_ping6_packets_first=yes
1064                 AC_MSG_RESULT([$with_ping_command])
1066         elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \
1067                 egrep -i "^round-trip|^rtt" >/dev/null
1068         then
1069                 with_ping6_command="$PATH_TO_PING6 -n -c %d %s"
1070                 ac_cv_ping6_packets_first=yes
1071                 AC_MSG_RESULT([$with_ping6_command])
1073         fi
1075 elif test "x$PATH_TO_PING" != "x"; then
1076         if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
1077                 $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \
1078                 egrep -i "^round-trip|^rtt" >/dev/null
1079         then
1080                 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s"
1081                 ac_cv_ping6_packets_first=yes
1082                 AC_MSG_RESULT([$with_ping6_command])
1084         elif $PATH_TO_PING -A inet6 -n -U -c 1 ::1 2>/dev/null | \
1085                 egrep -i "^round-trip|^rtt" >/dev/null
1086         then
1087                 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s"
1088                 ac_cv_ping6_packets_first=yes
1089                 AC_MSG_RESULT([$with_ping6_command])
1091         elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \
1092                 egrep -i "^round-trip|^rtt" >/dev/null
1093         then
1094                 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s"
1095                 ac_cv_ping6_packets_first=yes
1096                 AC_MSG_RESULT([$with_ping6_command])
1098         elif $PATH_TO_PING -A inet6 -n ::1 -c 1 2>/dev/null | \
1099                 egrep -i "^round-trip|^rtt" >/dev/null
1100         then
1101                 with_ping6_command="$PATH_TO_PING -A inet6 -n %s -c %d"
1102                 AC_MSG_RESULT([$with_ping6_command])
1104         elif $PATH_TO_PING -A inet6 ::1 -n 1 2>/dev/null | \
1105                 egrep -i "^round-trip|^rtt" >/dev/null
1106         then
1107                 with_ping6_command="$PATH_TO_PING -A inet6 %s -n %d"
1108                 AC_MSG_RESULT([$with_ping6_command])
1110         elif $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \
1111                 egrep -i "^round-trip|^rtt" >/dev/null
1112         then
1113                 with_ping6_command="$PATH_TO_PING -A inet6 -n -s %s 56 %d"
1114                 AC_MSG_RESULT([$with_ping6_command])
1116         elif $PATH_TO_PING -A inet6 -n -h ::1 -s 56 -c 1 2>/dev/null | \
1117                 egrep -i "^round-trip|^rtt" >/dev/null
1118         then
1119                 with_ping6_command="$PATH_TO_PING -A inet6 -n -h %s -s 56 -c %d"
1120                 AC_MSG_RESULT([$with_ping6_command])
1122         elif $PATH_TO_PING -A inet6 -n -s 56 -c 1 ::1 2>/dev/null | \
1123                 egrep -i "^round-trip|^rtt" >/dev/null
1124         then
1125                 with_ping6_command="$PATH_TO_PING -A inet6 -n -s 56 -c %d %s"
1126                 ac_cv_ping6_packets_first=yes
1127                 AC_MSG_RESULT([$with_ping_command])
1129         elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \
1130                 egrep -i "^round-trip|^rtt" >/dev/null
1131         then
1132                 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s"
1133                 ac_cv_ping6_packets_first=yes
1134                 AC_MSG_RESULT([$with_ping6_command])
1136         fi
1138 fi
1140 if test "x$with_ping6_command" != "x"; then
1141         AC_DEFINE_UNQUOTED(PING6_COMMAND,"$with_ping6_command",
1142                 [path and args for ICMPv6 ping command])
1143 else
1144         AC_MSG_RESULT([none])
1145 fi
1147 if test "x$ac_cv_ping6_packets_first" != "xno"; then
1148         AC_DEFINE(PING6_PACKETS_FIRST,1,
1149                 [Define if packet count must precede host])
1150 fi
1151 fi
1154 AC_ARG_WITH(nslookup_command,
1155             ACX_HELP_STRING([--with-nslookup-command=PATH],
1156                             [sets path to nslookup executable]),
1157             ac_cv_nslookup_command=$withval)
1158 if test -n "$ac_cv_nslookup_command"; then
1159         AC_MSG_NOTICE([Using specific nslookup at $ac_cv_nslookup_command])
1160 else
1161         AC_PATH_PROG(PATH_TO_NSLOOKUP,nslookup)
1162         if test -n "$PATH_TO_NSLOOKUP"
1163         then
1164                 AC_MSG_CHECKING(for nslookup syntax)
1165                 if $PATH_TO_NSLOOKUP -sil 127.0.0.1 2>&1 | grep ["Invalid option: sil"] >/dev/null
1166                 then
1167                         ac_cv_nslookup_command="$PATH_TO_NSLOOKUP"
1168                         AC_MSG_RESULT([$ac_cv_nslookup_command])
1170                 else
1171                         ac_cv_nslookup_command="$PATH_TO_NSLOOKUP -sil"
1172                         AC_MSG_RESULT([$ac_cv_nslookup_command])
1174                 fi
1175         else
1176                 AC_MSG_WARN([nslookup command not found])
1177         fi
1178 fi
1180 if test -n "$ac_cv_nslookup_command"; then
1181         EXTRAS="$EXTRAS check_dns"
1182         AC_DEFINE_UNQUOTED(NSLOOKUP_COMMAND,"$ac_cv_nslookup_command", [path and args for nslookup])
1183 fi
1185 AC_MSG_CHECKING([for number of cpus])
1186 AC_TRY_COMPILE([#include <unistd.h>],
1187         [sysconf(_SC_NPROCESSORS_CONF) > 0;],
1188         AC_DEFINE(HAVE_SYSCONF__SC_NPROCESSORS_CONF,1,[Define if sysconf returns number of cpus])
1189         AC_MSG_RESULT([sysconf(_SC_NPROCESSORS_CONF)]),
1190         AC_MSG_RESULT([cannot calculate])
1191         )
1193 AC_PATH_PROG(PATH_TO_UPTIME,uptime)
1194 AC_ARG_WITH(uptime_command,
1195             ACX_HELP_STRING([--with-uptime-command=PATH],
1196                             [sets path to uptime]), PATH_TO_UPTIME=$withval)
1197 AC_DEFINE_UNQUOTED(PATH_TO_UPTIME,"$PATH_TO_UPTIME",[path to uptime binary])
1199 AC_PATH_PROG(PATH_TO_RPCINFO,rpcinfo)
1200 AC_ARG_WITH(rpcinfo_command,
1201             ACX_HELP_STRING([--with-rpcinfo-command=PATH],
1202                             [sets path to rpcinfo]), PATH_TO_RPCINFO=$withval)
1203 AC_DEFINE_UNQUOTED(PATH_TO_RPCINFO,"$PATH_TO_RPCINFO",[path to rpcinfo binary])
1205 AC_PATH_PROG(PATH_TO_LMSTAT,lmstat)
1206 if test -x "$PATH_TO_LMSTAT"
1207 then
1208         AC_DEFINE_UNQUOTED(PATH_TO_LMSTAT,"$PATH_TO_LMSTAT",[path to lmstat])
1209 else
1210         AC_MSG_WARN([Get lmstat from Globetrotter Software to monitor flexlm licenses])
1211 fi
1213 AC_PATH_PROG(PATH_TO_SMBCLIENT,smbclient)
1214 AC_ARG_WITH(smbclient_command,
1215             ACX_HELP_STRING([--with-smbclient-command=PATH],
1216                             [sets path to smbclient]),
1217             PATH_TO_SMBCLIENT=$withval)
1218 if test -n "$PATH_TO_SMBCLIENT"
1219 then
1220         AC_DEFINE_UNQUOTED(PATH_TO_SMBCLIENT,"$PATH_TO_SMBCLIENT",[path to smbclient binary])
1221 else
1222         AC_MSG_WARN([Get smbclient from Samba.org to monitor SMB shares])
1223 fi
1226 AC_PATH_PROG(PATH_TO_WHO,who)
1228 if [$PATH_TO_WHO -q 2>/dev/null | egrep -i "^# users=[0-9]+$" >/dev/null]
1229 then
1230         ac_cv_path_to_who="$PATH_TO_WHO -q"
1231 else
1232         ac_cv_path_to_who="$PATH_TO_WHO"
1233 fi
1235 AC_DEFINE_UNQUOTED(WHO_COMMAND,"$ac_cv_path_to_who",
1236         [path and arguments for invoking 'who'])
1238 AC_PATH_PROG(PATH_TO_SNMPGET,snmpget)
1239 AC_ARG_WITH(snmpget_command,
1240             ACX_HELP_STRING([--with-snmpget-command=PATH],
1241                             [Path to snmpget command]),
1242             PATH_TO_SNMPGET=$withval)
1243 if test -n "$PATH_TO_SNMPGET"
1244 then
1245         AC_DEFINE_UNQUOTED(PATH_TO_SNMPGET,"$PATH_TO_SNMPGET",[path to snmpget binary])
1246         EXTRAS="$EXTRAS check_hpjd check_snmp"
1247 else
1248         AC_MSG_WARN([Get snmpget from http://net-snmp.sourceforge.net to make check_hpjd and check_snmp plugins])
1249 fi
1251 AC_PATH_PROG(PATH_TO_SNMPGETNEXT,snmpgetnext)
1252 AC_ARG_WITH(snmpgetnext_command,
1253             ACX_HELP_STRING([--with-snmpgetnext-command=PATH],
1254                             [Path to snmpgetnext command]),
1255             PATH_TO_SNMPGETNEXT=$withval)
1256 if test -n "$PATH_TO_SNMPGETNEXT"
1257 then
1258         AC_DEFINE_UNQUOTED(PATH_TO_SNMPGETNEXT,"$PATH_TO_SNMPGETNEXT",[path to snmpgetnext binary])
1259 fi
1261 if ( $PERL -M"Net::SNMP 3.6" -e 'exit' 2>/dev/null  )
1262 then
1263         AC_MSG_CHECKING(for Net::SNMP perl module)
1264         AC_MSG_RESULT([found])
1265 else
1266         AC_MSG_WARN([Tried $PERL - install Net::SNMP perl module if you want to use the perl snmp plugins])
1267 fi
1269 AC_PATH_PROG(PATH_TO_QUAKESTAT,quakestat)
1270 AC_PATH_PROG(PATH_TO_QSTAT,qstat)
1271 AC_ARG_WITH(qstat_command,
1272             ACX_HELP_STRING([--with-qstat-command=PATH],
1273                             [Path to qstat command]), PATH_TO_QSTAT=$withval)
1275 if test -x "$PATH_TO_QUAKESTAT"
1276 then
1277         ac_cv_path_to_qstat="$PATH_TO_QUAKESTAT"
1278         EXTRAS="$EXTRAS check_game"
1280 elif test -n "$PATH_TO_QSTAT"
1281 then
1282         ac_cv_path_to_qstat="$PATH_TO_QSTAT"
1283         EXTRAS="$EXTRAS check_game"
1284 else
1285         AC_MSG_WARN([Get qstat from http://www.activesw.com/people/steve/qstat.html in order to make check_game plugin])
1286 fi
1288 if test $ac_cv_path_to_qstat
1289 then
1290         AC_DEFINE_UNQUOTED(PATH_TO_QSTAT,"$ac_cv_path_to_qstat",
1291                 [path to qstat/quakestat])
1292 fi
1294 AC_PATH_PROG(PATH_TO_FPING,fping)
1295 AC_ARG_WITH(fping_command,
1296             ACX_HELP_STRING([--with-fping-command=PATH],
1297                             [Path to fping command]), PATH_TO_FPING=$withval)
1298 if test -n "$PATH_TO_FPING"
1299 then
1300         AC_DEFINE_UNQUOTED(PATH_TO_FPING,"$PATH_TO_FPING",[path to fping])
1301         EXTRAS="$EXTRAS check_fping"
1302 else
1303         AC_MSG_WARN([Get fping from http://www.fping.com in order to make check_fping plugin])
1304 fi
1306 AC_PATH_PROG(PATH_TO_SSH,ssh)
1307 AC_ARG_WITH(ssh_command,
1308             ACX_HELP_STRING([--with-ssh-command=PATH],
1309                             [sets path for ssh]), PATH_TO_SSH=$withval)
1310 if test -n "$PATH_TO_SSH"
1311 then
1312         AC_DEFINE_UNQUOTED(SSH_COMMAND,"$PATH_TO_SSH",[path to ssh binary])
1313         EXTRAS="$EXTRAS check_by_ssh"
1314 else
1315         AC_MSG_WARN([Get ssh in order to make check_by_ssh plugin])
1316 fi
1319 AC_PATH_PROG(PATH_TO_MAILQ,mailq)
1320 AC_ARG_WITH(mailq_command,
1321             ACX_HELP_STRING([--with-mailq-command=PATH],
1322                             [sets path to mailq]), PATH_TO_MAILQ=$withval)
1323 if test -n "$PATH_TO_MAILQ"
1324 then
1325         AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_MAILQ",[path to mailq])
1326 else
1327         AC_MSG_WARN([Could not find mailq or eqivalent])
1328 fi
1330 AC_PATH_PROG(PATH_TO_QMAIL_QSTAT,qmail-qstat)
1331 if test -x "$PATH_TO_QMAIL_QSTAT"
1332 then
1333         AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_QMAIL_QSTAT",[path to qmail-qstat])
1334 else
1335         AC_MSG_WARN([Could not find qmail-qstat or eqivalent])
1336 fi
1338 dnl SWAP info required is amount allocated/available and amount free
1339 dnl The plugin works through all the swap devices and adds up the total swap
1340 dnl available.
1341 AC_PATH_PROG(PATH_TO_SWAP,swap)
1342 if (test -n "$PATH_TO_SWAP")
1343 then
1344 AC_MSG_CHECKING([for $PATH_TO_SWAP format])
1345 if [$PATH_TO_SWAP -l 2>&1 >/dev/null]
1346 then
1347         ac_cv_have_swap=yes
1348         ac_cv_swap_command="$PATH_TO_SWAP -l"
1349         if [$PATH_TO_SWAP -l 2>/dev/null | \
1350                 egrep -i "^lswap +path +pri +swaplo +blocks +free +maxswap" \
1351                 >/dev/null]
1352         then
1353                 ac_cv_swap_format=[" %*d %*s %*d,%*d %*d %*d %f %f"]
1354                 ac_cv_swap_conv=2048
1355                 AC_MSG_RESULT([using IRIX format swap])
1357         elif [$PATH_TO_SWAP -l 2>/dev/null | egrep -i "^path +dev +swaplo +blocks +free" >/dev/null]
1358         then
1359                 ac_cv_swap_format=["%*s %*[0-9,-] %*d %f %f"]
1360                 ac_cv_swap_conv=2048
1361                 AC_MSG_RESULT([using Unixware format swap])
1362         else
1363                 dnl if we don't know what format swap's output is
1364                 dnl we might as well pretend we didn't see it
1365                 ac_cv_have_swap=""
1366                 ac_cv_swap_command=""
1367         fi
1368 fi
1369 dnl end if for PATH_TO_SWAP
1370 fi
1372 AC_PATH_PROG(PATH_TO_SWAPINFO,swapinfo)
1373 if (test -n "$PATH_TO_SWAPINFO")
1374 then
1375 AC_MSG_CHECKING([for $PATH_TO_SWAPINFO format])
1376 if [$PATH_TO_SWAPINFO -k 2>&1 | egrep -i "^Device" >/dev/null]
1377 then
1378         ac_cv_have_swap=yes
1379         ac_cv_swap_command="$PATH_TO_SWAPINFO -k"
1381         if [$PATH_TO_SWAPINFO -k 2>/dev/null | egrep -i "^Device +1K-blocks +Used +Avail" >/dev/null]
1382         then
1383                 ac_cv_swap_format=["%*s %f %*d %f"]
1384                 ac_cv_swap_conv=1024
1385                 AC_MSG_RESULT([using FreeBSD format swapinfo])
1386         fi
1388 elif [$PATH_TO_SWAPINFO -dfM 2>/dev/null | egrep -i "^TYPE +AVAIL +USED +FREE" >/dev/null]
1389 then
1390         ac_cv_have_swap=yes
1391         ac_cv_swap_command="$PATH_TO_SWAPINFO -dfM"
1392         ac_cv_swap_format=["%*s %f %*d %f"]
1393         ac_cv_swap_conv=1024
1394         AC_MSG_RESULT([using HP-UX format swapinfo])
1395 fi
1396 dnl end if for PATH_TO_SWAPINFO
1397 fi
1399 AC_PATH_PROG(PATH_TO_LSPS,lsps)
1400 if (test -n "$PATH_TO_LSPS")
1401 then
1402 AC_MSG_CHECKING([for $PATH_TO_LSPS format])
1403 if [$PATH_TO_LSPS -a 2>/dev/null | egrep -i "^Page Space" > /dev/null]
1404 then
1405         ac_cv_have_swap=yes
1406         ac_cv_swap_command="$PATH_TO_LSPS -a"
1407         ac_cv_swap_format=["%*s %*s %*s %f%*s %f %*s"]
1408         ac_cv_swap_conv=1
1409         AC_MSG_RESULT([using AIX lsps])
1410 fi
1411 dnl end if for PATH_TO_SWAPINFO
1412 fi
1414 dnl
1415 dnl test for swapctl system call, both the 2-arg and 3-arg variants
1416 dnl fwict, the 2-arg is an SVR4 standard, whereas the 3-arg is shared
1417 dnl in the various BSD's
1418 dnl
1420 AC_CHECK_HEADERS([sys/stat.h sys/param.h])
1421 AC_CHECK_HEADERS([sys/swap.h], [], [], [
1422 #ifdef HAVE_SYS_PARAM_H
1423 #include <sys/param.h>
1424 #endif
1425 ])
1426 AC_CHECK_DECLS([swapctl],,,[
1427                #include <unistd.h>
1428                #include <sys/types.h>
1429                #include <sys/param.h>
1430                #include <sys/stat.h>
1431                #include <sys/swap.h>
1432                ])
1433 AC_CHECK_TYPES([swaptbl_t, swapent_t],,,[
1434                #include <sys/types.h>
1435                #include <sys/param.h>
1436                #include <sys/stat.h>
1437                #include <sys/swap.h>
1438                ])
1439 AC_CHECK_MEMBERS([struct swapent.se_nblks],,,[
1440                  #include <unistd.h>
1441                  #include <sys/types.h>
1442                  #include <sys/param.h>
1443                  #include <sys/stat.h>
1444                  #include <sys/swap.h>
1445                  ])
1447 if test "$ac_cv_have_decl_swapctl" = "yes";
1448 then
1449         EXTRAS="$EXTRAS check_swap"
1450         AC_MSG_CHECKING([for 2-arg (SVR4) swapctl])
1451         if test "$ac_cv_type_swaptbl_t" = "yes" -a \
1452                 "$ac_cv_type_swapent_t" = "yes";
1453         then
1454                 AC_MSG_RESULT([yes])
1455                 ac_cv_check_swap_swapctl_svr4="1";
1456                 AC_DEFINE([CHECK_SWAP_SWAPCTL_SVR4],1,
1457                           [Define if 2-argument SVR4 swapctl exists])
1458         else
1459                 AC_MSG_RESULT([no])
1460                 AC_MSG_CHECKING([for 3-arg (*BSD) swapctl])
1461                 if test "$ac_cv_member_struct_swapent_se_nblks" = "yes";
1462                 then
1463                         AC_MSG_RESULT([yes])
1464                         AC_DEFINE([CHECK_SWAP_SWAPCTL_BSD],1,
1465                                   [Define if 3-argument BSD swapctl exists])
1466                 else
1467                         AC_MSG_RESULT([no])
1468                 fi
1469         fi
1470         AC_MSG_CHECKING([for whether swapctl uses blocks or pages])
1471         if test "$ac_cv_check_swap_swapctl_svr4" = "1";
1472         then
1473                 dnl
1474                 dnl the SVR4 spec returns values in pages
1475                 dnl
1476                 AC_MSG_RESULT([page])
1477                 AC_CHECK_DECLS([sysconf])
1478                 AC_MSG_CHECKING([for system page size])
1479                 if test "$ac_cv_have_decl_sysconf" = "yes";
1480                 then
1481                         AC_MSG_RESULT([determined by sysconf(3)])
1482                         ac_cv_swap_conv="(1048576/sysconf(_SC_PAGESIZE))"
1483                 else
1484                         AC_MSG_WARN([don't know. guessing 4096k])
1485                         ac_cv_swap_conv=256
1486                 fi
1487         else
1488                 dnl
1489                 dnl the BSD spec returns values in blocks
1490                 dnl
1491                 AC_MSG_RESULT([blocks (assuming 512b)])
1492                 ac_cv_swap_conv=2048
1493         fi
1494         AC_DEFINE_UNQUOTED(SWAP_CONVERSION,$ac_cv_swap_conv,
1495                 [Conversion factor to MB])
1496 fi
1497 dnl
1498 dnl end tests for the swapctl system calls
1499 dnl
1502 if test "x$ac_cv_have_swap" != "x"
1503 then
1504         AC_DEFINE(HAVE_SWAP,1,[Define if swap/swapinfo command is found])
1505         EXTRAS="$EXTRAS check_swap"
1506 fi
1507 if test "x$ac_cv_swap_command" != "x"
1508 then
1509         AC_DEFINE_UNQUOTED(SWAP_COMMAND,"$ac_cv_swap_command",
1510                 [Path to swap/swapinfo binary, with any args])
1511         AC_DEFINE_UNQUOTED(SWAP_FORMAT,"$ac_cv_swap_format",
1512                 [Format string for parsing swap output])
1513         AC_DEFINE_UNQUOTED(SWAP_CONVERSION,$ac_cv_swap_conv,
1514                 [Conversion factor to MB])
1515 fi
1517 AC_ARG_WITH(proc-meminfo,
1518             ACX_HELP_STRING([--with-proc-meminfo=PATH],
1519                             [path to /proc/meminfo or equivalent]),
1520                             ac_cv_proc_meminfo=$withval)
1521 dnl dunno why this does not work below - use hack (kbd)
1522 dnl fine on linux, broken on solaris
1523 dnl if /bin/test -e "/proc/meminfo"
1524 AC_MSG_CHECKING([for /proc/meminfo])
1525 if test -n "$ac_cv_proc_meminfo"; then
1526         AC_MSG_RESULT([(command line) $ac_cv_proc_meminfo])
1527 elif [cat /proc/meminfo > /dev/null 2>&1]; then
1528         AC_MSG_RESULT([found /proc/meminfo])
1529         ac_cv_proc_meminfo="/proc/meminfo"
1530 else
1531         AC_MSG_RESULT([no])
1532 fi
1534 if test -n "$ac_cv_proc_meminfo"; then
1535         AC_DEFINE(HAVE_PROC_MEMINFO,1,[Define if we have /proc/meminfo])
1536         AC_DEFINE_UNQUOTED(PROC_MEMINFO,"$ac_cv_proc_meminfo",[path to /proc/meminfo if name changes])
1537         EXTRAS="$EXTRAS check_swap"
1538 fi
1540 AC_PATH_PROG(PATH_TO_DIG,dig)
1541 AC_ARG_WITH(dig_command,
1542             ACX_HELP_STRING([--with-dig-command=PATH],
1543                             [Path to dig command]), PATH_TO_DIG=$withval)
1544 if test -n "$PATH_TO_DIG"; then
1545         EXTRAS="$EXTRAS check_dig"
1546         AC_DEFINE_UNQUOTED(PATH_TO_DIG,"$PATH_TO_DIG",[Path to dig command, if present])
1547 fi
1549 AC_PATH_PROG(PATH_TO_APTGET,apt-get)
1550 AC_ARG_WITH(apt-get_command,
1551             ACX_HELP_STRING([--with-apt-get-command=PATH],
1552                             [Path to apt-get command]),
1553                             with_apt_get_command=$withval,
1554                             with_apt_get_command=$PATH_TO_APTGET)
1555 AC_DEFINE_UNQUOTED(PATH_TO_APTGET,"$PATH_TO_APTGET",[Path to apt-get command, if present])
1556 if test -n "$PATH_TO_APTGET" ; then
1557         EXTRAS="$EXTRAS check_apt"
1558 fi
1561 if test -f $srcdir/plugins/check_nt.c ; then
1562   EXTRAS="$EXTRAS check_nt"
1563 fi
1566 dnl used in check_dhcp
1567 AC_CHECK_HEADERS(sys/sockio.h)
1569 case $host in
1570         *bsd*)
1571                 AC_DEFINE(__bsd__,1,[bsd specific code in check_dhcp.c])
1572         ;;
1573         *linux*)
1574                 AC_DEFINE(__linux__,1,[linux specific code in check_dhcp.c])
1575         ;;
1576         *sun* | *solaris*)
1577                 AC_DEFINE(__sun__,1,[sun specific code in check_dhcp.c])
1578         ;;
1579         *hpux*)
1580                 AC_DEFINE(__hpux__,1,[hpux specific code in check_dhcp.c])
1581         ;;
1582 esac
1584 AC_SUBST(EXTRAS)
1585 AC_SUBST(EXTRAS_ROOT)
1586 AC_SUBST(EXTRA_NETOBJS)
1587 AC_SUBST(DEPLIBS)
1589 AM_GNU_GETTEXT([external], [need-ngettext])
1590 AM_GNU_GETTEXT_VERSION(0.15)
1592 dnl Check for Redhat spopen problem
1593 dnl Wierd problem where ECHILD is returned from a wait call in error
1594 dnl Only appears to affect nslookup and dig calls. Only affects redhat around
1595 dnl 2.6.9-11 (okay in 2.6.9-5). Redhat investigating root cause
1596 dnl We patch plugins/popen.c
1597 dnl Need to add smp because uname different on those
1598 dnl Can force patch to be applied with --enable-redhat-pthread-workaround
1599 AC_ARG_ENABLE(redhat-pthread-workaround,
1600         AC_HELP_STRING([--enable-redhat-pthread-workaround],
1601                 [force Redhat patch to be applied (default: test system)]),
1602         [ac_cv_enable_redhat_pthread_workaround=$enableval],
1603         [ac_cv_enable_redhat_pthread_workaround=test])
1604 if test "$ac_cv_enable_redhat_pthread_workaround" = "test" ; then
1605         if echo $ac_cv_uname_r | egrep "\.EL(smp)?$" >/dev/null 2>&1 ; then
1606                 AC_MSG_NOTICE([See http://nagiosplugins.org/faq/compile/configure_appears_to_hang if this next part takes a long time])
1607                 AC_MSG_CHECKING(for redhat spopen problem)
1608                 ( cd config_test && make && make test ) > /dev/null 2>&1
1609                 if test $? -eq 0 ; then
1610                         AC_MSG_RESULT(okay)
1611                 else
1612                         AC_MSG_RESULT(error)
1613                         AC_DEFINE(REDHAT_SPOPEN_ERROR, 1, [Workaround on redhat in spopen])
1614                 fi
1615         fi
1616 elif test "$ac_cv_enable_redhat_pthread_workaround" = "yes" ; then
1617         AC_DEFINE(REDHAT_SPOPEN_ERROR, 1, [Forced workaround on redhat in spopen])
1618 fi
1620 dnl Perl modules
1621 AC_ARG_ENABLE(perl-modules,
1622         AC_HELP_STRING([--enable-perl-modules],
1623                 [Enables installation of Nagios::Plugin and its dependencies (default: no)]),
1624         [enable_perl_modules=$enableval],
1625         [enable_perl_modules=no])
1626 if test "$enable_perl_modules" = "yes" ; then
1627   AC_SUBST(PERLMODS_DIR,perlmods)
1628 fi
1630 # From Tap configure
1631 # Checks for libraries
1632 case "$host" in
1633         *-*-*freebsd4*)
1634                 LDFLAGS="$LDFLAGS -pthread"
1635                 HAVE_LIBPTHREAD=1
1636                 ;;
1637         *)
1638                 AC_CHECK_LIB(pthread, main)
1639                 ;;
1640 esac
1642 dnl External libraries - see ACKNOWLEDGEMENTS
1643 gl_INIT
1645 dnl Some helpful common compile errors checked here
1646 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
1647         AC_MSG_ERROR(No ar found for Solaris - is /usr/ccs/bin in PATH?)
1648 fi
1650 AC_OUTPUT(
1651   Makefile
1652   tap/Makefile
1653   lib/Makefile
1654   plugins/Makefile
1655   lib/tests/Makefile
1656   plugins-root/Makefile
1657   plugins-scripts/Makefile
1658   plugins-scripts/subst
1659   plugins-scripts/utils.pm
1660   plugins-scripts/utils.sh
1661   perlmods/Makefile
1662   command.cfg
1663   test.pl
1664   pkg/solaris/pkginfo
1665   po/Makefile.in
1669 dnl the ones below that are commented out need to be cleaned up
1670 dnl in the configure code above to use with_foo instead of ac_cv_foo
1671 dnl if we want them to show up here.  it'd also make the code cleaner.
1672 dnl i'll get to that on another rainy day :) -sf
1673 ACX_FEATURE([with],[apt-get-command])
1674 dnl ACX_FEATURE([with],[dig-command])
1675 dnl ACX_FEATURE([with],[fping-command])
1676 dnl ACX_FEATURE([with],[mailq-command])
1677 dnl ACX_FEATURE([with],[nslookup-command])
1678 ACX_FEATURE([with],[ping6-command])
1679 ACX_FEATURE([with],[ping-command])
1680 dnl ACX_FEATURE([with],[qstat-command])
1681 dnl ACX_FEATURE([with],[rpcinfo-command])
1682 dnl ACX_FEATURE([with],[smbclient-command])
1683 dnl ACX_FEATURE([with],[snmpget-command])
1684 dnl ACX_FEATURE([with],[snmpgetnext-command])
1685 dnl ACX_FEATURE([with],[ssh-command])
1686 dnl ACX_FEATURE([with],[uptime-command])
1688 dnl ACX_FEATURE([with],[proc-meminfo])
1689 dnl ACX_FEATURE([with],[ps-command])
1690 dnl ACX_FEATURE([with],[ps-format])
1691 dnl ACX_FEATURE([with],[ps-cols])
1692 dnl ACX_FEATURE([with],[ps-varlist])
1694 ACX_FEATURE([with],[ipv6])
1695 ACX_FEATURE([with],[mysql])
1696 ACX_FEATURE([with],[openssl])
1697 ACX_FEATURE([with],[gnutls])
1698 ACX_FEATURE([enable],[extra-opts])
1699 ACX_FEATURE([with],[perl])
1700 ACX_FEATURE([enable],[perl-modules])
1701 ACX_FEATURE([with],[cgiurl])
1702 ACX_FEATURE([with],[trusted-path])
1703 ACX_FEATURE([enable],[libtap])