Code

fixes for check_procs:
[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.5)
5 AC_CONFIG_SRCDIR(Helper.pm)
6 AM_INIT_AUTOMAKE
7 AM_CONFIG_HEADER(config.h)
8 AC_CANONICAL_HOST
10 RELEASE=1
11 AC_SUBST(RELEASE)
13 AC_PREFIX_DEFAULT(/usr/local/nagios)
15 dnl Figure out how to invoke "install" and what install options to use.
16 AC_PROG_INSTALL
17 AC_SUBST(INSTALL)
19 dnl Must come very early on due to coreutils requirement
20 dnl Takes care of AC_GNU_SOURCE, AC_AIX and AC_MINIX
21 gl_USE_SYSTEM_EXTENSIONS
23 AC_PROG_CC
24 AC_PROG_CPP
25 AC_PROG_GCC_TRADITIONAL
26 AC_PROG_RANLIB
28 AC_PROG_MAKE_SET
29 AC_PROG_AWK
31 AC_FUNC_MALLOC
32 AC_FUNC_REALLOC
33 AC_FUNC_ERROR_AT_LINE
35 AC_CONFIG_LIBOBJ_DIR(lib)
36 AC_FUNC_GETLOADAVG([lib])
38 ifdef([AC_FUNC_STRTOD],[AC_FUNC_STRTOD],[AM_FUNC_STRTOD])
39 dnl AM_WITH_REGEX
41 PLUGIN_TEST=`echo $srcdir/plugins/t/*.t|sed -e 's,\.*/plugins/,,g'`
42 AC_SUBST(PLUGIN_TEST)dnl
44 SCRIPT_TEST=`echo $srcdir/plugins-scripts/t/*.t|sed -e 's,\.*/plugins-scripts/,,g'`
45 AC_SUBST(SCRIPT_TEST)dnl
47 WARRANTY="The nagios plugins come with ABSOLUTELY NO WARRANTY. You may redistribute\ncopies of the plugins under the terms of the GNU General Public License.\nFor more information about these matters, see the file named COPYING.\n"
48 AC_SUBST(WARRANTY)
50 SUPPORT="Send email to nagios-users@lists.sourceforge.net if you have questions\nregarding use of this software. To submit patches or suggest improvements,\nsend email to nagiosplug-devel@lists.sourceforge.net.\nPlease include version information with all correspondence (when possible,\nuse output from the --version option of the plugin itself).\n"
51 AC_SUBST(SUPPORT)
53 dnl CGIURL has changed for Nagios with 1.0 beta
54 AC_ARG_WITH(cgiurl,
55         ACX_HELP_STRING([--with-cgiurl=DIR],
56                 [sets URL for cgi programs]),
57         with_cgiurl=$withval,
58         with_cgiurl=/nagios/cgi-bin)
59 CGIURL="$with_cgiurl"
60 AC_DEFINE_UNQUOTED(CGIURL,"$CGIURL",[URL of CGI programs])
62 AC_ARG_WITH(nagios_user,
63         ACX_HELP_STRING([--with-nagios-user=USER],
64                 [set user name to run nagios]),
65         with_nagios_user=$withval,
66         with_nagios_user=nagios)
67 AC_ARG_WITH(nagios_group,
68         ACX_HELP_STRING([--with-nagios-group=GROUP],
69                 [set group name to run nagios]),
70         with_nagios_group=$withval,
71         with_nagios_group=nagios)
72 AC_SUBST(with_nagios_user)
73 AC_SUBST(with_nagios_group)
74 INSTALL_OPTS="-o $with_nagios_user -g $with_nagios_group"
75 AC_SUBST(INSTALL_OPTS)
77 AC_ARG_WITH(trusted_path,
78         ACX_HELP_STRING([--with-trusted-path=PATH],
79                 [sets trusted path for executables called by scripts (default=/bin:/sbin:/usr/bin:/usr/sbin)]),
80         with_trusted_path=$withval,
81         with_trusted_path=/bin:/sbin:/usr/bin:/usr/sbin)
82 AC_SUBST(with_trusted_path)
84 EXTRAS=
85 dnl PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/etc:/usr/local/bin:/usr/local/sbin:$PATH
87 LDFLAGS="$LDFLAGS -L."
89 ac_cv_uname_m=`uname -m`
90 ac_cv_uname_s=`uname -s`
91 ac_cv_uname_r=`uname -r`
92 ac_cv_uname_v=`uname -v`
94 PKG_ARCH=`uname -p`
95 REV_DATESTAMP=`date '+%Y.%m.%d.%H.%M'`
96 REV_TIMESTAMP=`date '+%Y%m%d%H%M%S'`
98 AC_SUBST(PKG_ARCH)
99 AC_SUBST(REV_DATESTAMP)
100 AC_SUBST(REV_TIMESTAMP)
102 dnl Checks for programs.
103 AC_PATH_PROG(PYTHON,python)
104 AC_PATH_PROG(SH,sh)
105 AC_PATH_PROG(PERL,perl)
107 dnl allow them to override the path of perl
108 AC_ARG_WITH(perl,
109         ACX_HELP_STRING([--with-perl=PATH],
110                         [sets path to perl executable]),
111                         with_perl=$withval,with_perl=$PERL)
112 AC_SUBST(PERL, $with_perl)
114 AC_PATH_PROG(HOSTNAME,hostname)
115 AC_PATH_PROG(BASENAME,basename)
117 dnl
118 dnl Check for miscellaneous stuff
119 dnl 
121 case $host_vender-$host_os in
122 sun*)
123         AC_DEFINE(__EXTENSIONS__,1,[Sun's netdb.h needs this for getaddrinfo])
124         ;;
125 osf*)
126         AC_DEFINE(_OSF_SOURCE,1,[OSF needs this for getaddrinfo])
127         ;;
128 esac
130 dnl
131 dnl Checks for libraries.
132 dnl
134 AC_CHECK_LIB(dce,main,SOCKETLIBS="$SOCKETLIBS -ldce")
135 AC_CHECK_LIB(nsl,main,SOCKETLIBS="$SOCKETLIBS -lnsl")
136 AC_CHECK_LIB(socket,socket,SOCKETLIBS="$SOCKETLIBS -lsocket")
137 AC_CHECK_LIB(resolv,main,SOCKETLIBS="$SOCKETLIBS -lresolv")
138 AC_SUBST(SOCKETLIBS)
140 dnl Check for PostgreSQL libraries
141 _SAVEDLIBS="$LIBS"
142 _SAVEDCPPFLAGS="$CPPFLAGS"
143 AC_ARG_WITH(pgsql,
144         ACX_HELP_STRING([--with-pgsql=DIR],
145                 [sets path to pgsql installation]),
146         PGSQL=$withval,)
147 AC_CHECK_LIB(crypt,main)
148 if test "$ac_cv_lib_crypt_main" = "yes"; then
149   if test -n "$PGSQL"; then
150     LDFLAGS="$LDFLAGS -L$PGSQL/lib"
151     CPPFLAGS="$CPPFLAGS -I$PGSQL/include"
152   fi
153   AC_CHECK_LIB(pq,PQsetdbLogin,,,-lcrypt)
154   if test "$ac_cv_lib_pq_PQsetdbLogin" = "yes"; then
155     AC_CHECK_HEADERS(pgsql/libpq-fe.h)
156     AC_CHECK_HEADERS(postgresql/libpq-fe.h)
157     AC_CHECK_HEADERS(libpq-fe.h)
158     if [[ -n "$PGSQL" -a "$ac_cv_header_libpq_fe_h" = "yes" ]]; then
159       PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
160       PGINCLUDE="-I$PGSQL/include"
161     elif test  "$ac_cv_header_pgsql_libpq_fe_h" = "yes"; then
162       PGLIBS="-lpq -lcrypt"
163       PGINCLUDE="-I/usr/include/pgsql"
164     elif test  "$ac_cv_header_postgresql_libpq_fe_h" = "yes"; then
165       PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
166       PGINCLUDE="-I/usr/include/postgresql"
167     elif test  "$ac_cv_header_libpq_fe_h" = "yes"; then
168       PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
169       PGINCLUDE="-I$PGSQL/include"
170     fi
171     if test -z "$PGINCLUDE"; then
172       AC_MSG_WARN([Skipping PostgreSQL plugin (check_pgsql)])
173       AC_MSG_WARN([install PostgreSQL headers to compile this plugin (see REQUIREMENTS).])
174     else
175       AC_SUBST(PGLIBS)
176       AC_SUBST(PGINCLUDE)
177       EXTRAS="$EXTRAS check_pgsql"
178     fi
179   else
180     AC_MSG_WARN([Skipping PostgreSQL plugin (check_pgsql)])
181     AC_MSG_WARN([LIBS="$LIBS" CPPFLAGS="$CPPFLAGS"])
182     AC_MSG_WARN([install PostgreSQL libs to compile this plugin (see REQUIREMENTS).])
183   fi
184 else
185   AC_MSG_WARN([Skipping PostgreSQL plugin (check_pgsql)])
186   AC_MSG_WARN([install lib crypt and PostgreSQL libs to compile this plugin (see REQUIREMENTS).])
187 fi
188 LIBS="$_SAVEDLIBS"
189 CPPFLAGS="$_SAVEDCPPFLAGS"
191 dnl Check for radius libraries
192 _SAVEDLIBS="$LIBS"
193 AC_CHECK_LIB(radiusclient,rc_read_config)
194 if test "$ac_cv_lib_radiusclient_rc_read_config" = "yes"; then
195   EXTRAS="$EXTRAS check_radius"
196         RADIUSLIBS="-lradiusclient"
197   AC_SUBST(RADIUSLIBS)
198 else
199   AC_MSG_WARN([Skipping radius plugin])
200   AC_MSG_WARN([install radius libs to compile this plugin (see REQUIREMENTS).])
201 fi
202 LIBS="$_SAVEDLIBS"
204 dnl Check for LDAP libraries
205 _SAVEDLIBS="$LIBS"
206 AC_CHECK_LIB(ldap,main,,,-llber)
207 if test "$ac_cv_lib_ldap_main" = "yes"; then
208   LDAPLIBS="-lldap -llber"\
209   LDAPINCLUDE="-I/usr/include/ldap"
210   AC_SUBST(LDAPLIBS)
211   AC_SUBST(LDAPINCLUDE)
212   AC_CHECK_FUNCS(ldap_set_option)
213   EXTRAS="$EXTRAS check_ldap"
214         AC_CHECK_FUNCS(ldap_init ldap_set_option ldap_get_option ldap_start_tls_s)
215 else
216   AC_MSG_WARN([Skipping LDAP plugin])
217   AC_MSG_WARN([install LDAP libs to compile this plugin (see REQUIREMENTS).])
218 fi
219 LIBS="$_SAVEDLIBS"
222 dnl Check for mysql libraries
223 _SAVEDLIBS="$LIBS"
224 _SAVEDCPPFLAGS="$CPPFLAGS"
225 AC_ARG_WITH(mysql,
226         ACX_HELP_STRING([--with-mysql=DIR],
227                 [sets path to mysql installation (assumes lib/mysql and include subdirs]),
228         MYSQL=$withval,)
229 if test -n "$MYSQL"; then
230   MYSQLLIBDIR=$MYSQL/lib/mysql
231   CPPFLAGS="-I$MYSQL/include"
232   AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz" check_mysql_LDFLAGS="-L$MYSQLLIBDIR ",,-L$MYSQLLIBDIR -lz)
233   AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient")
234 elif test -f /usr/lib/libmysqlclient.so; then
235   AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz",,-lz)
236   AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient")
237 elif test -f /usr/lib/libmysqlclient.a; then
238   AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz",,-lz)
239   AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient")
240 elif test -f /usr/lib/mysql/libmysqlclient.so; then
241   AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz" check_mysql_LDFLAGS="-L/usr/lib/mysql",,-L/usr/lib/mysql -lz)
242   AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient" check_mysql_LDFLAGS="-L/usr/lib/mysql",,-L/usr/lib/mysql)
243 elif test -f /usr/lib/mysql/libmysqlclient.a; then
244   AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz" check_mysql_LDFLAGS="-L/usr/lib/mysql",,-L/usr/lib/mysql -lz)
245   AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient" check_mysql_LDFLAGS="-L/usr/lib/mysql",,-L/usr/lib/mysql)
246 fi
247 if test "$ac_cv_lib_mysqlclient_mysql_init" = "yes" -o "$ac_cv_lib_mysqlclient_mysql_close" = "yes"; then
248   AC_CHECK_HEADERS(mysql/mysql.h mysql/errmsg.h, MYSQLINCLUDE="-I$MYSQL/include" )
249   if test "$ac_cv_header_mysql_mysql_h" = "yes" -a "$ac_cv_header_mysql_errmsg_h" = "yes"; then
250     EXTRAS="$EXTRAS check_mysql"
251     AC_SUBST(MYSQLINCLUDE)
252     AC_SUBST(MYSQLLIBS)
253     AC_SUBST(check_mysql_LDFLAGS)
254   else
255     AC_MSG_WARN([Skipping mysql plugin])
256     AC_MSG_WARN([install mysql client headers to compile this plugin (see REQUIREMENTS).])
257   fi
258 else
259   AC_MSG_WARN([Skipping mysql plugin])
260   AC_MSG_WARN([install mysql client libs to compile this plugin (see REQUIREMENTS).])
261 fi
262 CPPFLAGS="$_SAVEDCPPFLAGS $MYSQLINCLUDE"
263 LIBS="$_SAVEDLIBS"
265 AC_CHECK_HEADERS(unistd.h)
267 dnl Check for AF_INET6 support - unistd.h required for Darwin
268 AC_CACHE_CHECK([for IPv6 support], with_ipv6, [
269         AC_TRY_COMPILE([#ifdef HAVE_UNISTD_H
270                         #include <unistd.h>
271                         #endif
272                         #include <netinet/in.h>
273                         #include <sys/socket.h>],
274                         [struct sockaddr_in6 sin6;
275                         void *p;
277                         sin6.sin6_family = AF_INET6;
278                         sin6.sin6_port = 587;
279                         p = &sin6.sin6_addr;],
280                         [with_ipv6=yes], 
281                         [with_ipv6=no])
282         ])
284 if test x"$with_ipv6" != xno ; then
285         AC_DEFINE(USE_IPV6,1,[Enable IPv6 support])
286 fi
288 dnl #########################################################################
289 dnl Check if Posix getaddrinfo() is available.  It is also possible to use
290 dnl the version from the lwres library distributed with BIND.
291 dnl #########################################################################
292 AC_ARG_ENABLE([emulate-getaddrinfo],
293               ACX_HELP_STRING([--enable-emulate-getaddrinfo],
294                              [enable getaddrinfo emulation (default=no)]),
295               ,
296               enable_emulate_getaddrinfo=no)
298 AC_ARG_WITH(lwres,
299             ACX_HELP_STRING([--with-lwres=DIR],
300                            [use lwres library for getaddrinfo (default=no)]),
301             ,
302             with_lwres=no)
304 dnl ## enable force to test getaddrinfo.c
305 if test x$enable_emulate_getaddrinfo = xforce ; then
306         enable_emulate_getaddrinfo=yes
307         have_getaddrinfo=no
308 else
310 have_getaddrinfo=no
311 if test x$with_lwres != xno ; then
312         if test "$with_lwres" != yes ; then
313                    CPPFLAGS="-I${with_lwres}/include $CPPFLAGS"
314                    LDFLAGS="-L${with_lwres}/lib $LDFLAGS"
315         fi
316         AC_CHECK_HEADERS(lwres/netdb.h, ,
317                         [AC_MSG_ERROR([cannot find <lwres/netdb.h>])])
318         AC_CHECK_LIB(lwres, lwres_getaddrinfo, ,
319                      [AC_MSG_ERROR([cannot find the lwres library])],
320                      -lnsl -lpthread)
321         have_getaddrinfo=yes
322 fi
324 if test x$have_getaddrinfo != xyes ; then
325         AC_SEARCH_LIBS(getaddrinfo, socket resolv bind nsl c_r cr, have_getaddrinfo=yes)
326 fi
328 dnl # Special nonsense for systems that actually have getaddrinfo but
329 dnl # redefine the name to something else, e.g. OSF
330 if test x$have_getaddrinfo != xyes ; then
331         AC_MSG_CHECKING(if getaddrinfo is redefined in netdb.h)
332         AC_TRY_LINK([
333 #               include <netdb.h>
334         ], [
335                 struct addrinfo hints, *res;
336                 int err;
338                 err = getaddrinfo ("host", "service", &hints, &res);
339         ], [
340                 have_getaddrinfo=yes
341                 AC_MSG_RESULT(yes)
342         ], [AC_MSG_RESULT(no)])
343 fi
345 fi
347 if test x$have_getaddrinfo != xno ; then
348         if test x$enable_emulate_getaddrinfo != xno ; then
349                 AC_MSG_ERROR([getaddrinfo found but emulate-getaddrinfo was enabled])
350         fi
351         AC_DEFINE(HAVE_GETADDRINFO, 1,
352                   [Does system provide RFC 2553/Posix getaddrinfo?])
353 else
354         if test x$enable_emulate_getaddrinfo != xyes ; then
355 dnl                AC_MSG_ERROR([getaddrinfo not found: try --with-lwres or --enable-emulate-getaddrinfo])
356                enable_emulate_getaddrinfo=yes
357                AC_MSG_WARN([enabling getaddrinfo emulation])
358         fi
359         EXTRA_NETOBJS="$EXTRA_NETOBJS getaddrinfo.o"
360 fi
362 if test x"$enable_emulate_getaddrinfo" != xno ; then
363     have_resolver=no
365   dnl  Try for getipnodebyname
366     AC_SEARCH_LIBS(getipnodebyname, resolv bind nsl c_r cr, have_resolver=yes)
367     if test x"$have_resolver" != xno ; then
368          AC_DEFINE(HAVE_GETIPNODEBYNAME, 1,
369                    [Set when getipnodebyname is available])
370     fi
372   dnl  Try for gethostbyname_r
373     if test x"$have_resolver" = xno ; then
374         AC_SEARCH_LIBS(gethostbyname_r, resolv bind nsl c_r cr,
375                        [have_resolver=yes
376                         ACX_WHICH_GETHOSTBYNAME_R])
377     fi
379   dnl  Try for gethostbyname
380     if test x"$have_resolver" = xno ; then
381         if test x"$enable_pthreads" != xno ; then
382             AC_MSG_WARN([using threads but cannot find gethostbyname_r or getipnodebyname])
383         fi
384         AC_SEARCH_LIBS(gethostbyname, resolv bind nsl, ,
385                        [AC_MSG_ERROR([cannot find gethostbyname])])
386     fi
387     EXTRA_NETOBJS="$EXTRA_NETOBJS gethostbyname.o"
389 fi
391 dnl Checks for Kerberos. Must come before openssl checks for Redhat EL 3
392 AC_CHECK_HEADERS(krb5.h,FOUNDINCLUDE=yes,FOUNDINCLUDE=no)
393 if test "$FOUNDINCLUDE" = "no"; then
394   _SAVEDCPPFLAGS="$CPPFLAGS"
395   CPPFLAGS="$_SAVEDCPPFLAGS -I/usr/kerberos/include"
396   unset ac_cv_header_krb5_h
397   AC_CHECK_HEADERS(krb5.h,
398                    KRB5INCLUDE="-I/usr/kerberos/include"
399                    FOUNDINCLUDE=yes,
400                    FOUNDINCLUDE=no)
401 fi
402 AC_SUBST(KRBINCLUDE)
403 if test "$FOUNDINCLUDE" = "no"; then
404   CPPFLAGS="$_SAVEDCPPFLAGS"
405 fi
407 dnl Check for OpenSSL location
408 AC_PATH_PROG(OPENSSL,openssl)
409 if test "$OPENSSL" = "/usr/bin/openssl"; then
410   OPENSSL=/usr
411 elif test "$OPENSSL" = "/usr/sbin/openssl"; then
412   OPENSSL=/usr
413 elif test "$OPENSSL" = "/opt/bin/openssl"; then
414   OPENSSL=/opt
415 elif test "$OPENSSL" = "/opt/openssl/bin/openssl"; then
416   OPENSSL=/opt/openssl
417 elif test "$OPENSSL" = "/usr/slocal/bin/openssl"; then
418   OPENSSL=/usr/slocal
419 elif test "$OPENSSL" = "/usr/local/bin/openssl"; then
420   OPENSSL=/usr/local
421 elif test "$OPENSSL" = "/usr/local/ssl/bin/openssl"; then
422   OPENSSL=/usr/local/ssl
423 fi
424 AC_ARG_WITH(openssl,
425 AC_HELP_STRING([--with-openssl=DIR], [sets path to openssl installation])
426 AC_HELP_STRING([--without-openssl], [disable openssl]),
427 OPENSSL=$withval)
429 _SAVEDCPPFLAGS="$CPPFLAGS"
430 _SAVEDLDFLAGS="$LDFLAGS"
431 if test X"$OPENSSL" = "Xno"; then
432   AC_MSG_WARN([openssl disabled, you will not be able to use ssl options in some plugins])
433   FOUNDSSL="dontbother"
434 else
435   dnl Check for OpenSSL header files
436   unset FOUNDINCLUDE
437   if test "$OPENSSL" != "/usr"; then
438     CPPFLAGS="$CPPFLAGS -I$OPENSSL/include"
439     LDFLAGS="$LDFLAGS -R$OPENSSL/lib"
440   fi
441   AC_CHECK_HEADERS(openssl/ssl.h openssl/x509.h openssl/rsa.h openssl/pem.h openssl/crypto.h openssl/err.h,
442                  SSLINCLUDE="-I$OPENSSL/include"
443                  FOUNDINCLUDE=yes,
444                  FOUNDINCLUDE=no)
445   if test "$FOUNDINCLUDE" = "no"; then
446     AC_CHECK_HEADERS(ssl.h x509.h rsa.h pem.h crypto.h err.h,
447                    SSLINCLUDE="-I$OPENSSL/include"
448                    FOUNDINCLUDE=yes,
449                    FOUNDINCLUDE=no)
450   fi
451   AC_SUBST(SSLINCLUDE)
452   if test "$FOUNDINCLUDE" = "no"; then
453     CPPFLAGS="$_SAVEDCPPFLAGS"
454   fi
456   dnl Check for crypto lib
457   _SAVEDLIBS="$LIBS"
458   AC_CHECK_LIB(crypto,CRYPTO_lock,,,-L$OPENSSL/lib)
459   if test "$ac_cv_lib_crypto_CRYPTO_lock" = "yes"; then
460     dnl Check for SSL lib
461     AC_CHECK_LIB(ssl,main,LDFLAGS="$LDFLAGS -L$OPENSSL/lib" SSLLIBS="-lssl -lcrypto",AC_CHECK_LIB(ssl,main,LDFLAGS="$LDFLAGS -L$OPENSSL/lib" SSLLIBS="-lssl -lcrypto"),-L$OPENSSL/lib -lcrypto)
462   fi
463   LIBS="$_SAVEDLIBS"
465   FOUNDSSL="no"
466   dnl test headers and libs to decide whether check_http should use SSL
467   if test "$ac_cv_lib_crypto_CRYPTO_lock" = "yes"; then
468     if test "$ac_cv_lib_ssl_main" = "yes"; then
469       if test "$FOUNDINCLUDE" = "yes"; then
470         FOUNDSSL="yes"
471       fi
472     fi
473   fi
474 fi
476 if test "$FOUNDSSL" = "yes"; then
477   check_tcp_ssl="check_simap check_spop check_jabber check_nntps check_ssmtp"
478   AC_SUBST(check_tcp_ssl)
479   AC_SUBST(SSLLIBS)
480   AC_DEFINE(HAVE_SSL,1,[Define if SSL libraries are found])
481   with_openssl="yes"
482 else
483   if test "$FOUNDSSL" = "no"; then
484     AC_MSG_WARN([OpenSSL libs could not be found])
485   dnl else deliberately disabled
486   fi
487   with_openssl="no"
488   CPPFLAGS="$_SAVEDCPPFLAGS"
489   LDFLAGS="$_SAVEDLDFLAGS"
490 fi
492 dnl
493 dnl Checks for header files.
494 dnl
496 AC_HEADER_STDC
497 AC_HEADER_TIME
498 AC_HEADER_SYS_WAIT
499 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)
500 AC_CHECK_HEADERS(features.h stdarg.h sys/unistd.h ctype.h stdlib.h)
502 dnl Checks for typedefs, structures, and compiler characteristics.
503 AC_C_CONST
504 AC_STRUCT_TM
505 AC_TYPE_PID_T
506 AC_TYPE_SIZE_T
507 AC_TYPE_SIGNAL
509 AC_CACHE_CHECK([for va_copy],ac_cv_HAVE_VA_COPY,[
510 AC_TRY_LINK([#include <stdarg.h>
511 va_list ap1,ap2;], [va_copy(ap1,ap2);],
512 ac_cv_HAVE_VA_COPY=yes,
513 ac_cv_HAVE_VA_COPY=no)])
514 if test x"$ac_cv_HAVE_VA_COPY" = x"yes"; then
515     AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available])
516 else    
517     AC_CACHE_CHECK([for __va_copy],ac_cv_HAVE___VA_COPY,[
518     AC_TRY_LINK([#include <stdarg.h>
519     va_list ap1,ap2;], [__va_copy(ap1,ap2);],
520     ac_cv_HAVE___VA_COPY=yes,
521     ac_cv_HAVE___VA_COPY=no)])
522     if test x"$ac_cv_HAVE___VA_COPY" = x"yes"; then
523         AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available])
524     fi
525 fi
527 AC_CHECK_FUNCS(vsnprintf snprintf asprintf vasprintf)
528 AC_CACHE_CHECK([for C99 vsnprintf],ac_cv_HAVE_C99_VSNPRINTF,[
529 AC_TRY_RUN([
530 #include <sys/types.h>
531 #include <stdarg.h>
532 void foo(const char *format, ...) { 
533        va_list ap;
534        int len;
535        char buf[5];
537        va_start(ap, format);
538        len = vsnprintf(buf, 0, format, ap);
539        va_end(ap);
540        if (len != 5) exit(1);
542        va_start(ap, format);
543        len = vsnprintf(0, 0, format, ap);
544        va_end(ap);
545        if (len != 5) exit(1);
547        if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
549        exit(0);
551 main() { foo("hello"); }
552 ],
553 ac_cv_HAVE_C99_VSNPRINTF=yes,ac_cv_HAVE_C99_VSNPRINTF=no,ac_cv_HAVE_C99_VSNPRINTF=cross)])
554 if test x"$ac_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
555     AC_DEFINE(HAVE_C99_VSNPRINTF,1,[Define if system has C99 compatible vsnprintf])
556 fi
558 AC_TRY_COMPILE([#include <sys/time.h>],
559                [struct timeval *tv;
560                 struct timezone *tz;],
561                AC_DEFINE(HAVE_STRUCT_TIMEVAL,1,[Define if we have a timeval structure])
562                AC_TRY_COMPILE([#include <sys/time.h>],
563                               [struct timeval *tv;
564                                struct timezone *tz;
565                                gettimeofday(tv, tz);],
566                               AC_DEFINE(HAVE_GETTIMEOFDAY,1,[Define if gettimeofday is found]),
567                               AC_DEFINE(NEED_GETTIMEOFDAY,1,[Define if gettimeofday is needed])))
569 dnl Checks for library functions.
570 AC_CHECK_FUNCS(memmove select socket strdup strstr strtod strtol strtoul)
572 AC_MSG_CHECKING(return type of socket size)
573 AC_TRY_COMPILE([#include <stdlib.h>
574                 #include <sys/types.h>
575                 #include <sys/socket.h>],
576                [int a = send(1, (const void *) buffer, (size_t *) 0, (int *) 0);],
577                ac_cv_socket_size_type=["size_t"]
578                 AC_MSG_RESULT(size_t),
579                ac_cv_socket_size_type=["int"]
580                 AC_MSG_RESULT(int))
582 AC_DEFINE_UNQUOTED(SOCKET_SIZE_TYPE, $ac_cv_socket_size_type ,
583         [Define type of socket size])
585 if test -f "/proc/loadavg"
586 then
587   AC_DEFINE(HAVE_PROC_LOADAVG,1,[Define if /proc/loadavg or similar exists])
588   AC_DEFINE_UNQUOTED(PROC_LOADAVG,"/proc/loadavg",[Location of /proc/loadavg])
589 fi
591 dnl #### Process table test
593 AC_PATH_PROG(PATH_TO_PS,ps)
595 AC_MSG_CHECKING(for ps syntax)
596 dnl Some gnu/linux systems (debian for one) don't like -axwo and need axwo.
597 dnl so test for this first...
598 if ps axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
599         egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null
600 then
601         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
602         ac_cv_ps_command="$PATH_TO_PS axwo 'stat uid pid ppid vsz rss pcpu comm args'"
603         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
604         ac_cv_ps_cols=9
605         AC_MSG_RESULT([$ac_cv_ps_command])
607 dnl For OpenBSD 3.2 & 3.3. Must come before ps -weo
608 dnl Should also work for FreeBSD 5.2.1 and 5.3
609 dnl  STAT UCOMM              VSZ   RSS USER      PPID COMMAND
610 elif ps -axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
611         egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null
612 then
613         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
614         ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid pid ppid vsz rss pcpu comm args'"
615         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
616         ac_cv_ps_cols=9
617         AC_MSG_RESULT([$ac_cv_ps_command])
619 dnl Some *BSDs have different format for ps. This is mainly to catch FreeBSD 4. 
620 dnl Limitation: Only first 16 chars returned for ucomm field
621 dnl Must come before ps -weo
622 elif ps -axwo 'stat uid pid ppid vsz rss pcpu ucomm command' 2>/dev/null | \
623         egrep -i ["^ *STAT +UID +PID +PPID +VSZ +RSS +%CPU +UCOMM +COMMAND"] > /dev/null
624 then
625         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
626         ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid pid ppid vsz rss pcpu ucomm command'"
627         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
628         ac_cv_ps_cols=9
629         AC_MSG_RESULT([$ac_cv_ps_command])
631 dnl  STAT UCOMM              VSZ   RSS USER       UID  PPID COMMAND
632 elif ps -weo 'stat comm vsz rss user uid pid ppid etime args' 2>/dev/null | \
633         egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[ID]+ +P[PID]+ +[ELAPSD]+ +[RGSCOMDNA]+"] >/dev/null
634 then
635         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procetime,procprog,&pos]"
636         ac_cv_ps_command="$PATH_TO_PS -weo 'stat uid pid ppid vsz rss pcpu etime comm args'"
637         ac_cv_ps_format="%s %d %d %d %d %d %f %s %s %n"
638         ac_cv_ps_cols=10
639         AC_MSG_RESULT([$ac_cv_ps_command])
641 dnl FreeBSD
642 elif ps waxco 'state command vsz rss uid user pid ppid' 2>/dev/null | \
643         egrep -i ["^STAT +COMMAND +VSZ +RSS +UID +USER +PID +PPID"] >/dev/null
644 then
645         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
646         ac_cv_ps_command="$PATH_TO_PS waxco 'state uid pid ppid vsz rss pcpu command command'"
647         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
648         ac_cv_ps_cols=9
649         AC_MSG_RESULT([$ac_cv_ps_command])
651 dnl BSD-like mode in RH 6.1
652 elif ps waxno 'state comm vsz rss uid user pid ppid args' 2>/dev/null | \
653         egrep -i ["^S +COMMAND +VSZ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
654 then
655         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
656         ac_cv_ps_command="$PATH_TO_PS waxno 'state uid pid ppid vsz rss pcpu comm args'"
657         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
658         ac_cv_ps_cols=9
659         AC_MSG_RESULT([$ac_cv_ps_command])
661 dnl SunOS 4.1.3:
662 dnl  F  UID  PID  PPID  CP  PRI  NI  SZ  RSS  WCHAN  STAT  TT  TIME  COMMAND
663 dnl Need the head -1 otherwise test will work because arguments are found
664 elif ps -laxnwww 2>/dev/null | head -1 | \
665         egrep -i ["^ *F(LAGS)? +UID +PID +PPID +CP +PRI +NI +(SZ)|(VSZ)|(SIZE) +RSS +WCHAN +STAT? +TTY? +TIME +COMMAND"] >/dev/null
666 then
667         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]"
668         ac_cv_ps_command="$PATH_TO_PS -laxnwww"
669         ac_cv_ps_format="%*s %d %d %d %*s %*s %*s %d %d %*s %s %*s %*s %n%s"
670         ac_cv_ps_cols=9
671         AC_MSG_RESULT([$ac_cv_ps_command])
673 dnl Debian Linux / procps v1.2.9:
674 dnl  FLAGS   UID   PID  PPID PRI  NI   SIZE   RSS WCHAN       STA TTY TIME COMMAND
675 dnl    100     0     1     0   0   0    776    76  c0131c8c   S  ffff  0:11 init [2]
676 dnl
677 elif ps laxnwww 2>/dev/null | \
678         egrep -i ["^ *F(LAGS)? +UID +PID +PPID +PRI +NI +(VSZ)|(SIZE) +RSS +WCHAN +STAT? TTY +TIME +COMMAND"] >/dev/null
679 then
680         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,procstat,&procvsz,&procrss,&pos,procprog]"
681         ac_cv_ps_command="$PATH_TO_PS laxnwww"
682         ac_cv_ps_format="%*s %d %d %d %*s %*s %d %d %*s %s %*s %*s %n%s"
683         ac_cv_ps_cols=9
684         AC_MSG_RESULT([$ac_cv_ps_command])
686 dnl OpenBSD (needs to come early because -exo appears to work, but does not give all procs)
687 elif ps -axo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
688         egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[PID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null
689 then
690         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
691         ac_cv_ps_command="$PATH_TO_PS -axo 'stat uid pid ppid vsz rss pcpu comm args'"
692         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
693         ac_cv_ps_cols=9
694         AC_MSG_RESULT([$ac_cv_ps_command])
696 dnl Tru64 - needs %*[ +] in PS_FORMAT
697 elif ps -ao 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
698         egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[ID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null
699 then
700         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
701         ac_cv_ps_command="$PATH_TO_PS -ao 'stat uid pid ppid vsz rss pcpu comm args'"
702         ac_cv_ps_format=["%s%*[ +] %d %d %d %d %d %f %s %n"]
703         ac_cv_ps_cols=9
704         AC_MSG_RESULT([$ac_cv_ps_command])
706 XXX
707 elif ps -eo 's comm vsz rss user uid pid ppid args' 2>/dev/null | \
708         egrep -i ["^S[TAUES]* +C[OMDNA]+ +[VSIZE]+ +U[SER]+ +U[ID]+ +P[PID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null
709 then
710         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procpid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
711         ac_cv_ps_command="$PATH_TO_PS -eo 's uid pid ppid vsz rss pcpu comm args'"
712         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
713         ac_cv_ps_cols=9
714         AC_MSG_RESULT([$ac_cv_ps_command])
716 dnl AIX 4.3.3 and 5.1 do not have an rss field
717 elif ps -eo 'stat uid pid ppid vsz pcpu comm args' 2>/dev/null | \
718         egrep -i ["^ *S[TAUES]* +UID +PID +PPID +VSZ +%CPU +COMMAND +COMMAND"] >/dev/null
719 then
720         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procpid,&procvsz,&procpcpu,procprog,&pos]"
721         ac_cv_ps_command="$PATH_TO_PS -eo 'stat uid pid ppid vsz pcpu comm args'"
722         ac_cv_ps_format="%s %d %d %d %d %f %s %n"
723         ac_cv_ps_cols=8
724         AC_MSG_RESULT([$ac_cv_ps_command - with no RSS])
726 dnl Solaris 2.6
727 elif ps -Ao 's comm vsz rss uid user pid ppid args' 2>/dev/null | \
728         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
729 then
730         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procpid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
731         ac_cv_ps_command="$PATH_TO_PS -Ao 's uid pid ppid vsz rss pcpu comm args'"
732         # There must be no space between the %s and %n due to a wierd problem in sscanf where
733         # it will return %n as longer than the line length
734         ac_cv_ps_format="%s %d %d %d %d %d %f %s%n"
735         ac_cv_ps_cols=9
736         AC_MSG_RESULT([$ac_cv_ps_command])
738 elif ps -Ao 'status comm vsz rss uid user pid ppid args' 2>/dev/null | \
739         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
740 then
741         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procpid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
742         ac_cv_ps_command="$PATH_TO_PS -Ao 'status uid pid ppid vsz rss pcpu comm args'"
743         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
744         ac_cv_ps_cols=9
745         AC_MSG_RESULT([$ac_cv_ps_command])
747 elif ps -Ao 'state comm vsz rss uid user pid ppid args' 2>/dev/null | \
748         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
749 then
750         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procpid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
751         ac_cv_ps_command="$PATH_TO_PS -Ao 'state uid pid ppid vsz rss pcpu comm args'"
752         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
753         ac_cv_ps_cols=9
754         AC_MSG_RESULT([$ac_cv_ps_command])
756 dnl wonder who takes state instead of stat
757 elif ps -ao 'state command vsz rss user pid ppid args' 2>/dev/null | \
758         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
759 then
760         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procpid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
761         ac_cv_ps_command="$PATH_TO_PS -ao 'state uid pid ppid vsz rss pcpu command args'"
762         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
763         ac_cv_ps_cols=8
764         AC_MSG_RESULT([$ac_cv_ps_command])
766 dnl IRIX 53
767 elif ps -el 2>/dev/null | \
768         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
769 then
770         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procpid,&procvsz,&procrss,&pos,procprog]"
771         ac_cv_ps_command="$PATH_TO_PS -el (IRIX 53)"
772         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %d %d %*s %*s %*s %n%s"
773         ac_cv_ps_cols=8
774         AC_MSG_RESULT([$ac_cv_ps_command])
776 dnl IRIX 63
777 elif ps -el 2>/dev/null | \
778         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +ADDR +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
779 then
780         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procpid,&pos,procprog]"
781         ac_cv_ps_command="$PATH_TO_PS -el (IRIX 63)"
782         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
783         ac_cv_ps_cols=6
784         AC_MSG_RESULT([$ac_cv_ps_command])
786 dnl AIX 4.1:
787 dnl     F S      UID   PID  PPID   C PRI NI ADDR  SZ  RSS   WCHAN    TTY  TIME CMD
788 dnl    303 A        0     0     0 120  16 -- 1c07  20   24              -  0:45 swapper
789 elif ps -el 2>/dev/null | \
790         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +ADDR +SZ +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
791 then
792         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procpid,&pos,procprog]"
793         ac_cv_ps_command="$PATH_TO_PS -el (AIX 4.1 and HP-UX)"
794         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
795         ac_cv_ps_cols=6
796         AC_MSG_RESULT([$ac_cv_ps_command])
798 dnl AIX?
799 elif ps glaxen 2>/dev/null | \
800         egrep -i ["^ *F +UID +PID +PPID +PRI +NI +VSZ +RSS +WCHAN +STAT +TTY +TIME +COMMAND"] >/dev/null
801 then
802         ac_cv_ps_varlist="[&procuid,&procpid,&procpid,&procvsz,&procrss,procstat,&pos,procprog]"
803         ac_cv_ps_command="$PATH_TO_PS glaxen"
804         ac_cv_ps_format="%*s %d %d %d %*s %*s %d %d %*s %s %*s %*s %n%s"
805         ac_cv_ps_cols=8
806         AC_MSG_RESULT([$ac_cv_ps_command])
808 dnl MacOSX / Darwin
809 dnl TODO: MacOSX has commands with spaces which will cause problems to PS_FORMAT
810 dnl Some truncation will happen in UCOMM column
811 dnl STAT      VSZ    RSS   UID  PPID %CPU UCOMM            COMMAND
812 dnl Ss      52756  22496   501     1   6.9 Window Manager   /System/Library/CoreServices/WindowServer -daemon
813 elif ps wwaxo 'state vsz rss uid pid ppid pcpu ucomm command' 2>/dev/null | \
814         egrep -i ["^STAT +VSZ +RSS +UID +PPID +%CPU +UCOMM +COMMAND"] >/dev/null
815 then
816         ac_cv_ps_command="$PATH_TO_PS wwaxo 'state vsz rss uid pid ppid pcpu ucomm command'"
817         ac_cv_ps_varlist="[procstat,&procvsz,&procrss,&procuid,&procpid,&procpid,&procpcpu,procprog,&pos]"
818         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
819         ac_cv_ps_cols=8
820         AC_MSG_RESULT([$ac_cv_ps_command])
822 dnl UnixWare 
823 elif ps -Al 2>/dev/null | \
824         egrep -i ["^ *F +S +UID +PID +PPID +CLS +PRI +NI +C +ADDR +SZ +WCHAN +TTY +TIME +COMD"] >/dev/null
825 then
826         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procpid,&pos,procprog]"
827         ac_cv_ps_command="$PATH_TO_PS -Al"
828         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
829         ac_cv_ps_cols=8
830         AC_MSG_RESULT([$ac_cv_ps_command])
831 XXX
833 else
834         AC_MSG_WARN([unable to find usable ps syntax - check_procs and check_nagios will not be compiled])
835 fi
837 if test -n "$ac_cv_ps_varlist" ; then
838         AC_DEFINE_UNQUOTED(PS_VARLIST,$ac_cv_ps_varlist,
839                 [Variable list for sscanf of 'ps' output])
840         AC_DEFINE_UNQUOTED(PS_COMMAND,"$ac_cv_ps_command",
841                 [Verbatim command to execute for ps in check_procs])
842         AC_DEFINE_UNQUOTED(PS_FORMAT,"$ac_cv_ps_format",
843                 [Format string for scanning ps output in check_procs])
844         AC_DEFINE_UNQUOTED(PS_COLS,$ac_cv_ps_cols,
845                 [Number of columns in ps command])
846         EXTRAS="$EXTRAS check_procs check_nagios"
847 fi
849 AC_PATH_PROG(PATH_TO_PING,ping)
850 AC_PATH_PROG(PATH_TO_PING6,ping6)
852 AC_ARG_WITH(ping_command,
853         ACX_HELP_STRING([--with-ping-command=SYNTAX],
854                 [sets syntax for ICMP ping]),
855         with_ping_command=$withval,)
857 AC_MSG_CHECKING(for ICMP ping syntax)
858 ac_cv_ping_packets_first=no
859 ac_cv_ping_has_timeout=no
860 if test -n "$with_ping_command"
861 then
862         AC_MSG_RESULT([(command-line) $with_ping_command])
863         if test -n "$ac_cv_ping_packets_first"
864         then
865                 ac_cv_ping_packets_first=yes
866         fi
868 elif [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
869         $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
870         egrep -i "^round-trip|^rtt" >/dev/null
871 then
872         with_ping_command="$PATH_TO_PING -n -U -c %d %s"
873         ac_cv_ping_packets_first=yes
874         AC_MSG_RESULT([$with_ping_command])
876 elif $PATH_TO_PING -n -U -w 10 -c 1 127.0.0.1 2>/dev/null | \
877         egrep -i "^round-trip|^rtt" >/dev/null
878 then
879         with_ping_command="$PATH_TO_PING -n -U -w %d -c %d %s"
880         ac_cv_ping_packets_first=yes
881   ac_cv_ping_has_timeout=yes
882         AC_MSG_RESULT([$with_ping_command])
884 elif $PATH_TO_PING -n -U -c 1 127.0.0.1 2>/dev/null | \
885         egrep -i "^round-trip|^rtt" >/dev/null
886 then
887         with_ping_command="$PATH_TO_PING -n -U -c %d %s"
888         ac_cv_ping_packets_first=yes
889         AC_MSG_RESULT([$with_ping_command])
891 elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \
892         egrep -i "^round-trip|^rtt" >/dev/null
893 then
894         with_ping_command="$PATH_TO_PING -n -c %d %s"
895         ac_cv_ping_packets_first=yes
896         AC_MSG_RESULT([$with_ping_command])
898 elif $PATH_TO_PING -n 127.0.0.1 -c 1 2>/dev/null | \
899         egrep -i "^round-trip|^rtt" >/dev/null
900 then
901         with_ping_command="$PATH_TO_PING -n %s -c %d"
902         AC_MSG_RESULT([$with_ping_command])
904 elif $PATH_TO_PING 127.0.0.1 -n 1 2>/dev/null | \
905         egrep -i "^round-trip|^rtt" >/dev/null
906 then
907         with_ping_command="$PATH_TO_PING %s -n %d"
908         AC_MSG_RESULT([$with_ping_command])
910 elif $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
911         egrep -i "^round-trip|^rtt" >/dev/null
912 then
913         with_ping_command="$PATH_TO_PING -n -s %s 56 %d"
914         AC_MSG_RESULT([$with_ping_command])
916 elif $PATH_TO_PING -n -h 127.0.0.1 -s 56 -c 1 2>/dev/null | \
917         egrep -i "^round-trip|^rtt" >/dev/null
918 then
919         with_ping_command="$PATH_TO_PING -n -h %s -s 56 -c %d"
920         AC_MSG_RESULT([$with_ping_command])
922 elif $PATH_TO_PING -n -s 56 -c 1 127.0.0.1 2>/dev/null | \
923         egrep -i "^round-trip|^rtt" >/dev/null
924 then
925         with_ping_command="$PATH_TO_PING -n -s 56 -c %d %s"
926         ac_cv_ping_packets_first=yes
927         AC_MSG_RESULT([$with_ping_command])
929 elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \
930         egrep -i "^round-trip|^rtt" >/dev/null
931 then
932         with_ping_command="$PATH_TO_PING -n -c %d %s"
933         ac_cv_ping_packets_first=yes
934         AC_MSG_RESULT([$with_ping_command])
936 else
937         AC_MSG_WARN([unable to find usable ping syntax])
938 fi
940 AC_DEFINE_UNQUOTED(PING_COMMAND,"$with_ping_command",
941         [path and args for ICMP ping command])
943 if test "x$ac_cv_ping_packets_first" != "xno"
944 then
945         AC_DEFINE(PING_PACKETS_FIRST,1,
946                 [Define if packet count must precede host])
947 fi
949 if test "x$ac_cv_ping_has_timeout" != "xno"
950 then
951         AC_DEFINE(PING_HAS_TIMEOUT,1,
952                 [Define if ping has its own timeout option that should be set])
953 fi
955 AC_ARG_WITH(ping6_command,
956         ACX_HELP_STRING([--with-ping6-command=SYNTAX],
957                 [sets syntax for ICMPv6 ping]),
958         with_ping6_command=$withval,)
960 if test x"$with_ipv6" != xno ; then
961 AC_MSG_CHECKING(for ICMPv6 ping syntax)
962 ac_cv_ping6_packets_first=no
963 if test -n "$with_ping6_command"
964 then
965         AC_MSG_RESULT([(command-line) $with_ping6_command])
966         if test -n "$ac_cv_ping6_packets_first"
967         then
968                 ac_cv_ping6_packets_first=yes
969         fi
971 elif test "x$PATH_TO_PING6" != "x"; then
972         if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
973                 $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \
974                 egrep -i "^round-trip|^rtt" >/dev/null
975         then
976                 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s"
977                 ac_cv_ping6_packets_first=yes
978                 AC_MSG_RESULT([$with_ping6_command])
980         elif $PATH_TO_PING6 -n -U -w 10 -c 1 ::1 2>/dev/null | \
981                 egrep -i "^round-trip|^rtt" >/dev/null
982         then
983                 with_ping6_command="$PATH_TO_PING6 -n -U -w %d -c %d %s"
984                 ac_cv_ping6_packets_first=yes
985                 ac_cv_ping_has_timeout=yes
986                 AC_MSG_RESULT([$with_ping6_command])
988         elif $PATH_TO_PING6 -n -U -c 1 ::1 2>/dev/null | \
989                 egrep -i "^round-trip|^rtt" >/dev/null
990         then
991                 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s"
992                 ac_cv_ping6_packets_first=yes
993                 AC_MSG_RESULT([$with_ping6_command])
995         elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \
996                 egrep -i "^round-trip|^rtt" >/dev/null
997         then
998                 with_ping6_command="$PATH_TO_PING6 -n -c %d %s"
999                 ac_cv_ping6_packets_first=yes
1000                 AC_MSG_RESULT([$with_ping6_command])
1002         elif $PATH_TO_PING6 -n ::1 -c 1 2>/dev/null | \
1003                 egrep -i "^round-trip|^rtt" >/dev/null
1004         then
1005                 with_ping6_command="$PATH_TO_PING6 -n %s -c %d"
1006                 AC_MSG_RESULT([$with_ping6_command])
1008         elif $PATH_TO_PING6 ::1 -n 1 2>/dev/null | \
1009                 egrep -i "^round-trip|^rtt" >/dev/null
1010         then
1011                 with_ping6_command="$PATH_TO_PING6 %s -n %d"
1012                 AC_MSG_RESULT([$with_ping6_command])
1014         elif $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \
1015                 egrep -i "^round-trip|^rtt" >/dev/null
1016         then
1017                 with_ping6_command="$PATH_TO_PING6 -n -s %s 56 %d"
1018                 AC_MSG_RESULT([$with_ping6_command])
1020         elif $PATH_TO_PING6 -n -h ::1 -s 56 -c 1 2>/dev/null | \
1021                 egrep -i "^round-trip|^rtt" >/dev/null
1022         then
1023                 with_ping6_command="$PATH_TO_PING6 -n -h %s -s 56 -c %d"
1024                 AC_MSG_RESULT([$with_ping6_command])
1026         elif $PATH_TO_PING6 -n -s 56 -c 1 ::1 2>/dev/null | \
1027                 egrep -i "^round-trip|^rtt" >/dev/null
1028         then
1029                 with_ping6_command="$PATH_TO_PING6 -n -s 56 -c %d %s"
1030                 ac_cv_ping6_packets_first=yes
1031                 AC_MSG_RESULT([$with_ping_command])
1033         elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \
1034                 egrep -i "^round-trip|^rtt" >/dev/null
1035         then
1036                 with_ping6_command="$PATH_TO_PING6 -n -c %d %s"
1037                 ac_cv_ping6_packets_first=yes
1038                 AC_MSG_RESULT([$with_ping6_command])
1040         fi
1042 elif test "x$PATH_TO_PING" != "x"; then
1043         if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
1044                 $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \
1045                 egrep -i "^round-trip|^rtt" >/dev/null
1046         then
1047                 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s"
1048                 ac_cv_ping6_packets_first=yes
1049                 AC_MSG_RESULT([$with_ping6_command])
1051         elif $PATH_TO_PING -A inet6 -n -U -c 1 ::1 2>/dev/null | \
1052                 egrep -i "^round-trip|^rtt" >/dev/null
1053         then
1054                 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s"
1055                 ac_cv_ping6_packets_first=yes
1056                 AC_MSG_RESULT([$with_ping6_command])
1058         elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \
1059                 egrep -i "^round-trip|^rtt" >/dev/null
1060         then
1061                 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s"
1062                 ac_cv_ping6_packets_first=yes
1063                 AC_MSG_RESULT([$with_ping6_command])
1065         elif $PATH_TO_PING -A inet6 -n ::1 -c 1 2>/dev/null | \
1066                 egrep -i "^round-trip|^rtt" >/dev/null
1067         then
1068                 with_ping6_command="$PATH_TO_PING -A inet6 -n %s -c %d"
1069                 AC_MSG_RESULT([$with_ping6_command])
1071         elif $PATH_TO_PING -A inet6 ::1 -n 1 2>/dev/null | \
1072                 egrep -i "^round-trip|^rtt" >/dev/null
1073         then
1074                 with_ping6_command="$PATH_TO_PING -A inet6 %s -n %d"
1075                 AC_MSG_RESULT([$with_ping6_command])
1077         elif $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \
1078                 egrep -i "^round-trip|^rtt" >/dev/null
1079         then
1080                 with_ping6_command="$PATH_TO_PING -A inet6 -n -s %s 56 %d"
1081                 AC_MSG_RESULT([$with_ping6_command])
1083         elif $PATH_TO_PING -A inet6 -n -h ::1 -s 56 -c 1 2>/dev/null | \
1084                 egrep -i "^round-trip|^rtt" >/dev/null
1085         then
1086                 with_ping6_command="$PATH_TO_PING -A inet6 -n -h %s -s 56 -c %d"
1087                 AC_MSG_RESULT([$with_ping6_command])
1089         elif $PATH_TO_PING -A inet6 -n -s 56 -c 1 ::1 2>/dev/null | \
1090                 egrep -i "^round-trip|^rtt" >/dev/null
1091         then
1092                 with_ping6_command="$PATH_TO_PING -A inet6 -n -s 56 -c %d %s"
1093                 ac_cv_ping6_packets_first=yes
1094                 AC_MSG_RESULT([$with_ping_command])
1096         elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \
1097                 egrep -i "^round-trip|^rtt" >/dev/null
1098         then
1099                 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s"
1100                 ac_cv_ping6_packets_first=yes
1101                 AC_MSG_RESULT([$with_ping6_command])
1103         fi
1105 fi
1107 if test "x$with_ping6_command" != "x"; then
1108         AC_DEFINE_UNQUOTED(PING6_COMMAND,"$with_ping6_command",
1109                 [path and args for ICMPv6 ping command])
1110 else
1111         AC_MSG_RESULT([none])
1112 fi
1114 if test "x$ac_cv_ping6_packets_first" != "xno"; then
1115         AC_DEFINE(PING6_PACKETS_FIRST,1,
1116                 [Define if packet count must precede host])
1117 fi
1118 fi
1120 AC_PATH_PROG(PATH_TO_NSLOOKUP,nslookup)
1122 AC_MSG_CHECKING(for nslookup syntax)
1123 if test -n "$PATH_TO_NSLOOKUP"
1124 then
1125         if $PATH_TO_NSLOOKUP -sil 127.0.0.1 2>&1 | grep ["Invalid option: sil"] >/dev/null
1126         then
1127                 ac_cv_nslookup_command="$PATH_TO_NSLOOKUP"
1128                 AC_MSG_RESULT([$ac_cv_nslookup_command])
1130         else
1131                 ac_cv_nslookup_command="$PATH_TO_NSLOOKUP -sil"
1132                 AC_MSG_RESULT([$ac_cv_nslookup_command])
1134         fi
1135         EXTRAS="$EXTRAS check_dns"
1137 else
1138         AC_MSG_WARN([nslookup command not found])
1139 fi
1141 AC_DEFINE_UNQUOTED(NSLOOKUP_COMMAND,"$ac_cv_nslookup_command",
1142         [path and args for nslookup])
1144 AC_PATH_PROG(PATH_TO_HOST,host)
1145 if test -n "$ac_cv_path_PATH_TO_HOST"
1146 then
1147         EXTRAS="$EXTRAS check_dns"
1148 fi
1150 AC_PATH_PROG(PATH_TO_UPTIME,uptime)
1151 AC_DEFINE_UNQUOTED(PATH_TO_UPTIME,"$PATH_TO_UPTIME",[path to uptime binary])
1153 AC_PATH_PROG(PATH_TO_RPCINFO,rpcinfo)
1154 AC_DEFINE_UNQUOTED(PATH_TO_RPCINFO,"$PATH_TO_RPCINFO",[path to rpcinfo binary])
1156 AC_PATH_PROG(PATH_TO_NTPDATE,ntpdate)
1157 AC_PATH_PROGS(PATH_TO_NTPDC,ntpdc xntpdc)
1158 AC_PATH_PROGS(PATH_TO_NTPQ,ntpq)
1159 if (test -x "$PATH_TO_NTPDATE" || test -x "$PATH_TO_NTPQ")
1160 then
1161         AC_DEFINE_UNQUOTED(PATH_TO_NTPQ,"$PATH_TO_NTPQ",[path to ntpq binary])
1162         AC_DEFINE_UNQUOTED(PATH_TO_NTPDATE,"$PATH_TO_NTPDATE",[path to ntpdate binary])
1163 else
1164         AC_MSG_WARN([Install NTP programs (http://www.ntp.org) if you want to monitor time synchronization])
1165 fi
1167 AC_PATH_PROG(PATH_TO_LMSTAT,lmstat)
1168 if test -x "$PATH_TO_LMSTAT"
1169 then
1170         AC_DEFINE_UNQUOTED(PATH_TO_LMSTAT,"$PATH_TO_LMSTAT",[path to lmstat])
1171 else
1172         AC_MSG_WARN([Get lmstat from Globetrotter Software to monitor flexlm licenses])
1173 fi
1175 AC_PATH_PROG(PATH_TO_SMBCLIENT,smbclient)
1176 if test -x "$PATH_TO_SMBCLIENT"
1177 then
1178         AC_DEFINE_UNQUOTED(PATH_TO_SMBCLIENT,"$PATH_TO_SMBCLIENT",[path to smbclient binary])
1179 else
1180         AC_MSG_WARN([Get smbclient from Samba.org to monitor SMB shares])
1181 fi
1184 AC_PATH_PROG(PATH_TO_WHO,who)
1186 if [$PATH_TO_WHO -q 2>/dev/null | egrep -i "^# users=[0-9]+$" >/dev/null]
1187 then
1188         ac_cv_path_to_who="$PATH_TO_WHO -q"
1189 else
1190         ac_cv_path_to_who="$PATH_TO_WHO"
1191 fi
1193 AC_DEFINE_UNQUOTED(WHO_COMMAND,"$ac_cv_path_to_who",
1194         [path and arguments for invoking 'who'])
1196 AC_PATH_PROG(PATH_TO_SNMPGET,snmpget)
1197 if test -x "$PATH_TO_SNMPGET"
1198 then
1199         AC_DEFINE_UNQUOTED(PATH_TO_SNMPGET,"$PATH_TO_SNMPGET",[path to snmpget binary])
1200         EXTRAS="$EXTRAS check_hpjd check_snmp"
1201 else
1202         AC_MSG_WARN([Get snmpget from http://net-snmp.sourceforge.net to make check_hpjd and check_snmp plugins])
1203 fi
1205 AC_PATH_PROG(PATH_TO_SNMPGETNEXT,snmpgetnext)
1206 if test -x "$PATH_TO_SNMPGETNEXT"
1207 then
1208         AC_DEFINE_UNQUOTED(PATH_TO_SNMPGETNEXT,"$PATH_TO_SNMPGETNEXT",[path to snmpgetnext binary])
1209 fi
1211 if ( $PERL -M"Net::SNMP 3.6" -e 'exit' 2>/dev/null  )
1212 then
1213         AC_MSG_CHECKING(for Net::SNMP perl module)
1214         AC_MSG_RESULT([found])
1215 else
1216         AC_MSG_WARN([Tried $PERL - install Net::SNMP perl module if you want to use the perl snmp plugins])
1217 fi
1219 AC_PATH_PROG(PATH_TO_QUAKESTAT,quakestat)
1220 AC_PATH_PROG(PATH_TO_QSTAT,qstat)
1222 if test -x "$PATH_TO_QUAKESTAT"
1223 then
1224         ac_cv_path_to_qstat="$PATH_TO_QUAKESTAT"
1225         EXTRAS="$EXTRAS check_game"
1227 elif test -x "$PATH_TO_QSTAT"
1228 then
1229         ac_cv_path_to_qstat="$PATH_TO_QSTAT"
1230         EXTRAS="$EXTRAS check_game"
1231 else
1232         AC_MSG_WARN([Get qstat from http://www.activesw.com/people/steve/qstat.html in order to make check_game plugin])
1233 fi
1235 if test $ac_cv_path_to_qstat 
1236 then
1237         AC_DEFINE_UNQUOTED(PATH_TO_QSTAT,"$ac_cv_path_to_qstat",
1238                 [path to qstat/quakestat])
1239 fi
1241 AC_PATH_PROG(PATH_TO_FPING,fping)
1242 if test -x "$PATH_TO_FPING"
1243 then
1244         AC_DEFINE_UNQUOTED(PATH_TO_FPING,"$PATH_TO_FPING",[path to fping])
1245         EXTRAS="$EXTRAS check_fping"
1246 else
1247         AC_MSG_WARN([Get fping from http://www.fping.com in order to make check_fping plugin])
1248 fi
1250 AC_PATH_PROG(PATH_TO_SSH,ssh)
1252 if test -x "$PATH_TO_SSH"
1253 then
1254         AC_DEFINE_UNQUOTED(SSH_COMMAND,"$PATH_TO_SSH",[path to ssh binary])
1255         EXTRAS="$EXTRAS check_by_ssh"
1256 else
1257         AC_MSG_WARN([Get ssh in order to make check_by_ssh plugin])
1258 fi
1261 AC_PATH_PROG(PATH_TO_MAILQ,mailq)
1262 if test -x "$PATH_TO_MAILQ"
1263 then
1264         AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_MAILQ",[path to mailq])
1265 else
1266         AC_MSG_WARN([Could not find mailq or eqivalent])
1267 fi
1269 AC_PATH_PROG(PATH_TO_QMAIL_QSTAT,qmail-qstat)
1270 if test -x "$PATH_TO_QMAIL_QSTAT"
1271 then
1272         AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_QMAIL_QSTAT",[path to qmail-qstat])
1273 else
1274         AC_MSG_WARN([Could not find qmail-qstat or eqivalent])
1275 fi
1277 dnl SWAP info required is amount allocated/available and amount free
1278 dnl The plugin works through all the swap devices and adds up the total swap
1279 dnl available.
1280 AC_PATH_PROG(PATH_TO_SWAP,swap)
1281 if (test -n "$PATH_TO_SWAP")
1282 then
1283 AC_MSG_CHECKING([for $PATH_TO_SWAP format])
1284 if [$PATH_TO_SWAP -l 2>&1 >/dev/null]
1285 then
1286         ac_cv_have_swap=yes
1287         ac_cv_swap_command="$PATH_TO_SWAP -l"
1288         if [$PATH_TO_SWAP -l 2>/dev/null | \
1289                 egrep -i "^lswap +path +pri +swaplo +blocks +free +maxswap" \
1290                 >/dev/null]
1291         then
1292                 ac_cv_swap_format=[" %*d %*s %*d,%*d %*d %*d %f %f"]
1293                 ac_cv_swap_conv=2048
1294                 AC_MSG_RESULT([using IRIX format swap])
1296         elif [$PATH_TO_SWAP -l 2>/dev/null | egrep -i "^path +dev +swaplo +blocks +free" >/dev/null]
1297         then
1298                 ac_cv_swap_format=["%*s %*[0-9,-] %*d %f %f"]
1299                 ac_cv_swap_conv=2048
1300                 AC_MSG_RESULT([using Unixware format swap])
1301         else
1302                 dnl if we don't know what format swap's output is
1303                 dnl we might as well pretend we didn't see it
1304                 ac_cv_have_swap=""
1305                 ac_cv_swap_command=""
1306         fi
1307 fi
1308 dnl end if for PATH_TO_SWAP
1309 fi
1311 AC_PATH_PROG(PATH_TO_SWAPINFO,swapinfo)
1312 if (test -n "$PATH_TO_SWAPINFO")
1313 then
1314 AC_MSG_CHECKING([for $PATH_TO_SWAPINFO format])
1315 if [$PATH_TO_SWAPINFO -k 2>&1 | egrep -i "^Device" >/dev/null]
1316 then
1317         ac_cv_have_swap=yes
1318         ac_cv_swap_command="$PATH_TO_SWAPINFO -k"
1320         if [$PATH_TO_SWAPINFO -k 2>/dev/null | egrep -i "^Device +1K-blocks +Used +Avail" >/dev/null]
1321         then
1322                 ac_cv_swap_format=["%*s %f %*d %f"]
1323                 ac_cv_swap_conv=1024
1324                 AC_MSG_RESULT([using FreeBSD format swapinfo])
1325         fi
1327 elif [$PATH_TO_SWAPINFO -dfM 2>/dev/null | egrep -i "^TYPE +AVAIL +USED +FREE" >/dev/null]
1328 then
1329         ac_cv_have_swap=yes
1330         ac_cv_swap_command="$PATH_TO_SWAPINFO -dfM",
1331         ac_cv_swap_format=["%*s %f %*d %f"]
1332         ac_cv_swap_conv=1024
1333         AC_MSG_RESULT([using HP-UX format swapinfo])
1334 fi
1335 dnl end if for PATH_TO_SWAPINFO
1336 fi
1338 AC_PATH_PROG(PATH_TO_LSPS,lsps)
1339 if (test -n "$PATH_TO_LSPS")
1340 then
1341 AC_MSG_CHECKING([for $PATH_TO_LSPS format])
1342 if [$PATH_TO_LSPS -a 2>/dev/null | egrep -i "^Page Space" > /dev/null]
1343 then
1344         ac_cv_have_swap=yes
1345         ac_cv_swap_command="$PATH_TO_LSPS -a"
1346         ac_cv_swap_format=["%*s %*s %*s %f%*s %f %*s"]
1347         ac_cv_swap_conv=1
1348         AC_MSG_RESULT([using AIX lsps])
1349 fi
1350 dnl end if for PATH_TO_SWAPINFO
1351 fi
1353 dnl
1354 dnl test for swapctl system call, both the 2-arg and 3-arg variants
1355 dnl fwict, the 2-arg is an SVR4 standard, whereas the 3-arg is shared
1356 dnl in the various BSD's
1357 dnl
1359 AC_CHECK_HEADERS([sys/stat.h sys/param.h])
1360 AC_CHECK_HEADERS([sys/swap.h], [], [], [
1361 #ifdef HAVE_SYS_PARAM_H
1362 #include <sys/param.h>
1363 #endif
1364 ])
1365 AC_CHECK_DECLS([swapctl],,,[
1366                #include <unistd.h>
1367                #include <sys/types.h>
1368                #include <sys/param.h>
1369                #include <sys/stat.h>
1370                #include <sys/swap.h>
1371                ])
1372 AC_CHECK_TYPES([swaptbl_t, swapent_t],,,[
1373                #include <sys/types.h>
1374                #include <sys/param.h>
1375                #include <sys/stat.h>
1376                #include <sys/swap.h>
1377                ])
1378 AC_CHECK_MEMBERS([struct swapent.se_nblks],,,[
1379                #include <unistd.h>
1380                #include <sys/types.h>
1381                #include <sys/param.h>
1382                #include <sys/stat.h>
1383                #include <sys/swap.h>
1384                ])
1386 if test "$ac_cv_have_decl_swapctl" = "yes"; 
1387 then
1388         EXTRAS="$EXTRAS check_swap"
1389         AC_MSG_CHECKING([for 2-arg (SVR4) swapctl])
1390         if test "$ac_cv_type_swaptbl_t" = "yes" -a \
1391                 "$ac_cv_type_swapent_t" = "yes"; 
1392         then
1393                 AC_MSG_RESULT([yes])
1394                 ac_cv_check_swap_swapctl_svr4="1";
1395                 AC_DEFINE([CHECK_SWAP_SWAPCTL_SVR4],1,
1396                           [Define if 2-argument SVR4 swapctl exists])
1397         else
1398                 AC_MSG_RESULT([no])
1399                 AC_MSG_CHECKING([for 3-arg (*BSD) swapctl])
1400                 if test "$ac_cv_member_struct_swapent_se_nblks" = "yes"; 
1401                 then
1402                         AC_MSG_RESULT([yes])
1403                         AC_DEFINE([CHECK_SWAP_SWAPCTL_BSD],1,
1404                                   [Define if 3-argument BSD swapctl exists])
1405                 else
1406                         AC_MSG_RESULT([no])
1407                 fi
1408         fi
1409         AC_MSG_CHECKING([for whether swapctl uses blocks or pages])
1410         if test "$ac_cv_check_swap_swapctl_svr4" = "1";
1411         then
1412                 dnl
1413                 dnl the SVR4 spec returns values in pages
1414                 dnl
1415                 AC_MSG_RESULT([page])
1416                 AC_CHECK_DECLS([sysconf])
1417                 AC_MSG_CHECKING([for system page size])
1418                 if test "$ac_cv_have_decl_sysconf" = "yes";
1419                 then
1420                         AC_MSG_RESULT([determined by sysconf(3)])
1421                         ac_cv_swap_conv="(1048576/sysconf(_SC_PAGESIZE))"
1422                 else
1423                         AC_MSG_WARN([don't know. guessing 4096k])
1424                         ac_cv_swap_conv=256
1425                 fi
1426         else
1427                 dnl
1428                 dnl the BSD spec returns values in blocks
1429                 dnl
1430                 AC_MSG_RESULT([blocks (assuming 512b)])
1431                 ac_cv_swap_conv=2048
1432         fi
1433         AC_DEFINE_UNQUOTED(SWAP_CONVERSION,$ac_cv_swap_conv,
1434                 [Conversion factor to MB])
1435 fi
1436 dnl
1437 dnl end tests for the swapctl system calls
1438 dnl
1441 if test "x$ac_cv_have_swap" != "x" 
1442 then
1443         AC_DEFINE(HAVE_SWAP,1,[Define if swap/swapinfo command is found])
1444         EXTRAS="$EXTRAS check_swap"
1445 fi
1446 if test "x$ac_cv_swap_command" != "x" 
1447 then
1448         AC_DEFINE_UNQUOTED(SWAP_COMMAND,"$ac_cv_swap_command",
1449                 [Path to swap/swapinfo binary, with any args])
1450         AC_DEFINE_UNQUOTED(SWAP_FORMAT,"$ac_cv_swap_format",
1451                 [Format string for parsing swap output])
1452         AC_DEFINE_UNQUOTED(SWAP_CONVERSION,$ac_cv_swap_conv,
1453                 [Conversion factor to MB])
1454 fi
1456 dnl dunno why this does not work below - use hack (kbd)
1457 dnl fine on linux, broken on solaris
1458 dnl if /bin/test -e "/proc/meminfo"
1459 AC_MSG_CHECKING([for /proc/meminfo])
1460 if [cat /proc/meminfo > /dev/null 2>&1]
1461 then
1462         AC_MSG_RESULT([found /proc/meminfo])
1463         AC_DEFINE(HAVE_PROC_MEMINFO,1,[Define if we have /proc/meminfo])
1464         AC_DEFINE_UNQUOTED(PROC_MEMINFO,"/proc/meminfo",[path to /proc/meminfo if name changes])
1465         EXTRAS="$EXTRAS check_swap"
1466 else
1467         AC_MSG_RESULT([no])
1468 fi
1470 AC_PATH_PROG(PATH_TO_DIG,dig)
1471 AC_DEFINE_UNQUOTED(PATH_TO_DIG,"$PATH_TO_DIG",[Path to dig command, if present])
1472 if test -n "$PATH_TO_DIG"; then
1473         EXTRAS="$EXTRAS check_dig"
1474 fi
1476 if test -f plugins/check_nt.c ; then
1477   EXTRAS="$EXTRAS check_nt"
1478 elif test -f ../plugins/check_nt.c ; then
1479   EXTRAS="$EXTRAS check_nt"
1480 fi
1482 AC_MSG_CHECKING(for va_list)
1483 AC_TRY_COMPILE([#ifdef __STDC__
1484                 #include <stdio.h>
1485                 #include <stdlib.h>
1486                 #include <stdarg.h>
1487                 #else
1488                 #include <sys/types.h>
1489                 #include <stdio.h>
1490                 #include <varargs.h>
1491                 #endif],
1492                 [va_list args;],
1493                 [AC_MSG_RESULT(yes)],
1494                 [NEED_VA_LIST=-DNEED_VA_LIST AC_SUBST(NEED_VA_LIST) AC_MSG_RESULT(no)])
1496 case $host in
1497         *bsd*)
1498                 AC_DEFINE(__bsd__,1,[bsd specific code in check_dhcp.c])
1499         ;;
1500         *linux*)
1501                 AC_DEFINE(__linux__,1,[sun specific code in check_dhcp.c])
1502         ;;
1503         *sun* | solaris*)
1504                 AC_DEFINE(__sun__,1,[sun specific code in check_dhcp.c])
1505         ;;
1506         *hpux*)  
1507                 AC_DEFINE(__hpux__,1,[hpux specific code in check_dhcp.c])
1508         ;;
1509 esac
1511 AC_SUBST(EXTRAS)
1512 AC_SUBST(EXTRA_NETOBJS)
1513 AC_SUBST(DEPLIBS)
1515 AM_GNU_GETTEXT([no-libtool], [need-ngettext])
1516 AM_GNU_GETTEXT_VERSION(0.11.5)
1518 dnl External libraries - see ACKNOWLEDGEMENTS
1519 np_COREUTILS
1520 np_CURL
1522 AC_OUTPUT(
1523   Makefile 
1524   lib/Makefile 
1525   m4/Makefile 
1526   plugins/Makefile 
1527   plugins-scripts/Makefile 
1528   plugins-scripts/subst 
1529   plugins-scripts/utils.pm 
1530   plugins-scripts/utils.sh 
1531   command.cfg 
1532   test.pl 
1533   pkg/solaris/pkginfo 
1534   intl/Makefile
1535   po/Makefile.in 
1538 ACX_FEATURE([with],[perl])
1539 ACX_FEATURE([with],[cgiurl])
1540 ACX_FEATURE([with],[nagios-user])
1541 ACX_FEATURE([with],[nagios-group])
1542 ACX_FEATURE([with],[trusted-path])
1543 ACX_FEATURE([with],[ping-command])
1544 ACX_FEATURE([with],[ping6-command])
1545 ACX_FEATURE([with],[lwres])
1546 ACX_FEATURE([with],[ipv6])
1547 ACX_FEATURE([with],[openssl])
1548 ACX_FEATURE([enable],[emulate-getaddrinfo])