Code

Clean compile of check_mysql_query on MacOSX
[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(libtap-srcdir,
78         ACX_HELP_STRING([--with-libtap-srcdir=path],
79                 [full path to a compiled libtap srcdir]),
80         EXTRA_TEST=test_utils
81         EXTRA_TAPOBJ=$withval/tap.o
82         AC_SUBST(EXTRA_TEST)
83         AC_SUBST(EXTRA_TAPOBJ)
84         LDFLAGS="$LDFLAGS -L$withval"
85         CPPFLAGS="$CPPFLAGS -I$withval"
86         )
88 AC_ARG_WITH(trusted_path,
89         ACX_HELP_STRING([--with-trusted-path=PATH],
90                 [sets trusted path for executables called by scripts (default=/bin:/sbin:/usr/bin:/usr/sbin)]),
91         with_trusted_path=$withval,
92         with_trusted_path=/bin:/sbin:/usr/bin:/usr/sbin)
93 AC_SUBST(with_trusted_path)
95 EXTRAS=
96 dnl PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/etc:/usr/local/bin:/usr/local/sbin:$PATH
98 LDFLAGS="$LDFLAGS -L."
100 ac_cv_uname_m=`uname -m`
101 ac_cv_uname_s=`uname -s`
102 ac_cv_uname_r=`uname -r`
103 ac_cv_uname_v=`uname -v`
105 PKG_ARCH=`uname -p`
106 REV_DATESTAMP=`date '+%Y.%m.%d.%H.%M'`
107 REV_TIMESTAMP=`date '+%Y%m%d%H%M%S'`
109 AC_SUBST(PKG_ARCH)
110 AC_SUBST(REV_DATESTAMP)
111 AC_SUBST(REV_TIMESTAMP)
113 dnl Checks for programs.
114 AC_PATH_PROG(PYTHON,python)
115 AC_PATH_PROG(SH,sh)
116 AC_PATH_PROG(PERL,perl)
117 AC_PATH_PROG(LIBGNUTLS_CONFIG,libgnutls-config)
118 AC_PATH_PROG(HOSTNAME,hostname)
119 AC_PATH_PROG(BASENAME,basename)
121 dnl allow them to override the path of perl
122 AC_ARG_WITH(perl,
123         ACX_HELP_STRING([--with-perl=PATH],
124                         [sets path to perl executable]),
125                         with_perl=$withval,with_perl=$PERL)
126 AC_SUBST(PERL, $with_perl)
128 dnl openssl/gnutls
129 AC_ARG_WITH(openssl,
130             AC_HELP_STRING([--with-openssl=DIR], 
131                            [path to openssl installation]),)
133 AC_ARG_WITH(gnutls,
134             ACX_HELP_STRING([--with-gnutls=PATH],
135                             [path to gnutls installation root]),)
137 dnl you can only have one or the other
138 if test ! "$with_openssl" = "" && test ! "$with_openssl" = "no"; then
139         with_gnutls="no"
140 fi
141 if test ! "$with_gnutls" = "" && test ! "$with_gnutls" = "no"; then
142         with_openssl="no"
143 fi
145 dnl list of possible dirs to try to autodetect openssl
146 dnl if $dir/include exists, we consider it found
147 dnl the order should allow locally installed versions to override distros' ones
148 OPENSSL_DIRS="/usr /usr/local /usr/slocal /usr/local/openssl /usr/local/ssl \
149               /opt /opt/openssl"
151 dnl
152 dnl Check for miscellaneous stuff
153 dnl 
155 case $host_vender-$host_os in
156 sun*)
157         AC_DEFINE(__EXTENSIONS__,1,[Sun's netdb.h needs this for getaddrinfo])
158         ;;
159 osf*)
160         AC_DEFINE(_OSF_SOURCE,1,[OSF needs this for getaddrinfo])
161         ;;
162 esac
164 dnl
165 dnl Checks for libraries.
166 dnl
168 AC_CHECK_LIB(dce,main,SOCKETLIBS="$SOCKETLIBS -ldce")
169 AC_CHECK_LIB(nsl,main,SOCKETLIBS="$SOCKETLIBS -lnsl")
170 AC_CHECK_LIB(socket,socket,SOCKETLIBS="$SOCKETLIBS -lsocket")
171 AC_CHECK_LIB(resolv,main,SOCKETLIBS="$SOCKETLIBS -lresolv")
172 AC_SUBST(SOCKETLIBS)
174 dnl
175 dnl check for math-related functions needing -lm
176 AC_CHECK_HEADERS(math.h)
177 AC_CHECK_LIB(m,floor,MATHLIBS="-lm")
178 AC_SUBST(MATHLIBS)
180 dnl Check for PostgreSQL libraries
181 _SAVEDLIBS="$LIBS"
182 _SAVEDCPPFLAGS="$CPPFLAGS"
183 AC_ARG_WITH(pgsql,
184         ACX_HELP_STRING([--with-pgsql=DIR],
185                 [sets path to pgsql installation]),
186         PGSQL=$withval,)
187 AC_CHECK_LIB(crypt,main)
188 if test "$ac_cv_lib_crypt_main" = "yes"; then
189   if test -n "$PGSQL"; then
190     LDFLAGS="$LDFLAGS -L$PGSQL/lib"
191     CPPFLAGS="$CPPFLAGS -I$PGSQL/include"
192   fi
193   AC_CHECK_LIB(pq,PQsetdbLogin,,,-lcrypt)
194   if test "$ac_cv_lib_pq_PQsetdbLogin" = "yes"; then
195     AC_CHECK_HEADERS(pgsql/libpq-fe.h)
196     AC_CHECK_HEADERS(postgresql/libpq-fe.h)
197     AC_CHECK_HEADERS(libpq-fe.h)
198     if [[ -n "$PGSQL" -a "$ac_cv_header_libpq_fe_h" = "yes" ]]; then
199       PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
200       PGINCLUDE="-I$PGSQL/include"
201     elif test  "$ac_cv_header_pgsql_libpq_fe_h" = "yes"; then
202       PGLIBS="-lpq -lcrypt"
203       PGINCLUDE="-I/usr/include/pgsql"
204     elif test  "$ac_cv_header_postgresql_libpq_fe_h" = "yes"; then
205       PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
206       PGINCLUDE="-I/usr/include/postgresql"
207     elif test  "$ac_cv_header_libpq_fe_h" = "yes"; then
208       PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
209       PGINCLUDE="-I$PGSQL/include"
210     fi
211     if test -z "$PGINCLUDE"; then
212       AC_MSG_WARN([Skipping PostgreSQL plugin (check_pgsql)])
213       AC_MSG_WARN([install PostgreSQL headers to compile this plugin (see REQUIREMENTS).])
214     else
215       AC_SUBST(PGLIBS)
216       AC_SUBST(PGINCLUDE)
217       EXTRAS="$EXTRAS check_pgsql"
218     fi
219   else
220     AC_MSG_WARN([Skipping PostgreSQL plugin (check_pgsql)])
221     AC_MSG_WARN([LIBS="$LIBS" CPPFLAGS="$CPPFLAGS"])
222     AC_MSG_WARN([install PostgreSQL libs to compile this plugin (see REQUIREMENTS).])
223   fi
224 else
225   AC_MSG_WARN([Skipping PostgreSQL plugin (check_pgsql)])
226   AC_MSG_WARN([install lib crypt and PostgreSQL libs to compile this plugin (see REQUIREMENTS).])
227 fi
228 LIBS="$_SAVEDLIBS"
229 CPPFLAGS="$_SAVEDCPPFLAGS"
231 dnl Check for radius libraries
232 _SAVEDLIBS="$LIBS"
233 AC_CHECK_LIB(radiusclient,rc_read_config)
234 if test "$ac_cv_lib_radiusclient_rc_read_config" = "yes"; then
235   EXTRAS="$EXTRAS check_radius"
236         RADIUSLIBS="-lradiusclient"
237   AC_SUBST(RADIUSLIBS)
238 else
239   AC_MSG_WARN([Skipping radius plugin])
240   AC_MSG_WARN([install radius libs to compile this plugin (see REQUIREMENTS).])
241 fi
242 LIBS="$_SAVEDLIBS"
244 dnl Check for LDAP libraries
245 _SAVEDLIBS="$LIBS"
246 AC_CHECK_LIB(ldap,main,,,-llber)
247 if test "$ac_cv_lib_ldap_main" = "yes"; then
248   LDAPLIBS="-lldap -llber"\
249   LDAPINCLUDE="-I/usr/include/ldap"
250   AC_SUBST(LDAPLIBS)
251   AC_SUBST(LDAPINCLUDE)
252   AC_CHECK_FUNCS(ldap_set_option)
253   EXTRAS="$EXTRAS check_ldap"
254         AC_CHECK_FUNCS(ldap_init ldap_set_option ldap_get_option ldap_start_tls_s)
255 else
256   AC_MSG_WARN([Skipping LDAP plugin])
257   AC_MSG_WARN([install LDAP libs to compile this plugin (see REQUIREMENTS).])
258 fi
259 LIBS="$_SAVEDLIBS"
262 dnl Check for mysql libraries
263 _SAVEDLIBS="$LIBS"
264 _SAVEDCPPFLAGS="$CPPFLAGS"
265 AC_ARG_WITH(mysql,
266         ACX_HELP_STRING([--with-mysql=DIR],
267                 [sets path to mysql installation (assumes lib/mysql and include subdirs]),
268         MYSQL=$withval,)
269 if test -n "$MYSQL"; then
270   MYSQLLIBDIR=$MYSQL/lib/mysql
271   CPPFLAGS="-I$MYSQL/include"
272   AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz" check_mysql_LDFLAGS="-L$MYSQLLIBDIR " check_mysql_query_LDFLAGS="-L$MYSQLLIBDIR ",,-L$MYSQLLIBDIR -lz)
273   AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient")
274 elif test -f /usr/lib/libmysqlclient.so; then
275   AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz",,-lz)
276   AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient")
277 elif test -f /usr/lib/libmysqlclient.a; then
278   AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz",,-lz)
279   AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient")
280 elif test -f /usr/lib/mysql/libmysqlclient.so; then
281   AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz" check_mysql_LDFLAGS="-L/usr/lib/mysql" check_mysql_query_LDFLAGS="-L/usr/lib/mysql",,-L/usr/lib/mysql -lz)
282   AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient" check_mysql_LDFLAGS="-L/usr/lib/mysql" check_mysql_query_LDFLAGS="-L/usr/lib/mysql",,-L/usr/lib/mysql)
283 elif test -f /usr/lib/mysql/libmysqlclient.a; then
284   AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz" check_mysql_LDFLAGS="-L/usr/lib/mysql" check_mysql_query_LDFLAGS="-L/usr/lib/mysql",,-L/usr/lib/mysql -lz)
285   AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient" check_mysql_LDFLAGS="-L/usr/lib/mysql" check_mysql_query_LDFLAGS="-L/usr/lib/mysql",,-L/usr/lib/mysql)
286 fi
287 if test "$ac_cv_lib_mysqlclient_mysql_init" = "yes" -o "$ac_cv_lib_mysqlclient_mysql_close" = "yes"; then
288   AC_CHECK_HEADERS(mysql/mysql.h mysql/errmsg.h, MYSQLINCLUDE="-I$MYSQL/include" )
289   if test "$ac_cv_header_mysql_mysql_h" = "yes" -a "$ac_cv_header_mysql_errmsg_h" = "yes"; then
290     EXTRAS="$EXTRAS check_mysql check_mysql_query"
291     AC_SUBST(MYSQLINCLUDE)
292     AC_SUBST(MYSQLLIBS)
293     AC_SUBST(check_mysql_LDFLAGS)
294     AC_SUBST(check_mysql_query_LDFLAGS)
295   else
296     AC_MSG_WARN([Skipping mysql plugin])
297     AC_MSG_WARN([install mysql client headers to compile this plugin (see REQUIREMENTS).])
298   fi
299 else
300   AC_MSG_WARN([Skipping mysql plugin])
301   AC_MSG_WARN([install mysql client libs to compile this plugin (see REQUIREMENTS).])
302 fi
303 CPPFLAGS="$_SAVEDCPPFLAGS $MYSQLINCLUDE"
304 LIBS="$_SAVEDLIBS"
306 AC_CHECK_HEADERS(unistd.h)
308 dnl Check for AF_INET6 support - unistd.h required for Darwin
309 AC_CACHE_CHECK([for IPv6 support], with_ipv6, [
310         AC_TRY_COMPILE([#ifdef HAVE_UNISTD_H
311                         #include <unistd.h>
312                         #endif
313                         #include <netinet/in.h>
314                         #include <sys/socket.h>],
315                         [struct sockaddr_in6 sin6;
316                         void *p;
318                         sin6.sin6_family = AF_INET6;
319                         sin6.sin6_port = 587;
320                         p = &sin6.sin6_addr;],
321                         [with_ipv6=yes], 
322                         [with_ipv6=no])
323         ])
325 if test x"$with_ipv6" != xno ; then
326         AC_DEFINE(USE_IPV6,1,[Enable IPv6 support])
327 fi
329 dnl #########################################################################
330 dnl Check if Posix getaddrinfo() is available.  It is also possible to use
331 dnl the version from the lwres library distributed with BIND.
332 dnl #########################################################################
333 AC_ARG_ENABLE([emulate-getaddrinfo],
334               ACX_HELP_STRING([--enable-emulate-getaddrinfo],
335                              [enable getaddrinfo emulation (default=no)]),
336               ,
337               enable_emulate_getaddrinfo=no)
339 AC_ARG_WITH(lwres,
340             ACX_HELP_STRING([--with-lwres=DIR],
341                            [use lwres library for getaddrinfo (default=no)]),
342             ,
343             with_lwres=no)
345 dnl ## enable force to test getaddrinfo.c
346 if test x$enable_emulate_getaddrinfo = xforce ; then
347         enable_emulate_getaddrinfo=yes
348         have_getaddrinfo=no
349 else
351 have_getaddrinfo=no
352 if test x$with_lwres != xno ; then
353         if test "$with_lwres" != yes ; then
354                    CPPFLAGS="-I${with_lwres}/include $CPPFLAGS"
355                    LDFLAGS="-L${with_lwres}/lib $LDFLAGS"
356         fi
357         AC_CHECK_HEADERS(lwres/netdb.h, ,
358                         [AC_MSG_ERROR([cannot find <lwres/netdb.h>])])
359         AC_CHECK_LIB(lwres, lwres_getaddrinfo, ,
360                      [AC_MSG_ERROR([cannot find the lwres library])],
361                      -lnsl -lpthread)
362         have_getaddrinfo=yes
363 fi
365 if test x$have_getaddrinfo != xyes ; then
366         AC_SEARCH_LIBS(getaddrinfo, socket resolv bind nsl c_r cr, have_getaddrinfo=yes)
367 fi
369 dnl # Special nonsense for systems that actually have getaddrinfo but
370 dnl # redefine the name to something else, e.g. OSF
371 if test x$have_getaddrinfo != xyes ; then
372         AC_MSG_CHECKING(if getaddrinfo is redefined in netdb.h)
373         AC_TRY_LINK([
374 #               include <netdb.h>
375         ], [
376                 struct addrinfo hints, *res;
377                 int err;
379                 err = getaddrinfo ("host", "service", &hints, &res);
380         ], [
381                 have_getaddrinfo=yes
382                 AC_MSG_RESULT(yes)
383         ], [AC_MSG_RESULT(no)])
384 fi
386 fi
388 if test x$have_getaddrinfo != xno ; then
389         if test x$enable_emulate_getaddrinfo != xno ; then
390                 AC_MSG_ERROR([getaddrinfo found but emulate-getaddrinfo was enabled])
391         fi
392         AC_DEFINE(HAVE_GETADDRINFO, 1,
393                   [Does system provide RFC 2553/Posix getaddrinfo?])
394 else
395         if test x$enable_emulate_getaddrinfo != xyes ; then
396 dnl                AC_MSG_ERROR([getaddrinfo not found: try --with-lwres or --enable-emulate-getaddrinfo])
397                enable_emulate_getaddrinfo=yes
398                AC_MSG_WARN([enabling getaddrinfo emulation])
399         fi
400         EXTRA_NETOBJS="$EXTRA_NETOBJS getaddrinfo.o"
401 fi
403 if test x"$enable_emulate_getaddrinfo" != xno ; then
404     have_resolver=no
406   dnl  Try for getipnodebyname
407     AC_SEARCH_LIBS(getipnodebyname, resolv bind nsl c_r cr, have_resolver=yes)
408     if test x"$have_resolver" != xno ; then
409          AC_DEFINE(HAVE_GETIPNODEBYNAME, 1,
410                    [Set when getipnodebyname is available])
411     fi
413   dnl  Try for gethostbyname_r
414     if test x"$have_resolver" = xno ; then
415         AC_SEARCH_LIBS(gethostbyname_r, resolv bind nsl c_r cr,
416                        [have_resolver=yes
417                         ACX_WHICH_GETHOSTBYNAME_R])
418     fi
420   dnl  Try for gethostbyname
421     if test x"$have_resolver" = xno ; then
422         if test x"$enable_pthreads" != xno ; then
423             AC_MSG_WARN([using threads but cannot find gethostbyname_r or getipnodebyname])
424         fi
425         AC_SEARCH_LIBS(gethostbyname, resolv bind nsl, ,
426                        [AC_MSG_ERROR([cannot find gethostbyname])])
427     fi
428     EXTRA_NETOBJS="$EXTRA_NETOBJS gethostbyname.o"
430 fi
432 dnl Checks for Kerberos. Must come before openssl checks for Redhat EL 3
433 AC_CHECK_HEADERS(krb5.h,FOUNDINCLUDE=yes,FOUNDINCLUDE=no)
434 if test "$FOUNDINCLUDE" = "no"; then
435   _SAVEDCPPFLAGS="$CPPFLAGS"
436   CPPFLAGS="$_SAVEDCPPFLAGS -I/usr/kerberos/include"
437   unset ac_cv_header_krb5_h
438   AC_CHECK_HEADERS(krb5.h,
439                    KRB5INCLUDE="-I/usr/kerberos/include"
440                    FOUNDINCLUDE=yes,
441                    FOUNDINCLUDE=no)
442 fi
443 AC_SUBST(KRBINCLUDE)
444 if test "$FOUNDINCLUDE" = "no"; then
445   CPPFLAGS="$_SAVEDCPPFLAGS"
446 fi
449 dnl openssl detection/configuration
450 if ! test "$with_openssl" = "no"; then
451         dnl Check for OpenSSL location if it wasn't already specified
452         if ! test -d "$with_openssl"; then
453                 for d in $OPENSSL_DIRS; do
454                         if test -x ${d}/bin/openssl || test -x ${d}/sbin/openssl ; then
455                                 with_openssl=$d
456                         fi
457                 done
458         fi
460         _SAVEDCPPFLAGS="$CPPFLAGS"
461         _SAVEDLDFLAGS="$LDFLAGS"
462         dnl Check for OpenSSL header files
463         unset FOUNDINCLUDE
464         CPPFLAGS="$CPPFLAGS -I$OPENSSL/include"
465         LDFLAGS="$LDFLAGS -R$OPENSSL/lib"
467         dnl check for openssl in $dir/include/openssl
468         AC_CHECK_HEADERS(openssl/ssl.h openssl/x509.h openssl/rsa.h openssl/pem.h openssl/crypto.h openssl/err.h,
469                          SSLINCLUDE="-I$OPENSSL/include"
470                          FOUNDINCLUDE=yes,
471                          FOUNDINCLUDE=no)
472         dnl else check to see if $dir/include has it
473         if test "$FOUNDINCLUDE" = "no"; then
474                 AC_CHECK_HEADERS(ssl.h x509.h rsa.h pem.h crypto.h err.h,
475                                  SSLINCLUDE="-I$OPENSSL/include"
476                                  FOUNDINCLUDE=yes,
477                                  FOUNDINCLUDE=no)
478         fi
479         AC_SUBST(SSLINCLUDE)
480         dnl if we didn't find it, reset CPPFLAGS
481         if test "$FOUNDINCLUDE" = "no"; then
482                 CPPFLAGS="$_SAVEDCPPFLAGS"
483                 LDFLAGS="$_SAVEDLDFLAGS"
484         fi
486         dnl Check for crypto lib
487         _SAVEDLIBS="$LIBS"
488         LIBS="-L${with_openssl}/lib"
489         AC_CHECK_LIB(crypto,CRYPTO_lock)
490         if test "$ac_cv_lib_crypto_CRYPTO_lock" = "yes"; then
491                 dnl Check for SSL lib
492                 AC_CHECK_LIB(ssl,main, SSLLIBS="-lssl -lcrypto",,-lcrypto)
493         fi
494         LIBS="$_SAVEDLIBS"
496         dnl test headers and libs to decide whether check_http should use SSL
497         if test "$ac_cv_lib_crypto_CRYPTO_lock" = "yes"; then
498                 if test "$ac_cv_lib_ssl_main" = "yes"; then
499                         if test "$FOUNDINCLUDE" = "yes"; then
500                                 FOUNDOPENSSL="yes"
501                         fi
502                 fi
503         fi
504 fi
507 dnl check for gnutls if openssl isn't found (or is disabled)
508 if test ! "$FOUNDOPENSSL" = "yes" && test ! "$with_gnutls" = "no"; then
509         if test ! "$with_gnutls" = ""; then
510                 CPPFLAGS="$CPPFLAGS -I${with_gnutls}/include"
511         elif test ! "$LIBGNUTLS_CONFIG" = ""; then
512                 CPPFLAGS="$CPPFLAGS -I`$LIBGNUTLS_CONFIG --prefix`"
513         fi
514         AC_CHECK_HEADERS([gnutls/openssl.h],FOUNDGNUTLS="yes",)
515         if test "$FOUNDGNUTLS" = "yes"; then
516                 AC_CHECK_LIB(gnutls-openssl,main,SSLLIBS="-lgnutls-openssl")
517         fi
518 fi
519 dnl end check for gnutls
521 if test "$FOUNDOPENSSL" = "yes" || test "$FOUNDGNUTLS" = "yes"; then
522         check_tcp_ssl="check_simap check_spop check_jabber check_nntps check_ssmtp"
523         AC_SUBST(check_tcp_ssl)
524         AC_SUBST(SSLLIBS)
525         AC_DEFINE(HAVE_SSL,1,[Define if SSL libraries are found])
526         if test "$FOUNDOPENSSL" = "yes"; then
527                 AC_DEFINE(USE_OPENSSL,1,[Define if using OpenSSL libraries])
528                 with_openssl="yes"
529                 with_gnutls="no"
530         else
531                 AC_DEFINE(USE_GNUTLS,1,[Define if using gnutls libraries])
532                 with_gnutls="yes"
533                 with_openssl="no"
534         fi
535 else
536         dnl else deliberately disabled or no ssl support available
537         AC_MSG_WARN([OpenSSL or GnuTLS libs could not be found or were disabled])
538         with_openssl="no"
539         with_gnutls="no"
540 fi
542 dnl
543 dnl Checks for header files.
544 dnl
546 AC_HEADER_STDC
547 AC_HEADER_TIME
548 AC_HEADER_SYS_WAIT
549 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)
550 AC_CHECK_HEADERS(features.h stdarg.h sys/unistd.h ctype.h stdlib.h)
552 dnl Checks for typedefs, structures, and compiler characteristics.
553 AC_C_CONST
554 AC_STRUCT_TM
555 AC_TYPE_PID_T
556 AC_TYPE_SIZE_T
557 AC_TYPE_SIGNAL
559 AC_CACHE_CHECK([for va_copy],ac_cv_HAVE_VA_COPY,[
560 AC_TRY_LINK([#include <stdarg.h>
561 va_list ap1,ap2;], [va_copy(ap1,ap2);],
562 ac_cv_HAVE_VA_COPY=yes,
563 ac_cv_HAVE_VA_COPY=no)])
564 if test x"$ac_cv_HAVE_VA_COPY" = x"yes"; then
565     AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available])
566 else    
567     AC_CACHE_CHECK([for __va_copy],ac_cv_HAVE___VA_COPY,[
568     AC_TRY_LINK([#include <stdarg.h>
569     va_list ap1,ap2;], [__va_copy(ap1,ap2);],
570     ac_cv_HAVE___VA_COPY=yes,
571     ac_cv_HAVE___VA_COPY=no)])
572     if test x"$ac_cv_HAVE___VA_COPY" = x"yes"; then
573         AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available])
574     fi
575 fi
577 AC_CHECK_FUNCS(vsnprintf snprintf asprintf vasprintf)
578 AC_CACHE_CHECK([for C99 vsnprintf],ac_cv_HAVE_C99_VSNPRINTF,[
579 AC_TRY_RUN([
580 #include <sys/types.h>
581 #include <stdarg.h>
582 void foo(const char *format, ...) { 
583        va_list ap;
584        int len;
585        char buf[5];
587        va_start(ap, format);
588        len = vsnprintf(buf, 0, format, ap);
589        va_end(ap);
590        if (len != 5) exit(1);
592        va_start(ap, format);
593        len = vsnprintf(0, 0, format, ap);
594        va_end(ap);
595        if (len != 5) exit(1);
597        if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
599        exit(0);
601 main() { foo("hello"); }
602 ],
603 ac_cv_HAVE_C99_VSNPRINTF=yes,ac_cv_HAVE_C99_VSNPRINTF=no,ac_cv_HAVE_C99_VSNPRINTF=cross)])
604 if test x"$ac_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
605     AC_DEFINE(HAVE_C99_VSNPRINTF,1,[Define if system has C99 compatible vsnprintf])
606 fi
608 AC_TRY_COMPILE([#include <sys/time.h>],
609                [struct timeval *tv;
610                 struct timezone *tz;],
611                AC_DEFINE(HAVE_STRUCT_TIMEVAL,1,[Define if we have a timeval structure])
612                AC_TRY_COMPILE([#include <sys/time.h>],
613                               [struct timeval *tv;
614                                struct timezone *tz;
615                                gettimeofday(tv, tz);],
616                               AC_DEFINE(HAVE_GETTIMEOFDAY,1,[Define if gettimeofday is found]),
617                               AC_DEFINE(NEED_GETTIMEOFDAY,1,[Define if gettimeofday is needed])))
619 dnl Checks for library functions.
620 AC_CHECK_FUNCS(memmove select socket strdup strstr strtod strtol strtoul floor)
622 AC_MSG_CHECKING(return type of socket size)
623 AC_TRY_COMPILE([#include <stdlib.h>
624                 #include <sys/types.h>
625                 #include <sys/socket.h>],
626                [int a = send(1, (const void *) buffer, (size_t *) 0, (int *) 0);],
627                ac_cv_socket_size_type=["size_t"]
628                 AC_MSG_RESULT(size_t),
629                ac_cv_socket_size_type=["int"]
630                 AC_MSG_RESULT(int))
632 AC_DEFINE_UNQUOTED(SOCKET_SIZE_TYPE, $ac_cv_socket_size_type ,
633         [Define type of socket size])
635 AC_ARG_WITH(proc-loadavg,
636             ACX_HELP_STRING([--with-proc-loadavg=PATH],
637                             [path to /proc/loadavg or equivalent]),
638             ac_cv_proc_loadavg=$withval)
639 AC_MSG_CHECKING([for /proc/loadavg])
640 if test -n "$ac_cv_proc_loadavg"; then
641   AC_MSG_RESULT([(command line) $ac_cv_proc_loadavg])
642 elif test -f "/proc/loadavg"; then
643   AC_MSG_RESULT([found /proc/loadavg])
644   ac_cv_proc_loadavg="/proc/loadavg"
645 else
646   AC_MSG_RESULT([no])
647 fi
649 if test -n "$ac_cv_proc_loadavg"; then
650   AC_DEFINE(HAVE_PROC_LOADAVG,1,[Define if /proc/loadavg or similar exists])
651   AC_DEFINE_UNQUOTED(PROC_LOADAVG,"/proc/loadavg",[Location of /proc/loadavg])
652 fi
654 dnl #### Process table test
656 AC_PATH_PROG(PATH_TO_PS,ps)
658 AC_MSG_CHECKING(for ps syntax)
659 AC_ARG_WITH(ps_command,
660             ACX_HELP_STRING([--with-ps-command=PATH], 
661                             [Verbatim command to execute for ps]),
662             PS_COMMAND=$withval)
663 AC_ARG_WITH(ps_format,
664             ACX_HELP_STRING([--with-ps-format=FORMAT],
665                             [Format string for scanning ps output]),
666             PS_FORMAT=$withval)
667 AC_ARG_WITH(ps_cols,
668             ACX_HELP_STRING([--with-ps-cols=NUM], 
669                             [Number of columns in ps command]),
670             PS_COLS=$withval)
671 AC_ARG_WITH(ps_varlist,
672             ACX_HELP_STRING([--with-ps-varlist=LIST],
673                             [Variable list for sscanf of 'ps' output]),
674             PS_VARLIST=$withval)
676 AM_CONDITIONAL(WANT_PST3, false)
678 if test -n "$PS_COMMAND" && test -n "$PS_FORMAT" && test -n "$PS_COLS" && test -n "$PS_VARLIST"; then 
679         ac_cv_ps_command="$PS_COMMAND"
680         ac_cv_ps_format="$PS_FORMAT"
681         ac_cv_ps_varlist="$PS_VARLIST"
682         ac_cv_ps_cols="$PS_COLS"
683         AC_MSG_RESULT([(command-line) $ac_cv_ps_command])
685 dnl Now using the pst3/kmem hack for solaris systems to avoid truncation
686 elif test "$ac_cv_uname_s" = "SunOS"; then
687         #
688         # this is a very, very ugly hack, to hardcode the location for plugins
689         #
690         if test "$libexecdir" = '${exec_prefix}/libexec'; then
691                 if test "$exec_prefix" = "NONE"; then
692                         if test "$prefix" = "NONE"; then
693                                 pst3="$ac_default_prefix/libexec/pst3"
694                         else
695                                 pst3="$prefix/libexec/pst3"
696                         fi
697                 else
698                         pst3="$exec_prefix/libexec/pst3"
699                 fi
700         else
701                 pst3="$libexecdir/pst3"
702         fi
703         ac_cv_ps_command="$pst3"
704         ac_cv_ps_format="%s %d %d %d %d %f %s %n"
705         ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
706         ac_cv_ps_cols=8
707         AC_MSG_RESULT([using nagios-plugins internal ps for solaris])
708         AM_CONDITIONAL(WANT_PST3, true)
710 dnl Some gnu/linux systems (debian for one) don't like -axwo and need axwo.
711 dnl so test for this first...
712 elif ps axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
713         egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null
714 then
715         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
716         ac_cv_ps_command="$PATH_TO_PS axwo 'stat uid pid ppid vsz rss pcpu comm args'"
717         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
718         ac_cv_ps_cols=9
719         AC_MSG_RESULT([$ac_cv_ps_command])
721 dnl For OpenBSD 3.2 & 3.3. Must come before ps -weo
722 dnl Should also work for FreeBSD 5.2.1 and 5.3
723 dnl  STAT UCOMM              VSZ   RSS USER      PPID COMMAND
724 elif ps -axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
725         egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null
726 then
727         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
728         ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid pid ppid vsz rss pcpu comm args'"
729         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
730         ac_cv_ps_cols=9
731         AC_MSG_RESULT([$ac_cv_ps_command])
733 dnl Some *BSDs have different format for ps. This is mainly to catch FreeBSD 4. 
734 dnl Limitation: Only first 16 chars returned for ucomm field
735 dnl Must come before ps -weo
736 elif ps -axwo 'stat uid pid ppid vsz rss pcpu ucomm command' 2>/dev/null | \
737         egrep -i ["^ *STAT +UID +PID +PPID +VSZ +RSS +%CPU +UCOMM +COMMAND"] > /dev/null
738 then
739         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
740         ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid pid ppid vsz rss pcpu ucomm command'"
741         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
742         ac_cv_ps_cols=9
743         AC_MSG_RESULT([$ac_cv_ps_command])
745 dnl  STAT UCOMM              VSZ   RSS USER       UID  PPID COMMAND
746 elif ps -weo 'stat comm vsz rss user uid pid ppid etime args' 2>/dev/null | \
747         egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[ID]+ +P[PID]+ +[ELAPSD]+ +[RGSCOMDNA]+"] >/dev/null
748 then
749         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procetime,procprog,&pos]"
750         ac_cv_ps_command="$PATH_TO_PS -weo 'stat uid pid ppid vsz rss pcpu etime comm args'"
751         ac_cv_ps_format="%s %d %d %d %d %d %f %s %s %n"
752         ac_cv_ps_cols=10
753         AC_MSG_RESULT([$ac_cv_ps_command])
755 dnl FreeBSD
756 elif ps waxco 'state command vsz rss uid user pid ppid' 2>/dev/null | \
757         egrep -i ["^STAT +COMMAND +VSZ +RSS +UID +USER +PID +PPID"] >/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 waxco 'state uid pid ppid vsz rss pcpu command command'"
761         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
762         ac_cv_ps_cols=9
763         AC_MSG_RESULT([$ac_cv_ps_command])
765 dnl BSD-like mode in RH 6.1
766 elif ps waxno 'state comm vsz rss uid user pid ppid args' 2>/dev/null | \
767         egrep -i ["^S +COMMAND +VSZ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
768 then
769         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
770         ac_cv_ps_command="$PATH_TO_PS waxno 'state uid pid ppid vsz rss pcpu comm args'"
771         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
772         ac_cv_ps_cols=9
773         AC_MSG_RESULT([$ac_cv_ps_command])
775 dnl SunOS 4.1.3:
776 dnl  F  UID  PID  PPID  CP  PRI  NI  SZ  RSS  WCHAN  STAT  TT  TIME  COMMAND
777 dnl Need the head -1 otherwise test will work because arguments are found
778 elif ps -laxnwww 2>/dev/null | head -1 | \
779         egrep -i ["^ *F(LAGS)? +UID +PID +PPID +CP +PRI +NI +(SZ)|(VSZ)|(SIZE) +RSS +WCHAN +STAT? +TTY? +TIME +COMMAND"] >/dev/null
780 then
781         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]"
782         ac_cv_ps_command="$PATH_TO_PS -laxnwww"
783         ac_cv_ps_format="%*s %d %d %d %*s %*s %*s %d %d %*s %s %*s %*s %n%s"
784         ac_cv_ps_cols=9
785         AC_MSG_RESULT([$ac_cv_ps_command])
787 dnl Debian Linux / procps v1.2.9:
788 dnl  FLAGS   UID   PID  PPID PRI  NI   SIZE   RSS WCHAN       STA TTY TIME COMMAND
789 dnl    100     0     1     0   0   0    776    76  c0131c8c   S  ffff  0:11 init [2]
790 dnl
791 elif ps laxnwww 2>/dev/null | \
792         egrep -i ["^ *F(LAGS)? +UID +PID +PPID +PRI +NI +(VSZ)|(SIZE) +RSS +WCHAN +STAT? TTY +TIME +COMMAND"] >/dev/null
793 then
794         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,procstat,&procvsz,&procrss,&pos,procprog]"
795         ac_cv_ps_command="$PATH_TO_PS laxnwww"
796         ac_cv_ps_format="%*s %d %d %d %*s %*s %d %d %*s %s %*s %*s %n%s"
797         ac_cv_ps_cols=9
798         AC_MSG_RESULT([$ac_cv_ps_command])
800 dnl OpenBSD (needs to come early because -exo appears to work, but does not give all procs)
801 elif ps -axo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
802         egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[PID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null
803 then
804         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
805         ac_cv_ps_command="$PATH_TO_PS -axo 'stat uid pid ppid vsz rss pcpu comm args'"
806         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
807         ac_cv_ps_cols=9
808         AC_MSG_RESULT([$ac_cv_ps_command])
810 dnl Tru64 - needs %*[ +<>] in PS_FORMAT. 
811 dnl Has /usr/bin/ps and /sbin/ps - force sbin version
812 dnl Can't use vsize and rssize because comes back with text (eg, 1.5M instead 
813 dnl of 1500). Will need big changes to check_procs to support
814 elif /sbin/ps -eo 'stat uid pid ppid pcpu etime comm args' 2>/dev/null | \
815         egrep -i ["^ *S +[UID]+ +[PID]+ +[PID]+ +[%CPU]+ +[ELAPSD]+ +[COMMAND]+ +[COMMAND]+"] > /dev/null
816 then
817         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procpcpu,procetime,procprog,&pos]"
818         ac_cv_ps_command="/sbin/ps -eo 'stat uid pid ppid pcpu etime comm args'"
819         ac_cv_ps_format=["%s%*[ +<>] %d %d %d %f %s %s %n"]
820         ac_cv_ps_cols=8
821         AC_MSG_RESULT([$ac_cv_ps_command])
823 elif ps -eo 's comm vsz rss user uid pid ppid args' 2>/dev/null | \
824         egrep -i ["^S[TAUES]* +C[OMDNA]+ +[VSIZE]+ +U[SER]+ +U[ID]+ +P[PID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null
825 then
826         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
827         ac_cv_ps_command="$PATH_TO_PS -eo 's uid pid ppid vsz rss pcpu comm args'"
828         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
829         ac_cv_ps_cols=9
830         AC_MSG_RESULT([$ac_cv_ps_command])
832 dnl AIX 4.3.3 and 5.1 do not have an rss field
833 elif ps -eo 'stat uid pid ppid vsz pcpu comm args' 2>/dev/null | \
834         egrep -i ["^ *S[TAUES]* +UID +PID +PPID +VSZ +%CPU +COMMAND +COMMAND"] >/dev/null
835 then
836         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procpcpu,procprog,&pos]"
837         ac_cv_ps_command="$PATH_TO_PS -eo 'stat uid pid ppid vsz pcpu comm args'"
838         ac_cv_ps_format="%s %d %d %d %d %f %s %n"
839         ac_cv_ps_cols=8
840         AC_MSG_RESULT([$ac_cv_ps_command - with no RSS])
842 dnl Solaris 2.6
843 elif ps -Ao 's comm vsz rss uid user pid ppid args' 2>/dev/null | \
844         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
845 then
846         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
847         ac_cv_ps_command="$PATH_TO_PS -Ao 's uid pid ppid vsz rss pcpu comm args'"
848         # There must be no space between the %s and %n due to a wierd problem in sscanf where
849         # it will return %n as longer than the line length
850         ac_cv_ps_format="%s %d %d %d %d %d %f %s%n"
851         ac_cv_ps_cols=9
852         AC_MSG_RESULT([$ac_cv_ps_command])
854 elif ps -Ao 'status comm vsz rss uid user pid ppid args' 2>/dev/null | \
855         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
856 then
857         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
858         ac_cv_ps_command="$PATH_TO_PS -Ao 'status uid pid ppid vsz rss pcpu comm args'"
859         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
860         ac_cv_ps_cols=9
861         AC_MSG_RESULT([$ac_cv_ps_command])
863 elif ps -Ao 'state comm vsz rss uid user pid ppid args' 2>/dev/null | \
864         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
865 then
866         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
867         ac_cv_ps_command="$PATH_TO_PS -Ao 'state uid pid ppid vsz rss pcpu comm args'"
868         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
869         ac_cv_ps_cols=9
870         AC_MSG_RESULT([$ac_cv_ps_command])
872 dnl wonder who takes state instead of stat
873 elif ps -ao 'state command vsz rss user pid ppid args' 2>/dev/null | \
874         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
875 then
876         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
877         ac_cv_ps_command="$PATH_TO_PS -ao 'state uid pid ppid vsz rss pcpu command args'"
878         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
879         ac_cv_ps_cols=8
880         AC_MSG_RESULT([$ac_cv_ps_command])
882 dnl IRIX 53
883 elif ps -el 2>/dev/null | \
884         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
885 then
886         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&pos,procprog]"
887         ac_cv_ps_command="$PATH_TO_PS -el (IRIX 53)"
888         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %d %d %*s %*s %*s %n%s"
889         ac_cv_ps_cols=8
890         AC_MSG_RESULT([$ac_cv_ps_command])
892 dnl IRIX 63
893 elif ps -el 2>/dev/null | \
894         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +ADDR +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
895 then
896         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
897         ac_cv_ps_command="$PATH_TO_PS -el (IRIX 63)"
898         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
899         ac_cv_ps_cols=6
900         AC_MSG_RESULT([$ac_cv_ps_command])
902 dnl AIX 4.1:
903 dnl     F S      UID   PID  PPID   C PRI NI ADDR  SZ  RSS   WCHAN    TTY  TIME CMD
904 dnl    303 A        0     0     0 120  16 -- 1c07  20   24              -  0:45 swapper
905 elif ps -el 2>/dev/null | \
906         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +ADDR +SZ +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
907 then
908         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
909         ac_cv_ps_command="$PATH_TO_PS -el (AIX 4.1 and HP-UX)"
910         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
911         ac_cv_ps_cols=6
912         AC_MSG_RESULT([$ac_cv_ps_command])
914 dnl AIX?
915 elif ps glaxen 2>/dev/null | \
916         egrep -i ["^ *F +UID +PID +PPID +PRI +NI +VSZ +RSS +WCHAN +STAT +TTY +TIME +COMMAND"] >/dev/null
917 then
918         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]"
919         ac_cv_ps_command="$PATH_TO_PS glaxen"
920         ac_cv_ps_format="%*s %d %d %d %*s %*s %d %d %*s %s %*s %*s %n%s"
921         ac_cv_ps_cols=8
922         AC_MSG_RESULT([$ac_cv_ps_command])
924 dnl MacOSX / Darwin
925 dnl TODO: MacOSX has commands with spaces which will cause problems to PS_FORMAT
926 dnl Some truncation will happen in UCOMM column
927 dnl STAT      VSZ    RSS   UID  PPID %CPU UCOMM            COMMAND
928 dnl Ss      52756  22496   501     1   6.9 Window Manager   /System/Library/CoreServices/WindowServer -daemon
929 elif ps wwaxo 'state vsz rss uid pid ppid pcpu ucomm command' 2>/dev/null | \
930         egrep -i ["^STAT +VSZ +RSS +UID +PPID +%CPU +UCOMM +COMMAND"] >/dev/null
931 then
932         ac_cv_ps_command="$PATH_TO_PS wwaxo 'state vsz rss uid pid ppid pcpu ucomm command'"
933         ac_cv_ps_varlist="[procstat,&procvsz,&procrss,&procuid,&procpid,&procppid,&procpcpu,procprog,&pos]"
934         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
935         ac_cv_ps_cols=8
936         AC_MSG_RESULT([$ac_cv_ps_command])
938 dnl UnixWare 
939 elif ps -Al 2>/dev/null | \
940         egrep -i ["^ *F +S +UID +PID +PPID +CLS +PRI +NI +C +ADDR +SZ +WCHAN +TTY +TIME +COMD"] >/dev/null
941 then
942         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
943         ac_cv_ps_command="$PATH_TO_PS -Al"
944         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
945         ac_cv_ps_cols=8
946         AC_MSG_RESULT([$ac_cv_ps_command])
948 else
949         AC_MSG_WARN([unable to find usable ps syntax - check_procs and check_nagios will not be compiled])
950 fi
952 if test -n "$ac_cv_ps_varlist" ; then
953         AC_DEFINE_UNQUOTED(PS_VARLIST,$ac_cv_ps_varlist,
954                 [Variable list for sscanf of 'ps' output])
955         AC_DEFINE_UNQUOTED(PS_COMMAND,"$ac_cv_ps_command",
956                 [Verbatim command to execute for ps in check_procs])
957         AC_DEFINE_UNQUOTED(PS_FORMAT,"$ac_cv_ps_format",
958                 [Format string for scanning ps output in check_procs])
959         AC_DEFINE_UNQUOTED(PS_COLS,$ac_cv_ps_cols,
960                 [Number of columns in ps command])
961         EXTRAS="$EXTRAS check_procs check_nagios"
962         if echo "$ac_cv_ps_varlist" | grep -q "procetime"; then
963                 AC_DEFINE(PS_USES_PROCETIME,"yes",
964                           [Whether the ps utility uses the "procetime" field])
965         fi
966 fi
968 AC_PATH_PROG(PATH_TO_PING,ping)
969 AC_PATH_PROG(PATH_TO_PING6,ping6)
971 AC_ARG_WITH(ping_command,
972         ACX_HELP_STRING([--with-ping-command=SYNTAX],
973                 [sets syntax for ICMP ping]),
974         with_ping_command=$withval,)
976 AC_MSG_CHECKING(for ICMP ping syntax)
977 ac_cv_ping_packets_first=no
978 ac_cv_ping_has_timeout=no
979 if test -n "$with_ping_command"
980 then
981         AC_MSG_RESULT([(command-line) $with_ping_command])
982         if test -n "$ac_cv_ping_packets_first"
983         then
984                 ac_cv_ping_packets_first=yes
985                 ac_cv_ping_has_timeout=yes
986         fi
988 elif [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
989         $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
990         egrep -i "^round-trip|^rtt" >/dev/null
991 then
992         with_ping_command="$PATH_TO_PING -n -U -c %d %s"
993         ac_cv_ping_packets_first=yes
994         AC_MSG_RESULT([$with_ping_command])
996 elif $PATH_TO_PING -n -U -w 10 -c 1 127.0.0.1 2>/dev/null | \
997         egrep -i "^round-trip|^rtt" >/dev/null
998 then
999         with_ping_command="$PATH_TO_PING -n -U -w %d -c %d %s"
1000         ac_cv_ping_packets_first=yes
1001   ac_cv_ping_has_timeout=yes
1002         AC_MSG_RESULT([$with_ping_command])
1004 elif $PATH_TO_PING -n -U -c 1 127.0.0.1 2>/dev/null | \
1005         egrep -i "^round-trip|^rtt" >/dev/null
1006 then
1007         with_ping_command="$PATH_TO_PING -n -U -c %d %s"
1008         ac_cv_ping_packets_first=yes
1009         AC_MSG_RESULT([$with_ping_command])
1011 elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \
1012         egrep -i "^round-trip|^rtt" >/dev/null
1013 then
1014         with_ping_command="$PATH_TO_PING -n -c %d %s"
1015         ac_cv_ping_packets_first=yes
1016         AC_MSG_RESULT([$with_ping_command])
1018 elif $PATH_TO_PING -n 127.0.0.1 -c 1 2>/dev/null | \
1019         egrep -i "^round-trip|^rtt" >/dev/null
1020 then
1021         with_ping_command="$PATH_TO_PING -n %s -c %d"
1022         AC_MSG_RESULT([$with_ping_command])
1024 elif $PATH_TO_PING 127.0.0.1 -n 1 2>/dev/null | \
1025         egrep -i "^round-trip|^rtt" >/dev/null
1026 then
1027         with_ping_command="$PATH_TO_PING %s -n %d"
1028         AC_MSG_RESULT([$with_ping_command])
1030 elif $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
1031         egrep -i "^round-trip|^rtt" >/dev/null
1032 then
1033         with_ping_command="$PATH_TO_PING -n -s %s 56 %d"
1034         AC_MSG_RESULT([$with_ping_command])
1036 elif $PATH_TO_PING -n -h 127.0.0.1 -s 56 -c 1 2>/dev/null | \
1037         egrep -i "^round-trip|^rtt" >/dev/null
1038 then
1039         with_ping_command="$PATH_TO_PING -n -h %s -s 56 -c %d"
1040         AC_MSG_RESULT([$with_ping_command])
1042 elif $PATH_TO_PING -n -s 56 -c 1 127.0.0.1 2>/dev/null | \
1043         egrep -i "^round-trip|^rtt" >/dev/null
1044 then
1045         with_ping_command="$PATH_TO_PING -n -s 56 -c %d %s"
1046         ac_cv_ping_packets_first=yes
1047         AC_MSG_RESULT([$with_ping_command])
1049 elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \
1050         egrep -i "^round-trip|^rtt" >/dev/null
1051 then
1052         with_ping_command="$PATH_TO_PING -n -c %d %s"
1053         ac_cv_ping_packets_first=yes
1054         AC_MSG_RESULT([$with_ping_command])
1056 else
1057         AC_MSG_WARN([unable to find usable ping syntax])
1058 fi
1060 AC_DEFINE_UNQUOTED(PING_COMMAND,"$with_ping_command",
1061         [path and args for ICMP ping command])
1063 if test "x$ac_cv_ping_packets_first" != "xno"
1064 then
1065         AC_DEFINE(PING_PACKETS_FIRST,1,
1066                 [Define if packet count must precede host])
1067 fi
1069 if test "x$ac_cv_ping_has_timeout" != "xno"
1070 then
1071         AC_DEFINE(PING_HAS_TIMEOUT,1,
1072                 [Define if ping has its own timeout option that should be set])
1073 fi
1075 AC_ARG_WITH(ping6_command,
1076         ACX_HELP_STRING([--with-ping6-command=SYNTAX],
1077                 [sets syntax for ICMPv6 ping]),
1078         with_ping6_command=$withval,)
1080 if test x"$with_ipv6" != xno ; then
1081 AC_MSG_CHECKING(for ICMPv6 ping syntax)
1082 ac_cv_ping6_packets_first=no
1083 if test -n "$with_ping6_command"
1084 then
1085         AC_MSG_RESULT([(command-line) $with_ping6_command])
1086         if test -n "$ac_cv_ping6_packets_first"
1087         then
1088                 ac_cv_ping6_packets_first=yes
1089         fi
1091 elif test "x$PATH_TO_PING6" != "x"; then
1092         if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
1093                 $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \
1094                 egrep -i "^round-trip|^rtt" >/dev/null
1095         then
1096                 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s"
1097                 ac_cv_ping6_packets_first=yes
1098                 AC_MSG_RESULT([$with_ping6_command])
1100         elif $PATH_TO_PING6 -n -U -w 10 -c 1 ::1 2>/dev/null | \
1101                 egrep -i "^round-trip|^rtt" >/dev/null
1102         then
1103                 with_ping6_command="$PATH_TO_PING6 -n -U -w %d -c %d %s"
1104                 ac_cv_ping6_packets_first=yes
1105                 ac_cv_ping_has_timeout=yes
1106                 AC_MSG_RESULT([$with_ping6_command])
1108         elif $PATH_TO_PING6 -n -U -c 1 ::1 2>/dev/null | \
1109                 egrep -i "^round-trip|^rtt" >/dev/null
1110         then
1111                 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s"
1112                 ac_cv_ping6_packets_first=yes
1113                 AC_MSG_RESULT([$with_ping6_command])
1115         elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \
1116                 egrep -i "^round-trip|^rtt" >/dev/null
1117         then
1118                 with_ping6_command="$PATH_TO_PING6 -n -c %d %s"
1119                 ac_cv_ping6_packets_first=yes
1120                 AC_MSG_RESULT([$with_ping6_command])
1122         elif $PATH_TO_PING6 -n ::1 -c 1 2>/dev/null | \
1123                 egrep -i "^round-trip|^rtt" >/dev/null
1124         then
1125                 with_ping6_command="$PATH_TO_PING6 -n %s -c %d"
1126                 AC_MSG_RESULT([$with_ping6_command])
1128         elif $PATH_TO_PING6 ::1 -n 1 2>/dev/null | \
1129                 egrep -i "^round-trip|^rtt" >/dev/null
1130         then
1131                 with_ping6_command="$PATH_TO_PING6 %s -n %d"
1132                 AC_MSG_RESULT([$with_ping6_command])
1134         elif $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \
1135                 egrep -i "^round-trip|^rtt" >/dev/null
1136         then
1137                 with_ping6_command="$PATH_TO_PING6 -n -s %s 56 %d"
1138                 AC_MSG_RESULT([$with_ping6_command])
1140         elif $PATH_TO_PING6 -n -h ::1 -s 56 -c 1 2>/dev/null | \
1141                 egrep -i "^round-trip|^rtt" >/dev/null
1142         then
1143                 with_ping6_command="$PATH_TO_PING6 -n -h %s -s 56 -c %d"
1144                 AC_MSG_RESULT([$with_ping6_command])
1146         elif $PATH_TO_PING6 -n -s 56 -c 1 ::1 2>/dev/null | \
1147                 egrep -i "^round-trip|^rtt" >/dev/null
1148         then
1149                 with_ping6_command="$PATH_TO_PING6 -n -s 56 -c %d %s"
1150                 ac_cv_ping6_packets_first=yes
1151                 AC_MSG_RESULT([$with_ping_command])
1153         elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \
1154                 egrep -i "^round-trip|^rtt" >/dev/null
1155         then
1156                 with_ping6_command="$PATH_TO_PING6 -n -c %d %s"
1157                 ac_cv_ping6_packets_first=yes
1158                 AC_MSG_RESULT([$with_ping6_command])
1160         fi
1162 elif test "x$PATH_TO_PING" != "x"; then
1163         if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
1164                 $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \
1165                 egrep -i "^round-trip|^rtt" >/dev/null
1166         then
1167                 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s"
1168                 ac_cv_ping6_packets_first=yes
1169                 AC_MSG_RESULT([$with_ping6_command])
1171         elif $PATH_TO_PING -A inet6 -n -U -c 1 ::1 2>/dev/null | \
1172                 egrep -i "^round-trip|^rtt" >/dev/null
1173         then
1174                 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s"
1175                 ac_cv_ping6_packets_first=yes
1176                 AC_MSG_RESULT([$with_ping6_command])
1178         elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \
1179                 egrep -i "^round-trip|^rtt" >/dev/null
1180         then
1181                 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s"
1182                 ac_cv_ping6_packets_first=yes
1183                 AC_MSG_RESULT([$with_ping6_command])
1185         elif $PATH_TO_PING -A inet6 -n ::1 -c 1 2>/dev/null | \
1186                 egrep -i "^round-trip|^rtt" >/dev/null
1187         then
1188                 with_ping6_command="$PATH_TO_PING -A inet6 -n %s -c %d"
1189                 AC_MSG_RESULT([$with_ping6_command])
1191         elif $PATH_TO_PING -A inet6 ::1 -n 1 2>/dev/null | \
1192                 egrep -i "^round-trip|^rtt" >/dev/null
1193         then
1194                 with_ping6_command="$PATH_TO_PING -A inet6 %s -n %d"
1195                 AC_MSG_RESULT([$with_ping6_command])
1197         elif $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \
1198                 egrep -i "^round-trip|^rtt" >/dev/null
1199         then
1200                 with_ping6_command="$PATH_TO_PING -A inet6 -n -s %s 56 %d"
1201                 AC_MSG_RESULT([$with_ping6_command])
1203         elif $PATH_TO_PING -A inet6 -n -h ::1 -s 56 -c 1 2>/dev/null | \
1204                 egrep -i "^round-trip|^rtt" >/dev/null
1205         then
1206                 with_ping6_command="$PATH_TO_PING -A inet6 -n -h %s -s 56 -c %d"
1207                 AC_MSG_RESULT([$with_ping6_command])
1209         elif $PATH_TO_PING -A inet6 -n -s 56 -c 1 ::1 2>/dev/null | \
1210                 egrep -i "^round-trip|^rtt" >/dev/null
1211         then
1212                 with_ping6_command="$PATH_TO_PING -A inet6 -n -s 56 -c %d %s"
1213                 ac_cv_ping6_packets_first=yes
1214                 AC_MSG_RESULT([$with_ping_command])
1216         elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \
1217                 egrep -i "^round-trip|^rtt" >/dev/null
1218         then
1219                 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s"
1220                 ac_cv_ping6_packets_first=yes
1221                 AC_MSG_RESULT([$with_ping6_command])
1223         fi
1225 fi
1227 if test "x$with_ping6_command" != "x"; then
1228         AC_DEFINE_UNQUOTED(PING6_COMMAND,"$with_ping6_command",
1229                 [path and args for ICMPv6 ping command])
1230 else
1231         AC_MSG_RESULT([none])
1232 fi
1234 if test "x$ac_cv_ping6_packets_first" != "xno"; then
1235         AC_DEFINE(PING6_PACKETS_FIRST,1,
1236                 [Define if packet count must precede host])
1237 fi
1238 fi
1241 AC_MSG_CHECKING(for nslookup syntax)
1242 AC_ARG_WITH(nslookup_command,
1243             ACX_HELP_STRING([--with-nslookup-command=PATH],
1244                             [sets path to nslookup executable]),
1245             ac_cv_nslookup_command=$withval)
1246 if test -n "$ac_cv_nslookup_command"; then
1247         AC_MSG_RESULT([(command line) $ac_cv_nslookup_command])
1248 else
1249         AC_PATH_PROG(PATH_TO_NSLOOKUP,nslookup)
1250         if test -n "$PATH_TO_NSLOOKUP"
1251         then
1252                 if $PATH_TO_NSLOOKUP -sil 127.0.0.1 2>&1 | grep ["Invalid option: sil"] >/dev/null
1253                 then
1254                         ac_cv_nslookup_command="$PATH_TO_NSLOOKUP"
1255                         AC_MSG_RESULT([$ac_cv_nslookup_command])
1257                 else
1258                         ac_cv_nslookup_command="$PATH_TO_NSLOOKUP -sil"
1259                         AC_MSG_RESULT([$ac_cv_nslookup_command])
1261                 fi
1262         else
1263                 AC_MSG_WARN([nslookup command not found])
1264         fi
1265 fi
1267 if test -n "$ac_cv_nslookup_command"; then
1268         EXTRAS="$EXTRAS check_dns"
1269         AC_DEFINE_UNQUOTED(NSLOOKUP_COMMAND,"$ac_cv_nslookup_command", [path and args for nslookup])
1270 fi
1272 AC_PATH_PROG(PATH_TO_HOST,host)
1273 if test -n "$ac_cv_path_PATH_TO_HOST"
1274 then
1275         EXTRAS="$EXTRAS check_dns"
1276 fi
1278 AC_PATH_PROG(PATH_TO_UPTIME,uptime)
1279 AC_ARG_WITH(uptime_command,
1280             ACX_HELP_STRING([--with-uptime-command=PATH],
1281                             [sets path to uptime]), PATH_TO_UPTIME=$withval)
1282 AC_DEFINE_UNQUOTED(PATH_TO_UPTIME,"$PATH_TO_UPTIME",[path to uptime binary])
1284 AC_PATH_PROG(PATH_TO_RPCINFO,rpcinfo)
1285 AC_ARG_WITH(rpcinfo_command,
1286             ACX_HELP_STRING([--with-rpcinfo-command=PATH],
1287                             [sets path to rpcinfo]), PATH_TO_RPCINFO=$withval)
1288 AC_DEFINE_UNQUOTED(PATH_TO_RPCINFO,"$PATH_TO_RPCINFO",[path to rpcinfo binary])
1290 AC_PATH_PROG(PATH_TO_NTPDATE,ntpdate)
1291 AC_ARG_WITH(ntpdate_command,
1292             ACX_HELP_STRING([--with-ntpdate-command=PATH],
1293                             [sets path to ntpdate]), PATH_TO_NTPDATE=$withval)
1294 AC_PATH_PROGS(PATH_TO_NTPDC,ntpdc xntpdc)
1295 AC_PATH_PROGS(PATH_TO_NTPQ,ntpq)
1296 if (test -n "$PATH_TO_NTPDATE" || test -n "$PATH_TO_NTPQ")
1297 then
1298         AC_DEFINE_UNQUOTED(PATH_TO_NTPQ,"$PATH_TO_NTPQ",[path to ntpq binary])
1299         AC_DEFINE_UNQUOTED(PATH_TO_NTPDATE,"$PATH_TO_NTPDATE",[path to ntpdate binary])
1300 else
1301         AC_MSG_WARN([Install NTP programs (http://www.ntp.org) if you want to monitor time synchronization])
1302 fi
1304 AC_PATH_PROG(PATH_TO_LMSTAT,lmstat)
1305 if test -x "$PATH_TO_LMSTAT"
1306 then
1307         AC_DEFINE_UNQUOTED(PATH_TO_LMSTAT,"$PATH_TO_LMSTAT",[path to lmstat])
1308 else
1309         AC_MSG_WARN([Get lmstat from Globetrotter Software to monitor flexlm licenses])
1310 fi
1312 AC_PATH_PROG(PATH_TO_SMBCLIENT,smbclient)
1313 AC_ARG_WITH(smbclient_command,
1314             ACX_HELP_STRING([--with-smbclient-command=PATH],
1315                             [sets path to smbclient]), 
1316             PATH_TO_SMBCLIENT=$withval)
1317 if test -n "$PATH_TO_SMBCLIENT"
1318 then
1319         AC_DEFINE_UNQUOTED(PATH_TO_SMBCLIENT,"$PATH_TO_SMBCLIENT",[path to smbclient binary])
1320 else
1321         AC_MSG_WARN([Get smbclient from Samba.org to monitor SMB shares])
1322 fi
1325 AC_PATH_PROG(PATH_TO_WHO,who)
1327 if [$PATH_TO_WHO -q 2>/dev/null | egrep -i "^# users=[0-9]+$" >/dev/null]
1328 then
1329         ac_cv_path_to_who="$PATH_TO_WHO -q"
1330 else
1331         ac_cv_path_to_who="$PATH_TO_WHO"
1332 fi
1334 AC_DEFINE_UNQUOTED(WHO_COMMAND,"$ac_cv_path_to_who",
1335         [path and arguments for invoking 'who'])
1337 AC_PATH_PROG(PATH_TO_SNMPGET,snmpget)
1338 AC_ARG_WITH(snmpget_command,
1339             ACX_HELP_STRING([--with-snmpget-command=PATH],
1340                             [Path to snmpget command]),
1341             PATH_TO_SNMPGET=$withval)
1342 if test -n "$PATH_TO_SNMPGET"
1343 then
1344         AC_DEFINE_UNQUOTED(PATH_TO_SNMPGET,"$PATH_TO_SNMPGET",[path to snmpget binary])
1345         EXTRAS="$EXTRAS check_hpjd check_snmp"
1346 else
1347         AC_MSG_WARN([Get snmpget from http://net-snmp.sourceforge.net to make check_hpjd and check_snmp plugins])
1348 fi
1350 AC_PATH_PROG(PATH_TO_SNMPGETNEXT,snmpgetnext)
1351 AC_ARG_WITH(snmpgetnext_command,
1352             ACX_HELP_STRING([--with-snmpgetnext-command=PATH],
1353                             [Path to snmpgetnext command]),
1354             PATH_TO_SNMPGETNEXT=$withval)
1355 if test -n "$PATH_TO_SNMPGETNEXT"
1356 then
1357         AC_DEFINE_UNQUOTED(PATH_TO_SNMPGETNEXT,"$PATH_TO_SNMPGETNEXT",[path to snmpgetnext binary])
1358 fi
1360 if ( $PERL -M"Net::SNMP 3.6" -e 'exit' 2>/dev/null  )
1361 then
1362         AC_MSG_CHECKING(for Net::SNMP perl module)
1363         AC_MSG_RESULT([found])
1364 else
1365         AC_MSG_WARN([Tried $PERL - install Net::SNMP perl module if you want to use the perl snmp plugins])
1366 fi
1368 AC_PATH_PROG(PATH_TO_QUAKESTAT,quakestat)
1369 AC_PATH_PROG(PATH_TO_QSTAT,qstat)
1370 AC_ARG_WITH(qstat_command,
1371             ACX_HELP_STRING([--with-qstat-command=PATH], 
1372                             [Path to qstat command]), PATH_TO_QSTAT=$withval)
1374 if test -x "$PATH_TO_QUAKESTAT"
1375 then
1376         ac_cv_path_to_qstat="$PATH_TO_QUAKESTAT"
1377         EXTRAS="$EXTRAS check_game"
1379 elif test -n "$PATH_TO_QSTAT"
1380 then
1381         ac_cv_path_to_qstat="$PATH_TO_QSTAT"
1382         EXTRAS="$EXTRAS check_game"
1383 else
1384         AC_MSG_WARN([Get qstat from http://www.activesw.com/people/steve/qstat.html in order to make check_game plugin])
1385 fi
1387 if test $ac_cv_path_to_qstat 
1388 then
1389         AC_DEFINE_UNQUOTED(PATH_TO_QSTAT,"$ac_cv_path_to_qstat",
1390                 [path to qstat/quakestat])
1391 fi
1393 AC_PATH_PROG(PATH_TO_FPING,fping)
1394 AC_ARG_WITH(fping_command,
1395             ACX_HELP_STRING([--with-fping-command=PATH],
1396                             [Path to fping command]), PATH_TO_FPING=$withval)
1397 if test -n "$PATH_TO_FPING"
1398 then
1399         AC_DEFINE_UNQUOTED(PATH_TO_FPING,"$PATH_TO_FPING",[path to fping])
1400         EXTRAS="$EXTRAS check_fping"
1401 else
1402         AC_MSG_WARN([Get fping from http://www.fping.com in order to make check_fping plugin])
1403 fi
1405 AC_PATH_PROG(PATH_TO_SSH,ssh)
1406 AC_ARG_WITH(ssh_command,
1407             ACX_HELP_STRING([--with-ssh-command=PATH],
1408                             [sets path for ssh]), PATH_TO_SSH=$withval)
1409 if test -n "$PATH_TO_SSH"
1410 then
1411         AC_DEFINE_UNQUOTED(SSH_COMMAND,"$PATH_TO_SSH",[path to ssh binary])
1412         EXTRAS="$EXTRAS check_by_ssh"
1413 else
1414         AC_MSG_WARN([Get ssh in order to make check_by_ssh plugin])
1415 fi
1418 AC_PATH_PROG(PATH_TO_MAILQ,mailq)
1419 AC_ARG_WITH(mailq_command,
1420             ACX_HELP_STRING([--with-mailq-command=PATH],
1421                             [sets path to mailq]), PATH_TO_MAILQ=$withval)
1422 if test -n "$PATH_TO_MAILQ"
1423 then
1424         AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_MAILQ",[path to mailq])
1425 else
1426         AC_MSG_WARN([Could not find mailq or eqivalent])
1427 fi
1429 AC_PATH_PROG(PATH_TO_QMAIL_QSTAT,qmail-qstat)
1430 if test -x "$PATH_TO_QMAIL_QSTAT"
1431 then
1432         AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_QMAIL_QSTAT",[path to qmail-qstat])
1433 else
1434         AC_MSG_WARN([Could not find qmail-qstat or eqivalent])
1435 fi
1437 dnl SWAP info required is amount allocated/available and amount free
1438 dnl The plugin works through all the swap devices and adds up the total swap
1439 dnl available.
1440 AC_PATH_PROG(PATH_TO_SWAP,swap)
1441 if (test -n "$PATH_TO_SWAP")
1442 then
1443 AC_MSG_CHECKING([for $PATH_TO_SWAP format])
1444 if [$PATH_TO_SWAP -l 2>&1 >/dev/null]
1445 then
1446         ac_cv_have_swap=yes
1447         ac_cv_swap_command="$PATH_TO_SWAP -l"
1448         if [$PATH_TO_SWAP -l 2>/dev/null | \
1449                 egrep -i "^lswap +path +pri +swaplo +blocks +free +maxswap" \
1450                 >/dev/null]
1451         then
1452                 ac_cv_swap_format=[" %*d %*s %*d,%*d %*d %*d %f %f"]
1453                 ac_cv_swap_conv=2048
1454                 AC_MSG_RESULT([using IRIX format swap])
1456         elif [$PATH_TO_SWAP -l 2>/dev/null | egrep -i "^path +dev +swaplo +blocks +free" >/dev/null]
1457         then
1458                 ac_cv_swap_format=["%*s %*[0-9,-] %*d %f %f"]
1459                 ac_cv_swap_conv=2048
1460                 AC_MSG_RESULT([using Unixware format swap])
1461         else
1462                 dnl if we don't know what format swap's output is
1463                 dnl we might as well pretend we didn't see it
1464                 ac_cv_have_swap=""
1465                 ac_cv_swap_command=""
1466         fi
1467 fi
1468 dnl end if for PATH_TO_SWAP
1469 fi
1471 AC_PATH_PROG(PATH_TO_SWAPINFO,swapinfo)
1472 if (test -n "$PATH_TO_SWAPINFO")
1473 then
1474 AC_MSG_CHECKING([for $PATH_TO_SWAPINFO format])
1475 if [$PATH_TO_SWAPINFO -k 2>&1 | egrep -i "^Device" >/dev/null]
1476 then
1477         ac_cv_have_swap=yes
1478         ac_cv_swap_command="$PATH_TO_SWAPINFO -k"
1480         if [$PATH_TO_SWAPINFO -k 2>/dev/null | egrep -i "^Device +1K-blocks +Used +Avail" >/dev/null]
1481         then
1482                 ac_cv_swap_format=["%*s %f %*d %f"]
1483                 ac_cv_swap_conv=1024
1484                 AC_MSG_RESULT([using FreeBSD format swapinfo])
1485         fi
1487 elif [$PATH_TO_SWAPINFO -dfM 2>/dev/null | egrep -i "^TYPE +AVAIL +USED +FREE" >/dev/null]
1488 then
1489         ac_cv_have_swap=yes
1490         ac_cv_swap_command="$PATH_TO_SWAPINFO -dfM",
1491         ac_cv_swap_format=["%*s %f %*d %f"]
1492         ac_cv_swap_conv=1024
1493         AC_MSG_RESULT([using HP-UX format swapinfo])
1494 fi
1495 dnl end if for PATH_TO_SWAPINFO
1496 fi
1498 AC_PATH_PROG(PATH_TO_LSPS,lsps)
1499 if (test -n "$PATH_TO_LSPS")
1500 then
1501 AC_MSG_CHECKING([for $PATH_TO_LSPS format])
1502 if [$PATH_TO_LSPS -a 2>/dev/null | egrep -i "^Page Space" > /dev/null]
1503 then
1504         ac_cv_have_swap=yes
1505         ac_cv_swap_command="$PATH_TO_LSPS -a"
1506         ac_cv_swap_format=["%*s %*s %*s %f%*s %f %*s"]
1507         ac_cv_swap_conv=1
1508         AC_MSG_RESULT([using AIX lsps])
1509 fi
1510 dnl end if for PATH_TO_SWAPINFO
1511 fi
1513 dnl
1514 dnl test for swapctl system call, both the 2-arg and 3-arg variants
1515 dnl fwict, the 2-arg is an SVR4 standard, whereas the 3-arg is shared
1516 dnl in the various BSD's
1517 dnl
1519 AC_CHECK_HEADERS([sys/stat.h sys/param.h])
1520 AC_CHECK_HEADERS([sys/swap.h], [], [], [
1521 #ifdef HAVE_SYS_PARAM_H
1522 #include <sys/param.h>
1523 #endif
1524 ])
1525 AC_CHECK_DECLS([swapctl],,,[
1526                #include <unistd.h>
1527                #include <sys/types.h>
1528                #include <sys/param.h>
1529                #include <sys/stat.h>
1530                #include <sys/swap.h>
1531                ])
1532 AC_CHECK_TYPES([swaptbl_t, swapent_t],,,[
1533                #include <sys/types.h>
1534                #include <sys/param.h>
1535                #include <sys/stat.h>
1536                #include <sys/swap.h>
1537                ])
1538 AC_CHECK_MEMBERS([struct swapent.se_nblks],,,[
1539                #include <unistd.h>
1540                #include <sys/types.h>
1541                #include <sys/param.h>
1542                #include <sys/stat.h>
1543                #include <sys/swap.h>
1544                ])
1546 if test "$ac_cv_have_decl_swapctl" = "yes"; 
1547 then
1548         EXTRAS="$EXTRAS check_swap"
1549         AC_MSG_CHECKING([for 2-arg (SVR4) swapctl])
1550         if test "$ac_cv_type_swaptbl_t" = "yes" -a \
1551                 "$ac_cv_type_swapent_t" = "yes"; 
1552         then
1553                 AC_MSG_RESULT([yes])
1554                 ac_cv_check_swap_swapctl_svr4="1";
1555                 AC_DEFINE([CHECK_SWAP_SWAPCTL_SVR4],1,
1556                           [Define if 2-argument SVR4 swapctl exists])
1557         else
1558                 AC_MSG_RESULT([no])
1559                 AC_MSG_CHECKING([for 3-arg (*BSD) swapctl])
1560                 if test "$ac_cv_member_struct_swapent_se_nblks" = "yes"; 
1561                 then
1562                         AC_MSG_RESULT([yes])
1563                         AC_DEFINE([CHECK_SWAP_SWAPCTL_BSD],1,
1564                                   [Define if 3-argument BSD swapctl exists])
1565                 else
1566                         AC_MSG_RESULT([no])
1567                 fi
1568         fi
1569         AC_MSG_CHECKING([for whether swapctl uses blocks or pages])
1570         if test "$ac_cv_check_swap_swapctl_svr4" = "1";
1571         then
1572                 dnl
1573                 dnl the SVR4 spec returns values in pages
1574                 dnl
1575                 AC_MSG_RESULT([page])
1576                 AC_CHECK_DECLS([sysconf])
1577                 AC_MSG_CHECKING([for system page size])
1578                 if test "$ac_cv_have_decl_sysconf" = "yes";
1579                 then
1580                         AC_MSG_RESULT([determined by sysconf(3)])
1581                         ac_cv_swap_conv="(1048576/sysconf(_SC_PAGESIZE))"
1582                 else
1583                         AC_MSG_WARN([don't know. guessing 4096k])
1584                         ac_cv_swap_conv=256
1585                 fi
1586         else
1587                 dnl
1588                 dnl the BSD spec returns values in blocks
1589                 dnl
1590                 AC_MSG_RESULT([blocks (assuming 512b)])
1591                 ac_cv_swap_conv=2048
1592         fi
1593         AC_DEFINE_UNQUOTED(SWAP_CONVERSION,$ac_cv_swap_conv,
1594                 [Conversion factor to MB])
1595 fi
1596 dnl
1597 dnl end tests for the swapctl system calls
1598 dnl
1601 if test "x$ac_cv_have_swap" != "x" 
1602 then
1603         AC_DEFINE(HAVE_SWAP,1,[Define if swap/swapinfo command is found])
1604         EXTRAS="$EXTRAS check_swap"
1605 fi
1606 if test "x$ac_cv_swap_command" != "x" 
1607 then
1608         AC_DEFINE_UNQUOTED(SWAP_COMMAND,"$ac_cv_swap_command",
1609                 [Path to swap/swapinfo binary, with any args])
1610         AC_DEFINE_UNQUOTED(SWAP_FORMAT,"$ac_cv_swap_format",
1611                 [Format string for parsing swap output])
1612         AC_DEFINE_UNQUOTED(SWAP_CONVERSION,$ac_cv_swap_conv,
1613                 [Conversion factor to MB])
1614 fi
1616 AC_ARG_WITH(proc-meminfo,
1617             ACX_HELP_STRING([--with-proc-meminfo=PATH],
1618                             [path to /proc/meminfo or equivalent]),
1619                             ac_cv_proc_meminfo=$withval)
1620 dnl dunno why this does not work below - use hack (kbd)
1621 dnl fine on linux, broken on solaris
1622 dnl if /bin/test -e "/proc/meminfo"
1623 AC_MSG_CHECKING([for /proc/meminfo])
1624 if test -n "$ac_cv_proc_meminfo"; then
1625         AC_MSG_RESULT([(command line) $ac_cv_proc_meminfo])
1626 elif [cat /proc/meminfo > /dev/null 2>&1]; then
1627         AC_MSG_RESULT([found /proc/meminfo])
1628         ac_cv_proc_meminfo="/proc/meminfo"
1629 else
1630         AC_MSG_RESULT([no])
1631 fi
1633 if test -n "$ac_cv_proc_meminfo"; then
1634         AC_DEFINE(HAVE_PROC_MEMINFO,1,[Define if we have /proc/meminfo])
1635         AC_DEFINE_UNQUOTED(PROC_MEMINFO,"$ac_cv_proc_meminfo",[path to /proc/meminfo if name changes])
1636         EXTRAS="$EXTRAS check_swap"
1637 fi
1639 AC_PATH_PROG(PATH_TO_DIG,dig)
1640 AC_ARG_WITH(dig_command,
1641             ACX_HELP_STRING([--with-dig-command=PATH],
1642                             [Path to dig command]), PATH_TO_DIG=$withval)
1643 if test -n "$PATH_TO_DIG"; then
1644         EXTRAS="$EXTRAS check_dig"
1645         AC_DEFINE_UNQUOTED(PATH_TO_DIG,"$PATH_TO_DIG",[Path to dig command, if present])
1646 fi
1648 if test -f plugins/check_nt.c ; then
1649   EXTRAS="$EXTRAS check_nt"
1650 elif test -f ../plugins/check_nt.c ; then
1651   EXTRAS="$EXTRAS check_nt"
1652 fi
1654 AC_MSG_CHECKING(for va_list)
1655 AC_TRY_COMPILE([#ifdef __STDC__
1656                 #include <stdio.h>
1657                 #include <stdlib.h>
1658                 #include <stdarg.h>
1659                 #else
1660                 #include <sys/types.h>
1661                 #include <stdio.h>
1662                 #include <varargs.h>
1663                 #endif],
1664                 [va_list args;],
1665                 [AC_MSG_RESULT(yes)],
1666                 [NEED_VA_LIST=-DNEED_VA_LIST AC_SUBST(NEED_VA_LIST) AC_MSG_RESULT(no)])
1668 case $host in
1669         *bsd*)
1670                 AC_DEFINE(__bsd__,1,[bsd specific code in check_dhcp.c])
1671         ;;
1672         *linux*)
1673                 AC_DEFINE(__linux__,1,[sun specific code in check_dhcp.c])
1674         ;;
1675         *sun* | solaris*)
1676                 AC_DEFINE(__sun__,1,[sun specific code in check_dhcp.c])
1677         ;;
1678         *hpux*)  
1679                 AC_DEFINE(__hpux__,1,[hpux specific code in check_dhcp.c])
1680         ;;
1681 esac
1683 AC_SUBST(EXTRAS)
1684 AC_SUBST(EXTRA_NETOBJS)
1685 AC_SUBST(DEPLIBS)
1687 AM_GNU_GETTEXT([no-libtool], [need-ngettext])
1688 AM_GNU_GETTEXT_VERSION(0.11.5)
1690 dnl Check for Redhat spopen problem
1691 dnl Wierd problem where ECHILD is returned from a wait call in error
1692 dnl Only appears to affect nslookup and dig calls. Only affects redhat around
1693 dnl 2.6.9-11 (okay in 2.6.9-5). Redhat investigating root cause
1694 dnl We patch plugins/popen.c
1695 dnl Need to add smp because uname different on those
1696 dnl Can force patch to be applied with --enable-redhat-pthread-workaround
1697 AC_ARG_ENABLE(redhat-pthread-workaround, 
1698         AC_HELP_STRING([--enable-redhat-pthread-workaround], 
1699                 [force Redhat patch to be applied (default: test system)]),
1700         [ac_cv_enable_redhat_pthread_workaround=$enableval],
1701         [ac_cv_enable_redhat_pthread_workaround=test])
1702 if test "$ac_cv_enable_redhat_pthread_workaround" = "test" ; then
1703         if echo $ac_cv_uname_r | egrep "\.EL(smp)?$" >/dev/null 2>&1 ; then
1704                 AC_MSG_CHECKING(for redhat spopen problem)
1705                 ( cd config_test && make && make test ) > /dev/null 2>&1
1706                 if test $? -eq 0 ; then
1707                         AC_MSG_RESULT(okay)
1708                 else
1709                         AC_MSG_RESULT(error)
1710                         AC_DEFINE(REDHAT_SPOPEN_ERROR, 1, [Workaround on redhat in spopen])
1711                 fi
1712         fi
1713 elif test "$ac_cv_enable_redhat_pthread_workaround" = "yes" ; then
1714         AC_DEFINE(REDHAT_SPOPEN_ERROR, 1, [Forced workaround on redhat in spopen])
1715 fi
1717 dnl External libraries - see ACKNOWLEDGEMENTS
1718 np_COREUTILS
1719 np_CURL
1721 AC_OUTPUT(
1722   Makefile 
1723   lib/Makefile 
1724   m4/Makefile 
1725   plugins/Makefile 
1726   plugins/tests/Makefile
1727   plugins-root/Makefile
1728   plugins-scripts/Makefile 
1729   plugins-scripts/subst 
1730   plugins-scripts/utils.pm 
1731   plugins-scripts/utils.sh 
1732   command.cfg 
1733   test.pl 
1734   pkg/solaris/pkginfo 
1735   intl/Makefile
1736   po/Makefile.in 
1740 dnl the ones below that are commented out need to be cleaned up 
1741 dnl in the configure code above to use with_foo instead of ac_cv_foo
1742 dnl if we want them to show up here.  it'd also make the code cleaner.
1743 dnl i'll get to that on another rainy day :) -sf
1744 dnl ACX_FEATURE([with],[dig-command])
1745 dnl ACX_FEATURE([with],[fping-command])
1746 dnl ACX_FEATURE([with],[mailq-command])
1747 dnl ACX_FEATURE([with],[nslookup-command])
1748 dnl ACX_FEATURE([with],[ntpdate-command])
1749 ACX_FEATURE([with],[ping6-command])
1750 ACX_FEATURE([with],[ping-command])
1751 dnl ACX_FEATURE([with],[qstat-command])
1752 dnl ACX_FEATURE([with],[rpcinfo-command])
1753 dnl ACX_FEATURE([with],[smbclient-command])
1754 dnl ACX_FEATURE([with],[snmpget-command])
1755 dnl ACX_FEATURE([with],[snmpgetnext-command])
1756 dnl ACX_FEATURE([with],[ssh-command])
1757 dnl ACX_FEATURE([with],[uptime-command])
1759 dnl ACX_FEATURE([with],[proc-loadavg])
1760 dnl ACX_FEATURE([with],[proc-meminfo])
1761 dnl ACX_FEATURE([with],[ps-command])
1762 dnl ACX_FEATURE([with],[ps-format])
1763 dnl ACX_FEATURE([with],[ps-cols])
1764 dnl ACX_FEATURE([with],[ps-varlist])
1766 ACX_FEATURE([with],[lwres])
1767 ACX_FEATURE([with],[ipv6])
1768 ACX_FEATURE([with],[openssl])
1769 ACX_FEATURE([with],[gnutls])
1770 ACX_FEATURE([enable],[emulate-getaddrinfo])
1771 ACX_FEATURE([with],[perl])
1772 ACX_FEATURE([with],[cgiurl])
1773 ACX_FEATURE([with],[nagios-user])
1774 ACX_FEATURE([with],[nagios-group])
1775 ACX_FEATURE([with],[trusted-path])