Code

#995761: patch from ben o'hara to include inode calculations in
[nagiosplug.git] / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2 AC_REVISION ($Revision$)
3 AC_PREREQ(2.58)
4 AC_INIT(nagios-plugins,1.4.2)
5 AC_CONFIG_SRCDIR(NPTest.pm)
6 AM_INIT_AUTOMAKE
7 AM_CONFIG_HEADER(config.h)
8 AC_CANONICAL_HOST
10 RELEASE=1
11 AC_SUBST(RELEASE)
13 AC_PREFIX_DEFAULT(/usr/local/nagios)
15 dnl Figure out how to invoke "install" and what install options to use.
16 AC_PROG_INSTALL
17 AC_SUBST(INSTALL)
19 dnl Must come very early on due to coreutils requirement
20 dnl Takes care of AC_GNU_SOURCE, AC_AIX and AC_MINIX
21 gl_USE_SYSTEM_EXTENSIONS
23 AC_PROG_CC
24 AC_PROG_CPP
25 AC_PROG_GCC_TRADITIONAL
26 AC_PROG_RANLIB
28 AC_PROG_MAKE_SET
29 AC_PROG_AWK
31 AC_FUNC_MALLOC
32 AC_FUNC_REALLOC
33 AC_FUNC_ERROR_AT_LINE
35 AC_CONFIG_LIBOBJ_DIR(lib)
36 AC_FUNC_GETLOADAVG([lib])
38 ifdef([AC_FUNC_STRTOD],[AC_FUNC_STRTOD],[AM_FUNC_STRTOD])
39 dnl AM_WITH_REGEX
41 PLUGIN_TEST=`echo $srcdir/plugins/t/*.t|sed -e 's,\.*/plugins/,,g'`
42 AC_SUBST(PLUGIN_TEST)dnl
44 SCRIPT_TEST=`echo $srcdir/plugins-scripts/t/*.t|sed -e 's,\.*/plugins-scripts/,,g'`
45 AC_SUBST(SCRIPT_TEST)dnl
47 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"
48 AC_SUBST(WARRANTY)
50 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"
51 AC_SUBST(SUPPORT)
53 dnl CGIURL has changed for Nagios with 1.0 beta
54 AC_ARG_WITH(cgiurl,
55         ACX_HELP_STRING([--with-cgiurl=DIR],
56                 [sets URL for cgi programs]),
57         with_cgiurl=$withval,
58         with_cgiurl=/nagios/cgi-bin)
59 CGIURL="$with_cgiurl"
60 AC_DEFINE_UNQUOTED(CGIURL,"$CGIURL",[URL of CGI programs])
62 AC_ARG_WITH(nagios_user,
63         ACX_HELP_STRING([--with-nagios-user=USER],
64                 [set user name to run nagios]),
65         with_nagios_user=$withval,
66         with_nagios_user=nagios)
67 AC_ARG_WITH(nagios_group,
68         ACX_HELP_STRING([--with-nagios-group=GROUP],
69                 [set group name to run nagios]),
70         with_nagios_group=$withval,
71         with_nagios_group=nagios)
72 AC_SUBST(with_nagios_user)
73 AC_SUBST(with_nagios_group)
74 INSTALL_OPTS="-o $with_nagios_user -g $with_nagios_group"
75 AC_SUBST(INSTALL_OPTS)
77 AC_ARG_WITH(trusted_path,
78         ACX_HELP_STRING([--with-trusted-path=PATH],
79                 [sets trusted path for executables called by scripts (default=/bin:/sbin:/usr/bin:/usr/sbin)]),
80         with_trusted_path=$withval,
81         with_trusted_path=/bin:/sbin:/usr/bin:/usr/sbin)
82 AC_SUBST(with_trusted_path)
84 EXTRAS=
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                            [sets path to openssl installation]) AC_HELP_STRING([--without-openssl], [disable openssl]),)
122 AC_ARG_WITH(gnutls,
123             ACX_HELP_STRING([--with-gnutls=PATH],
124                             [path to gnutls installation root]) AC_HELP_STRING([--without-gnutls], [disable gnutls]),)
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"
140 dnl
141 dnl Check for miscellaneous stuff
142 dnl 
144 case $host_vender-$host_os in
145 sun*)
146         AC_DEFINE(__EXTENSIONS__,1,[Sun's netdb.h needs this for getaddrinfo])
147         ;;
148 osf*)
149         AC_DEFINE(_OSF_SOURCE,1,[OSF needs this for getaddrinfo])
150         ;;
151 esac
153 dnl
154 dnl Checks for libraries.
155 dnl
157 AC_CHECK_LIB(dce,main,SOCKETLIBS="$SOCKETLIBS -ldce")
158 AC_CHECK_LIB(nsl,main,SOCKETLIBS="$SOCKETLIBS -lnsl")
159 AC_CHECK_LIB(socket,socket,SOCKETLIBS="$SOCKETLIBS -lsocket")
160 AC_CHECK_LIB(resolv,main,SOCKETLIBS="$SOCKETLIBS -lresolv")
161 AC_SUBST(SOCKETLIBS)
163 dnl
164 dnl check for math-related functions needing -lm
165 AC_CHECK_HEADERS(math.h)
166 AC_CHECK_LIB(m,floor,MATHLIBS="-lm")
167 AC_SUBST(MATHLIBS)
169 dnl Check for PostgreSQL libraries
170 _SAVEDLIBS="$LIBS"
171 _SAVEDCPPFLAGS="$CPPFLAGS"
172 AC_ARG_WITH(pgsql,
173         ACX_HELP_STRING([--with-pgsql=DIR],
174                 [sets path to pgsql installation]),
175         PGSQL=$withval,)
176 AC_CHECK_LIB(crypt,main)
177 if test "$ac_cv_lib_crypt_main" = "yes"; then
178   if test -n "$PGSQL"; then
179     LDFLAGS="$LDFLAGS -L$PGSQL/lib"
180     CPPFLAGS="$CPPFLAGS -I$PGSQL/include"
181   fi
182   AC_CHECK_LIB(pq,PQsetdbLogin,,,-lcrypt)
183   if test "$ac_cv_lib_pq_PQsetdbLogin" = "yes"; then
184     AC_CHECK_HEADERS(pgsql/libpq-fe.h)
185     AC_CHECK_HEADERS(postgresql/libpq-fe.h)
186     AC_CHECK_HEADERS(libpq-fe.h)
187     if [[ -n "$PGSQL" -a "$ac_cv_header_libpq_fe_h" = "yes" ]]; then
188       PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
189       PGINCLUDE="-I$PGSQL/include"
190     elif test  "$ac_cv_header_pgsql_libpq_fe_h" = "yes"; then
191       PGLIBS="-lpq -lcrypt"
192       PGINCLUDE="-I/usr/include/pgsql"
193     elif test  "$ac_cv_header_postgresql_libpq_fe_h" = "yes"; then
194       PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
195       PGINCLUDE="-I/usr/include/postgresql"
196     elif test  "$ac_cv_header_libpq_fe_h" = "yes"; then
197       PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
198       PGINCLUDE="-I$PGSQL/include"
199     fi
200     if test -z "$PGINCLUDE"; then
201       AC_MSG_WARN([Skipping PostgreSQL plugin (check_pgsql)])
202       AC_MSG_WARN([install PostgreSQL headers to compile this plugin (see REQUIREMENTS).])
203     else
204       AC_SUBST(PGLIBS)
205       AC_SUBST(PGINCLUDE)
206       EXTRAS="$EXTRAS check_pgsql"
207     fi
208   else
209     AC_MSG_WARN([Skipping PostgreSQL plugin (check_pgsql)])
210     AC_MSG_WARN([LIBS="$LIBS" CPPFLAGS="$CPPFLAGS"])
211     AC_MSG_WARN([install PostgreSQL libs to compile this plugin (see REQUIREMENTS).])
212   fi
213 else
214   AC_MSG_WARN([Skipping PostgreSQL plugin (check_pgsql)])
215   AC_MSG_WARN([install lib crypt and PostgreSQL libs to compile this plugin (see REQUIREMENTS).])
216 fi
217 LIBS="$_SAVEDLIBS"
218 CPPFLAGS="$_SAVEDCPPFLAGS"
220 dnl Check for radius libraries
221 _SAVEDLIBS="$LIBS"
222 AC_CHECK_LIB(radiusclient,rc_read_config)
223 if test "$ac_cv_lib_radiusclient_rc_read_config" = "yes"; then
224   EXTRAS="$EXTRAS check_radius"
225         RADIUSLIBS="-lradiusclient"
226   AC_SUBST(RADIUSLIBS)
227 else
228   AC_MSG_WARN([Skipping radius plugin])
229   AC_MSG_WARN([install radius libs to compile this plugin (see REQUIREMENTS).])
230 fi
231 LIBS="$_SAVEDLIBS"
233 dnl Check for LDAP libraries
234 _SAVEDLIBS="$LIBS"
235 AC_CHECK_LIB(ldap,main,,,-llber)
236 if test "$ac_cv_lib_ldap_main" = "yes"; then
237   LDAPLIBS="-lldap -llber"\
238   LDAPINCLUDE="-I/usr/include/ldap"
239   AC_SUBST(LDAPLIBS)
240   AC_SUBST(LDAPINCLUDE)
241   AC_CHECK_FUNCS(ldap_set_option)
242   EXTRAS="$EXTRAS check_ldap"
243         AC_CHECK_FUNCS(ldap_init ldap_set_option ldap_get_option ldap_start_tls_s)
244 else
245   AC_MSG_WARN([Skipping LDAP plugin])
246   AC_MSG_WARN([install LDAP libs to compile this plugin (see REQUIREMENTS).])
247 fi
248 LIBS="$_SAVEDLIBS"
251 dnl Check for mysql libraries
252 _SAVEDLIBS="$LIBS"
253 _SAVEDCPPFLAGS="$CPPFLAGS"
254 AC_ARG_WITH(mysql,
255         ACX_HELP_STRING([--with-mysql=DIR],
256                 [sets path to mysql installation (assumes lib/mysql and include subdirs]),
257         MYSQL=$withval,)
258 if test -n "$MYSQL"; then
259   MYSQLLIBDIR=$MYSQL/lib/mysql
260   CPPFLAGS="-I$MYSQL/include"
261   AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz" check_mysql_LDFLAGS="-L$MYSQLLIBDIR ",,-L$MYSQLLIBDIR -lz)
262   AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient")
263 elif test -f /usr/lib/libmysqlclient.so; then
264   AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz",,-lz)
265   AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient")
266 elif test -f /usr/lib/libmysqlclient.a; then
267   AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz",,-lz)
268   AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient")
269 elif test -f /usr/lib/mysql/libmysqlclient.so; then
270   AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz" check_mysql_LDFLAGS="-L/usr/lib/mysql",,-L/usr/lib/mysql -lz)
271   AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient" check_mysql_LDFLAGS="-L/usr/lib/mysql",,-L/usr/lib/mysql)
272 elif test -f /usr/lib/mysql/libmysqlclient.a; then
273   AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz" check_mysql_LDFLAGS="-L/usr/lib/mysql",,-L/usr/lib/mysql -lz)
274   AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient" check_mysql_LDFLAGS="-L/usr/lib/mysql",,-L/usr/lib/mysql)
275 fi
276 if test "$ac_cv_lib_mysqlclient_mysql_init" = "yes" -o "$ac_cv_lib_mysqlclient_mysql_close" = "yes"; then
277   AC_CHECK_HEADERS(mysql/mysql.h mysql/errmsg.h, MYSQLINCLUDE="-I$MYSQL/include" )
278   if test "$ac_cv_header_mysql_mysql_h" = "yes" -a "$ac_cv_header_mysql_errmsg_h" = "yes"; then
279     EXTRAS="$EXTRAS check_mysql"
280     AC_SUBST(MYSQLINCLUDE)
281     AC_SUBST(MYSQLLIBS)
282     AC_SUBST(check_mysql_LDFLAGS)
283   else
284     AC_MSG_WARN([Skipping mysql plugin])
285     AC_MSG_WARN([install mysql client headers to compile this plugin (see REQUIREMENTS).])
286   fi
287 else
288   AC_MSG_WARN([Skipping mysql plugin])
289   AC_MSG_WARN([install mysql client libs to compile this plugin (see REQUIREMENTS).])
290 fi
291 CPPFLAGS="$_SAVEDCPPFLAGS $MYSQLINCLUDE"
292 LIBS="$_SAVEDLIBS"
294 AC_CHECK_HEADERS(unistd.h)
296 dnl Check for AF_INET6 support - unistd.h required for Darwin
297 AC_CACHE_CHECK([for IPv6 support], with_ipv6, [
298         AC_TRY_COMPILE([#ifdef HAVE_UNISTD_H
299                         #include <unistd.h>
300                         #endif
301                         #include <netinet/in.h>
302                         #include <sys/socket.h>],
303                         [struct sockaddr_in6 sin6;
304                         void *p;
306                         sin6.sin6_family = AF_INET6;
307                         sin6.sin6_port = 587;
308                         p = &sin6.sin6_addr;],
309                         [with_ipv6=yes], 
310                         [with_ipv6=no])
311         ])
313 if test x"$with_ipv6" != xno ; then
314         AC_DEFINE(USE_IPV6,1,[Enable IPv6 support])
315 fi
317 dnl #########################################################################
318 dnl Check if Posix getaddrinfo() is available.  It is also possible to use
319 dnl the version from the lwres library distributed with BIND.
320 dnl #########################################################################
321 AC_ARG_ENABLE([emulate-getaddrinfo],
322               ACX_HELP_STRING([--enable-emulate-getaddrinfo],
323                              [enable getaddrinfo emulation (default=no)]),
324               ,
325               enable_emulate_getaddrinfo=no)
327 AC_ARG_WITH(lwres,
328             ACX_HELP_STRING([--with-lwres=DIR],
329                            [use lwres library for getaddrinfo (default=no)]),
330             ,
331             with_lwres=no)
333 dnl ## enable force to test getaddrinfo.c
334 if test x$enable_emulate_getaddrinfo = xforce ; then
335         enable_emulate_getaddrinfo=yes
336         have_getaddrinfo=no
337 else
339 have_getaddrinfo=no
340 if test x$with_lwres != xno ; then
341         if test "$with_lwres" != yes ; then
342                    CPPFLAGS="-I${with_lwres}/include $CPPFLAGS"
343                    LDFLAGS="-L${with_lwres}/lib $LDFLAGS"
344         fi
345         AC_CHECK_HEADERS(lwres/netdb.h, ,
346                         [AC_MSG_ERROR([cannot find <lwres/netdb.h>])])
347         AC_CHECK_LIB(lwres, lwres_getaddrinfo, ,
348                      [AC_MSG_ERROR([cannot find the lwres library])],
349                      -lnsl -lpthread)
350         have_getaddrinfo=yes
351 fi
353 if test x$have_getaddrinfo != xyes ; then
354         AC_SEARCH_LIBS(getaddrinfo, socket resolv bind nsl c_r cr, have_getaddrinfo=yes)
355 fi
357 dnl # Special nonsense for systems that actually have getaddrinfo but
358 dnl # redefine the name to something else, e.g. OSF
359 if test x$have_getaddrinfo != xyes ; then
360         AC_MSG_CHECKING(if getaddrinfo is redefined in netdb.h)
361         AC_TRY_LINK([
362 #               include <netdb.h>
363         ], [
364                 struct addrinfo hints, *res;
365                 int err;
367                 err = getaddrinfo ("host", "service", &hints, &res);
368         ], [
369                 have_getaddrinfo=yes
370                 AC_MSG_RESULT(yes)
371         ], [AC_MSG_RESULT(no)])
372 fi
374 fi
376 if test x$have_getaddrinfo != xno ; then
377         if test x$enable_emulate_getaddrinfo != xno ; then
378                 AC_MSG_ERROR([getaddrinfo found but emulate-getaddrinfo was enabled])
379         fi
380         AC_DEFINE(HAVE_GETADDRINFO, 1,
381                   [Does system provide RFC 2553/Posix getaddrinfo?])
382 else
383         if test x$enable_emulate_getaddrinfo != xyes ; then
384 dnl                AC_MSG_ERROR([getaddrinfo not found: try --with-lwres or --enable-emulate-getaddrinfo])
385                enable_emulate_getaddrinfo=yes
386                AC_MSG_WARN([enabling getaddrinfo emulation])
387         fi
388         EXTRA_NETOBJS="$EXTRA_NETOBJS getaddrinfo.o"
389 fi
391 if test x"$enable_emulate_getaddrinfo" != xno ; then
392     have_resolver=no
394   dnl  Try for getipnodebyname
395     AC_SEARCH_LIBS(getipnodebyname, resolv bind nsl c_r cr, have_resolver=yes)
396     if test x"$have_resolver" != xno ; then
397          AC_DEFINE(HAVE_GETIPNODEBYNAME, 1,
398                    [Set when getipnodebyname is available])
399     fi
401   dnl  Try for gethostbyname_r
402     if test x"$have_resolver" = xno ; then
403         AC_SEARCH_LIBS(gethostbyname_r, resolv bind nsl c_r cr,
404                        [have_resolver=yes
405                         ACX_WHICH_GETHOSTBYNAME_R])
406     fi
408   dnl  Try for gethostbyname
409     if test x"$have_resolver" = xno ; then
410         if test x"$enable_pthreads" != xno ; then
411             AC_MSG_WARN([using threads but cannot find gethostbyname_r or getipnodebyname])
412         fi
413         AC_SEARCH_LIBS(gethostbyname, resolv bind nsl, ,
414                        [AC_MSG_ERROR([cannot find gethostbyname])])
415     fi
416     EXTRA_NETOBJS="$EXTRA_NETOBJS gethostbyname.o"
418 fi
420 dnl Checks for Kerberos. Must come before openssl checks for Redhat EL 3
421 AC_CHECK_HEADERS(krb5.h,FOUNDINCLUDE=yes,FOUNDINCLUDE=no)
422 if test "$FOUNDINCLUDE" = "no"; then
423   _SAVEDCPPFLAGS="$CPPFLAGS"
424   CPPFLAGS="$_SAVEDCPPFLAGS -I/usr/kerberos/include"
425   unset ac_cv_header_krb5_h
426   AC_CHECK_HEADERS(krb5.h,
427                    KRB5INCLUDE="-I/usr/kerberos/include"
428                    FOUNDINCLUDE=yes,
429                    FOUNDINCLUDE=no)
430 fi
431 AC_SUBST(KRBINCLUDE)
432 if test "$FOUNDINCLUDE" = "no"; then
433   CPPFLAGS="$_SAVEDCPPFLAGS"
434 fi
437 dnl openssl detection/configuration
438 if ! test "$with_openssl" = "no"; then
439         dnl Check for OpenSSL location if it wasn't already specified
440         if ! test -d "$with_openssl"; then
441                 for d in $OPENSSL_DIRS; do
442                         if test -x ${d}/bin/openssl || test -x ${d}/sbin/openssl ; then
443                                 with_openssl=$d
444                         fi
445                 done
446         fi
448         _SAVEDCPPFLAGS="$CPPFLAGS"
449         _SAVEDLDFLAGS="$LDFLAGS"
450         dnl Check for OpenSSL header files
451         unset FOUNDINCLUDE
452         CPPFLAGS="$CPPFLAGS -I$OPENSSL/include"
453         LDFLAGS="$LDFLAGS -R$OPENSSL/lib"
455         dnl check for openssl in $dir/include/openssl
456         AC_CHECK_HEADERS(openssl/ssl.h openssl/x509.h openssl/rsa.h openssl/pem.h openssl/crypto.h openssl/err.h,
457                          SSLINCLUDE="-I$OPENSSL/include"
458                          FOUNDINCLUDE=yes,
459                          FOUNDINCLUDE=no)
460         dnl else check to see if $dir/include has it
461         if test "$FOUNDINCLUDE" = "no"; then
462                 AC_CHECK_HEADERS(ssl.h x509.h rsa.h pem.h crypto.h err.h,
463                                  SSLINCLUDE="-I$OPENSSL/include"
464                                  FOUNDINCLUDE=yes,
465                                  FOUNDINCLUDE=no)
466         fi
467         AC_SUBST(SSLINCLUDE)
468         dnl if we didn't find it, reset CPPFLAGS
469         if test "$FOUNDINCLUDE" = "no"; then
470                 CPPFLAGS="$_SAVEDCPPFLAGS"
471                 LDFLAGS="$_SAVEDLDFLAGS"
472         fi
474         dnl Check for crypto lib
475         _SAVEDLIBS="$LIBS"
476         LIBS="-L${with_openssl}/lib"
477         AC_CHECK_LIB(crypto,CRYPTO_lock)
478         if test "$ac_cv_lib_crypto_CRYPTO_lock" = "yes"; then
479                 dnl Check for SSL lib
480                 AC_CHECK_LIB(ssl,main, SSLLIBS="-lssl -lcrypto",,-lcrypto)
481         fi
482         LIBS="$_SAVEDLIBS"
484         dnl test headers and libs to decide whether check_http should use SSL
485         if test "$ac_cv_lib_crypto_CRYPTO_lock" = "yes"; then
486                 if test "$ac_cv_lib_ssl_main" = "yes"; then
487                         if test "$FOUNDINCLUDE" = "yes"; then
488                                 FOUNDOPENSSL="yes"
489                         fi
490                 fi
491         fi
492 fi
495 dnl check for gnutls if openssl isn't found (or is disabled)
496 if test ! "$FOUNDOPENSSL" = "yes" && test ! "$with_gnutls" = "no"; then
497         if test ! "$with_gnutls" = ""; then
498                 CPPFLAGS="$CPPFLAGS -I${with_gnutls}/include"
499         elif test ! "$LIBGNUTLS_CONFIG" = ""; then
500                 CPPFLAGS="$CPPFLAGS -I`$LIBGNUTLS_CONFIG --prefix`"
501         fi
502         AC_CHECK_HEADERS([gnutls/openssl.h],FOUNDGNUTLS="yes",)
503         if test "$FOUNDGNUTLS" = "yes"; then
504                 AC_CHECK_LIB(gnutls-openssl,main,SSLLIBS="-lgnutls-openssl")
505         fi
506 fi
507 dnl end check for gnutls
509 if test "$FOUNDOPENSSL" = "yes" || test "$FOUNDGNUTLS" = "yes"; then
510         check_tcp_ssl="check_simap check_spop check_jabber check_nntps check_ssmtp"
511         AC_SUBST(check_tcp_ssl)
512         AC_SUBST(SSLLIBS)
513         AC_DEFINE(HAVE_SSL,1,[Define if SSL libraries are found])
514         if test "$FOUNDOPENSSL" = "yes"; then
515                 AC_DEFINE(USE_OPENSSL,1,[Define if using OpenSSL libraries])
516                 with_openssl="yes"
517                 with_gnutls="no"
518         else
519                 AC_DEFINE(USE_GNUTLS,1,[Define if using gnutls libraries])
520                 with_gnutls="yes"
521                 with_openssl="no"
522         fi
523 else
524         dnl else deliberately disabled or no ssl support available
525         AC_MSG_WARN([OpenSSL or GnuTLS libs could not be found or were disabled])
526         with_openssl="no"
527         with_gnutls="no"
528 fi
530 dnl
531 dnl Checks for header files.
532 dnl
534 AC_HEADER_STDC
535 AC_HEADER_TIME
536 AC_HEADER_SYS_WAIT
537 AC_CHECK_HEADERS(signal.h strings.h string.h syslog.h uio.h errno.h regex.h sys/types.h sys/time.h sys/socket.h sys/loadavg.h sys/un.h)
538 AC_CHECK_HEADERS(features.h stdarg.h sys/unistd.h ctype.h stdlib.h)
540 dnl Checks for typedefs, structures, and compiler characteristics.
541 AC_C_CONST
542 AC_STRUCT_TM
543 AC_TYPE_PID_T
544 AC_TYPE_SIZE_T
545 AC_TYPE_SIGNAL
547 AC_CACHE_CHECK([for va_copy],ac_cv_HAVE_VA_COPY,[
548 AC_TRY_LINK([#include <stdarg.h>
549 va_list ap1,ap2;], [va_copy(ap1,ap2);],
550 ac_cv_HAVE_VA_COPY=yes,
551 ac_cv_HAVE_VA_COPY=no)])
552 if test x"$ac_cv_HAVE_VA_COPY" = x"yes"; then
553     AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available])
554 else    
555     AC_CACHE_CHECK([for __va_copy],ac_cv_HAVE___VA_COPY,[
556     AC_TRY_LINK([#include <stdarg.h>
557     va_list ap1,ap2;], [__va_copy(ap1,ap2);],
558     ac_cv_HAVE___VA_COPY=yes,
559     ac_cv_HAVE___VA_COPY=no)])
560     if test x"$ac_cv_HAVE___VA_COPY" = x"yes"; then
561         AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available])
562     fi
563 fi
565 AC_CHECK_FUNCS(vsnprintf snprintf asprintf vasprintf)
566 AC_CACHE_CHECK([for C99 vsnprintf],ac_cv_HAVE_C99_VSNPRINTF,[
567 AC_TRY_RUN([
568 #include <sys/types.h>
569 #include <stdarg.h>
570 void foo(const char *format, ...) { 
571        va_list ap;
572        int len;
573        char buf[5];
575        va_start(ap, format);
576        len = vsnprintf(buf, 0, format, ap);
577        va_end(ap);
578        if (len != 5) exit(1);
580        va_start(ap, format);
581        len = vsnprintf(0, 0, format, ap);
582        va_end(ap);
583        if (len != 5) exit(1);
585        if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
587        exit(0);
589 main() { foo("hello"); }
590 ],
591 ac_cv_HAVE_C99_VSNPRINTF=yes,ac_cv_HAVE_C99_VSNPRINTF=no,ac_cv_HAVE_C99_VSNPRINTF=cross)])
592 if test x"$ac_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
593     AC_DEFINE(HAVE_C99_VSNPRINTF,1,[Define if system has C99 compatible vsnprintf])
594 fi
596 AC_TRY_COMPILE([#include <sys/time.h>],
597                [struct timeval *tv;
598                 struct timezone *tz;],
599                AC_DEFINE(HAVE_STRUCT_TIMEVAL,1,[Define if we have a timeval structure])
600                AC_TRY_COMPILE([#include <sys/time.h>],
601                               [struct timeval *tv;
602                                struct timezone *tz;
603                                gettimeofday(tv, tz);],
604                               AC_DEFINE(HAVE_GETTIMEOFDAY,1,[Define if gettimeofday is found]),
605                               AC_DEFINE(NEED_GETTIMEOFDAY,1,[Define if gettimeofday is needed])))
607 dnl Checks for library functions.
608 AC_CHECK_FUNCS(memmove select socket strdup strstr strtod strtol strtoul floor)
610 AC_MSG_CHECKING(return type of socket size)
611 AC_TRY_COMPILE([#include <stdlib.h>
612                 #include <sys/types.h>
613                 #include <sys/socket.h>],
614                [int a = send(1, (const void *) buffer, (size_t *) 0, (int *) 0);],
615                ac_cv_socket_size_type=["size_t"]
616                 AC_MSG_RESULT(size_t),
617                ac_cv_socket_size_type=["int"]
618                 AC_MSG_RESULT(int))
620 AC_DEFINE_UNQUOTED(SOCKET_SIZE_TYPE, $ac_cv_socket_size_type ,
621         [Define type of socket size])
623 if test -f "/proc/loadavg"
624 then
625   AC_DEFINE(HAVE_PROC_LOADAVG,1,[Define if /proc/loadavg or similar exists])
626   AC_DEFINE_UNQUOTED(PROC_LOADAVG,"/proc/loadavg",[Location of /proc/loadavg])
627 fi
629 dnl #### Process table test
631 AC_PATH_PROG(PATH_TO_PS,ps)
633 AC_MSG_CHECKING(for ps syntax)
635 dnl Now using the pst3/kmem hack for solaris systems to avoid truncation
636 AM_CONDITIONAL(WANT_PST3, false)
637 if test "$ac_cv_uname_s" = "SunOS"; then
638         #
639         # this is a very, very ugly hack, to hardcode the location for plugins
640         #
641         if test "$libexecdir" = '${exec_prefix}/libexec'; then
642                 if test "$exec_prefix" = "NONE"; then
643                         if test "$prefix" = "NONE"; then
644                                 pst3="$ac_default_prefix/libexec/pst3"
645                         else
646                                 pst3="$prefix/libexec/pst3"
647                         fi
648                 else
649                         pst3="$exec_prefix/libexec/pst3"
650                 fi
651         else
652                 pst3="$libexecdir/pst3"
653         fi
654         ac_cv_ps_command="$pst3"
655         ac_cv_ps_format="%s %d %d %d %d %f %s %n"
656         ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
657         ac_cv_ps_cols=8
658         AC_MSG_RESULT([using nagios-plugins internal ps for solaris])
659         AM_CONDITIONAL(WANT_PST3, true)
661 dnl Some gnu/linux systems (debian for one) don't like -axwo and need axwo.
662 dnl so test for this first...
663 elif ps axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
664         egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null
665 then
666         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
667         ac_cv_ps_command="$PATH_TO_PS axwo 'stat uid pid ppid vsz rss pcpu comm args'"
668         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
669         ac_cv_ps_cols=9
670         AC_MSG_RESULT([$ac_cv_ps_command])
672 dnl For OpenBSD 3.2 & 3.3. Must come before ps -weo
673 dnl Should also work for FreeBSD 5.2.1 and 5.3
674 dnl  STAT UCOMM              VSZ   RSS USER      PPID COMMAND
675 elif ps -axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
676         egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null
677 then
678         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
679         ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid pid ppid vsz rss pcpu comm args'"
680         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
681         ac_cv_ps_cols=9
682         AC_MSG_RESULT([$ac_cv_ps_command])
684 dnl Some *BSDs have different format for ps. This is mainly to catch FreeBSD 4. 
685 dnl Limitation: Only first 16 chars returned for ucomm field
686 dnl Must come before ps -weo
687 elif ps -axwo 'stat uid pid ppid vsz rss pcpu ucomm command' 2>/dev/null | \
688         egrep -i ["^ *STAT +UID +PID +PPID +VSZ +RSS +%CPU +UCOMM +COMMAND"] > /dev/null
689 then
690         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
691         ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid pid ppid vsz rss pcpu ucomm command'"
692         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
693         ac_cv_ps_cols=9
694         AC_MSG_RESULT([$ac_cv_ps_command])
696 dnl  STAT UCOMM              VSZ   RSS USER       UID  PPID COMMAND
697 elif ps -weo 'stat comm vsz rss user uid pid ppid etime args' 2>/dev/null | \
698         egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[ID]+ +P[PID]+ +[ELAPSD]+ +[RGSCOMDNA]+"] >/dev/null
699 then
700         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procetime,procprog,&pos]"
701         ac_cv_ps_command="$PATH_TO_PS -weo 'stat uid pid ppid vsz rss pcpu etime comm args'"
702         ac_cv_ps_format="%s %d %d %d %d %d %f %s %s %n"
703         ac_cv_ps_cols=10
704         AC_MSG_RESULT([$ac_cv_ps_command])
706 dnl FreeBSD
707 elif ps waxco 'state command vsz rss uid user pid ppid' 2>/dev/null | \
708         egrep -i ["^STAT +COMMAND +VSZ +RSS +UID +USER +PID +PPID"] >/dev/null
709 then
710         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
711         ac_cv_ps_command="$PATH_TO_PS waxco 'state uid pid ppid vsz rss pcpu command command'"
712         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
713         ac_cv_ps_cols=9
714         AC_MSG_RESULT([$ac_cv_ps_command])
716 dnl BSD-like mode in RH 6.1
717 elif ps waxno 'state comm vsz rss uid user pid ppid args' 2>/dev/null | \
718         egrep -i ["^S +COMMAND +VSZ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
719 then
720         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
721         ac_cv_ps_command="$PATH_TO_PS waxno 'state uid pid ppid vsz rss pcpu comm args'"
722         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
723         ac_cv_ps_cols=9
724         AC_MSG_RESULT([$ac_cv_ps_command])
726 dnl SunOS 4.1.3:
727 dnl  F  UID  PID  PPID  CP  PRI  NI  SZ  RSS  WCHAN  STAT  TT  TIME  COMMAND
728 dnl Need the head -1 otherwise test will work because arguments are found
729 elif ps -laxnwww 2>/dev/null | head -1 | \
730         egrep -i ["^ *F(LAGS)? +UID +PID +PPID +CP +PRI +NI +(SZ)|(VSZ)|(SIZE) +RSS +WCHAN +STAT? +TTY? +TIME +COMMAND"] >/dev/null
731 then
732         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]"
733         ac_cv_ps_command="$PATH_TO_PS -laxnwww"
734         ac_cv_ps_format="%*s %d %d %d %*s %*s %*s %d %d %*s %s %*s %*s %n%s"
735         ac_cv_ps_cols=9
736         AC_MSG_RESULT([$ac_cv_ps_command])
738 dnl Debian Linux / procps v1.2.9:
739 dnl  FLAGS   UID   PID  PPID PRI  NI   SIZE   RSS WCHAN       STA TTY TIME COMMAND
740 dnl    100     0     1     0   0   0    776    76  c0131c8c   S  ffff  0:11 init [2]
741 dnl
742 elif ps laxnwww 2>/dev/null | \
743         egrep -i ["^ *F(LAGS)? +UID +PID +PPID +PRI +NI +(VSZ)|(SIZE) +RSS +WCHAN +STAT? TTY +TIME +COMMAND"] >/dev/null
744 then
745         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,procstat,&procvsz,&procrss,&pos,procprog]"
746         ac_cv_ps_command="$PATH_TO_PS laxnwww"
747         ac_cv_ps_format="%*s %d %d %d %*s %*s %d %d %*s %s %*s %*s %n%s"
748         ac_cv_ps_cols=9
749         AC_MSG_RESULT([$ac_cv_ps_command])
751 dnl OpenBSD (needs to come early because -exo appears to work, but does not give all procs)
752 elif ps -axo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
753         egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[PID]+ +P[PID]+ +[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 -axo 'stat 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 dnl Tru64 - needs %*[ +<>] in PS_FORMAT. 
762 dnl Has /usr/bin/ps and /sbin/ps - force sbin version
763 dnl Can't use vsize and rssize because comes back with text (eg, 1.5M instead 
764 dnl of 1500). Will need big changes to check_procs to support
765 elif /sbin/ps -eo 'stat uid pid ppid pcpu etime comm args' 2>/dev/null | \
766         egrep -i ["^ *S +[UID]+ +[PID]+ +[PID]+ +[%CPU]+ +[ELAPSD]+ +[COMMAND]+ +[COMMAND]+"] > /dev/null
767 then
768         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procpcpu,procetime,procprog,&pos]"
769         ac_cv_ps_command="/sbin/ps -eo 'stat uid pid ppid pcpu etime comm args'"
770         ac_cv_ps_format=["%s%*[ +<>] %d %d %d %f %s %s %n"]
771         ac_cv_ps_cols=8
772         AC_MSG_RESULT([$ac_cv_ps_command])
774 elif ps -eo 's comm vsz rss user uid pid ppid args' 2>/dev/null | \
775         egrep -i ["^S[TAUES]* +C[OMDNA]+ +[VSIZE]+ +U[SER]+ +U[ID]+ +P[PID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null
776 then
777         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
778         ac_cv_ps_command="$PATH_TO_PS -eo 's uid pid ppid vsz rss pcpu comm args'"
779         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
780         ac_cv_ps_cols=9
781         AC_MSG_RESULT([$ac_cv_ps_command])
783 dnl AIX 4.3.3 and 5.1 do not have an rss field
784 elif ps -eo 'stat uid pid ppid vsz pcpu comm args' 2>/dev/null | \
785         egrep -i ["^ *S[TAUES]* +UID +PID +PPID +VSZ +%CPU +COMMAND +COMMAND"] >/dev/null
786 then
787         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procpcpu,procprog,&pos]"
788         ac_cv_ps_command="$PATH_TO_PS -eo 'stat uid pid ppid vsz pcpu comm args'"
789         ac_cv_ps_format="%s %d %d %d %d %f %s %n"
790         ac_cv_ps_cols=8
791         AC_MSG_RESULT([$ac_cv_ps_command - with no RSS])
793 dnl Solaris 2.6
794 elif ps -Ao 's comm vsz rss uid user pid ppid args' 2>/dev/null | \
795         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
796 then
797         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
798         ac_cv_ps_command="$PATH_TO_PS -Ao 's uid pid ppid vsz rss pcpu comm args'"
799         # There must be no space between the %s and %n due to a wierd problem in sscanf where
800         # it will return %n as longer than the line length
801         ac_cv_ps_format="%s %d %d %d %d %d %f %s%n"
802         ac_cv_ps_cols=9
803         AC_MSG_RESULT([$ac_cv_ps_command])
805 elif ps -Ao 'status comm vsz rss uid user pid ppid args' 2>/dev/null | \
806         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
807 then
808         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
809         ac_cv_ps_command="$PATH_TO_PS -Ao 'status uid pid ppid vsz rss pcpu comm args'"
810         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
811         ac_cv_ps_cols=9
812         AC_MSG_RESULT([$ac_cv_ps_command])
814 elif ps -Ao 'state comm vsz rss uid user pid ppid args' 2>/dev/null | \
815         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
816 then
817         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
818         ac_cv_ps_command="$PATH_TO_PS -Ao 'state uid pid ppid vsz rss pcpu comm args'"
819         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
820         ac_cv_ps_cols=9
821         AC_MSG_RESULT([$ac_cv_ps_command])
823 dnl wonder who takes state instead of stat
824 elif ps -ao 'state command vsz rss user pid ppid args' 2>/dev/null | \
825         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
826 then
827         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
828         ac_cv_ps_command="$PATH_TO_PS -ao 'state uid pid ppid vsz rss pcpu command args'"
829         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
830         ac_cv_ps_cols=8
831         AC_MSG_RESULT([$ac_cv_ps_command])
833 dnl IRIX 53
834 elif ps -el 2>/dev/null | \
835         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
836 then
837         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&pos,procprog]"
838         ac_cv_ps_command="$PATH_TO_PS -el (IRIX 53)"
839         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %d %d %*s %*s %*s %n%s"
840         ac_cv_ps_cols=8
841         AC_MSG_RESULT([$ac_cv_ps_command])
843 dnl IRIX 63
844 elif ps -el 2>/dev/null | \
845         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +ADDR +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
846 then
847         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
848         ac_cv_ps_command="$PATH_TO_PS -el (IRIX 63)"
849         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
850         ac_cv_ps_cols=6
851         AC_MSG_RESULT([$ac_cv_ps_command])
853 dnl AIX 4.1:
854 dnl     F S      UID   PID  PPID   C PRI NI ADDR  SZ  RSS   WCHAN    TTY  TIME CMD
855 dnl    303 A        0     0     0 120  16 -- 1c07  20   24              -  0:45 swapper
856 elif ps -el 2>/dev/null | \
857         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +ADDR +SZ +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
858 then
859         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
860         ac_cv_ps_command="$PATH_TO_PS -el (AIX 4.1 and HP-UX)"
861         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
862         ac_cv_ps_cols=6
863         AC_MSG_RESULT([$ac_cv_ps_command])
865 dnl AIX?
866 elif ps glaxen 2>/dev/null | \
867         egrep -i ["^ *F +UID +PID +PPID +PRI +NI +VSZ +RSS +WCHAN +STAT +TTY +TIME +COMMAND"] >/dev/null
868 then
869         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]"
870         ac_cv_ps_command="$PATH_TO_PS glaxen"
871         ac_cv_ps_format="%*s %d %d %d %*s %*s %d %d %*s %s %*s %*s %n%s"
872         ac_cv_ps_cols=8
873         AC_MSG_RESULT([$ac_cv_ps_command])
875 dnl MacOSX / Darwin
876 dnl TODO: MacOSX has commands with spaces which will cause problems to PS_FORMAT
877 dnl Some truncation will happen in UCOMM column
878 dnl STAT      VSZ    RSS   UID  PPID %CPU UCOMM            COMMAND
879 dnl Ss      52756  22496   501     1   6.9 Window Manager   /System/Library/CoreServices/WindowServer -daemon
880 elif ps wwaxo 'state vsz rss uid pid ppid pcpu ucomm command' 2>/dev/null | \
881         egrep -i ["^STAT +VSZ +RSS +UID +PPID +%CPU +UCOMM +COMMAND"] >/dev/null
882 then
883         ac_cv_ps_command="$PATH_TO_PS wwaxo 'state vsz rss uid pid ppid pcpu ucomm command'"
884         ac_cv_ps_varlist="[procstat,&procvsz,&procrss,&procuid,&procpid,&procppid,&procpcpu,procprog,&pos]"
885         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
886         ac_cv_ps_cols=8
887         AC_MSG_RESULT([$ac_cv_ps_command])
889 dnl UnixWare 
890 elif ps -Al 2>/dev/null | \
891         egrep -i ["^ *F +S +UID +PID +PPID +CLS +PRI +NI +C +ADDR +SZ +WCHAN +TTY +TIME +COMD"] >/dev/null
892 then
893         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
894         ac_cv_ps_command="$PATH_TO_PS -Al"
895         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
896         ac_cv_ps_cols=8
897         AC_MSG_RESULT([$ac_cv_ps_command])
899 else
900         AC_MSG_WARN([unable to find usable ps syntax - check_procs and check_nagios will not be compiled])
901 fi
903 if test -n "$ac_cv_ps_varlist" ; then
904         AC_DEFINE_UNQUOTED(PS_VARLIST,$ac_cv_ps_varlist,
905                 [Variable list for sscanf of 'ps' output])
906         AC_DEFINE_UNQUOTED(PS_COMMAND,"$ac_cv_ps_command",
907                 [Verbatim command to execute for ps in check_procs])
908         AC_DEFINE_UNQUOTED(PS_FORMAT,"$ac_cv_ps_format",
909                 [Format string for scanning ps output in check_procs])
910         AC_DEFINE_UNQUOTED(PS_COLS,$ac_cv_ps_cols,
911                 [Number of columns in ps command])
912         EXTRAS="$EXTRAS check_procs check_nagios"
913         if echo "$ac_cv_ps_varlist" | grep -q "procetime"; then
914                 AC_DEFINE(PS_USES_PROCETIME,"yes",
915                           [Whether the ps utility uses the "procetime" field])
916         fi
917 fi
919 AC_PATH_PROG(PATH_TO_PING,ping)
920 AC_PATH_PROG(PATH_TO_PING6,ping6)
922 AC_ARG_WITH(ping_command,
923         ACX_HELP_STRING([--with-ping-command=SYNTAX],
924                 [sets syntax for ICMP ping]),
925         with_ping_command=$withval,)
927 AC_MSG_CHECKING(for ICMP ping syntax)
928 ac_cv_ping_packets_first=no
929 ac_cv_ping_has_timeout=no
930 if test -n "$with_ping_command"
931 then
932         AC_MSG_RESULT([(command-line) $with_ping_command])
933         if test -n "$ac_cv_ping_packets_first"
934         then
935                 ac_cv_ping_packets_first=yes
936         fi
938 elif [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
939         $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
940         egrep -i "^round-trip|^rtt" >/dev/null
941 then
942         with_ping_command="$PATH_TO_PING -n -U -c %d %s"
943         ac_cv_ping_packets_first=yes
944         AC_MSG_RESULT([$with_ping_command])
946 elif $PATH_TO_PING -n -U -w 10 -c 1 127.0.0.1 2>/dev/null | \
947         egrep -i "^round-trip|^rtt" >/dev/null
948 then
949         with_ping_command="$PATH_TO_PING -n -U -w %d -c %d %s"
950         ac_cv_ping_packets_first=yes
951   ac_cv_ping_has_timeout=yes
952         AC_MSG_RESULT([$with_ping_command])
954 elif $PATH_TO_PING -n -U -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 -U -c %d %s"
958         ac_cv_ping_packets_first=yes
959         AC_MSG_RESULT([$with_ping_command])
961 elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \
962         egrep -i "^round-trip|^rtt" >/dev/null
963 then
964         with_ping_command="$PATH_TO_PING -n -c %d %s"
965         ac_cv_ping_packets_first=yes
966         AC_MSG_RESULT([$with_ping_command])
968 elif $PATH_TO_PING -n 127.0.0.1 -c 1 2>/dev/null | \
969         egrep -i "^round-trip|^rtt" >/dev/null
970 then
971         with_ping_command="$PATH_TO_PING -n %s -c %d"
972         AC_MSG_RESULT([$with_ping_command])
974 elif $PATH_TO_PING 127.0.0.1 -n 1 2>/dev/null | \
975         egrep -i "^round-trip|^rtt" >/dev/null
976 then
977         with_ping_command="$PATH_TO_PING %s -n %d"
978         AC_MSG_RESULT([$with_ping_command])
980 elif $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
981         egrep -i "^round-trip|^rtt" >/dev/null
982 then
983         with_ping_command="$PATH_TO_PING -n -s %s 56 %d"
984         AC_MSG_RESULT([$with_ping_command])
986 elif $PATH_TO_PING -n -h 127.0.0.1 -s 56 -c 1 2>/dev/null | \
987         egrep -i "^round-trip|^rtt" >/dev/null
988 then
989         with_ping_command="$PATH_TO_PING -n -h %s -s 56 -c %d"
990         AC_MSG_RESULT([$with_ping_command])
992 elif $PATH_TO_PING -n -s 56 -c 1 127.0.0.1 2>/dev/null | \
993         egrep -i "^round-trip|^rtt" >/dev/null
994 then
995         with_ping_command="$PATH_TO_PING -n -s 56 -c %d %s"
996         ac_cv_ping_packets_first=yes
997         AC_MSG_RESULT([$with_ping_command])
999 elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \
1000         egrep -i "^round-trip|^rtt" >/dev/null
1001 then
1002         with_ping_command="$PATH_TO_PING -n -c %d %s"
1003         ac_cv_ping_packets_first=yes
1004         AC_MSG_RESULT([$with_ping_command])
1006 else
1007         AC_MSG_WARN([unable to find usable ping syntax])
1008 fi
1010 AC_DEFINE_UNQUOTED(PING_COMMAND,"$with_ping_command",
1011         [path and args for ICMP ping command])
1013 if test "x$ac_cv_ping_packets_first" != "xno"
1014 then
1015         AC_DEFINE(PING_PACKETS_FIRST,1,
1016                 [Define if packet count must precede host])
1017 fi
1019 if test "x$ac_cv_ping_has_timeout" != "xno"
1020 then
1021         AC_DEFINE(PING_HAS_TIMEOUT,1,
1022                 [Define if ping has its own timeout option that should be set])
1023 fi
1025 AC_ARG_WITH(ping6_command,
1026         ACX_HELP_STRING([--with-ping6-command=SYNTAX],
1027                 [sets syntax for ICMPv6 ping]),
1028         with_ping6_command=$withval,)
1030 if test x"$with_ipv6" != xno ; then
1031 AC_MSG_CHECKING(for ICMPv6 ping syntax)
1032 ac_cv_ping6_packets_first=no
1033 if test -n "$with_ping6_command"
1034 then
1035         AC_MSG_RESULT([(command-line) $with_ping6_command])
1036         if test -n "$ac_cv_ping6_packets_first"
1037         then
1038                 ac_cv_ping6_packets_first=yes
1039         fi
1041 elif test "x$PATH_TO_PING6" != "x"; then
1042         if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
1043                 $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \
1044                 egrep -i "^round-trip|^rtt" >/dev/null
1045         then
1046                 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s"
1047                 ac_cv_ping6_packets_first=yes
1048                 AC_MSG_RESULT([$with_ping6_command])
1050         elif $PATH_TO_PING6 -n -U -w 10 -c 1 ::1 2>/dev/null | \
1051                 egrep -i "^round-trip|^rtt" >/dev/null
1052         then
1053                 with_ping6_command="$PATH_TO_PING6 -n -U -w %d -c %d %s"
1054                 ac_cv_ping6_packets_first=yes
1055                 ac_cv_ping_has_timeout=yes
1056                 AC_MSG_RESULT([$with_ping6_command])
1058         elif $PATH_TO_PING6 -n -U -c 1 ::1 2>/dev/null | \
1059                 egrep -i "^round-trip|^rtt" >/dev/null
1060         then
1061                 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s"
1062                 ac_cv_ping6_packets_first=yes
1063                 AC_MSG_RESULT([$with_ping6_command])
1065         elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \
1066                 egrep -i "^round-trip|^rtt" >/dev/null
1067         then
1068                 with_ping6_command="$PATH_TO_PING6 -n -c %d %s"
1069                 ac_cv_ping6_packets_first=yes
1070                 AC_MSG_RESULT([$with_ping6_command])
1072         elif $PATH_TO_PING6 -n ::1 -c 1 2>/dev/null | \
1073                 egrep -i "^round-trip|^rtt" >/dev/null
1074         then
1075                 with_ping6_command="$PATH_TO_PING6 -n %s -c %d"
1076                 AC_MSG_RESULT([$with_ping6_command])
1078         elif $PATH_TO_PING6 ::1 -n 1 2>/dev/null | \
1079                 egrep -i "^round-trip|^rtt" >/dev/null
1080         then
1081                 with_ping6_command="$PATH_TO_PING6 %s -n %d"
1082                 AC_MSG_RESULT([$with_ping6_command])
1084         elif $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \
1085                 egrep -i "^round-trip|^rtt" >/dev/null
1086         then
1087                 with_ping6_command="$PATH_TO_PING6 -n -s %s 56 %d"
1088                 AC_MSG_RESULT([$with_ping6_command])
1090         elif $PATH_TO_PING6 -n -h ::1 -s 56 -c 1 2>/dev/null | \
1091                 egrep -i "^round-trip|^rtt" >/dev/null
1092         then
1093                 with_ping6_command="$PATH_TO_PING6 -n -h %s -s 56 -c %d"
1094                 AC_MSG_RESULT([$with_ping6_command])
1096         elif $PATH_TO_PING6 -n -s 56 -c 1 ::1 2>/dev/null | \
1097                 egrep -i "^round-trip|^rtt" >/dev/null
1098         then
1099                 with_ping6_command="$PATH_TO_PING6 -n -s 56 -c %d %s"
1100                 ac_cv_ping6_packets_first=yes
1101                 AC_MSG_RESULT([$with_ping_command])
1103         elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \
1104                 egrep -i "^round-trip|^rtt" >/dev/null
1105         then
1106                 with_ping6_command="$PATH_TO_PING6 -n -c %d %s"
1107                 ac_cv_ping6_packets_first=yes
1108                 AC_MSG_RESULT([$with_ping6_command])
1110         fi
1112 elif test "x$PATH_TO_PING" != "x"; then
1113         if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
1114                 $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \
1115                 egrep -i "^round-trip|^rtt" >/dev/null
1116         then
1117                 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s"
1118                 ac_cv_ping6_packets_first=yes
1119                 AC_MSG_RESULT([$with_ping6_command])
1121         elif $PATH_TO_PING -A inet6 -n -U -c 1 ::1 2>/dev/null | \
1122                 egrep -i "^round-trip|^rtt" >/dev/null
1123         then
1124                 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s"
1125                 ac_cv_ping6_packets_first=yes
1126                 AC_MSG_RESULT([$with_ping6_command])
1128         elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \
1129                 egrep -i "^round-trip|^rtt" >/dev/null
1130         then
1131                 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s"
1132                 ac_cv_ping6_packets_first=yes
1133                 AC_MSG_RESULT([$with_ping6_command])
1135         elif $PATH_TO_PING -A inet6 -n ::1 -c 1 2>/dev/null | \
1136                 egrep -i "^round-trip|^rtt" >/dev/null
1137         then
1138                 with_ping6_command="$PATH_TO_PING -A inet6 -n %s -c %d"
1139                 AC_MSG_RESULT([$with_ping6_command])
1141         elif $PATH_TO_PING -A inet6 ::1 -n 1 2>/dev/null | \
1142                 egrep -i "^round-trip|^rtt" >/dev/null
1143         then
1144                 with_ping6_command="$PATH_TO_PING -A inet6 %s -n %d"
1145                 AC_MSG_RESULT([$with_ping6_command])
1147         elif $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \
1148                 egrep -i "^round-trip|^rtt" >/dev/null
1149         then
1150                 with_ping6_command="$PATH_TO_PING -A inet6 -n -s %s 56 %d"
1151                 AC_MSG_RESULT([$with_ping6_command])
1153         elif $PATH_TO_PING -A inet6 -n -h ::1 -s 56 -c 1 2>/dev/null | \
1154                 egrep -i "^round-trip|^rtt" >/dev/null
1155         then
1156                 with_ping6_command="$PATH_TO_PING -A inet6 -n -h %s -s 56 -c %d"
1157                 AC_MSG_RESULT([$with_ping6_command])
1159         elif $PATH_TO_PING -A inet6 -n -s 56 -c 1 ::1 2>/dev/null | \
1160                 egrep -i "^round-trip|^rtt" >/dev/null
1161         then
1162                 with_ping6_command="$PATH_TO_PING -A inet6 -n -s 56 -c %d %s"
1163                 ac_cv_ping6_packets_first=yes
1164                 AC_MSG_RESULT([$with_ping_command])
1166         elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \
1167                 egrep -i "^round-trip|^rtt" >/dev/null
1168         then
1169                 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s"
1170                 ac_cv_ping6_packets_first=yes
1171                 AC_MSG_RESULT([$with_ping6_command])
1173         fi
1175 fi
1177 if test "x$with_ping6_command" != "x"; then
1178         AC_DEFINE_UNQUOTED(PING6_COMMAND,"$with_ping6_command",
1179                 [path and args for ICMPv6 ping command])
1180 else
1181         AC_MSG_RESULT([none])
1182 fi
1184 if test "x$ac_cv_ping6_packets_first" != "xno"; then
1185         AC_DEFINE(PING6_PACKETS_FIRST,1,
1186                 [Define if packet count must precede host])
1187 fi
1188 fi
1190 AC_PATH_PROG(PATH_TO_NSLOOKUP,nslookup)
1192 AC_MSG_CHECKING(for nslookup syntax)
1193 if test -n "$PATH_TO_NSLOOKUP"
1194 then
1195         if $PATH_TO_NSLOOKUP -sil 127.0.0.1 2>&1 | grep ["Invalid option: sil"] >/dev/null
1196         then
1197                 ac_cv_nslookup_command="$PATH_TO_NSLOOKUP"
1198                 AC_MSG_RESULT([$ac_cv_nslookup_command])
1200         else
1201                 ac_cv_nslookup_command="$PATH_TO_NSLOOKUP -sil"
1202                 AC_MSG_RESULT([$ac_cv_nslookup_command])
1204         fi
1205         EXTRAS="$EXTRAS check_dns"
1207 else
1208         AC_MSG_WARN([nslookup command not found])
1209 fi
1211 AC_DEFINE_UNQUOTED(NSLOOKUP_COMMAND,"$ac_cv_nslookup_command",
1212         [path and args for nslookup])
1214 AC_PATH_PROG(PATH_TO_HOST,host)
1215 if test -n "$ac_cv_path_PATH_TO_HOST"
1216 then
1217         EXTRAS="$EXTRAS check_dns"
1218 fi
1220 AC_PATH_PROG(PATH_TO_UPTIME,uptime)
1221 AC_DEFINE_UNQUOTED(PATH_TO_UPTIME,"$PATH_TO_UPTIME",[path to uptime binary])
1223 AC_PATH_PROG(PATH_TO_RPCINFO,rpcinfo)
1224 AC_DEFINE_UNQUOTED(PATH_TO_RPCINFO,"$PATH_TO_RPCINFO",[path to rpcinfo binary])
1226 AC_PATH_PROG(PATH_TO_NTPDATE,ntpdate)
1227 AC_PATH_PROGS(PATH_TO_NTPDC,ntpdc xntpdc)
1228 AC_PATH_PROGS(PATH_TO_NTPQ,ntpq)
1229 if (test -x "$PATH_TO_NTPDATE" || test -x "$PATH_TO_NTPQ")
1230 then
1231         AC_DEFINE_UNQUOTED(PATH_TO_NTPQ,"$PATH_TO_NTPQ",[path to ntpq binary])
1232         AC_DEFINE_UNQUOTED(PATH_TO_NTPDATE,"$PATH_TO_NTPDATE",[path to ntpdate binary])
1233 else
1234         AC_MSG_WARN([Install NTP programs (http://www.ntp.org) if you want to monitor time synchronization])
1235 fi
1237 AC_PATH_PROG(PATH_TO_LMSTAT,lmstat)
1238 if test -x "$PATH_TO_LMSTAT"
1239 then
1240         AC_DEFINE_UNQUOTED(PATH_TO_LMSTAT,"$PATH_TO_LMSTAT",[path to lmstat])
1241 else
1242         AC_MSG_WARN([Get lmstat from Globetrotter Software to monitor flexlm licenses])
1243 fi
1245 AC_PATH_PROG(PATH_TO_SMBCLIENT,smbclient)
1246 if test -x "$PATH_TO_SMBCLIENT"
1247 then
1248         AC_DEFINE_UNQUOTED(PATH_TO_SMBCLIENT,"$PATH_TO_SMBCLIENT",[path to smbclient binary])
1249 else
1250         AC_MSG_WARN([Get smbclient from Samba.org to monitor SMB shares])
1251 fi
1254 AC_PATH_PROG(PATH_TO_WHO,who)
1256 if [$PATH_TO_WHO -q 2>/dev/null | egrep -i "^# users=[0-9]+$" >/dev/null]
1257 then
1258         ac_cv_path_to_who="$PATH_TO_WHO -q"
1259 else
1260         ac_cv_path_to_who="$PATH_TO_WHO"
1261 fi
1263 AC_DEFINE_UNQUOTED(WHO_COMMAND,"$ac_cv_path_to_who",
1264         [path and arguments for invoking 'who'])
1266 AC_PATH_PROG(PATH_TO_SNMPGET,snmpget)
1267 if test -x "$PATH_TO_SNMPGET"
1268 then
1269         AC_DEFINE_UNQUOTED(PATH_TO_SNMPGET,"$PATH_TO_SNMPGET",[path to snmpget binary])
1270         EXTRAS="$EXTRAS check_hpjd check_snmp"
1271 else
1272         AC_MSG_WARN([Get snmpget from http://net-snmp.sourceforge.net to make check_hpjd and check_snmp plugins])
1273 fi
1275 AC_PATH_PROG(PATH_TO_SNMPGETNEXT,snmpgetnext)
1276 if test -x "$PATH_TO_SNMPGETNEXT"
1277 then
1278         AC_DEFINE_UNQUOTED(PATH_TO_SNMPGETNEXT,"$PATH_TO_SNMPGETNEXT",[path to snmpgetnext binary])
1279 fi
1281 if ( $PERL -M"Net::SNMP 3.6" -e 'exit' 2>/dev/null  )
1282 then
1283         AC_MSG_CHECKING(for Net::SNMP perl module)
1284         AC_MSG_RESULT([found])
1285 else
1286         AC_MSG_WARN([Tried $PERL - install Net::SNMP perl module if you want to use the perl snmp plugins])
1287 fi
1289 AC_PATH_PROG(PATH_TO_QUAKESTAT,quakestat)
1290 AC_PATH_PROG(PATH_TO_QSTAT,qstat)
1292 if test -x "$PATH_TO_QUAKESTAT"
1293 then
1294         ac_cv_path_to_qstat="$PATH_TO_QUAKESTAT"
1295         EXTRAS="$EXTRAS check_game"
1297 elif test -x "$PATH_TO_QSTAT"
1298 then
1299         ac_cv_path_to_qstat="$PATH_TO_QSTAT"
1300         EXTRAS="$EXTRAS check_game"
1301 else
1302         AC_MSG_WARN([Get qstat from http://www.activesw.com/people/steve/qstat.html in order to make check_game plugin])
1303 fi
1305 if test $ac_cv_path_to_qstat 
1306 then
1307         AC_DEFINE_UNQUOTED(PATH_TO_QSTAT,"$ac_cv_path_to_qstat",
1308                 [path to qstat/quakestat])
1309 fi
1311 AC_PATH_PROG(PATH_TO_FPING,fping)
1312 if test -x "$PATH_TO_FPING"
1313 then
1314         AC_DEFINE_UNQUOTED(PATH_TO_FPING,"$PATH_TO_FPING",[path to fping])
1315         EXTRAS="$EXTRAS check_fping"
1316 else
1317         AC_MSG_WARN([Get fping from http://www.fping.com in order to make check_fping plugin])
1318 fi
1320 AC_PATH_PROG(PATH_TO_SSH,ssh)
1322 if test -x "$PATH_TO_SSH"
1323 then
1324         AC_DEFINE_UNQUOTED(SSH_COMMAND,"$PATH_TO_SSH",[path to ssh binary])
1325         EXTRAS="$EXTRAS check_by_ssh"
1326 else
1327         AC_MSG_WARN([Get ssh in order to make check_by_ssh plugin])
1328 fi
1331 AC_PATH_PROG(PATH_TO_MAILQ,mailq)
1332 if test -x "$PATH_TO_MAILQ"
1333 then
1334         AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_MAILQ",[path to mailq])
1335 else
1336         AC_MSG_WARN([Could not find mailq or eqivalent])
1337 fi
1339 AC_PATH_PROG(PATH_TO_QMAIL_QSTAT,qmail-qstat)
1340 if test -x "$PATH_TO_QMAIL_QSTAT"
1341 then
1342         AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_QMAIL_QSTAT",[path to qmail-qstat])
1343 else
1344         AC_MSG_WARN([Could not find qmail-qstat or eqivalent])
1345 fi
1347 dnl SWAP info required is amount allocated/available and amount free
1348 dnl The plugin works through all the swap devices and adds up the total swap
1349 dnl available.
1350 AC_PATH_PROG(PATH_TO_SWAP,swap)
1351 if (test -n "$PATH_TO_SWAP")
1352 then
1353 AC_MSG_CHECKING([for $PATH_TO_SWAP format])
1354 if [$PATH_TO_SWAP -l 2>&1 >/dev/null]
1355 then
1356         ac_cv_have_swap=yes
1357         ac_cv_swap_command="$PATH_TO_SWAP -l"
1358         if [$PATH_TO_SWAP -l 2>/dev/null | \
1359                 egrep -i "^lswap +path +pri +swaplo +blocks +free +maxswap" \
1360                 >/dev/null]
1361         then
1362                 ac_cv_swap_format=[" %*d %*s %*d,%*d %*d %*d %f %f"]
1363                 ac_cv_swap_conv=2048
1364                 AC_MSG_RESULT([using IRIX format swap])
1366         elif [$PATH_TO_SWAP -l 2>/dev/null | egrep -i "^path +dev +swaplo +blocks +free" >/dev/null]
1367         then
1368                 ac_cv_swap_format=["%*s %*[0-9,-] %*d %f %f"]
1369                 ac_cv_swap_conv=2048
1370                 AC_MSG_RESULT([using Unixware format swap])
1371         else
1372                 dnl if we don't know what format swap's output is
1373                 dnl we might as well pretend we didn't see it
1374                 ac_cv_have_swap=""
1375                 ac_cv_swap_command=""
1376         fi
1377 fi
1378 dnl end if for PATH_TO_SWAP
1379 fi
1381 AC_PATH_PROG(PATH_TO_SWAPINFO,swapinfo)
1382 if (test -n "$PATH_TO_SWAPINFO")
1383 then
1384 AC_MSG_CHECKING([for $PATH_TO_SWAPINFO format])
1385 if [$PATH_TO_SWAPINFO -k 2>&1 | egrep -i "^Device" >/dev/null]
1386 then
1387         ac_cv_have_swap=yes
1388         ac_cv_swap_command="$PATH_TO_SWAPINFO -k"
1390         if [$PATH_TO_SWAPINFO -k 2>/dev/null | egrep -i "^Device +1K-blocks +Used +Avail" >/dev/null]
1391         then
1392                 ac_cv_swap_format=["%*s %f %*d %f"]
1393                 ac_cv_swap_conv=1024
1394                 AC_MSG_RESULT([using FreeBSD format swapinfo])
1395         fi
1397 elif [$PATH_TO_SWAPINFO -dfM 2>/dev/null | egrep -i "^TYPE +AVAIL +USED +FREE" >/dev/null]
1398 then
1399         ac_cv_have_swap=yes
1400         ac_cv_swap_command="$PATH_TO_SWAPINFO -dfM",
1401         ac_cv_swap_format=["%*s %f %*d %f"]
1402         ac_cv_swap_conv=1024
1403         AC_MSG_RESULT([using HP-UX format swapinfo])
1404 fi
1405 dnl end if for PATH_TO_SWAPINFO
1406 fi
1408 AC_PATH_PROG(PATH_TO_LSPS,lsps)
1409 if (test -n "$PATH_TO_LSPS")
1410 then
1411 AC_MSG_CHECKING([for $PATH_TO_LSPS format])
1412 if [$PATH_TO_LSPS -a 2>/dev/null | egrep -i "^Page Space" > /dev/null]
1413 then
1414         ac_cv_have_swap=yes
1415         ac_cv_swap_command="$PATH_TO_LSPS -a"
1416         ac_cv_swap_format=["%*s %*s %*s %f%*s %f %*s"]
1417         ac_cv_swap_conv=1
1418         AC_MSG_RESULT([using AIX lsps])
1419 fi
1420 dnl end if for PATH_TO_SWAPINFO
1421 fi
1423 dnl
1424 dnl test for swapctl system call, both the 2-arg and 3-arg variants
1425 dnl fwict, the 2-arg is an SVR4 standard, whereas the 3-arg is shared
1426 dnl in the various BSD's
1427 dnl
1429 AC_CHECK_HEADERS([sys/stat.h sys/param.h])
1430 AC_CHECK_HEADERS([sys/swap.h], [], [], [
1431 #ifdef HAVE_SYS_PARAM_H
1432 #include <sys/param.h>
1433 #endif
1434 ])
1435 AC_CHECK_DECLS([swapctl],,,[
1436                #include <unistd.h>
1437                #include <sys/types.h>
1438                #include <sys/param.h>
1439                #include <sys/stat.h>
1440                #include <sys/swap.h>
1441                ])
1442 AC_CHECK_TYPES([swaptbl_t, swapent_t],,,[
1443                #include <sys/types.h>
1444                #include <sys/param.h>
1445                #include <sys/stat.h>
1446                #include <sys/swap.h>
1447                ])
1448 AC_CHECK_MEMBERS([struct swapent.se_nblks],,,[
1449                #include <unistd.h>
1450                #include <sys/types.h>
1451                #include <sys/param.h>
1452                #include <sys/stat.h>
1453                #include <sys/swap.h>
1454                ])
1456 if test "$ac_cv_have_decl_swapctl" = "yes"; 
1457 then
1458         EXTRAS="$EXTRAS check_swap"
1459         AC_MSG_CHECKING([for 2-arg (SVR4) swapctl])
1460         if test "$ac_cv_type_swaptbl_t" = "yes" -a \
1461                 "$ac_cv_type_swapent_t" = "yes"; 
1462         then
1463                 AC_MSG_RESULT([yes])
1464                 ac_cv_check_swap_swapctl_svr4="1";
1465                 AC_DEFINE([CHECK_SWAP_SWAPCTL_SVR4],1,
1466                           [Define if 2-argument SVR4 swapctl exists])
1467         else
1468                 AC_MSG_RESULT([no])
1469                 AC_MSG_CHECKING([for 3-arg (*BSD) swapctl])
1470                 if test "$ac_cv_member_struct_swapent_se_nblks" = "yes"; 
1471                 then
1472                         AC_MSG_RESULT([yes])
1473                         AC_DEFINE([CHECK_SWAP_SWAPCTL_BSD],1,
1474                                   [Define if 3-argument BSD swapctl exists])
1475                 else
1476                         AC_MSG_RESULT([no])
1477                 fi
1478         fi
1479         AC_MSG_CHECKING([for whether swapctl uses blocks or pages])
1480         if test "$ac_cv_check_swap_swapctl_svr4" = "1";
1481         then
1482                 dnl
1483                 dnl the SVR4 spec returns values in pages
1484                 dnl
1485                 AC_MSG_RESULT([page])
1486                 AC_CHECK_DECLS([sysconf])
1487                 AC_MSG_CHECKING([for system page size])
1488                 if test "$ac_cv_have_decl_sysconf" = "yes";
1489                 then
1490                         AC_MSG_RESULT([determined by sysconf(3)])
1491                         ac_cv_swap_conv="(1048576/sysconf(_SC_PAGESIZE))"
1492                 else
1493                         AC_MSG_WARN([don't know. guessing 4096k])
1494                         ac_cv_swap_conv=256
1495                 fi
1496         else
1497                 dnl
1498                 dnl the BSD spec returns values in blocks
1499                 dnl
1500                 AC_MSG_RESULT([blocks (assuming 512b)])
1501                 ac_cv_swap_conv=2048
1502         fi
1503         AC_DEFINE_UNQUOTED(SWAP_CONVERSION,$ac_cv_swap_conv,
1504                 [Conversion factor to MB])
1505 fi
1506 dnl
1507 dnl end tests for the swapctl system calls
1508 dnl
1511 if test "x$ac_cv_have_swap" != "x" 
1512 then
1513         AC_DEFINE(HAVE_SWAP,1,[Define if swap/swapinfo command is found])
1514         EXTRAS="$EXTRAS check_swap"
1515 fi
1516 if test "x$ac_cv_swap_command" != "x" 
1517 then
1518         AC_DEFINE_UNQUOTED(SWAP_COMMAND,"$ac_cv_swap_command",
1519                 [Path to swap/swapinfo binary, with any args])
1520         AC_DEFINE_UNQUOTED(SWAP_FORMAT,"$ac_cv_swap_format",
1521                 [Format string for parsing swap output])
1522         AC_DEFINE_UNQUOTED(SWAP_CONVERSION,$ac_cv_swap_conv,
1523                 [Conversion factor to MB])
1524 fi
1526 dnl dunno why this does not work below - use hack (kbd)
1527 dnl fine on linux, broken on solaris
1528 dnl if /bin/test -e "/proc/meminfo"
1529 AC_MSG_CHECKING([for /proc/meminfo])
1530 if [cat /proc/meminfo > /dev/null 2>&1]
1531 then
1532         AC_MSG_RESULT([found /proc/meminfo])
1533         AC_DEFINE(HAVE_PROC_MEMINFO,1,[Define if we have /proc/meminfo])
1534         AC_DEFINE_UNQUOTED(PROC_MEMINFO,"/proc/meminfo",[path to /proc/meminfo if name changes])
1535         EXTRAS="$EXTRAS check_swap"
1536 else
1537         AC_MSG_RESULT([no])
1538 fi
1540 AC_PATH_PROG(PATH_TO_DIG,dig)
1541 AC_DEFINE_UNQUOTED(PATH_TO_DIG,"$PATH_TO_DIG",[Path to dig command, if present])
1542 if test -n "$PATH_TO_DIG"; then
1543         EXTRAS="$EXTRAS check_dig"
1544 fi
1546 if test -f plugins/check_nt.c ; then
1547   EXTRAS="$EXTRAS check_nt"
1548 elif test -f ../plugins/check_nt.c ; then
1549   EXTRAS="$EXTRAS check_nt"
1550 fi
1552 AC_MSG_CHECKING(for va_list)
1553 AC_TRY_COMPILE([#ifdef __STDC__
1554                 #include <stdio.h>
1555                 #include <stdlib.h>
1556                 #include <stdarg.h>
1557                 #else
1558                 #include <sys/types.h>
1559                 #include <stdio.h>
1560                 #include <varargs.h>
1561                 #endif],
1562                 [va_list args;],
1563                 [AC_MSG_RESULT(yes)],
1564                 [NEED_VA_LIST=-DNEED_VA_LIST AC_SUBST(NEED_VA_LIST) AC_MSG_RESULT(no)])
1566 case $host in
1567         *bsd*)
1568                 AC_DEFINE(__bsd__,1,[bsd specific code in check_dhcp.c])
1569         ;;
1570         *linux*)
1571                 AC_DEFINE(__linux__,1,[sun specific code in check_dhcp.c])
1572         ;;
1573         *sun* | solaris*)
1574                 AC_DEFINE(__sun__,1,[sun specific code in check_dhcp.c])
1575         ;;
1576         *hpux*)  
1577                 AC_DEFINE(__hpux__,1,[hpux specific code in check_dhcp.c])
1578         ;;
1579 esac
1581 AC_SUBST(EXTRAS)
1582 AC_SUBST(EXTRA_NETOBJS)
1583 AC_SUBST(DEPLIBS)
1585 AM_GNU_GETTEXT([no-libtool], [need-ngettext])
1586 AM_GNU_GETTEXT_VERSION(0.11.5)
1588 dnl Check for Redhat spopen problem
1589 dnl Wierd problem where ECHILD is returned from a wait call in error
1590 dnl Only appears to affect nslookup and dig calls. Only affects redhat around
1591 dnl 2.6.9-11 (okay in 2.6.9-5). Redhat investigating root cause
1592 dnl We patch plugins/popen.c
1593 dnl Need to add smp because uname different on those. May need to check
1594 dnl Fedora Core too in future
1595 if echo $ac_cv_uname_r | egrep "\.EL(smp)?$" >/dev/null 2>&1 ; then
1596         AC_MSG_CHECKING(for redhat spopen problem)
1597         ( cd config_test && make && make test ) > /dev/null 2>&1
1598         if test $? -eq 0 ; then
1599                 AC_MSG_RESULT(okay)
1600         else
1601                 AC_MSG_RESULT(error)
1602                 AC_DEFINE(REDHAT_SPOPEN_ERROR, 1, "Problem on redhat with spopen")
1603         fi
1604 fi
1606 dnl External libraries - see ACKNOWLEDGEMENTS
1607 np_COREUTILS
1608 np_CURL
1610 AC_OUTPUT(
1611   Makefile 
1612   lib/Makefile 
1613   m4/Makefile 
1614   plugins/Makefile 
1615   plugins-root/Makefile
1616   plugins-scripts/Makefile 
1617   plugins-scripts/subst 
1618   plugins-scripts/utils.pm 
1619   plugins-scripts/utils.sh 
1620   command.cfg 
1621   test.pl 
1622   pkg/solaris/pkginfo 
1623   intl/Makefile
1624   po/Makefile.in 
1627 ACX_FEATURE([with],[perl])
1628 ACX_FEATURE([with],[cgiurl])
1629 ACX_FEATURE([with],[nagios-user])
1630 ACX_FEATURE([with],[nagios-group])
1631 ACX_FEATURE([with],[trusted-path])
1632 ACX_FEATURE([with],[ping-command])
1633 ACX_FEATURE([with],[ping6-command])
1634 ACX_FEATURE([with],[lwres])
1635 ACX_FEATURE([with],[ipv6])
1636 ACX_FEATURE([with],[openssl])
1637 ACX_FEATURE([with],[gnutls])
1638 ACX_FEATURE([enable],[emulate-getaddrinfo])