Code

Changed configure option to --with-libtap-srcdir because requires
[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 ",,-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",,-L/usr/lib/mysql -lz)
282   AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient" check_mysql_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",,-L/usr/lib/mysql -lz)
285   AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient" check_mysql_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"
291     AC_SUBST(MYSQLINCLUDE)
292     AC_SUBST(MYSQLLIBS)
293     AC_SUBST(check_mysql_LDFLAGS)
294   else
295     AC_MSG_WARN([Skipping mysql plugin])
296     AC_MSG_WARN([install mysql client headers to compile this plugin (see REQUIREMENTS).])
297   fi
298 else
299   AC_MSG_WARN([Skipping mysql plugin])
300   AC_MSG_WARN([install mysql client libs to compile this plugin (see REQUIREMENTS).])
301 fi
302 CPPFLAGS="$_SAVEDCPPFLAGS $MYSQLINCLUDE"
303 LIBS="$_SAVEDLIBS"
305 AC_CHECK_HEADERS(unistd.h)
307 dnl Check for AF_INET6 support - unistd.h required for Darwin
308 AC_CACHE_CHECK([for IPv6 support], with_ipv6, [
309         AC_TRY_COMPILE([#ifdef HAVE_UNISTD_H
310                         #include <unistd.h>
311                         #endif
312                         #include <netinet/in.h>
313                         #include <sys/socket.h>],
314                         [struct sockaddr_in6 sin6;
315                         void *p;
317                         sin6.sin6_family = AF_INET6;
318                         sin6.sin6_port = 587;
319                         p = &sin6.sin6_addr;],
320                         [with_ipv6=yes], 
321                         [with_ipv6=no])
322         ])
324 if test x"$with_ipv6" != xno ; then
325         AC_DEFINE(USE_IPV6,1,[Enable IPv6 support])
326 fi
328 dnl #########################################################################
329 dnl Check if Posix getaddrinfo() is available.  It is also possible to use
330 dnl the version from the lwres library distributed with BIND.
331 dnl #########################################################################
332 AC_ARG_ENABLE([emulate-getaddrinfo],
333               ACX_HELP_STRING([--enable-emulate-getaddrinfo],
334                              [enable getaddrinfo emulation (default=no)]),
335               ,
336               enable_emulate_getaddrinfo=no)
338 AC_ARG_WITH(lwres,
339             ACX_HELP_STRING([--with-lwres=DIR],
340                            [use lwres library for getaddrinfo (default=no)]),
341             ,
342             with_lwres=no)
344 dnl ## enable force to test getaddrinfo.c
345 if test x$enable_emulate_getaddrinfo = xforce ; then
346         enable_emulate_getaddrinfo=yes
347         have_getaddrinfo=no
348 else
350 have_getaddrinfo=no
351 if test x$with_lwres != xno ; then
352         if test "$with_lwres" != yes ; then
353                    CPPFLAGS="-I${with_lwres}/include $CPPFLAGS"
354                    LDFLAGS="-L${with_lwres}/lib $LDFLAGS"
355         fi
356         AC_CHECK_HEADERS(lwres/netdb.h, ,
357                         [AC_MSG_ERROR([cannot find <lwres/netdb.h>])])
358         AC_CHECK_LIB(lwres, lwres_getaddrinfo, ,
359                      [AC_MSG_ERROR([cannot find the lwres library])],
360                      -lnsl -lpthread)
361         have_getaddrinfo=yes
362 fi
364 if test x$have_getaddrinfo != xyes ; then
365         AC_SEARCH_LIBS(getaddrinfo, socket resolv bind nsl c_r cr, have_getaddrinfo=yes)
366 fi
368 dnl # Special nonsense for systems that actually have getaddrinfo but
369 dnl # redefine the name to something else, e.g. OSF
370 if test x$have_getaddrinfo != xyes ; then
371         AC_MSG_CHECKING(if getaddrinfo is redefined in netdb.h)
372         AC_TRY_LINK([
373 #               include <netdb.h>
374         ], [
375                 struct addrinfo hints, *res;
376                 int err;
378                 err = getaddrinfo ("host", "service", &hints, &res);
379         ], [
380                 have_getaddrinfo=yes
381                 AC_MSG_RESULT(yes)
382         ], [AC_MSG_RESULT(no)])
383 fi
385 fi
387 if test x$have_getaddrinfo != xno ; then
388         if test x$enable_emulate_getaddrinfo != xno ; then
389                 AC_MSG_ERROR([getaddrinfo found but emulate-getaddrinfo was enabled])
390         fi
391         AC_DEFINE(HAVE_GETADDRINFO, 1,
392                   [Does system provide RFC 2553/Posix getaddrinfo?])
393 else
394         if test x$enable_emulate_getaddrinfo != xyes ; then
395 dnl                AC_MSG_ERROR([getaddrinfo not found: try --with-lwres or --enable-emulate-getaddrinfo])
396                enable_emulate_getaddrinfo=yes
397                AC_MSG_WARN([enabling getaddrinfo emulation])
398         fi
399         EXTRA_NETOBJS="$EXTRA_NETOBJS getaddrinfo.o"
400 fi
402 if test x"$enable_emulate_getaddrinfo" != xno ; then
403     have_resolver=no
405   dnl  Try for getipnodebyname
406     AC_SEARCH_LIBS(getipnodebyname, resolv bind nsl c_r cr, have_resolver=yes)
407     if test x"$have_resolver" != xno ; then
408          AC_DEFINE(HAVE_GETIPNODEBYNAME, 1,
409                    [Set when getipnodebyname is available])
410     fi
412   dnl  Try for gethostbyname_r
413     if test x"$have_resolver" = xno ; then
414         AC_SEARCH_LIBS(gethostbyname_r, resolv bind nsl c_r cr,
415                        [have_resolver=yes
416                         ACX_WHICH_GETHOSTBYNAME_R])
417     fi
419   dnl  Try for gethostbyname
420     if test x"$have_resolver" = xno ; then
421         if test x"$enable_pthreads" != xno ; then
422             AC_MSG_WARN([using threads but cannot find gethostbyname_r or getipnodebyname])
423         fi
424         AC_SEARCH_LIBS(gethostbyname, resolv bind nsl, ,
425                        [AC_MSG_ERROR([cannot find gethostbyname])])
426     fi
427     EXTRA_NETOBJS="$EXTRA_NETOBJS gethostbyname.o"
429 fi
431 dnl Checks for Kerberos. Must come before openssl checks for Redhat EL 3
432 AC_CHECK_HEADERS(krb5.h,FOUNDINCLUDE=yes,FOUNDINCLUDE=no)
433 if test "$FOUNDINCLUDE" = "no"; then
434   _SAVEDCPPFLAGS="$CPPFLAGS"
435   CPPFLAGS="$_SAVEDCPPFLAGS -I/usr/kerberos/include"
436   unset ac_cv_header_krb5_h
437   AC_CHECK_HEADERS(krb5.h,
438                    KRB5INCLUDE="-I/usr/kerberos/include"
439                    FOUNDINCLUDE=yes,
440                    FOUNDINCLUDE=no)
441 fi
442 AC_SUBST(KRBINCLUDE)
443 if test "$FOUNDINCLUDE" = "no"; then
444   CPPFLAGS="$_SAVEDCPPFLAGS"
445 fi
448 dnl openssl detection/configuration
449 if ! test "$with_openssl" = "no"; then
450         dnl Check for OpenSSL location if it wasn't already specified
451         if ! test -d "$with_openssl"; then
452                 for d in $OPENSSL_DIRS; do
453                         if test -x ${d}/bin/openssl || test -x ${d}/sbin/openssl ; then
454                                 with_openssl=$d
455                         fi
456                 done
457         fi
459         _SAVEDCPPFLAGS="$CPPFLAGS"
460         _SAVEDLDFLAGS="$LDFLAGS"
461         dnl Check for OpenSSL header files
462         unset FOUNDINCLUDE
463         CPPFLAGS="$CPPFLAGS -I$OPENSSL/include"
464         LDFLAGS="$LDFLAGS -R$OPENSSL/lib"
466         dnl check for openssl in $dir/include/openssl
467         AC_CHECK_HEADERS(openssl/ssl.h openssl/x509.h openssl/rsa.h openssl/pem.h openssl/crypto.h openssl/err.h,
468                          SSLINCLUDE="-I$OPENSSL/include"
469                          FOUNDINCLUDE=yes,
470                          FOUNDINCLUDE=no)
471         dnl else check to see if $dir/include has it
472         if test "$FOUNDINCLUDE" = "no"; then
473                 AC_CHECK_HEADERS(ssl.h x509.h rsa.h pem.h crypto.h err.h,
474                                  SSLINCLUDE="-I$OPENSSL/include"
475                                  FOUNDINCLUDE=yes,
476                                  FOUNDINCLUDE=no)
477         fi
478         AC_SUBST(SSLINCLUDE)
479         dnl if we didn't find it, reset CPPFLAGS
480         if test "$FOUNDINCLUDE" = "no"; then
481                 CPPFLAGS="$_SAVEDCPPFLAGS"
482                 LDFLAGS="$_SAVEDLDFLAGS"
483         fi
485         dnl Check for crypto lib
486         _SAVEDLIBS="$LIBS"
487         LIBS="-L${with_openssl}/lib"
488         AC_CHECK_LIB(crypto,CRYPTO_lock)
489         if test "$ac_cv_lib_crypto_CRYPTO_lock" = "yes"; then
490                 dnl Check for SSL lib
491                 AC_CHECK_LIB(ssl,main, SSLLIBS="-lssl -lcrypto",,-lcrypto)
492         fi
493         LIBS="$_SAVEDLIBS"
495         dnl test headers and libs to decide whether check_http should use SSL
496         if test "$ac_cv_lib_crypto_CRYPTO_lock" = "yes"; then
497                 if test "$ac_cv_lib_ssl_main" = "yes"; then
498                         if test "$FOUNDINCLUDE" = "yes"; then
499                                 FOUNDOPENSSL="yes"
500                         fi
501                 fi
502         fi
503 fi
506 dnl check for gnutls if openssl isn't found (or is disabled)
507 if test ! "$FOUNDOPENSSL" = "yes" && test ! "$with_gnutls" = "no"; then
508         if test ! "$with_gnutls" = ""; then
509                 CPPFLAGS="$CPPFLAGS -I${with_gnutls}/include"
510         elif test ! "$LIBGNUTLS_CONFIG" = ""; then
511                 CPPFLAGS="$CPPFLAGS -I`$LIBGNUTLS_CONFIG --prefix`"
512         fi
513         AC_CHECK_HEADERS([gnutls/openssl.h],FOUNDGNUTLS="yes",)
514         if test "$FOUNDGNUTLS" = "yes"; then
515                 AC_CHECK_LIB(gnutls-openssl,main,SSLLIBS="-lgnutls-openssl")
516         fi
517 fi
518 dnl end check for gnutls
520 if test "$FOUNDOPENSSL" = "yes" || test "$FOUNDGNUTLS" = "yes"; then
521         check_tcp_ssl="check_simap check_spop check_jabber check_nntps check_ssmtp"
522         AC_SUBST(check_tcp_ssl)
523         AC_SUBST(SSLLIBS)
524         AC_DEFINE(HAVE_SSL,1,[Define if SSL libraries are found])
525         if test "$FOUNDOPENSSL" = "yes"; then
526                 AC_DEFINE(USE_OPENSSL,1,[Define if using OpenSSL libraries])
527                 with_openssl="yes"
528                 with_gnutls="no"
529         else
530                 AC_DEFINE(USE_GNUTLS,1,[Define if using gnutls libraries])
531                 with_gnutls="yes"
532                 with_openssl="no"
533         fi
534 else
535         dnl else deliberately disabled or no ssl support available
536         AC_MSG_WARN([OpenSSL or GnuTLS libs could not be found or were disabled])
537         with_openssl="no"
538         with_gnutls="no"
539 fi
541 dnl
542 dnl Checks for header files.
543 dnl
545 AC_HEADER_STDC
546 AC_HEADER_TIME
547 AC_HEADER_SYS_WAIT
548 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)
549 AC_CHECK_HEADERS(features.h stdarg.h sys/unistd.h ctype.h stdlib.h)
551 dnl Checks for typedefs, structures, and compiler characteristics.
552 AC_C_CONST
553 AC_STRUCT_TM
554 AC_TYPE_PID_T
555 AC_TYPE_SIZE_T
556 AC_TYPE_SIGNAL
558 AC_CACHE_CHECK([for va_copy],ac_cv_HAVE_VA_COPY,[
559 AC_TRY_LINK([#include <stdarg.h>
560 va_list ap1,ap2;], [va_copy(ap1,ap2);],
561 ac_cv_HAVE_VA_COPY=yes,
562 ac_cv_HAVE_VA_COPY=no)])
563 if test x"$ac_cv_HAVE_VA_COPY" = x"yes"; then
564     AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available])
565 else    
566     AC_CACHE_CHECK([for __va_copy],ac_cv_HAVE___VA_COPY,[
567     AC_TRY_LINK([#include <stdarg.h>
568     va_list ap1,ap2;], [__va_copy(ap1,ap2);],
569     ac_cv_HAVE___VA_COPY=yes,
570     ac_cv_HAVE___VA_COPY=no)])
571     if test x"$ac_cv_HAVE___VA_COPY" = x"yes"; then
572         AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available])
573     fi
574 fi
576 AC_CHECK_FUNCS(vsnprintf snprintf asprintf vasprintf)
577 AC_CACHE_CHECK([for C99 vsnprintf],ac_cv_HAVE_C99_VSNPRINTF,[
578 AC_TRY_RUN([
579 #include <sys/types.h>
580 #include <stdarg.h>
581 void foo(const char *format, ...) { 
582        va_list ap;
583        int len;
584        char buf[5];
586        va_start(ap, format);
587        len = vsnprintf(buf, 0, format, ap);
588        va_end(ap);
589        if (len != 5) exit(1);
591        va_start(ap, format);
592        len = vsnprintf(0, 0, format, ap);
593        va_end(ap);
594        if (len != 5) exit(1);
596        if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
598        exit(0);
600 main() { foo("hello"); }
601 ],
602 ac_cv_HAVE_C99_VSNPRINTF=yes,ac_cv_HAVE_C99_VSNPRINTF=no,ac_cv_HAVE_C99_VSNPRINTF=cross)])
603 if test x"$ac_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
604     AC_DEFINE(HAVE_C99_VSNPRINTF,1,[Define if system has C99 compatible vsnprintf])
605 fi
607 AC_TRY_COMPILE([#include <sys/time.h>],
608                [struct timeval *tv;
609                 struct timezone *tz;],
610                AC_DEFINE(HAVE_STRUCT_TIMEVAL,1,[Define if we have a timeval structure])
611                AC_TRY_COMPILE([#include <sys/time.h>],
612                               [struct timeval *tv;
613                                struct timezone *tz;
614                                gettimeofday(tv, tz);],
615                               AC_DEFINE(HAVE_GETTIMEOFDAY,1,[Define if gettimeofday is found]),
616                               AC_DEFINE(NEED_GETTIMEOFDAY,1,[Define if gettimeofday is needed])))
618 dnl Checks for library functions.
619 AC_CHECK_FUNCS(memmove select socket strdup strstr strtod strtol strtoul floor)
621 AC_MSG_CHECKING(return type of socket size)
622 AC_TRY_COMPILE([#include <stdlib.h>
623                 #include <sys/types.h>
624                 #include <sys/socket.h>],
625                [int a = send(1, (const void *) buffer, (size_t *) 0, (int *) 0);],
626                ac_cv_socket_size_type=["size_t"]
627                 AC_MSG_RESULT(size_t),
628                ac_cv_socket_size_type=["int"]
629                 AC_MSG_RESULT(int))
631 AC_DEFINE_UNQUOTED(SOCKET_SIZE_TYPE, $ac_cv_socket_size_type ,
632         [Define type of socket size])
634 AC_ARG_WITH(proc-loadavg,
635             ACX_HELP_STRING([--with-proc-loadavg=PATH],
636                             [path to /proc/loadavg or equivalent]),
637             ac_cv_proc_loadavg=$withval)
638 AC_MSG_CHECKING([for /proc/loadavg])
639 if test -n "$ac_cv_proc_loadavg"; then
640   AC_MSG_RESULT([(command line) $ac_cv_proc_loadavg])
641 elif test -f "/proc/loadavg"; then
642   AC_MSG_RESULT([found /proc/loadavg])
643   ac_cv_proc_loadavg="/proc/loadavg"
644 else
645   AC_MSG_RESULT([no])
646 fi
648 if test -n "$ac_cv_proc_loadavg"; then
649   AC_DEFINE(HAVE_PROC_LOADAVG,1,[Define if /proc/loadavg or similar exists])
650   AC_DEFINE_UNQUOTED(PROC_LOADAVG,"/proc/loadavg",[Location of /proc/loadavg])
651 fi
653 dnl #### Process table test
655 AC_PATH_PROG(PATH_TO_PS,ps)
657 AC_MSG_CHECKING(for ps syntax)
658 AC_ARG_WITH(ps_command,
659             ACX_HELP_STRING([--with-ps-command=PATH], 
660                             [Verbatim command to execute for ps]),
661             PS_COMMAND=$withval)
662 AC_ARG_WITH(ps_format,
663             ACX_HELP_STRING([--with-ps-format=FORMAT],
664                             [Format string for scanning ps output]),
665             PS_FORMAT=$withval)
666 AC_ARG_WITH(ps_cols,
667             ACX_HELP_STRING([--with-ps-cols=NUM], 
668                             [Number of columns in ps command]),
669             PS_COLS=$withval)
670 AC_ARG_WITH(ps_varlist,
671             ACX_HELP_STRING([--with-ps-varlist=LIST],
672                             [Variable list for sscanf of 'ps' output]),
673             PS_VARLIST=$withval)
675 AM_CONDITIONAL(WANT_PST3, false)
677 if test -n "$PS_COMMAND" && test -n "$PS_FORMAT" && test -n "$PS_COLS" && test -n "$PS_VARLIST"; then 
678         ac_cv_ps_command="$PS_COMMAND"
679         ac_cv_ps_format="$PS_FORMAT"
680         ac_cv_ps_varlist="$PS_VARLIST"
681         ac_cv_ps_cols="$PS_COLS"
682         AC_MSG_RESULT([(command-line) $ac_cv_ps_command])
684 dnl Now using the pst3/kmem hack for solaris systems to avoid truncation
685 elif test "$ac_cv_uname_s" = "SunOS"; then
686         #
687         # this is a very, very ugly hack, to hardcode the location for plugins
688         #
689         if test "$libexecdir" = '${exec_prefix}/libexec'; then
690                 if test "$exec_prefix" = "NONE"; then
691                         if test "$prefix" = "NONE"; then
692                                 pst3="$ac_default_prefix/libexec/pst3"
693                         else
694                                 pst3="$prefix/libexec/pst3"
695                         fi
696                 else
697                         pst3="$exec_prefix/libexec/pst3"
698                 fi
699         else
700                 pst3="$libexecdir/pst3"
701         fi
702         ac_cv_ps_command="$pst3"
703         ac_cv_ps_format="%s %d %d %d %d %f %s %n"
704         ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
705         ac_cv_ps_cols=8
706         AC_MSG_RESULT([using nagios-plugins internal ps for solaris])
707         AM_CONDITIONAL(WANT_PST3, true)
709 dnl Some gnu/linux systems (debian for one) don't like -axwo and need axwo.
710 dnl so test for this first...
711 elif ps axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
712         egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null
713 then
714         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
715         ac_cv_ps_command="$PATH_TO_PS axwo 'stat uid pid ppid vsz rss pcpu comm args'"
716         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
717         ac_cv_ps_cols=9
718         AC_MSG_RESULT([$ac_cv_ps_command])
720 dnl For OpenBSD 3.2 & 3.3. Must come before ps -weo
721 dnl Should also work for FreeBSD 5.2.1 and 5.3
722 dnl  STAT UCOMM              VSZ   RSS USER      PPID COMMAND
723 elif ps -axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
724         egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null
725 then
726         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
727         ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid pid ppid vsz rss pcpu comm args'"
728         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
729         ac_cv_ps_cols=9
730         AC_MSG_RESULT([$ac_cv_ps_command])
732 dnl Some *BSDs have different format for ps. This is mainly to catch FreeBSD 4. 
733 dnl Limitation: Only first 16 chars returned for ucomm field
734 dnl Must come before ps -weo
735 elif ps -axwo 'stat uid pid ppid vsz rss pcpu ucomm command' 2>/dev/null | \
736         egrep -i ["^ *STAT +UID +PID +PPID +VSZ +RSS +%CPU +UCOMM +COMMAND"] > /dev/null
737 then
738         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
739         ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid pid ppid vsz rss pcpu ucomm command'"
740         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
741         ac_cv_ps_cols=9
742         AC_MSG_RESULT([$ac_cv_ps_command])
744 dnl  STAT UCOMM              VSZ   RSS USER       UID  PPID COMMAND
745 elif ps -weo 'stat comm vsz rss user uid pid ppid etime args' 2>/dev/null | \
746         egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[ID]+ +P[PID]+ +[ELAPSD]+ +[RGSCOMDNA]+"] >/dev/null
747 then
748         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procetime,procprog,&pos]"
749         ac_cv_ps_command="$PATH_TO_PS -weo 'stat uid pid ppid vsz rss pcpu etime comm args'"
750         ac_cv_ps_format="%s %d %d %d %d %d %f %s %s %n"
751         ac_cv_ps_cols=10
752         AC_MSG_RESULT([$ac_cv_ps_command])
754 dnl FreeBSD
755 elif ps waxco 'state command vsz rss uid user pid ppid' 2>/dev/null | \
756         egrep -i ["^STAT +COMMAND +VSZ +RSS +UID +USER +PID +PPID"] >/dev/null
757 then
758         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
759         ac_cv_ps_command="$PATH_TO_PS waxco 'state uid pid ppid vsz rss pcpu command command'"
760         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
761         ac_cv_ps_cols=9
762         AC_MSG_RESULT([$ac_cv_ps_command])
764 dnl BSD-like mode in RH 6.1
765 elif ps waxno 'state comm vsz rss uid user pid ppid args' 2>/dev/null | \
766         egrep -i ["^S +COMMAND +VSZ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
767 then
768         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
769         ac_cv_ps_command="$PATH_TO_PS waxno 'state uid pid ppid vsz rss pcpu comm args'"
770         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
771         ac_cv_ps_cols=9
772         AC_MSG_RESULT([$ac_cv_ps_command])
774 dnl SunOS 4.1.3:
775 dnl  F  UID  PID  PPID  CP  PRI  NI  SZ  RSS  WCHAN  STAT  TT  TIME  COMMAND
776 dnl Need the head -1 otherwise test will work because arguments are found
777 elif ps -laxnwww 2>/dev/null | head -1 | \
778         egrep -i ["^ *F(LAGS)? +UID +PID +PPID +CP +PRI +NI +(SZ)|(VSZ)|(SIZE) +RSS +WCHAN +STAT? +TTY? +TIME +COMMAND"] >/dev/null
779 then
780         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]"
781         ac_cv_ps_command="$PATH_TO_PS -laxnwww"
782         ac_cv_ps_format="%*s %d %d %d %*s %*s %*s %d %d %*s %s %*s %*s %n%s"
783         ac_cv_ps_cols=9
784         AC_MSG_RESULT([$ac_cv_ps_command])
786 dnl Debian Linux / procps v1.2.9:
787 dnl  FLAGS   UID   PID  PPID PRI  NI   SIZE   RSS WCHAN       STA TTY TIME COMMAND
788 dnl    100     0     1     0   0   0    776    76  c0131c8c   S  ffff  0:11 init [2]
789 dnl
790 elif ps laxnwww 2>/dev/null | \
791         egrep -i ["^ *F(LAGS)? +UID +PID +PPID +PRI +NI +(VSZ)|(SIZE) +RSS +WCHAN +STAT? TTY +TIME +COMMAND"] >/dev/null
792 then
793         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,procstat,&procvsz,&procrss,&pos,procprog]"
794         ac_cv_ps_command="$PATH_TO_PS laxnwww"
795         ac_cv_ps_format="%*s %d %d %d %*s %*s %d %d %*s %s %*s %*s %n%s"
796         ac_cv_ps_cols=9
797         AC_MSG_RESULT([$ac_cv_ps_command])
799 dnl OpenBSD (needs to come early because -exo appears to work, but does not give all procs)
800 elif ps -axo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
801         egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[PID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null
802 then
803         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
804         ac_cv_ps_command="$PATH_TO_PS -axo 'stat uid pid ppid vsz rss pcpu comm args'"
805         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
806         ac_cv_ps_cols=9
807         AC_MSG_RESULT([$ac_cv_ps_command])
809 dnl Tru64 - needs %*[ +<>] in PS_FORMAT. 
810 dnl Has /usr/bin/ps and /sbin/ps - force sbin version
811 dnl Can't use vsize and rssize because comes back with text (eg, 1.5M instead 
812 dnl of 1500). Will need big changes to check_procs to support
813 elif /sbin/ps -eo 'stat uid pid ppid pcpu etime comm args' 2>/dev/null | \
814         egrep -i ["^ *S +[UID]+ +[PID]+ +[PID]+ +[%CPU]+ +[ELAPSD]+ +[COMMAND]+ +[COMMAND]+"] > /dev/null
815 then
816         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procpcpu,procetime,procprog,&pos]"
817         ac_cv_ps_command="/sbin/ps -eo 'stat uid pid ppid pcpu etime comm args'"
818         ac_cv_ps_format=["%s%*[ +<>] %d %d %d %f %s %s %n"]
819         ac_cv_ps_cols=8
820         AC_MSG_RESULT([$ac_cv_ps_command])
822 elif ps -eo 's comm vsz rss user uid pid ppid args' 2>/dev/null | \
823         egrep -i ["^S[TAUES]* +C[OMDNA]+ +[VSIZE]+ +U[SER]+ +U[ID]+ +P[PID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null
824 then
825         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
826         ac_cv_ps_command="$PATH_TO_PS -eo 's uid pid ppid vsz rss pcpu comm args'"
827         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
828         ac_cv_ps_cols=9
829         AC_MSG_RESULT([$ac_cv_ps_command])
831 dnl AIX 4.3.3 and 5.1 do not have an rss field
832 elif ps -eo 'stat uid pid ppid vsz pcpu comm args' 2>/dev/null | \
833         egrep -i ["^ *S[TAUES]* +UID +PID +PPID +VSZ +%CPU +COMMAND +COMMAND"] >/dev/null
834 then
835         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procpcpu,procprog,&pos]"
836         ac_cv_ps_command="$PATH_TO_PS -eo 'stat uid pid ppid vsz pcpu comm args'"
837         ac_cv_ps_format="%s %d %d %d %d %f %s %n"
838         ac_cv_ps_cols=8
839         AC_MSG_RESULT([$ac_cv_ps_command - with no RSS])
841 dnl Solaris 2.6
842 elif ps -Ao 's comm vsz rss uid user pid ppid args' 2>/dev/null | \
843         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
844 then
845         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
846         ac_cv_ps_command="$PATH_TO_PS -Ao 's uid pid ppid vsz rss pcpu comm args'"
847         # There must be no space between the %s and %n due to a wierd problem in sscanf where
848         # it will return %n as longer than the line length
849         ac_cv_ps_format="%s %d %d %d %d %d %f %s%n"
850         ac_cv_ps_cols=9
851         AC_MSG_RESULT([$ac_cv_ps_command])
853 elif ps -Ao 'status comm vsz rss uid user pid ppid args' 2>/dev/null | \
854         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
855 then
856         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
857         ac_cv_ps_command="$PATH_TO_PS -Ao 'status uid pid ppid vsz rss pcpu comm args'"
858         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
859         ac_cv_ps_cols=9
860         AC_MSG_RESULT([$ac_cv_ps_command])
862 elif ps -Ao 'state comm vsz rss uid user pid ppid args' 2>/dev/null | \
863         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
864 then
865         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
866         ac_cv_ps_command="$PATH_TO_PS -Ao 'state uid pid ppid vsz rss pcpu comm args'"
867         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
868         ac_cv_ps_cols=9
869         AC_MSG_RESULT([$ac_cv_ps_command])
871 dnl wonder who takes state instead of stat
872 elif ps -ao 'state command vsz rss user pid ppid args' 2>/dev/null | \
873         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
874 then
875         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
876         ac_cv_ps_command="$PATH_TO_PS -ao 'state uid pid ppid vsz rss pcpu command args'"
877         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
878         ac_cv_ps_cols=8
879         AC_MSG_RESULT([$ac_cv_ps_command])
881 dnl IRIX 53
882 elif ps -el 2>/dev/null | \
883         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
884 then
885         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&pos,procprog]"
886         ac_cv_ps_command="$PATH_TO_PS -el (IRIX 53)"
887         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %d %d %*s %*s %*s %n%s"
888         ac_cv_ps_cols=8
889         AC_MSG_RESULT([$ac_cv_ps_command])
891 dnl IRIX 63
892 elif ps -el 2>/dev/null | \
893         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +ADDR +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
894 then
895         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
896         ac_cv_ps_command="$PATH_TO_PS -el (IRIX 63)"
897         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
898         ac_cv_ps_cols=6
899         AC_MSG_RESULT([$ac_cv_ps_command])
901 dnl AIX 4.1:
902 dnl     F S      UID   PID  PPID   C PRI NI ADDR  SZ  RSS   WCHAN    TTY  TIME CMD
903 dnl    303 A        0     0     0 120  16 -- 1c07  20   24              -  0:45 swapper
904 elif ps -el 2>/dev/null | \
905         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +ADDR +SZ +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
906 then
907         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
908         ac_cv_ps_command="$PATH_TO_PS -el (AIX 4.1 and HP-UX)"
909         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
910         ac_cv_ps_cols=6
911         AC_MSG_RESULT([$ac_cv_ps_command])
913 dnl AIX?
914 elif ps glaxen 2>/dev/null | \
915         egrep -i ["^ *F +UID +PID +PPID +PRI +NI +VSZ +RSS +WCHAN +STAT +TTY +TIME +COMMAND"] >/dev/null
916 then
917         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]"
918         ac_cv_ps_command="$PATH_TO_PS glaxen"
919         ac_cv_ps_format="%*s %d %d %d %*s %*s %d %d %*s %s %*s %*s %n%s"
920         ac_cv_ps_cols=8
921         AC_MSG_RESULT([$ac_cv_ps_command])
923 dnl MacOSX / Darwin
924 dnl TODO: MacOSX has commands with spaces which will cause problems to PS_FORMAT
925 dnl Some truncation will happen in UCOMM column
926 dnl STAT      VSZ    RSS   UID  PPID %CPU UCOMM            COMMAND
927 dnl Ss      52756  22496   501     1   6.9 Window Manager   /System/Library/CoreServices/WindowServer -daemon
928 elif ps wwaxo 'state vsz rss uid pid ppid pcpu ucomm command' 2>/dev/null | \
929         egrep -i ["^STAT +VSZ +RSS +UID +PPID +%CPU +UCOMM +COMMAND"] >/dev/null
930 then
931         ac_cv_ps_command="$PATH_TO_PS wwaxo 'state vsz rss uid pid ppid pcpu ucomm command'"
932         ac_cv_ps_varlist="[procstat,&procvsz,&procrss,&procuid,&procpid,&procppid,&procpcpu,procprog,&pos]"
933         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
934         ac_cv_ps_cols=8
935         AC_MSG_RESULT([$ac_cv_ps_command])
937 dnl UnixWare 
938 elif ps -Al 2>/dev/null | \
939         egrep -i ["^ *F +S +UID +PID +PPID +CLS +PRI +NI +C +ADDR +SZ +WCHAN +TTY +TIME +COMD"] >/dev/null
940 then
941         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
942         ac_cv_ps_command="$PATH_TO_PS -Al"
943         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
944         ac_cv_ps_cols=8
945         AC_MSG_RESULT([$ac_cv_ps_command])
947 else
948         AC_MSG_WARN([unable to find usable ps syntax - check_procs and check_nagios will not be compiled])
949 fi
951 if test -n "$ac_cv_ps_varlist" ; then
952         AC_DEFINE_UNQUOTED(PS_VARLIST,$ac_cv_ps_varlist,
953                 [Variable list for sscanf of 'ps' output])
954         AC_DEFINE_UNQUOTED(PS_COMMAND,"$ac_cv_ps_command",
955                 [Verbatim command to execute for ps in check_procs])
956         AC_DEFINE_UNQUOTED(PS_FORMAT,"$ac_cv_ps_format",
957                 [Format string for scanning ps output in check_procs])
958         AC_DEFINE_UNQUOTED(PS_COLS,$ac_cv_ps_cols,
959                 [Number of columns in ps command])
960         EXTRAS="$EXTRAS check_procs check_nagios"
961         if echo "$ac_cv_ps_varlist" | grep -q "procetime"; then
962                 AC_DEFINE(PS_USES_PROCETIME,"yes",
963                           [Whether the ps utility uses the "procetime" field])
964         fi
965 fi
967 AC_PATH_PROG(PATH_TO_PING,ping)
968 AC_PATH_PROG(PATH_TO_PING6,ping6)
970 AC_ARG_WITH(ping_command,
971         ACX_HELP_STRING([--with-ping-command=SYNTAX],
972                 [sets syntax for ICMP ping]),
973         with_ping_command=$withval,)
975 AC_MSG_CHECKING(for ICMP ping syntax)
976 ac_cv_ping_packets_first=no
977 ac_cv_ping_has_timeout=no
978 if test -n "$with_ping_command"
979 then
980         AC_MSG_RESULT([(command-line) $with_ping_command])
981         if test -n "$ac_cv_ping_packets_first"
982         then
983                 ac_cv_ping_packets_first=yes
984                 ac_cv_ping_has_timeout=yes
985         fi
987 elif [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
988         $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
989         egrep -i "^round-trip|^rtt" >/dev/null
990 then
991         with_ping_command="$PATH_TO_PING -n -U -c %d %s"
992         ac_cv_ping_packets_first=yes
993         AC_MSG_RESULT([$with_ping_command])
995 elif $PATH_TO_PING -n -U -w 10 -c 1 127.0.0.1 2>/dev/null | \
996         egrep -i "^round-trip|^rtt" >/dev/null
997 then
998         with_ping_command="$PATH_TO_PING -n -U -w %d -c %d %s"
999         ac_cv_ping_packets_first=yes
1000   ac_cv_ping_has_timeout=yes
1001         AC_MSG_RESULT([$with_ping_command])
1003 elif $PATH_TO_PING -n -U -c 1 127.0.0.1 2>/dev/null | \
1004         egrep -i "^round-trip|^rtt" >/dev/null
1005 then
1006         with_ping_command="$PATH_TO_PING -n -U -c %d %s"
1007         ac_cv_ping_packets_first=yes
1008         AC_MSG_RESULT([$with_ping_command])
1010 elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \
1011         egrep -i "^round-trip|^rtt" >/dev/null
1012 then
1013         with_ping_command="$PATH_TO_PING -n -c %d %s"
1014         ac_cv_ping_packets_first=yes
1015         AC_MSG_RESULT([$with_ping_command])
1017 elif $PATH_TO_PING -n 127.0.0.1 -c 1 2>/dev/null | \
1018         egrep -i "^round-trip|^rtt" >/dev/null
1019 then
1020         with_ping_command="$PATH_TO_PING -n %s -c %d"
1021         AC_MSG_RESULT([$with_ping_command])
1023 elif $PATH_TO_PING 127.0.0.1 -n 1 2>/dev/null | \
1024         egrep -i "^round-trip|^rtt" >/dev/null
1025 then
1026         with_ping_command="$PATH_TO_PING %s -n %d"
1027         AC_MSG_RESULT([$with_ping_command])
1029 elif $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
1030         egrep -i "^round-trip|^rtt" >/dev/null
1031 then
1032         with_ping_command="$PATH_TO_PING -n -s %s 56 %d"
1033         AC_MSG_RESULT([$with_ping_command])
1035 elif $PATH_TO_PING -n -h 127.0.0.1 -s 56 -c 1 2>/dev/null | \
1036         egrep -i "^round-trip|^rtt" >/dev/null
1037 then
1038         with_ping_command="$PATH_TO_PING -n -h %s -s 56 -c %d"
1039         AC_MSG_RESULT([$with_ping_command])
1041 elif $PATH_TO_PING -n -s 56 -c 1 127.0.0.1 2>/dev/null | \
1042         egrep -i "^round-trip|^rtt" >/dev/null
1043 then
1044         with_ping_command="$PATH_TO_PING -n -s 56 -c %d %s"
1045         ac_cv_ping_packets_first=yes
1046         AC_MSG_RESULT([$with_ping_command])
1048 elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \
1049         egrep -i "^round-trip|^rtt" >/dev/null
1050 then
1051         with_ping_command="$PATH_TO_PING -n -c %d %s"
1052         ac_cv_ping_packets_first=yes
1053         AC_MSG_RESULT([$with_ping_command])
1055 else
1056         AC_MSG_WARN([unable to find usable ping syntax])
1057 fi
1059 AC_DEFINE_UNQUOTED(PING_COMMAND,"$with_ping_command",
1060         [path and args for ICMP ping command])
1062 if test "x$ac_cv_ping_packets_first" != "xno"
1063 then
1064         AC_DEFINE(PING_PACKETS_FIRST,1,
1065                 [Define if packet count must precede host])
1066 fi
1068 if test "x$ac_cv_ping_has_timeout" != "xno"
1069 then
1070         AC_DEFINE(PING_HAS_TIMEOUT,1,
1071                 [Define if ping has its own timeout option that should be set])
1072 fi
1074 AC_ARG_WITH(ping6_command,
1075         ACX_HELP_STRING([--with-ping6-command=SYNTAX],
1076                 [sets syntax for ICMPv6 ping]),
1077         with_ping6_command=$withval,)
1079 if test x"$with_ipv6" != xno ; then
1080 AC_MSG_CHECKING(for ICMPv6 ping syntax)
1081 ac_cv_ping6_packets_first=no
1082 if test -n "$with_ping6_command"
1083 then
1084         AC_MSG_RESULT([(command-line) $with_ping6_command])
1085         if test -n "$ac_cv_ping6_packets_first"
1086         then
1087                 ac_cv_ping6_packets_first=yes
1088         fi
1090 elif test "x$PATH_TO_PING6" != "x"; then
1091         if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
1092                 $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \
1093                 egrep -i "^round-trip|^rtt" >/dev/null
1094         then
1095                 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s"
1096                 ac_cv_ping6_packets_first=yes
1097                 AC_MSG_RESULT([$with_ping6_command])
1099         elif $PATH_TO_PING6 -n -U -w 10 -c 1 ::1 2>/dev/null | \
1100                 egrep -i "^round-trip|^rtt" >/dev/null
1101         then
1102                 with_ping6_command="$PATH_TO_PING6 -n -U -w %d -c %d %s"
1103                 ac_cv_ping6_packets_first=yes
1104                 ac_cv_ping_has_timeout=yes
1105                 AC_MSG_RESULT([$with_ping6_command])
1107         elif $PATH_TO_PING6 -n -U -c 1 ::1 2>/dev/null | \
1108                 egrep -i "^round-trip|^rtt" >/dev/null
1109         then
1110                 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s"
1111                 ac_cv_ping6_packets_first=yes
1112                 AC_MSG_RESULT([$with_ping6_command])
1114         elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \
1115                 egrep -i "^round-trip|^rtt" >/dev/null
1116         then
1117                 with_ping6_command="$PATH_TO_PING6 -n -c %d %s"
1118                 ac_cv_ping6_packets_first=yes
1119                 AC_MSG_RESULT([$with_ping6_command])
1121         elif $PATH_TO_PING6 -n ::1 -c 1 2>/dev/null | \
1122                 egrep -i "^round-trip|^rtt" >/dev/null
1123         then
1124                 with_ping6_command="$PATH_TO_PING6 -n %s -c %d"
1125                 AC_MSG_RESULT([$with_ping6_command])
1127         elif $PATH_TO_PING6 ::1 -n 1 2>/dev/null | \
1128                 egrep -i "^round-trip|^rtt" >/dev/null
1129         then
1130                 with_ping6_command="$PATH_TO_PING6 %s -n %d"
1131                 AC_MSG_RESULT([$with_ping6_command])
1133         elif $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \
1134                 egrep -i "^round-trip|^rtt" >/dev/null
1135         then
1136                 with_ping6_command="$PATH_TO_PING6 -n -s %s 56 %d"
1137                 AC_MSG_RESULT([$with_ping6_command])
1139         elif $PATH_TO_PING6 -n -h ::1 -s 56 -c 1 2>/dev/null | \
1140                 egrep -i "^round-trip|^rtt" >/dev/null
1141         then
1142                 with_ping6_command="$PATH_TO_PING6 -n -h %s -s 56 -c %d"
1143                 AC_MSG_RESULT([$with_ping6_command])
1145         elif $PATH_TO_PING6 -n -s 56 -c 1 ::1 2>/dev/null | \
1146                 egrep -i "^round-trip|^rtt" >/dev/null
1147         then
1148                 with_ping6_command="$PATH_TO_PING6 -n -s 56 -c %d %s"
1149                 ac_cv_ping6_packets_first=yes
1150                 AC_MSG_RESULT([$with_ping_command])
1152         elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \
1153                 egrep -i "^round-trip|^rtt" >/dev/null
1154         then
1155                 with_ping6_command="$PATH_TO_PING6 -n -c %d %s"
1156                 ac_cv_ping6_packets_first=yes
1157                 AC_MSG_RESULT([$with_ping6_command])
1159         fi
1161 elif test "x$PATH_TO_PING" != "x"; then
1162         if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
1163                 $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \
1164                 egrep -i "^round-trip|^rtt" >/dev/null
1165         then
1166                 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s"
1167                 ac_cv_ping6_packets_first=yes
1168                 AC_MSG_RESULT([$with_ping6_command])
1170         elif $PATH_TO_PING -A inet6 -n -U -c 1 ::1 2>/dev/null | \
1171                 egrep -i "^round-trip|^rtt" >/dev/null
1172         then
1173                 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s"
1174                 ac_cv_ping6_packets_first=yes
1175                 AC_MSG_RESULT([$with_ping6_command])
1177         elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \
1178                 egrep -i "^round-trip|^rtt" >/dev/null
1179         then
1180                 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s"
1181                 ac_cv_ping6_packets_first=yes
1182                 AC_MSG_RESULT([$with_ping6_command])
1184         elif $PATH_TO_PING -A inet6 -n ::1 -c 1 2>/dev/null | \
1185                 egrep -i "^round-trip|^rtt" >/dev/null
1186         then
1187                 with_ping6_command="$PATH_TO_PING -A inet6 -n %s -c %d"
1188                 AC_MSG_RESULT([$with_ping6_command])
1190         elif $PATH_TO_PING -A inet6 ::1 -n 1 2>/dev/null | \
1191                 egrep -i "^round-trip|^rtt" >/dev/null
1192         then
1193                 with_ping6_command="$PATH_TO_PING -A inet6 %s -n %d"
1194                 AC_MSG_RESULT([$with_ping6_command])
1196         elif $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \
1197                 egrep -i "^round-trip|^rtt" >/dev/null
1198         then
1199                 with_ping6_command="$PATH_TO_PING -A inet6 -n -s %s 56 %d"
1200                 AC_MSG_RESULT([$with_ping6_command])
1202         elif $PATH_TO_PING -A inet6 -n -h ::1 -s 56 -c 1 2>/dev/null | \
1203                 egrep -i "^round-trip|^rtt" >/dev/null
1204         then
1205                 with_ping6_command="$PATH_TO_PING -A inet6 -n -h %s -s 56 -c %d"
1206                 AC_MSG_RESULT([$with_ping6_command])
1208         elif $PATH_TO_PING -A inet6 -n -s 56 -c 1 ::1 2>/dev/null | \
1209                 egrep -i "^round-trip|^rtt" >/dev/null
1210         then
1211                 with_ping6_command="$PATH_TO_PING -A inet6 -n -s 56 -c %d %s"
1212                 ac_cv_ping6_packets_first=yes
1213                 AC_MSG_RESULT([$with_ping_command])
1215         elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \
1216                 egrep -i "^round-trip|^rtt" >/dev/null
1217         then
1218                 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s"
1219                 ac_cv_ping6_packets_first=yes
1220                 AC_MSG_RESULT([$with_ping6_command])
1222         fi
1224 fi
1226 if test "x$with_ping6_command" != "x"; then
1227         AC_DEFINE_UNQUOTED(PING6_COMMAND,"$with_ping6_command",
1228                 [path and args for ICMPv6 ping command])
1229 else
1230         AC_MSG_RESULT([none])
1231 fi
1233 if test "x$ac_cv_ping6_packets_first" != "xno"; then
1234         AC_DEFINE(PING6_PACKETS_FIRST,1,
1235                 [Define if packet count must precede host])
1236 fi
1237 fi
1240 AC_MSG_CHECKING(for nslookup syntax)
1241 AC_ARG_WITH(nslookup_command,
1242             ACX_HELP_STRING([--with-nslookup-command=PATH],
1243                             [sets path to nslookup executable]),
1244             ac_cv_nslookup_command=$withval)
1245 if test -n "$ac_cv_nslookup_command"; then
1246         AC_MSG_RESULT([(command line) $ac_cv_nslookup_command])
1247 else
1248         AC_PATH_PROG(PATH_TO_NSLOOKUP,nslookup)
1249         if test -n "$PATH_TO_NSLOOKUP"
1250         then
1251                 if $PATH_TO_NSLOOKUP -sil 127.0.0.1 2>&1 | grep ["Invalid option: sil"] >/dev/null
1252                 then
1253                         ac_cv_nslookup_command="$PATH_TO_NSLOOKUP"
1254                         AC_MSG_RESULT([$ac_cv_nslookup_command])
1256                 else
1257                         ac_cv_nslookup_command="$PATH_TO_NSLOOKUP -sil"
1258                         AC_MSG_RESULT([$ac_cv_nslookup_command])
1260                 fi
1261         else
1262                 AC_MSG_WARN([nslookup command not found])
1263         fi
1264 fi
1266 if test -n "$ac_cv_nslookup_command"; then
1267         EXTRAS="$EXTRAS check_dns"
1268         AC_DEFINE_UNQUOTED(NSLOOKUP_COMMAND,"$ac_cv_nslookup_command", [path and args for nslookup])
1269 fi
1271 AC_PATH_PROG(PATH_TO_HOST,host)
1272 if test -n "$ac_cv_path_PATH_TO_HOST"
1273 then
1274         EXTRAS="$EXTRAS check_dns"
1275 fi
1277 AC_PATH_PROG(PATH_TO_UPTIME,uptime)
1278 AC_ARG_WITH(uptime_command,
1279             ACX_HELP_STRING([--with-uptime-command=PATH],
1280                             [sets path to uptime]), PATH_TO_UPTIME=$withval)
1281 AC_DEFINE_UNQUOTED(PATH_TO_UPTIME,"$PATH_TO_UPTIME",[path to uptime binary])
1283 AC_PATH_PROG(PATH_TO_RPCINFO,rpcinfo)
1284 AC_ARG_WITH(rpcinfo_command,
1285             ACX_HELP_STRING([--with-rpcinfo-command=PATH],
1286                             [sets path to rpcinfo]), PATH_TO_RPCINFO=$withval)
1287 AC_DEFINE_UNQUOTED(PATH_TO_RPCINFO,"$PATH_TO_RPCINFO",[path to rpcinfo binary])
1289 AC_PATH_PROG(PATH_TO_NTPDATE,ntpdate)
1290 AC_ARG_WITH(ntpdate_command,
1291             ACX_HELP_STRING([--with-ntpdate-command=PATH],
1292                             [sets path to ntpdate]), PATH_TO_NTPDATE=$withval)
1293 AC_PATH_PROGS(PATH_TO_NTPDC,ntpdc xntpdc)
1294 AC_PATH_PROGS(PATH_TO_NTPQ,ntpq)
1295 if (test -n "$PATH_TO_NTPDATE" || test -n "$PATH_TO_NTPQ")
1296 then
1297         AC_DEFINE_UNQUOTED(PATH_TO_NTPQ,"$PATH_TO_NTPQ",[path to ntpq binary])
1298         AC_DEFINE_UNQUOTED(PATH_TO_NTPDATE,"$PATH_TO_NTPDATE",[path to ntpdate binary])
1299 else
1300         AC_MSG_WARN([Install NTP programs (http://www.ntp.org) if you want to monitor time synchronization])
1301 fi
1303 AC_PATH_PROG(PATH_TO_LMSTAT,lmstat)
1304 if test -x "$PATH_TO_LMSTAT"
1305 then
1306         AC_DEFINE_UNQUOTED(PATH_TO_LMSTAT,"$PATH_TO_LMSTAT",[path to lmstat])
1307 else
1308         AC_MSG_WARN([Get lmstat from Globetrotter Software to monitor flexlm licenses])
1309 fi
1311 AC_PATH_PROG(PATH_TO_SMBCLIENT,smbclient)
1312 AC_ARG_WITH(smbclient_command,
1313             ACX_HELP_STRING([--with-smbclient-command=PATH],
1314                             [sets path to smbclient]), 
1315             PATH_TO_SMBCLIENT=$withval)
1316 if test -n "$PATH_TO_SMBCLIENT"
1317 then
1318         AC_DEFINE_UNQUOTED(PATH_TO_SMBCLIENT,"$PATH_TO_SMBCLIENT",[path to smbclient binary])
1319 else
1320         AC_MSG_WARN([Get smbclient from Samba.org to monitor SMB shares])
1321 fi
1324 AC_PATH_PROG(PATH_TO_WHO,who)
1326 if [$PATH_TO_WHO -q 2>/dev/null | egrep -i "^# users=[0-9]+$" >/dev/null]
1327 then
1328         ac_cv_path_to_who="$PATH_TO_WHO -q"
1329 else
1330         ac_cv_path_to_who="$PATH_TO_WHO"
1331 fi
1333 AC_DEFINE_UNQUOTED(WHO_COMMAND,"$ac_cv_path_to_who",
1334         [path and arguments for invoking 'who'])
1336 AC_PATH_PROG(PATH_TO_SNMPGET,snmpget)
1337 AC_ARG_WITH(snmpget_command,
1338             ACX_HELP_STRING([--with-snmpget-command=PATH],
1339                             [Path to snmpget command]),
1340             PATH_TO_SNMPGET=$withval)
1341 if test -n "$PATH_TO_SNMPGET"
1342 then
1343         AC_DEFINE_UNQUOTED(PATH_TO_SNMPGET,"$PATH_TO_SNMPGET",[path to snmpget binary])
1344         EXTRAS="$EXTRAS check_hpjd check_snmp"
1345 else
1346         AC_MSG_WARN([Get snmpget from http://net-snmp.sourceforge.net to make check_hpjd and check_snmp plugins])
1347 fi
1349 AC_PATH_PROG(PATH_TO_SNMPGETNEXT,snmpgetnext)
1350 AC_ARG_WITH(snmpgetnext_command,
1351             ACX_HELP_STRING([--with-snmpgetnext-command=PATH],
1352                             [Path to snmpgetnext command]),
1353             PATH_TO_SNMPGETNEXT=$withval)
1354 if test -n "$PATH_TO_SNMPGETNEXT"
1355 then
1356         AC_DEFINE_UNQUOTED(PATH_TO_SNMPGETNEXT,"$PATH_TO_SNMPGETNEXT",[path to snmpgetnext binary])
1357 fi
1359 if ( $PERL -M"Net::SNMP 3.6" -e 'exit' 2>/dev/null  )
1360 then
1361         AC_MSG_CHECKING(for Net::SNMP perl module)
1362         AC_MSG_RESULT([found])
1363 else
1364         AC_MSG_WARN([Tried $PERL - install Net::SNMP perl module if you want to use the perl snmp plugins])
1365 fi
1367 AC_PATH_PROG(PATH_TO_QUAKESTAT,quakestat)
1368 AC_PATH_PROG(PATH_TO_QSTAT,qstat)
1369 AC_ARG_WITH(qstat_command,
1370             ACX_HELP_STRING([--with-qstat-command=PATH], 
1371                             [Path to qstat command]), PATH_TO_QSTAT=$withval)
1373 if test -x "$PATH_TO_QUAKESTAT"
1374 then
1375         ac_cv_path_to_qstat="$PATH_TO_QUAKESTAT"
1376         EXTRAS="$EXTRAS check_game"
1378 elif test -n "$PATH_TO_QSTAT"
1379 then
1380         ac_cv_path_to_qstat="$PATH_TO_QSTAT"
1381         EXTRAS="$EXTRAS check_game"
1382 else
1383         AC_MSG_WARN([Get qstat from http://www.activesw.com/people/steve/qstat.html in order to make check_game plugin])
1384 fi
1386 if test $ac_cv_path_to_qstat 
1387 then
1388         AC_DEFINE_UNQUOTED(PATH_TO_QSTAT,"$ac_cv_path_to_qstat",
1389                 [path to qstat/quakestat])
1390 fi
1392 AC_PATH_PROG(PATH_TO_FPING,fping)
1393 AC_ARG_WITH(fping_command,
1394             ACX_HELP_STRING([--with-fping-command=PATH],
1395                             [Path to fping command]), PATH_TO_FPING=$withval)
1396 if test -n "$PATH_TO_FPING"
1397 then
1398         AC_DEFINE_UNQUOTED(PATH_TO_FPING,"$PATH_TO_FPING",[path to fping])
1399         EXTRAS="$EXTRAS check_fping"
1400 else
1401         AC_MSG_WARN([Get fping from http://www.fping.com in order to make check_fping plugin])
1402 fi
1404 AC_PATH_PROG(PATH_TO_SSH,ssh)
1405 AC_ARG_WITH(ssh_command,
1406             ACX_HELP_STRING([--with-ssh-command=PATH],
1407                             [sets path for ssh]), PATH_TO_SSH=$withval)
1408 if test -n "$PATH_TO_SSH"
1409 then
1410         AC_DEFINE_UNQUOTED(SSH_COMMAND,"$PATH_TO_SSH",[path to ssh binary])
1411         EXTRAS="$EXTRAS check_by_ssh"
1412 else
1413         AC_MSG_WARN([Get ssh in order to make check_by_ssh plugin])
1414 fi
1417 AC_PATH_PROG(PATH_TO_MAILQ,mailq)
1418 AC_ARG_WITH(mailq_command,
1419             ACX_HELP_STRING([--with-mailq-command=PATH],
1420                             [sets path to mailq]), PATH_TO_MAILQ=$withval)
1421 if test -n "$PATH_TO_MAILQ"
1422 then
1423         AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_MAILQ",[path to mailq])
1424 else
1425         AC_MSG_WARN([Could not find mailq or eqivalent])
1426 fi
1428 AC_PATH_PROG(PATH_TO_QMAIL_QSTAT,qmail-qstat)
1429 if test -x "$PATH_TO_QMAIL_QSTAT"
1430 then
1431         AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_QMAIL_QSTAT",[path to qmail-qstat])
1432 else
1433         AC_MSG_WARN([Could not find qmail-qstat or eqivalent])
1434 fi
1436 dnl SWAP info required is amount allocated/available and amount free
1437 dnl The plugin works through all the swap devices and adds up the total swap
1438 dnl available.
1439 AC_PATH_PROG(PATH_TO_SWAP,swap)
1440 if (test -n "$PATH_TO_SWAP")
1441 then
1442 AC_MSG_CHECKING([for $PATH_TO_SWAP format])
1443 if [$PATH_TO_SWAP -l 2>&1 >/dev/null]
1444 then
1445         ac_cv_have_swap=yes
1446         ac_cv_swap_command="$PATH_TO_SWAP -l"
1447         if [$PATH_TO_SWAP -l 2>/dev/null | \
1448                 egrep -i "^lswap +path +pri +swaplo +blocks +free +maxswap" \
1449                 >/dev/null]
1450         then
1451                 ac_cv_swap_format=[" %*d %*s %*d,%*d %*d %*d %f %f"]
1452                 ac_cv_swap_conv=2048
1453                 AC_MSG_RESULT([using IRIX format swap])
1455         elif [$PATH_TO_SWAP -l 2>/dev/null | egrep -i "^path +dev +swaplo +blocks +free" >/dev/null]
1456         then
1457                 ac_cv_swap_format=["%*s %*[0-9,-] %*d %f %f"]
1458                 ac_cv_swap_conv=2048
1459                 AC_MSG_RESULT([using Unixware format swap])
1460         else
1461                 dnl if we don't know what format swap's output is
1462                 dnl we might as well pretend we didn't see it
1463                 ac_cv_have_swap=""
1464                 ac_cv_swap_command=""
1465         fi
1466 fi
1467 dnl end if for PATH_TO_SWAP
1468 fi
1470 AC_PATH_PROG(PATH_TO_SWAPINFO,swapinfo)
1471 if (test -n "$PATH_TO_SWAPINFO")
1472 then
1473 AC_MSG_CHECKING([for $PATH_TO_SWAPINFO format])
1474 if [$PATH_TO_SWAPINFO -k 2>&1 | egrep -i "^Device" >/dev/null]
1475 then
1476         ac_cv_have_swap=yes
1477         ac_cv_swap_command="$PATH_TO_SWAPINFO -k"
1479         if [$PATH_TO_SWAPINFO -k 2>/dev/null | egrep -i "^Device +1K-blocks +Used +Avail" >/dev/null]
1480         then
1481                 ac_cv_swap_format=["%*s %f %*d %f"]
1482                 ac_cv_swap_conv=1024
1483                 AC_MSG_RESULT([using FreeBSD format swapinfo])
1484         fi
1486 elif [$PATH_TO_SWAPINFO -dfM 2>/dev/null | egrep -i "^TYPE +AVAIL +USED +FREE" >/dev/null]
1487 then
1488         ac_cv_have_swap=yes
1489         ac_cv_swap_command="$PATH_TO_SWAPINFO -dfM",
1490         ac_cv_swap_format=["%*s %f %*d %f"]
1491         ac_cv_swap_conv=1024
1492         AC_MSG_RESULT([using HP-UX format swapinfo])
1493 fi
1494 dnl end if for PATH_TO_SWAPINFO
1495 fi
1497 AC_PATH_PROG(PATH_TO_LSPS,lsps)
1498 if (test -n "$PATH_TO_LSPS")
1499 then
1500 AC_MSG_CHECKING([for $PATH_TO_LSPS format])
1501 if [$PATH_TO_LSPS -a 2>/dev/null | egrep -i "^Page Space" > /dev/null]
1502 then
1503         ac_cv_have_swap=yes
1504         ac_cv_swap_command="$PATH_TO_LSPS -a"
1505         ac_cv_swap_format=["%*s %*s %*s %f%*s %f %*s"]
1506         ac_cv_swap_conv=1
1507         AC_MSG_RESULT([using AIX lsps])
1508 fi
1509 dnl end if for PATH_TO_SWAPINFO
1510 fi
1512 dnl
1513 dnl test for swapctl system call, both the 2-arg and 3-arg variants
1514 dnl fwict, the 2-arg is an SVR4 standard, whereas the 3-arg is shared
1515 dnl in the various BSD's
1516 dnl
1518 AC_CHECK_HEADERS([sys/stat.h sys/param.h])
1519 AC_CHECK_HEADERS([sys/swap.h], [], [], [
1520 #ifdef HAVE_SYS_PARAM_H
1521 #include <sys/param.h>
1522 #endif
1523 ])
1524 AC_CHECK_DECLS([swapctl],,,[
1525                #include <unistd.h>
1526                #include <sys/types.h>
1527                #include <sys/param.h>
1528                #include <sys/stat.h>
1529                #include <sys/swap.h>
1530                ])
1531 AC_CHECK_TYPES([swaptbl_t, swapent_t],,,[
1532                #include <sys/types.h>
1533                #include <sys/param.h>
1534                #include <sys/stat.h>
1535                #include <sys/swap.h>
1536                ])
1537 AC_CHECK_MEMBERS([struct swapent.se_nblks],,,[
1538                #include <unistd.h>
1539                #include <sys/types.h>
1540                #include <sys/param.h>
1541                #include <sys/stat.h>
1542                #include <sys/swap.h>
1543                ])
1545 if test "$ac_cv_have_decl_swapctl" = "yes"; 
1546 then
1547         EXTRAS="$EXTRAS check_swap"
1548         AC_MSG_CHECKING([for 2-arg (SVR4) swapctl])
1549         if test "$ac_cv_type_swaptbl_t" = "yes" -a \
1550                 "$ac_cv_type_swapent_t" = "yes"; 
1551         then
1552                 AC_MSG_RESULT([yes])
1553                 ac_cv_check_swap_swapctl_svr4="1";
1554                 AC_DEFINE([CHECK_SWAP_SWAPCTL_SVR4],1,
1555                           [Define if 2-argument SVR4 swapctl exists])
1556         else
1557                 AC_MSG_RESULT([no])
1558                 AC_MSG_CHECKING([for 3-arg (*BSD) swapctl])
1559                 if test "$ac_cv_member_struct_swapent_se_nblks" = "yes"; 
1560                 then
1561                         AC_MSG_RESULT([yes])
1562                         AC_DEFINE([CHECK_SWAP_SWAPCTL_BSD],1,
1563                                   [Define if 3-argument BSD swapctl exists])
1564                 else
1565                         AC_MSG_RESULT([no])
1566                 fi
1567         fi
1568         AC_MSG_CHECKING([for whether swapctl uses blocks or pages])
1569         if test "$ac_cv_check_swap_swapctl_svr4" = "1";
1570         then
1571                 dnl
1572                 dnl the SVR4 spec returns values in pages
1573                 dnl
1574                 AC_MSG_RESULT([page])
1575                 AC_CHECK_DECLS([sysconf])
1576                 AC_MSG_CHECKING([for system page size])
1577                 if test "$ac_cv_have_decl_sysconf" = "yes";
1578                 then
1579                         AC_MSG_RESULT([determined by sysconf(3)])
1580                         ac_cv_swap_conv="(1048576/sysconf(_SC_PAGESIZE))"
1581                 else
1582                         AC_MSG_WARN([don't know. guessing 4096k])
1583                         ac_cv_swap_conv=256
1584                 fi
1585         else
1586                 dnl
1587                 dnl the BSD spec returns values in blocks
1588                 dnl
1589                 AC_MSG_RESULT([blocks (assuming 512b)])
1590                 ac_cv_swap_conv=2048
1591         fi
1592         AC_DEFINE_UNQUOTED(SWAP_CONVERSION,$ac_cv_swap_conv,
1593                 [Conversion factor to MB])
1594 fi
1595 dnl
1596 dnl end tests for the swapctl system calls
1597 dnl
1600 if test "x$ac_cv_have_swap" != "x" 
1601 then
1602         AC_DEFINE(HAVE_SWAP,1,[Define if swap/swapinfo command is found])
1603         EXTRAS="$EXTRAS check_swap"
1604 fi
1605 if test "x$ac_cv_swap_command" != "x" 
1606 then
1607         AC_DEFINE_UNQUOTED(SWAP_COMMAND,"$ac_cv_swap_command",
1608                 [Path to swap/swapinfo binary, with any args])
1609         AC_DEFINE_UNQUOTED(SWAP_FORMAT,"$ac_cv_swap_format",
1610                 [Format string for parsing swap output])
1611         AC_DEFINE_UNQUOTED(SWAP_CONVERSION,$ac_cv_swap_conv,
1612                 [Conversion factor to MB])
1613 fi
1615 AC_ARG_WITH(proc-meminfo,
1616             ACX_HELP_STRING([--with-proc-meminfo=PATH],
1617                             [path to /proc/meminfo or equivalent]),
1618                             ac_cv_proc_meminfo=$withval)
1619 dnl dunno why this does not work below - use hack (kbd)
1620 dnl fine on linux, broken on solaris
1621 dnl if /bin/test -e "/proc/meminfo"
1622 AC_MSG_CHECKING([for /proc/meminfo])
1623 if test -n "$ac_cv_proc_meminfo"; then
1624         AC_MSG_RESULT([(command line) $ac_cv_proc_meminfo])
1625 elif [cat /proc/meminfo > /dev/null 2>&1]; then
1626         AC_MSG_RESULT([found /proc/meminfo])
1627         ac_cv_proc_meminfo="/proc/meminfo"
1628 else
1629         AC_MSG_RESULT([no])
1630 fi
1632 if test -n "$ac_cv_proc_meminfo"; then
1633         AC_DEFINE(HAVE_PROC_MEMINFO,1,[Define if we have /proc/meminfo])
1634         AC_DEFINE_UNQUOTED(PROC_MEMINFO,"$ac_cv_proc_meminfo",[path to /proc/meminfo if name changes])
1635         EXTRAS="$EXTRAS check_swap"
1636 fi
1638 AC_PATH_PROG(PATH_TO_DIG,dig)
1639 AC_ARG_WITH(dig_command,
1640             ACX_HELP_STRING([--with-dig-command=PATH],
1641                             [Path to dig command]), PATH_TO_DIG=$withval)
1642 if test -n "$PATH_TO_DIG"; then
1643         EXTRAS="$EXTRAS check_dig"
1644         AC_DEFINE_UNQUOTED(PATH_TO_DIG,"$PATH_TO_DIG",[Path to dig command, if present])
1645 fi
1647 if test -f plugins/check_nt.c ; then
1648   EXTRAS="$EXTRAS check_nt"
1649 elif test -f ../plugins/check_nt.c ; then
1650   EXTRAS="$EXTRAS check_nt"
1651 fi
1653 AC_MSG_CHECKING(for va_list)
1654 AC_TRY_COMPILE([#ifdef __STDC__
1655                 #include <stdio.h>
1656                 #include <stdlib.h>
1657                 #include <stdarg.h>
1658                 #else
1659                 #include <sys/types.h>
1660                 #include <stdio.h>
1661                 #include <varargs.h>
1662                 #endif],
1663                 [va_list args;],
1664                 [AC_MSG_RESULT(yes)],
1665                 [NEED_VA_LIST=-DNEED_VA_LIST AC_SUBST(NEED_VA_LIST) AC_MSG_RESULT(no)])
1667 case $host in
1668         *bsd*)
1669                 AC_DEFINE(__bsd__,1,[bsd specific code in check_dhcp.c])
1670         ;;
1671         *linux*)
1672                 AC_DEFINE(__linux__,1,[sun specific code in check_dhcp.c])
1673         ;;
1674         *sun* | solaris*)
1675                 AC_DEFINE(__sun__,1,[sun specific code in check_dhcp.c])
1676         ;;
1677         *hpux*)  
1678                 AC_DEFINE(__hpux__,1,[hpux specific code in check_dhcp.c])
1679         ;;
1680 esac
1682 AC_SUBST(EXTRAS)
1683 AC_SUBST(EXTRA_NETOBJS)
1684 AC_SUBST(DEPLIBS)
1686 AM_GNU_GETTEXT([no-libtool], [need-ngettext])
1687 AM_GNU_GETTEXT_VERSION(0.11.5)
1689 dnl Check for Redhat spopen problem
1690 dnl Wierd problem where ECHILD is returned from a wait call in error
1691 dnl Only appears to affect nslookup and dig calls. Only affects redhat around
1692 dnl 2.6.9-11 (okay in 2.6.9-5). Redhat investigating root cause
1693 dnl We patch plugins/popen.c
1694 dnl Need to add smp because uname different on those
1695 dnl Can force patch to be applied with --enable-redhat-pthread-workaround
1696 AC_ARG_ENABLE(redhat-pthread-workaround, 
1697         AC_HELP_STRING([--enable-redhat-pthread-workaround], 
1698                 [force Redhat patch to be applied (default: test system)]),
1699         [ac_cv_enable_redhat_pthread_workaround=$enableval],
1700         [ac_cv_enable_redhat_pthread_workaround=test])
1701 if test "$ac_cv_enable_redhat_pthread_workaround" = "test" ; then
1702         if echo $ac_cv_uname_r | egrep "\.EL(smp)?$" >/dev/null 2>&1 ; then
1703                 AC_MSG_CHECKING(for redhat spopen problem)
1704                 ( cd config_test && make && make test ) > /dev/null 2>&1
1705                 if test $? -eq 0 ; then
1706                         AC_MSG_RESULT(okay)
1707                 else
1708                         AC_MSG_RESULT(error)
1709                         AC_DEFINE(REDHAT_SPOPEN_ERROR, 1, [Workaround on redhat in spopen])
1710                 fi
1711         fi
1712 elif test "$ac_cv_enable_redhat_pthread_workaround" = "yes" ; then
1713         AC_DEFINE(REDHAT_SPOPEN_ERROR, 1, [Forced workaround on redhat in spopen])
1714 fi
1716 dnl External libraries - see ACKNOWLEDGEMENTS
1717 np_COREUTILS
1718 np_CURL
1720 AC_OUTPUT(
1721   Makefile 
1722   lib/Makefile 
1723   m4/Makefile 
1724   plugins/Makefile 
1725   plugins/tests/Makefile
1726   plugins-root/Makefile
1727   plugins-scripts/Makefile 
1728   plugins-scripts/subst 
1729   plugins-scripts/utils.pm 
1730   plugins-scripts/utils.sh 
1731   command.cfg 
1732   test.pl 
1733   pkg/solaris/pkginfo 
1734   intl/Makefile
1735   po/Makefile.in 
1739 dnl the ones below that are commented out need to be cleaned up 
1740 dnl in the configure code above to use with_foo instead of ac_cv_foo
1741 dnl if we want them to show up here.  it'd also make the code cleaner.
1742 dnl i'll get to that on another rainy day :) -sf
1743 dnl ACX_FEATURE([with],[dig-command])
1744 dnl ACX_FEATURE([with],[fping-command])
1745 dnl ACX_FEATURE([with],[mailq-command])
1746 dnl ACX_FEATURE([with],[nslookup-command])
1747 dnl ACX_FEATURE([with],[ntpdate-command])
1748 ACX_FEATURE([with],[ping6-command])
1749 ACX_FEATURE([with],[ping-command])
1750 dnl ACX_FEATURE([with],[qstat-command])
1751 dnl ACX_FEATURE([with],[rpcinfo-command])
1752 dnl ACX_FEATURE([with],[smbclient-command])
1753 dnl ACX_FEATURE([with],[snmpget-command])
1754 dnl ACX_FEATURE([with],[snmpgetnext-command])
1755 dnl ACX_FEATURE([with],[ssh-command])
1756 dnl ACX_FEATURE([with],[uptime-command])
1758 dnl ACX_FEATURE([with],[proc-loadavg])
1759 dnl ACX_FEATURE([with],[proc-meminfo])
1760 dnl ACX_FEATURE([with],[ps-command])
1761 dnl ACX_FEATURE([with],[ps-format])
1762 dnl ACX_FEATURE([with],[ps-cols])
1763 dnl ACX_FEATURE([with],[ps-varlist])
1765 ACX_FEATURE([with],[lwres])
1766 ACX_FEATURE([with],[ipv6])
1767 ACX_FEATURE([with],[openssl])
1768 ACX_FEATURE([with],[gnutls])
1769 ACX_FEATURE([enable],[emulate-getaddrinfo])
1770 ACX_FEATURE([with],[perl])
1771 ACX_FEATURE([with],[cgiurl])
1772 ACX_FEATURE([with],[nagios-user])
1773 ACX_FEATURE([with],[nagios-group])
1774 ACX_FEATURE([with],[trusted-path])