Code

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