Code

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