Code

Just a lil namespace clean-up
[nagiosplug.git] / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2 AC_REVISION ($Revision$)
3 AC_INIT(Helper.pm)
4 VER=1.3.99
5 REL=1
6 AC_SUBST(VER)
7 AC_SUBST(REL)
8 PACKAGE_VERSION="${VER}"
9 AC_SUBST(PACKAGE_VERSION)
10 PACKAGE_RELEASE="${REL}"
11 AC_SUBST(PACKAGE_RELEASE)
12 AM_INIT_AUTOMAKE(nagios-plugins,${PACKAGE_VERSION})
13 AM_CONFIG_HEADER(plugins/config.h plugins/common.h plugins/version.h plugins/netutils.h plugins/utils.h plugins/popen.h)
14 AC_CANONICAL_HOST
16 AC_PREFIX_DEFAULT(/usr/local/nagios)
18 dnl Figure out how to invoke "install" and what install options to use.
20 AC_PROG_INSTALL
21 AC_SUBST(INSTALL)
23 AC_PROG_CC
24 AC_PROG_CPP
25 AC_PROG_GCC_TRADITIONAL
26 AC_PROG_RANLIB
27 AC_AIX
28 AC_MINIX
30 AC_PROG_MAKE_SET
31 AC_PROG_AWK
33 # Check for SunOS statfs brokenness wrt partitions 2GB and larger.
34 # If <sys/vfs.h> exists and struct statfs has a member named f_spare,
35 # enable the work-around code in fsusage.c.
36 AC_MSG_CHECKING([for statfs that truncates block counts])
37 AC_CACHE_VAL(fu_cv_sys_truncating_statfs,
38 [AC_TRY_COMPILE([
39 #if !defined(sun) && !defined(__sun)
40 choke -- this is a workaround for a Sun-specific problem
41 #endif
42 #include <sys/types.h>
43 #include <sys/vfs.h>],
44 [struct statfs t; long c = *(t.f_spare);],
45 fu_cv_sys_truncating_statfs=yes
46 AC_MSG_RESULT(yes),
47 fu_cv_sys_truncating_statfs=no
48 AC_MSG_RESULT(no),
49 )])
50 if test $fu_cv_sys_truncating_statfs = yes; then
51   AC_DEFINE(STATFS_TRUNCATES_BLOCK_COUNTS, 1,
52 [  Define if the block counts reported by statfs may be truncated to 2GB
53    and the correct values may be stored in the f_spare array.
54    (SunOS 4.1.2, 4.1.3, and 4.1.3_U1 are reported to have this problem.
55    SunOS 4.1.1 seems not to be affected.)])
56 fi
58 saved_srcdir=$srcdir
59 srcdir=$srcdir/lib
60 test -f $srcdir/getloadavg.c \
61   || AC_MSG_ERROR([getloadavg.c is not in $srcdir])
62 AC_FUNC_GETLOADAVG
63 srcdir=$saved_srcdir
65 ifdef([AC_FUNC_STRTOD],[AC_FUNC_STRTOD],[AM_FUNC_STRTOD])
66 dnl AM_WITH_REGEX
67 AC_PROG_RANLIB
69 AC_PATH_PROG(ACLOCAL,aclocal)
70 AC_PATH_PROG(AUTOMAKE,automake)
71 AC_PATH_PROG(AUTOCONF,autoconf)
72 AC_PATH_PROG(AUTOHEADER,autoheader)
74 PLUGIN_TEST=`echo $srcdir/plugins/t/*.t|sed -e 's,\.*/plugins/,,g'`
75 AC_SUBST(PLUGIN_TEST)dnl
77 SCRIPT_TEST=`echo $srcdir/plugins-scripts/t/*.t|sed -e 's,\.*/plugins-scripts/,,g'`
78 AC_SUBST(SCRIPT_TEST)dnl
80 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"
81 AC_SUBST(WARRANTY)
83 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\n"
84 AC_SUBST(SUPPORT)
86 dnl CGIURL has changed for Nagios with 1.0 beta
87 AC_ARG_WITH(cgiurl,
88         ACX_HELP_STRING([--with-cgiurl=DIR],
89                 [sets URL for cgi programs]),
90         with_cgiurl=$withval,
91         with_cgiurl=/nagios/cgi-bin)
92 CGIURL="$with_cgiurl"
93 AC_DEFINE_UNQUOTED(CGIURL,"$CGIURL",[URL of CGI programs])
95 AC_ARG_WITH(nagios_user,
96         ACX_HELP_STRING([--with-nagios-user=USER],
97                 [set user name to run nagios]),
98         with_nagios_user=$withval,
99         with_nagios_user=nagios)
100 AC_ARG_WITH(nagios_group,
101         ACX_HELP_STRING([--with-nagios-group=GROUP],
102                 [set group name to run nagios]),
103         with_nagios_group=$withval,
104         with_nagios_group=nagios)
105 AC_SUBST(with_nagios_user)
106 AC_SUBST(with_nagios_group)
107 INSTALL_OPTS="-o $with_nagios_user -g $with_nagios_group"
108 AC_SUBST(INSTALL_OPTS)
110 AC_ARG_WITH(trusted_path,
111         ACX_HELP_STRING([--with-trusted-path=PATH],
112                 [sets trusted path for executables called by scripts (default=/bin:/sbin:/usr/bin:/usr/sbin)]),
113         with_trusted_path=$withval,
114         with_trusted_path=/bin:/sbin:/usr/bin:/usr/sbin)
115 AC_SUBST(with_trusted_path)
117 EXTRAS=
118 dnl PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/etc:/usr/local/bin:/usr/local/sbin:$PATH
120 LDFLAGS="$LDFLAGS -L."
122 ac_cv_uname_m=`uname -m`
123 ac_cv_uname_s=`uname -s`
124 ac_cv_uname_r=`uname -r`
125 ac_cv_uname_v=`uname -v`
127 dnl Checks for programs.
128 AC_PATH_PROG(PYTHON,python)
129 AC_PATH_PROG(PERL,perl)
130 AC_PATH_PROG(SH,sh)
132 AC_PATH_PROG(HOSTNAME,hostname)
133 AC_PATH_PROG(BASENAME,basename)
135 dnl
136 dnl Check for miscellaneous stuff
137 dnl 
139 case $host_vender-$host_os in
140 sun*)
141         AC_DEFINE(__EXTENSIONS__,1,[Sun's netdb.h needs this for getaddrinfo])
142         ;;
143 osf*)
144         AC_DEFINE(_OSF_SOURCE,1,[OSF needs this for getaddrinfo])
145         ;;
146 esac
148 dnl
149 dnl Checks for libraries.
150 dnl
152 AC_CHECK_LIB(dce,main,SOCKETLIBS="$SOCKETLIBS -ldce")
153 AC_CHECK_LIB(nsl,main,SOCKETLIBS="$SOCKETLIBS -lnsl")
154 AC_CHECK_LIB(socket,socket,SOCKETLIBS="$SOCKETLIBS -lsocket")
155 AC_CHECK_LIB(resolv,main,SOCKETLIBS="$SOCKETLIBS -lresolv")
156 AC_SUBST(SOCKETLIBS)
158 dnl Check for PostgreSQL libraries
159 _SAVEDLIBS="$LIBS"
160 _SAVEDCPPFLAGS="$CPPFLAGS"
161 AC_ARG_WITH(pgsql,
162         ACX_HELP_STRING([--with-pgsql=DIR],
163                 [sets path to pgsql installation]),
164         PGSQL=$withval,)
165 AC_CHECK_LIB(crypt,main)
166 if test "$ac_cv_lib_crypt_main" = "yes"; then
167   if test -n "$PGSQL"; then
168     LDFLAGS="$LDFLAGS -L$PGSQL/lib"
169     CPPFLAGS="$CPPFLAGS -I$PGSQL/include"
170   fi
171   AC_CHECK_LIB(pq,PQsetdbLogin,,,-lcrypt)
172   if test "$ac_cv_lib_pq_PQsetdbLogin" = "yes"; then
173     AC_CHECK_HEADERS(pgsql/libpq-fe.h)
174     AC_CHECK_HEADERS(postgresql/libpq-fe.h)
175     AC_CHECK_HEADERS(libpq-fe.h)
176     if [[ -n "$PGSQL" -a "$ac_cv_header_libpq_fe_h" = "yes" ]]; then
177       PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
178       PGINCLUDE="-I$PGSQL/include"
179     elif test  "$ac_cv_header_pgsql_libpq_fe_h" = "yes"; then
180       PGLIBS="-lpq -lcrypt"
181       PGINCLUDE="-I/usr/include/pgsql"
182     elif test  "$ac_cv_header_postgresql_libpq_fe_h" = "yes"; then
183       PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
184       PGINCLUDE="-I/usr/include/postgresql"
185     elif test  "$ac_cv_header_libpq_fe_h" = "yes"; then
186       PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
187       PGINCLUDE="-I$PGSQL/include"
188     fi
189     if test -z "$PGINCLUDE"; then
190       AC_MSG_WARN([Skipping PostgreSQL plugin (check_pgsql)])
191       AC_MSG_WARN([install PostgreSQL headers to compile this plugin (see REQUIREMENTS).])
192     else
193       AC_SUBST(PGLIBS)
194       AC_SUBST(PGINCLUDE)
195       EXTRAS="$EXTRAS check_pgsql"
196     fi
197   else
198     AC_MSG_WARN([Skipping PostgreSQL plugin (check_pgsql)])
199     AC_MSG_WARN([LIBS="$LIBS" CPPFLAGS="$CPPFLAGS"])
200     AC_MSG_WARN([install PostgreSQL libs to compile this plugin (see REQUIREMENTS).])
201   fi
202 else
203   AC_MSG_WARN([Skipping PostgreSQL plugin (check_pgsql)])
204   AC_MSG_WARN([install lib crypt and PostgreSQL libs to compile this plugin (see REQUIREMENTS).])
205 fi
206 LIBS="$_SAVEDLIBS"
207 CPPFLAGS="$_SAVEDCPPFLAGS"
209 dnl Check for radius libraries
210 _SAVEDLIBS="$LIBS"
211 AC_CHECK_LIB(radiusclient,rc_read_config)
212 if test "$ac_cv_lib_radiusclient_rc_read_config" = "yes"; then
213   EXTRAS="$EXTRAS check_radius"
214         RADIUSLIBS="-lradiusclient"
215   AC_SUBST(RADIUSLIBS)
216 else
217   AC_MSG_WARN([Skipping radius plugin])
218   AC_MSG_WARN([install radius libs to compile this plugin (see REQUIREMENTS).])
219 fi
220 LIBS="$_SAVEDLIBS"
222 dnl Check for LDAP libraries
223 _SAVEDLIBS="$LIBS"
224 AC_CHECK_LIB(ldap,main,,,-llber)
225 if test "$ac_cv_lib_ldap_main" = "yes"; then
226   LDAPLIBS="-lldap -llber"\
227   LDAPINCLUDE="-I/usr/include/ldap"
228   AC_SUBST(LDAPLIBS)
229   AC_SUBST(LDAPINCLUDE)
230   EXTRAS="$EXTRAS check_ldap"
231 else
232   AC_MSG_WARN([Skipping LDAP plugin])
233   AC_MSG_WARN([install LDAP libs to compile this plugin (see REQUIREMENTS).])
234 fi
235 LIBS="$_SAVEDLIBS"
238 dnl Check for mysql libraries
239 _SAVEDLIBS="$LIBS"
240 _SAVEDCPPFLAGS="$CPPFLAGS"
241 AC_ARG_WITH(mysql,
242         ACX_HELP_STRING([--with-mysql=DIR],
243                 [sets path to mysql installation (assumes lib/mysql and include subdirs]),
244         MYSQL=$withval,)
245 if test -n "$MYSQL"; then
246   MYSQLLIBDIR=$MYSQL/lib/mysql
247   CPPFLAGS="-I$MYSQL/include"
248   AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz" check_mysql_LDFLAGS="-L$MYSQLLIBDIR ",,-L$MYSQLLIBDIR -lz)
249   AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient")
250 elif test -f /usr/lib/libmysqlclient.so; then
251   AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz",,-lz)
252   AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient")
253 elif test -f /usr/lib/libmysqlclient.a; then
254   AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz",,-lz)
255   AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient")
256 elif test -f /usr/lib/mysql/libmysqlclient.so; then
257   AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz" check_mysql_LDFLAGS="-L/usr/lib/mysql",,-L/usr/lib/mysql -lz)
258   AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient" check_mysql_LDFLAGS="-L/usr/lib/mysql",,-L/usr/lib/mysql)
259 elif test -f /usr/lib/mysql/libmysqlclient.a; then
260   AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz" check_mysql_LDFLAGS="-L/usr/lib/mysql",,-L/usr/lib/mysql -lz)
261   AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient" check_mysql_LDFLAGS="-L/usr/lib/mysql",,-L/usr/lib/mysql)
262 fi
263 if test "$ac_cv_lib_mysqlclient_mysql_init" = "yes" -o "$ac_cv_lib_mysqlclient_mysql_close" = "yes"; then
264   AC_CHECK_HEADERS(mysql/mysql.h mysql/errmsg.h, MYSQLINCLUDE="-I$MYSQL/include" )
265   if test "$ac_cv_header_mysql_mysql_h" = "yes" -a "$ac_cv_header_mysql_errmsg_h" = "yes"; then
266     EXTRAS="$EXTRAS check_mysql"
267     AC_SUBST(MYSQLINCLUDE)
268     AC_SUBST(MYSQLLIBS)
269     AC_SUBST(check_mysql_LDFLAGS)
270   else
271     AC_MSG_WARN([Skipping mysql plugin])
272     AC_MSG_WARN([install mysql client headers to compile this plugin (see REQUIREMENTS).])
273   fi
274 else
275   AC_MSG_WARN([Skipping mysql plugin])
276   AC_MSG_WARN([install mysql client libs to compile this plugin (see REQUIREMENTS).])
277 fi
278 CPPFLAGS="$_SAVEDCPPFLAGS"
279 LIBS="$_SAVEDLIBS"
281 dnl Check for OpenSSL location
282 AC_PATH_PROG(OPENSSL,openssl)
283 if test "$OPENSSL" = "/usr/bin/openssl"; then
284   OPENSSL=/usr
285 elif test "$OPENSSL" = "/usr/sbin/openssl"; then
286   OPENSSL=/usr
287 elif test "$OPENSSL" = "/opt/bin/openssl"; then
288   OPENSSL=/opt
289 elif test "$OPENSSL" = "/opt/openssl/bin/openssl"; then
290   OPENSSL=/opt/openssl
291 elif test "$OPENSSL" = "/usr/slocal/bin/openssl"; then
292   OPENSSL=/usr/slocal
293 elif test "$OPENSSL" = "/usr/local/bin/openssl"; then
294   OPENSSL=/usr/local
295 elif test "$OPENSSL" = "/usr/local/ssl/bin/openssl"; then
296   OPENSSL=/usr/local/ssl
297 fi
298 AC_ARG_WITH(openssl,
299         ACX_HELP_STRING([--with-openssl=DIR],
300                 [sets path to openssl installation]),
301         OPENSSL=$withval,)
303 AC_ARG_WITH([ipv6],
304               ACX_HELP_STRING([--with-ipv6],
305                              [enable IPv6 support (default=no)]),
306               ,
307               with_ipv6=no)
309 dnl Check for AF_INET6 support
310 AC_CACHE_CHECK([for IPv6 support], with_ipv6, [
311         AC_TRY_COMPILE([#include <netinet/in.h>
312                         #include <sys/socket.h>],
313                         [struct sockaddr_in6 sin6;
314                         void *p;
316                         sin6.sin6_family = AF_INET6;
317                         sin6.sin6_port = 587;
318                         p = &sin6.sin6_addr;],
319                         [with_ipv6=yes], 
320                         [with_ipv6=no])
321         ])
323 if test x"$with_ipv6" != xno ; then
324         AC_DEFINE(USE_IPV6,1,[Enable IPv6 support])
325 fi
327 dnl #########################################################################
328 dnl Check if Posix getaddrinfo() is available.  It is also possible to use
329 dnl the version from the lwres library distributed with BIND.
330 dnl #########################################################################
331 AC_ARG_ENABLE([emulate-getaddrinfo],
332               ACX_HELP_STRING([--enable-emulate-getaddrinfo],
333                              [enable getaddrinfo emulation (default=no)]),
334               ,
335               enable_emulate_getaddrinfo=no)
336 AC_ARG_WITH(lwres,
337             ACX_HELP_STRING([--with-lwres=DIR],
338                            [use lwres library for getaddrinfo (default=no)]),
339             ,
340             with_lwres=no)
342 dnl ## enable force to test getaddrinfo.c
343 if test x$enable_emulate_getaddrinfo = xforce ; then
344         enable_emulate_getaddrinfo=yes
345         have_getaddrinfo=no
346 else
348 have_getaddrinfo=no
349 if test x$with_lwres != xno ; then
350         if test "$with_lwres" != yes ; then
351                    CPPFLAGS="-I${with_lwres}/include $CPPFLAGS"
352                    LDFLAGS="-L${with_lwres}/lib $LDFLAGS"
353         fi
354         AC_CHECK_HEADERS(lwres/netdb.h, ,
355                         [AC_MSG_ERROR([cannot find <lwres/netdb.h>])])
356         AC_CHECK_LIB(lwres, lwres_getaddrinfo, ,
357                      [AC_MSG_ERROR([cannot find the lwres library])],
358                      -lnsl -lpthread)
359         have_getaddrinfo=yes
360 fi
362 if test x$have_getaddrinfo != xyes ; then
363         AC_SEARCH_LIBS(getaddrinfo, socket resolv bind nsl c_r cr, have_getaddrinfo=yes)
364 fi
366 dnl # Special nonsense for systems that actually have getaddrinfo but
367 dnl # redefine the name to something else, e.g. OSF
368 if test x$have_getaddrinfo != xyes ; then
369         AC_MSG_CHECKING(if getaddrinfo is redefined in netdb.h)
370         AC_TRY_LINK([
371 #               include <netdb.h>
372         ], [
373                 struct addrinfo hints, *res;
374                 int err;
376                 err = getaddrinfo ("host", "service", &hints, &res);
377         ], [
378                 have_getaddrinfo=yes
379                 AC_MSG_RESULT(yes)
380         ], [AC_MSG_RESULT(no)])
381 fi
383 fi
385 if test x$have_getaddrinfo != xno ; then
386         if test x$enable_emulate_getaddrinfo != xno ; then
387                 AC_MSG_ERROR([getaddrinfo found but emulate-getaddrinfo was enabled])
388         fi
389         AC_DEFINE(HAVE_GETADDRINFO, 1,
390                   [Does system provide RFC 2553/Posix getaddrinfo?])
391 else
392         if test x$enable_emulate_getaddrinfo != xyes ; then
393                 AC_MSG_ERROR([getaddrinfo not found: try --with-lwres or --enable-emulate-getaddrinfo])
394         fi
395         LIBOBJS="$LIBOBJS getaddrinfo.o"
396 fi
398 if test x"$enable_emulate_getaddrinfo" != xno ; then
399     have_resolver=no
401   dnl  Try for getipnodebyname
402     AC_SEARCH_LIBS(getipnodebyname, resolv bind nsl c_r cr, have_resolver=yes)
403     if test x"$have_resolver" != xno ; then
404          AC_DEFINE(HAVE_GETIPNODEBYNAME, 1,
405                    [Set when getipnodebyname is available])
406     fi
408   dnl  Try for gethostbyname_r
409     if test x"$have_resolver" = xno ; then
410         AC_SEARCH_LIBS(gethostbyname_r, resolv bind nsl c_r cr,
411                        [have_resolver=yes
412                         ACX_WHICH_GETHOSTBYNAME_R])
413     fi
415   dnl  Try for gethostbyname
416     if test x"$have_resolver" = xno ; then
417         if test x"$enable_pthreads" != xno ; then
418             AC_MSG_WARN([using threads but cannot find gethostbyname_r or getipnodebyname])
419         fi
420         AC_SEARCH_LIBS(gethostbyname, resolv bind nsl, ,
421                        [AC_MSG_ERROR([cannot find gethostbyname])])
422     fi
423     LIBOBJS="$LIBOBJS gethostbyname.o"
425 fi
427 AC_CHECK_HEADERS(krb5.h,FOUNDINCLUDE=yes,FOUNDINCLUDE=no)
428 if test "$FOUNDINCLUDE" = "no"; then
429   _SAVEDCPPFLAGS="$CPPFLAGS"
430   CPPFLAGS="$_SAVEDCPPFLAGS -I/usr/kerberos/include"
431   unset ac_cv_header_krb5_h
432   AC_CHECK_HEADERS(krb5.h,
433                    KRB5INCLUDE="-I/usr/kerberos/include"
434                    FOUNDINCLUDE=yes,
435                    FOUNDINCLUDE=no)
436 fi
437 AC_SUBST(KRBINCLUDE)
438 if test "$FOUNDINCLUDE" = "no"; then
439   CPPFLAGS="$_SAVEDCPPFLAGS"
440 fi
442 dnl Check for OpenSSL header files
443 unset FOUNDINCLUDE
444 _SAVEDCPPFLAGS="$CPPFLAGS"
445 CPPFLAGS="$CPPFLAGS -I$OPENSSL/include"
446 AC_CHECK_HEADERS(openssl/ssl.h openssl/x509.h openssl/rsa.h openssl/pem.h openssl/crypto.h openssl/err.h,
447                  SSLINCLUDE="-I$OPENSSL/include"
448                  FOUNDINCLUDE=yes,
449                  FOUNDINCLUDE=no)
450 if test "$FOUNDINCLUDE" = "no"; then
451   AC_CHECK_HEADERS(ssl.h x509.h rsa.h pem.h crypto.h err.h,
452                    SSLINCLUDE="-I$OPENSSL/include"
453                    FOUNDINCLUDE=yes,
454                    FOUNDINCLUDE=no)
455 fi
456 AC_SUBST(SSLINCLUDE)
457 if test "$FOUNDINCLUDE" = "no"; then
458   CPPFLAGS="$_SAVEDCPPFLAGS"
459 fi
461 dnl Check for crypto lib
462 _SAVEDLIBS="$LIBS"
463 AC_CHECK_LIB(crypto,CRYPTO_lock,,,-L$OPENSSL/lib)
464 if test "$ac_cv_lib_crypto_CRYPTO_lock" = "yes"; then
465   dnl Check for SSL lib
466   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)
467 fi
468 LIBS="$_SAVEDLIBS"
470 dnl test headers and libs to decide whether check_http should use SSL
471 if test "$ac_cv_lib_crypto_CRYPTO_lock" = "yes"; then
472   if test "$ac_cv_lib_ssl_main" = "yes"; then
473     if test "$FOUNDINCLUDE" = "yes"; then
474       AC_SUBST(SSLLIBS)
475       AC_DEFINE(HAVE_SSL,1,[Define if SSL libraries are found])
476     fi
477   fi
478 fi
479 CPPFLAGS="$_SAVEDCPPFLAGS"
481 dnl
482 dnl Checks for header files.
483 dnl
485 AC_HEADER_STDC
486 AC_HEADER_TIME
487 AC_HEADER_SYS_WAIT
488 AC_CHECK_HEADERS(signal.h strings.h string.h syslog.h unistd.h uio.h errno.h regex.h sys/types.h sys/time.h sys/socket.h sys/loadavg.h)
489 AC_CHECK_HEADERS(stdarg.h sys/unistd.h unistd.h ctype.h stdlib.h)
491 dnl Linux
492 AC_CHECK_HEADERS(sys/vfs.h,
493                  [AC_TRY_COMPILE([#include <sys/vfs.h>],
494                                  [struct statfs buf; long foo; statfs ("/", &buf); foo = buf.f_namelen;],
495                                  [AC_DEFINE(HAVE_STRUCT_STATFS,1,[Define if statfs struct can be found])])])
497 dnl FreeBSD
498 AC_CHECK_HEADERS(sys/param.h sys/mount.h,
499                  [AC_TRY_COMPILE([#include <sys/param.h>
500 #include <sys/mount.h>],
501                                  [struct statfs buf; int foo; statfs ("/", &buf); foo = buf.f_flags;],
502                                  [AC_DEFINE(HAVE_STRUCT_STATFS,1,[Define if statfs struct can be found])])])
504 dnl Checks for typedefs, structures, and compiler characteristics.
505 AC_C_CONST
506 AC_STRUCT_TM
507 AC_TYPE_PID_T
508 AC_TYPE_SIZE_T
509 AC_TYPE_SIGNAL
511 AC_CHECK_SIZEOF(int,cross)
512 AC_CHECK_SIZEOF(long,cross)
513 AC_CHECK_SIZEOF(short,cross)
515 AC_CACHE_CHECK([for long long],ac_cv_have_longlong,[
516 AC_TRY_RUN([#include <stdio.h>
517 main() { long long x = 1000000; x *= x; exit(((x/1000000) == 1000000)? 0: 1); }],
518 ac_cv_have_longlong=yes,ac_cv_have_longlong=no,ac_cv_have_longlong=cross)])
519 if test x"$ac_cv_have_longlong" = x"yes"; then
520     AC_DEFINE(HAVE_LONGLONG,1,[Define if system has long long type])
521 fi
524 # Check if the compiler supports the LL prefix on long long integers.
525 # AIX needs this.
527 AC_CACHE_CHECK([for LL suffix on long long integers],ac_cv_compiler_supports_ll, [
528     AC_TRY_COMPILE([#include <stdio.h>],[long long i = 0x8000000000LL],
529         ac_cv_compiler_supports_ll=yes,ac_cv_compiler_supports_ll=no)])
530 if test x"$ac_cv_compiler_supports_ll" = x"yes"; then
531    AC_DEFINE(COMPILER_SUPPORTS_LL,1,[Define if compiler support long long])
532 fi
534 AC_CACHE_CHECK([for __va_copy],ac_cv_HAVE_VA_COPY,[
535 AC_TRY_LINK([#include <stdarg.h>
536 va_list ap1,ap2;], [__va_copy(ap1,ap2);],
537 ac_cv_HAVE_VA_COPY=yes,ac_cv_HAVE_VA_COPY=no)])
538 if test x"$ac_cv_HAVE_VA_COPY" = x"yes"; then
539     AC_DEFINE(HAVE_VA_COPY,1,[Define if system has va_copy])
540 fi
542 AC_CHECK_FUNCS(vsnprintf snprintf asprintf vasprintf)
543 AC_CACHE_CHECK([for C99 vsnprintf],ac_cv_HAVE_C99_VSNPRINTF,[
544 AC_TRY_RUN([
545 #include <sys/types.h>
546 #include <stdarg.h>
547 void foo(const char *format, ...) { 
548        va_list ap;
549        int len;
550        char buf[5];
552        va_start(ap, format);
553        len = vsnprintf(buf, 0, format, ap);
554        va_end(ap);
555        if (len != 5) exit(1);
557        va_start(ap, format);
558        len = vsnprintf(0, 0, format, ap);
559        va_end(ap);
560        if (len != 5) exit(1);
562        if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
564        exit(0);
566 main() { foo("hello"); }
567 ],
568 ac_cv_HAVE_C99_VSNPRINTF=yes,ac_cv_HAVE_C99_VSNPRINTF=no,ac_cv_HAVE_C99_VSNPRINTF=cross)])
569 if test x"$ac_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
570     AC_DEFINE(HAVE_C99_VSNPRINTF,1,[Define if system has C99 compatible vsnprintf])
571 fi
573 AC_TRY_COMPILE([#include <sys/time.h>],
574                [struct timeval *tv;
575                 struct timezone *tz;],
576                AC_DEFINE(HAVE_STRUCT_TIMEVAL,1,[Define if we have a timeval structure])
577                AC_TRY_COMPILE([#include <sys/time.h>],
578                               [struct timeval *tv;
579                                struct timezone *tz;
580                                gettimeofday(tv, tz);],
581                               AC_DEFINE(HAVE_GETTIMEOFDAY,1,[Define if gettimeofday is found]),
582                               AC_DEFINE(NEED_GETTIMEOFDAY,1,[Define if gettimeofday is needed])))
584 dnl Checks for library functions.
585 AC_CHECK_FUNCS(memmove select socket strdup strstr strtod strtol strtoul)
587 AC_MSG_CHECKING(return type of socket size)
588 AC_TRY_COMPILE([#include <stdlib.h>
589                 #include <sys/types.h>
590                 #include <sys/socket.h>],
591                [int a = send(1, (const void *) buffer, (size_t *) 0, (int *) 0);],
592                ac_cv_socket_size_type=["size_t"]
593                 AC_MSG_RESULT(size_t),
594                ac_cv_socket_size_type=["int"]
595                 AC_MSG_RESULT(int))
597 AC_DEFINE_UNQUOTED(SOCKET_SIZE_TYPE, $ac_cv_socket_size_type ,
598         [Define type of socket size])
600 if test -f "/proc/loadavg"
601 then
602   AC_DEFINE(HAVE_PROC_LOADAVG,1,[Define if /proc/loadavg or similar exists])
603   AC_DEFINE_UNQUOTED(PROC_LOADAVG,"/proc/loadavg",[Location of /proc/loadavg])
604 fi
606 dnl #### Process table test
608 AC_PATH_PROG(PATH_TO_PS,ps)
609 ac_cv_use_ps_vars=no
611 AC_MSG_CHECKING(for ps syntax)
612 dnl  STAT UCOMM              VSZ   RSS USER       UID  PPID COMMAND
613 if ps -weo 'stat comm vsz rss user uid ppid args' 2>/dev/null | \
614         egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null
615 then
616         ac_cv_use_ps_vars=yes
617         ac_cv_ps_varlist="[procstat,&procuid,&procppid,procprog,&pos]"
618         ac_cv_ps_raw_command="$PATH_TO_PS -weo 'stat user ppid args'"
619         ac_cv_ps_command="$PATH_TO_PS -weo 'stat uid ppid comm args'"
620         ac_cv_ps_format="%s %d %d %s %n"
621         ac_cv_vsz_command="$PATH_TO_PS -weo 'vsz comm'"
622         ac_cv_vsz_format="%d %s"
623         ac_cv_rss_command="$PATH_TO_PS -weo 'rss comm'"
624         ac_cv_rss_format="%d %s"
625         EXTRAS="$EXTRAS check_nagios"
626         AC_MSG_RESULT([$ac_cv_ps_command])
628 dnl FreeBSD
629 elif ps waxco 'state command vsz rss uid user ppid' 2>/dev/null | \
630         egrep -i ["^STAT +COMMAND +VSZ +RSS +UID +USER +PPID"] >/dev/null
631 then
632         ac_cv_use_ps_vars=yes
633         ac_cv_ps_varlist="[procstat,&procuid,&procppid,procprog,&pos]"
634         ac_cv_ps_raw_command="$PATH_TO_PS waxo 'state uid ppid command'"
635         ac_cv_ps_command="$PATH_TO_PS waxco 'state uid ppid command command'"
636         ac_cv_ps_format="%s %d %d %s %n"
637         ac_cv_vsz_command="$PATH_TO_PS waxco 'vsz command'"
638         ac_cv_vsz_format="%d %s"
639         ac_cv_rss_command="$PATH_TO_PS waxco 'rss command'"
640         ac_cv_rss_format="%d %s"
641         EXTRAS="$EXTRAS check_nagios"
642         AC_MSG_RESULT([$ac_cv_ps_command])
644 dnl BSD-like mode in RH 6.1
645 elif ps waxno 'state comm vsz rss uid user ppid args' 2>/dev/null | \
646         egrep -i ["^S +COMMAND +VSZ +RSS +UID +USER +PPID +[RGSCOMDNA]+"] >/dev/null
647 then
648         ac_cv_use_ps_vars=yes
649         ac_cv_ps_varlist="[procstat,&procuid,&procppid,procprog,&pos]"
650         ac_cv_ps_raw_command="$PATH_TO_PS waxno 'state user ppid comm'"
651         ac_cv_ps_command="$PATH_TO_PS waxno 'state uid ppid comm args'"
652         ac_cv_ps_format="%s %d %d %s %n"
653         ac_cv_vsz_command="$PATH_TO_PS waxno 'vsz comm'"
654         ac_cv_vsz_format="%d %s"
655         ac_cv_rss_command="$PATH_TO_PS waxno 'rss comm'"
656         ac_cv_rss_format="%d %s"
657         EXTRAS="$EXTRAS check_nagios"
658         AC_MSG_RESULT([$ac_cv_ps_command])
660 dnl SunOS 4.1.3:
661 dnl  F  UID  PID  PPID  CP  PRI  NI  SZ  RSS  WCHAN  STAT  TT  TIME  COMMAND
662 elif ps -laxnwww 2>/dev/null | \
663         egrep -i ["^ *F(LAGS)? +UID +PID +PPID +CP +PRI +NI +(SZ)|(VSZ)|(SIZE) +RSS +WCHAN +STAT? +TTY? +TIME +COMMAND"] >/dev/null
664 then
665         ac_cv_use_ps_vars=yes
666         ac_cv_ps_raw_command="$PATH_TO_PS laxnwww"
667         ac_cv_ps_varlist="[&procuid,&procppid,procstat,&pos,procprog]"
668         ac_cv_ps_command="$PATH_TO_PS -laxnwww"
669         ac_cv_ps_format="%*s %d %*s %d %*s %*s %*s %*s %*s %*s %s %*s %*s %n%s"
670         ac_cv_vsz_command="$PATH_TO_PS laxnwww"
671         ac_cv_vsz_format="%*s %*s %*s %*s %*s %*s %*s %d"
672         ac_cv_rss_command="$PATH_TO_PS laxnwww"
673         ac_cv_rss_format="%*s %*s %*s %*s %*s %*s %*s %*s %d"
674         EXTRAS="$EXTRAS check_nagios"
675         AC_MSG_RESULT([$ac_cv_ps_command])
677 dnl Debian Linux / procps v1.2.9:
678 dnl  FLAGS   UID   PID  PPID PRI  NI   SIZE   RSS WCHAN       STA TTY TIME COMMAND
679 dnl    100     0     1     0   0   0    776    76  c0131c8c   S  ffff  0:11 init [2]
680 dnl
681 elif ps laxnwww 2>/dev/null | \
682         egrep -i ["^ *F(LAGS)? +UID +PID +PPID +PRI +NI +(VSZ)|(SIZE) +RSS +WCHAN +STAT? TTY +TIME +COMMAND"] >/dev/null
683 then
684         ac_cv_use_ps_vars=yes
685         ac_cv_ps_raw_command="$PATH_TO_PS laxnwww"
686         ac_cv_ps_varlist="[&procuid,&procppid,procstat,&pos,procprog]"
687         ac_cv_ps_command="$PATH_TO_PS laxnwww"
688         ac_cv_ps_format="%*s %d %*s %d %*s %*s %*s %*s %*s %s %*s %*s %n%s"
689         ac_cv_vsz_command="$PATH_TO_PS laxnwww"
690         ac_cv_vsz_format="%*s %*s %*s %*s %*s %*s %d"
691         ac_cv_rss_command="$PATH_TO_PS laxnwww"
692         ac_cv_rss_format="%*s %*s %*s %*s %*s %*s %*s %d"
693         EXTRAS="$EXTRAS check_nagios"
694         AC_MSG_RESULT([$ac_cv_ps_command])
696 dnl OpenBSD (needs to come early because -exo appears to work, but does not give all procs)
697 elif ps -axo 'stat comm vsz rss user uid ppid args' 2>/dev/null | \
698         egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null
699 then
700         ac_cv_use_ps_vars=yes
701         ac_cv_ps_varlist="[procstat,&procuid,&procppid,procprog,&pos]"
702         ac_cv_ps_raw_command="$PATH_TO_PS -axo 'stat user ppid args'"
703         ac_cv_ps_command="$PATH_TO_PS -axo 'stat uid ppid comm args'"
704         ac_cv_ps_format="%s %d %d %s %n"
705         ac_cv_vsz_command="$PATH_TO_PS -axo 'vsz comm'"
706         ac_cv_vsz_format="%d %s"
707         ac_cv_rss_command="$PATH_TO_PS -axo 'rss comm'"
708         ac_cv_rss_format="%d %s"
709         EXTRAS="$EXTRAS check_nagios"
710         AC_MSG_RESULT([$ac_cv_ps_command])
712 dnl AIX 4.3.3 - needs verification. This works for Tru64 - needs %*[ +] in PS_FORMAT
713 elif ps -ao 'stat comm vsz rss user uid ppid args' 2>/dev/null | \
714         egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null
715 then
716         ac_cv_use_ps_vars=yes
717         ac_cv_ps_varlist="[procstat,&procuid,&procppid,procprog,&pos]"
718         ac_cv_ps_raw_command="$PATH_TO_PS -ao 'stat user ppid args'"
719         ac_cv_ps_command="$PATH_TO_PS -ao 'stat uid ppid comm args'"
720         ac_cv_ps_format="[["%s%*[ +] %d %d %s %n"]]"
721         ac_cv_vsz_command="$PATH_TO_PS -ao 'vsz comm'"
722         ac_cv_vsz_format="%d %s"
723         ac_cv_rss_command="$PATH_TO_PS -ao 'rss comm'"
724         ac_cv_rss_format="%d %s"
725         EXTRAS="$EXTRAS check_nagios"
726         AC_MSG_RESULT([$ac_cv_ps_command])
728 elif ps -eo 's comm vsz rss user uid ppid args' 2>/dev/null | \
729         egrep -i ["^S[TAUES]* +C[OMDNA]+ +[VSIZE]+ +U[SER]+ +U[ID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null
730 then
731         ac_cv_use_ps_vars=yes
732         ac_cv_ps_varlist="[procstat,&procuid,&procppid,procprog,&pos]"
733         ac_cv_ps_raw_command="$PATH_TO_PS -eo 's user ppid args'"
734         ac_cv_ps_command="$PATH_TO_PS -eo 's uid ppid comm args'"
735         ac_cv_ps_format="%s %d %d %s %n"
736         ac_cv_vsz_command="$PATH_TO_PS -eo 'vsz comm'"
737         ac_cv_vsz_format="%d %s"
738         ac_cv_rss_command="$PATH_TO_PS -eo 'rss comm'"
739         ac_cv_rss_format="%d %s"
740         EXTRAS="$EXTRAS check_nagios"
741         AC_MSG_RESULT([$ac_cv_ps_command])
743 elif ps -Ao 's comm vsz rss uid user ppid args' 2>/dev/null | \
744         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PPID +[RGSCOMDNA]+"] >/dev/null
745 then
746         ac_cv_use_ps_vars=yes
747         ac_cv_ps_varlist="[procstat,&procuid,&procppid,procprog,&pos]"
748         ac_cv_ps_raw_command="$PATH_TO_PS -Ao 's user ppid args'"
749         ac_cv_ps_command="$PATH_TO_PS -Ao 's uid ppid comm args'"
750         ac_cv_ps_format="%s %d %d %s %n"
751         ac_cv_vsz_command="$PATH_TO_PS -Ao 'vsz comm'"
752         ac_cv_vsz_format="%d %s"
753         ac_cv_rss_command="$PATH_TO_PS -Ao 'rss comm'"
754         ac_cv_rss_format="%d %s"
755         EXTRAS="$EXTRAS check_nagios"
756         AC_MSG_RESULT([$ac_cv_ps_command])
758 elif ps -Ao 'status comm vsz rss uid user ppid args' 2>/dev/null | \
759         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PPID +[RGSCOMDNA]+"] >/dev/null
760 then
761         ac_cv_use_ps_vars=yes
762         ac_cv_ps_varlist="[procstat,&procuid,&procppid,procprog,&pos]"
763         ac_cv_ps_raw_command="$PATH_TO_PS -Ao 'status user ppid args'"
764         ac_cv_ps_command="$PATH_TO_PS -Ao 'status uid ppid comm args'"
765         ac_cv_ps_format="%s %d %d %s %n"
766         ac_cv_vsz_command="$PATH_TO_PS -Ao 'vsz comm'"
767         ac_cv_vsz_format="%d %s"
768         ac_cv_rss_command="$PATH_TO_PS -Ao 'rss comm'"
769         ac_cv_rss_format="%d %s"
770         EXTRAS="$EXTRAS check_nagios"
771         AC_MSG_RESULT([$ac_cv_ps_command])
773 elif ps -Ao 'state comm vsz rss uid user ppid args' 2>/dev/null | \
774         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PPID +[RGSCOMDNA]+"] >/dev/null
775 then
776         ac_cv_use_ps_vars=yes
777         ac_cv_ps_varlist="[procstat,&procuid,&procppid,procprog,&pos]"
778         ac_cv_ps_raw_command="$PATH_TO_PS -Ao 'state user ppid args'"
779         ac_cv_ps_command="$PATH_TO_PS -Ao 'state uid ppid comm args'"
780         ac_cv_ps_format="%s %d %d %s %n"
781         ac_cv_vsz_command="$PATH_TO_PS -Ao 'vsz comm'"
782         ac_cv_vsz_format="%d %s"
783         ac_cv_rss_command="$PATH_TO_PS -Ao 'rss comm'"
784         ac_cv_rss_format="%d %s"
785         EXTRAS="$EXTRAS check_nagios"
786         AC_MSG_RESULT([$ac_cv_ps_command])
788 dnl wonder who takes state instead of stat
789 elif ps -ao 'state command vsz rss user ppid args' 2>/dev/null | \
790         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PPID +[RGSCOMDNA]+"] >/dev/null
791 then
792         ac_cv_use_ps_vars=yes
793         ac_cv_ps_varlist="[procstat,&procuid,&procppid,procprog,&pos]"
794         ac_cv_ps_raw_command="$PATH_TO_PS -ao 'state user ppid args'"
795         ac_cv_ps_command="$PATH_TO_PS -ao 'state uid ppid command args'"
796         ac_cv_ps_format="%s %d %d %s %n"
797         ac_cv_vsz_command="$PATH_TO_PS -ao 'vsz command'"
798         ac_cv_vsz_format="%d %s"
799         ac_cv_rss_command="$PATH_TO_PS -ao 'rss command'"
800         ac_cv_rss_format="%d %s"
801         EXTRAS="$EXTRAS check_nagios"
802         AC_MSG_RESULT([$ac_cv_ps_command])
804 dnl IRIX 53
805 elif ps -el 2>/dev/null | \
806         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
807 then
808         ac_cv_use_ps_vars=yes
809         ac_cv_ps_varlist="[procstat,&procuid,&procppid,&pos,procprog]"
810         ac_cv_ps_command="$PATH_TO_PS -el"
811         ac_cv_ps_format="%*s %s %d %*s %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
812         ac_cv_vsz_command="$PATH_TO_PS -el"
813         ac_cv_vsz_format="%*s %*s %*s %*s %d"
814         ac_cv_rss_command="$PATH_TO_PS -el"
815         ac_cv_rss_format="%*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %d"
816         AC_MSG_RESULT([$ac_cv_ps_command])
818 dnl IRIX 63
819 elif ps -el 2>/dev/null | \
820         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +ADDR +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
821 then
822         ac_cv_use_ps_vars=yes
823         ac_cv_ps_varlist="[procstat,&procuid,&procppid,&pos,procprog]"
824         ac_cv_ps_command="$PATH_TO_PS -el"
825         ac_cv_ps_format="%*s %s %d %*s %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
826         ac_cv_vsz_command="$PATH_TO_PS -el"
827         ac_cv_vsz_format="%*s %*s %*s %*s %d"
828         ac_cv_rss_command="$PATH_TO_PS -el"
829         ac_cv_rss_format="%*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %d"
830         AC_MSG_RESULT([$ac_cv_ps_command])
832 dnl AIX 4.1:
833 dnl     F S      UID   PID  PPID   C PRI NI ADDR  SZ  RSS   WCHAN    TTY  TIME CMD
834 dnl    303 A        0     0     0 120  16 -- 1c07  20   24              -  0:45 swapper
835 elif ps -el 2>/dev/null | \
836         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +ADDR +SZ +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
837 then
838         ac_cv_use_ps_vars=yes
839         ac_cv_ps_varlist="[procstat,&procuid,&procppid,&pos,procprog]"
840         ac_cv_ps_command="$PATH_TO_PS -el"
841         ac_cv_ps_format="%*s %s %d %*s %d %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
842         ac_cv_vsz_command="$PATH_TO_PS -el"
843         ac_cv_vsz_format="%*s %*s %*s %*s %*s %*s %*s %*s %*s %d"
844         ac_cv_rss_command="$PATH_TO_PS -el"
845         ac_cv_rss_format="%*s %*s %*s %*s %*s %*s %*s %*s %*s %d"
846         AC_MSG_RESULT([$ac_cv_ps_command])
848 dnl AIX?
849 elif ps glaxen 2>/dev/null | \
850         egrep -i ["^ *F +UID +PID +PPID +PRI +NI +VSZ +RSS +WCHAN +STAT +TTY +TIME +COMMAND"] >/dev/null
851 then
852         ac_cv_use_ps_vars=yes
853         ac_cv_ps_varlist="[&procuid,&procppid,procstat,&pos,procprog]"
854         ac_cv_ps_command="$PATH_TO_PS glaxen"
855         ac_cv_ps_format="%*s %d %*s %d %*s %*s %*s %*s %*s %s %*s %*s %n%s"
856         ac_cv_vsz_command="$PATH_TO_PS glaxen"
857         ac_cv_vsz_format="%*s %*s %*s %*s %*s %*s %d"
858         ac_cv_rss_command="$PATH_TO_PS glaxen"
859         ac_cv_rss_format="%*s %*s %*s %*s %*s %*s %*s %d"
860         AC_MSG_RESULT([$ac_cv_ps_command])
862 dnl MacOSX / Darwin
863 dnl TODO: MacOSX has commands with spaces which will cause problems to PS_FORMAT
864 dnl STAT      VSZ    RSS   UID USER     PPID UCOMM            COMMAND
865 dnl Ss       1308    272     0 root        0 init             /sbin/init
866 elif ps waxo 'state vsz rss uid user ppid ucomm command' 2>/dev/null | \
867         egrep -i ["^STAT +VSZ +RSS +UID +USER +PPID +UCOMM +COMMAND"] >/dev/null
868 then
869         ac_cv_use_ps_vars=yes
870         ac_cv_ps_varlist="[procstat,&procuid,&procppid,procprog,&pos]"
871         ac_cv_ps_raw_command="$PATH_TO_PS waxo 'state uid ppid command'"
872         ac_cv_ps_command="$PATH_TO_PS waxo 'state uid ppid ucomm command'"
873         ac_cv_ps_format="%s %d %d %s %n"
874         ac_cv_vsz_command="$PATH_TO_PS waxco 'vsz command'"
875         ac_cv_vsz_format="%d %s"
876         ac_cv_rss_command="$PATH_TO_PS waxco 'rss command'"
877         ac_cv_rss_format="%d %s"
878         EXTRAS="$EXTRAS check_nagios"
879         AC_MSG_RESULT([$ac_cv_ps_command])
881 dnl UnixWare 
882 elif ps -Al 2>/dev/null | \
883         egrep -i ["^ *F +S +UID +PID +PPID +CLS +PRI +NI +C +ADDR +SZ +WCHAN +TTY +TIME +COMD"] >/dev/null
884 then
885         ac_cv_use_ps_vars=yes
886         ac_cv_ps_varlist="[procstat,&procuid,&procppid,&pos,procprog]"
887         ac_cv_ps_command="$PATH_TO_PS -Al"
888         ac_cv_ps_format="%*s %s %d %*s %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
889         if ps -Ao 'vsz comm' 2>/dev/null | \
890                 egrep -i ["^ *VSZ +COMMAND"] >/dev/null
891         then
892                 ac_cv_vsz_command="$PATH_TO_PS -Ao 'vsz comm'"
893                 ac_cv_vsz_format="%*s %d"
894         fi
895         AC_MSG_RESULT([$ac_cv_ps_command])
897 else
898         AC_MSG_WARN([unable to find usable ps syntax])
899 fi
901 if test "x$ac_cv_use_ps_vars" != "xno"
902 then
903         AC_DEFINE(USE_PS_VARS,1,[Define if 'ps' will be parsed with sscanf])
904 fi
905 AC_DEFINE_UNQUOTED(PS_VARLIST,$ac_cv_ps_varlist,
906         [Variable list for sscanf of 'ps' output])
907 AC_DEFINE_UNQUOTED(PS_RAW_COMMAND,"$ac_cv_ps_raw_command",
908         [Verbatim command to execute for ps in check_netsaint])
909 AC_DEFINE_UNQUOTED(PS_COMMAND,"$ac_cv_ps_command",
910         [Verbatim command to execute for ps in check_procs])
911 AC_DEFINE_UNQUOTED(PS_FORMAT,"$ac_cv_ps_format",
912         [Format string for scanning ps output in check_procs])
913 AC_DEFINE_UNQUOTED(VSZ_COMMAND,"$ac_cv_vsz_command",
914         [Verbatim command to execute for ps in check_vsz])
915 AC_DEFINE_UNQUOTED(VSZ_FORMAT,"$ac_cv_vsz_format",
916         [Format string for scanning ps output in check_vsz])
917 AC_DEFINE_UNQUOTED(RSS_COMMAND,"$ac_cv_rss_command",
918         [Verbatim command to execute for ps in check_rss])
919 AC_DEFINE_UNQUOTED(RSS_FORMAT,"$ac_cv_rss_format",
920         [Format string for scanning ps output in check_rss])
922 AC_PATH_PROG(PATH_TO_DF,df)
923 AC_PATH_PROG(PATH_TO_BDF,bdf)
925 AC_ARG_WITH(df_command,
926         ACX_HELP_STRING([--with-df-command=SYNTAX],
927                 [sets syntax for df]),
928         with_df_command=$withval,)
930 AC_MSG_CHECKING(for df syntax)
931 if test -n "$with_df_command"
932 then
933         AC_MSG_RESULT([$with_df_command])
935 elif df -Pk 2>/dev/null | egrep -i ["^(/dev/|[a-zA-Z]:)[a-z0-9/\\]+ +[0-9]+ +[0-9]+ +[0-9]+ +[0-9]+% +/[a-z0-9/\\]*"] >/dev/null
936 then
937         with_df_command="$PATH_TO_DF -Pk"
938         AC_MSG_RESULT([$with_df_command])
940 elif df -k 2>/dev/null | egrep -i ["^/dev/[a-z0-9/]+ +[0-9]+ +[0-9]+ +[0-9]+ +[0-9]+% +/[a-z0-9/]*"] >/dev/null
941 then
942         with_df_command="$PATH_TO_DF -k"
943         AC_MSG_RESULT([$with_df_command])
945 elif df 2>/dev/null | egrep -i ["^/dev/[a-z0-9/]+ +[0-9]+ +[0-9]+ +[0-9]+ +[0-9]+% +/[a-z0-9/]*"] >/dev/null
946 then
947         with_df_command="$PATH_TO_DF"
948         AC_MSG_RESULT([$with_df_command])
950 elif bdf 2>/dev/null | egrep -i ["^/dev/[a-z0-9/]+ +[0-9]+ +[0-9]+ +[0-9]+ +[0-9]+% +/[a-z0-9/]*"] >/dev/null
951 then
952         with_df_command="$PATH_TO_BDF"
953         AC_MSG_RESULT([$with_df_command])
955 else
956         AC_MSG_WARN([unable to find usable df syntax])
957 fi
959 AC_DEFINE_UNQUOTED(DF_COMMAND,"$with_df_command",[path and args for df command])
961 AC_PATH_PROG(PATH_TO_PING,ping)
962 AC_PATH_PROG(PATH_TO_PING6,ping6)
964 AC_ARG_WITH(ping_command,
965         ACX_HELP_STRING([--with-ping-command=SYNTAX],
966                 [sets syntax for ICMP ping]),
967         with_ping_command=$withval,)
969 AC_MSG_CHECKING(for ICMP ping syntax)
970 ac_cv_ping_packets_first=no
971 if test -n "$with_ping_command"
972 then
973         AC_MSG_RESULT([(command-line) $with_ping_command])
974         if test -n "$ac_cv_ping_packets_first"
975         then
976                 ac_cv_ping_packets_first=yes
977         fi
979 elif [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
980         $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
981         egrep -i "^round-trip|^rtt" >/dev/null
982 then
983         with_ping_command="$PATH_TO_PING -n -U -c %d %s"
984         ac_cv_ping_packets_first=yes
985         AC_MSG_RESULT([$with_ping_command])
987 elif $PATH_TO_PING -n -U -c 1 127.0.0.1 2>/dev/null | \
988         egrep -i "^round-trip|^rtt" >/dev/null
989 then
990         with_ping_command="$PATH_TO_PING -n -U -c %d %s"
991         ac_cv_ping_packets_first=yes
992         AC_MSG_RESULT([$with_ping_command])
994 elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \
995         egrep -i "^round-trip|^rtt" >/dev/null
996 then
997         with_ping_command="$PATH_TO_PING -n -c %d %s"
998         ac_cv_ping_packets_first=yes
999         AC_MSG_RESULT([$with_ping_command])
1001 elif $PATH_TO_PING -n 127.0.0.1 -c 1 2>/dev/null | \
1002         egrep -i "^round-trip|^rtt" >/dev/null
1003 then
1004         with_ping_command="$PATH_TO_PING -n %s -c %d"
1005         AC_MSG_RESULT([$with_ping_command])
1007 elif $PATH_TO_PING 127.0.0.1 -n 1 2>/dev/null | \
1008         egrep -i "^round-trip|^rtt" >/dev/null
1009 then
1010         with_ping_command="$PATH_TO_PING %s -n %d"
1011         AC_MSG_RESULT([$with_ping_command])
1013 elif $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
1014         egrep -i "^round-trip|^rtt" >/dev/null
1015 then
1016         with_ping_command="$PATH_TO_PING -n -s %s 56 %d"
1017         AC_MSG_RESULT([$with_ping_command])
1019 elif $PATH_TO_PING -n -h 127.0.0.1 -s 56 -c 1 2>/dev/null | \
1020         egrep -i "^round-trip|^rtt" >/dev/null
1021 then
1022         with_ping_command="$PATH_TO_PING -n -h %s -s 56 -c %d"
1023         AC_MSG_RESULT([$with_ping_command])
1025 elif $PATH_TO_PING -n -s 56 -c 1 127.0.0.1 2>/dev/null | \
1026         egrep -i "^round-trip|^rtt" >/dev/null
1027 then
1028         with_ping_command="$PATH_TO_PING -n -s 56 -c %d %s"
1029         ac_cv_ping_packets_first=yes
1030         AC_MSG_RESULT([$with_ping_command])
1032 elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \
1033         egrep -i "^round-trip|^rtt" >/dev/null
1034 then
1035         with_ping_command="$PATH_TO_PING -n -c %d %s"
1036         ac_cv_ping_packets_first=yes
1037         AC_MSG_RESULT([$with_ping_command])
1039 else
1040         AC_MSG_WARN([unable to find usable ping syntax])
1041 fi
1043 AC_DEFINE_UNQUOTED(PING_COMMAND,"$with_ping_command",
1044         [path and args for ICMP ping command])
1046 if test "x$ac_cv_ping_packets_first" != "xno"
1047 then
1048         AC_DEFINE(PING_PACKETS_FIRST,1,
1049                 [Define if packet count must precede host])
1050 fi
1052 AC_ARG_WITH(ping6_command,
1053         ACX_HELP_STRING([--with-ping6-command=SYNTAX],
1054                 [sets syntax for ICMPv6 ping]),
1055         with_ping6_command=$withval,)
1057 if test x"$with_ipv6" != xno ; then
1058 AC_MSG_CHECKING(for ICMPv6 ping syntax)
1059 ac_cv_ping6_packets_first=no
1060 if test -n "$with_ping6_command"
1061 then
1062         AC_MSG_RESULT([(command-line) $with_ping6_command])
1063         if test -n "$ac_cv_ping6_packets_first"
1064         then
1065                 ac_cv_ping6_packets_first=yes
1066         fi
1068 elif test "x$PATH_TO_PING6" != "x"; then
1069         if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
1070                 $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \
1071                 egrep -i "^round-trip|^rtt" >/dev/null
1072         then
1073                 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s"
1074                 ac_cv_ping6_packets_first=yes
1075                 AC_MSG_RESULT([$with_ping6_command])
1077         elif $PATH_TO_PING6 -n -U -c 1 ::1 2>/dev/null | \
1078                 egrep -i "^round-trip|^rtt" >/dev/null
1079         then
1080                 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s"
1081                 ac_cv_ping6_packets_first=yes
1082                 AC_MSG_RESULT([$with_ping6_command])
1084         elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \
1085                 egrep -i "^round-trip|^rtt" >/dev/null
1086         then
1087                 with_ping6_command="$PATH_TO_PING6 -n -c %d %s"
1088                 ac_cv_ping6_packets_first=yes
1089                 AC_MSG_RESULT([$with_ping6_command])
1091         elif $PATH_TO_PING6 -n ::1 -c 1 2>/dev/null | \
1092                 egrep -i "^round-trip|^rtt" >/dev/null
1093         then
1094                 with_ping6_command="$PATH_TO_PING6 -n %s -c %d"
1095                 AC_MSG_RESULT([$with_ping6_command])
1097         elif $PATH_TO_PING6 ::1 -n 1 2>/dev/null | \
1098                 egrep -i "^round-trip|^rtt" >/dev/null
1099         then
1100                 with_ping6_command="$PATH_TO_PING6 %s -n %d"
1101                 AC_MSG_RESULT([$with_ping6_command])
1103         elif $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \
1104                 egrep -i "^round-trip|^rtt" >/dev/null
1105         then
1106                 with_ping6_command="$PATH_TO_PING6 -n -s %s 56 %d"
1107                 AC_MSG_RESULT([$with_ping6_command])
1109         elif $PATH_TO_PING6 -n -h ::1 -s 56 -c 1 2>/dev/null | \
1110                 egrep -i "^round-trip|^rtt" >/dev/null
1111         then
1112                 with_ping6_command="$PATH_TO_PING6 -n -h %s -s 56 -c %d"
1113                 AC_MSG_RESULT([$with_ping6_command])
1115         elif $PATH_TO_PING6 -n -s 56 -c 1 ::1 2>/dev/null | \
1116                 egrep -i "^round-trip|^rtt" >/dev/null
1117         then
1118                 with_ping6_command="$PATH_TO_PING6 -n -s 56 -c %d %s"
1119                 ac_cv_ping6_packets_first=yes
1120                 AC_MSG_RESULT([$with_ping_command])
1122         elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \
1123                 egrep -i "^round-trip|^rtt" >/dev/null
1124         then
1125                 with_ping6_command="$PATH_TO_PING6 -n -c %d %s"
1126                 ac_cv_ping6_packets_first=yes
1127                 AC_MSG_RESULT([$with_ping6_command])
1129         fi
1131 elif test "x$PATH_TO_PING" != "x"; then
1132         if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
1133                 $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \
1134                 egrep -i "^round-trip|^rtt" >/dev/null
1135         then
1136                 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s"
1137                 ac_cv_ping6_packets_first=yes
1138                 AC_MSG_RESULT([$with_ping6_command])
1140         elif $PATH_TO_PING -A inet6 -n -U -c 1 ::1 2>/dev/null | \
1141                 egrep -i "^round-trip|^rtt" >/dev/null
1142         then
1143                 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s"
1144                 ac_cv_ping6_packets_first=yes
1145                 AC_MSG_RESULT([$with_ping6_command])
1147         elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \
1148                 egrep -i "^round-trip|^rtt" >/dev/null
1149         then
1150                 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s"
1151                 ac_cv_ping6_packets_first=yes
1152                 AC_MSG_RESULT([$with_ping6_command])
1154         elif $PATH_TO_PING -A inet6 -n ::1 -c 1 2>/dev/null | \
1155                 egrep -i "^round-trip|^rtt" >/dev/null
1156         then
1157                 with_ping6_command="$PATH_TO_PING -A inet6 -n %s -c %d"
1158                 AC_MSG_RESULT([$with_ping6_command])
1160         elif $PATH_TO_PING -A inet6 ::1 -n 1 2>/dev/null | \
1161                 egrep -i "^round-trip|^rtt" >/dev/null
1162         then
1163                 with_ping6_command="$PATH_TO_PING -A inet6 %s -n %d"
1164                 AC_MSG_RESULT([$with_ping6_command])
1166         elif $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \
1167                 egrep -i "^round-trip|^rtt" >/dev/null
1168         then
1169                 with_ping6_command="$PATH_TO_PING -A inet6 -n -s %s 56 %d"
1170                 AC_MSG_RESULT([$with_ping6_command])
1172         elif $PATH_TO_PING -A inet6 -n -h ::1 -s 56 -c 1 2>/dev/null | \
1173                 egrep -i "^round-trip|^rtt" >/dev/null
1174         then
1175                 with_ping6_command="$PATH_TO_PING -A inet6 -n -h %s -s 56 -c %d"
1176                 AC_MSG_RESULT([$with_ping6_command])
1178         elif $PATH_TO_PING -A inet6 -n -s 56 -c 1 ::1 2>/dev/null | \
1179                 egrep -i "^round-trip|^rtt" >/dev/null
1180         then
1181                 with_ping6_command="$PATH_TO_PING -A inet6 -n -s 56 -c %d %s"
1182                 ac_cv_ping6_packets_first=yes
1183                 AC_MSG_RESULT([$with_ping_command])
1185         elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \
1186                 egrep -i "^round-trip|^rtt" >/dev/null
1187         then
1188                 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s"
1189                 ac_cv_ping6_packets_first=yes
1190                 AC_MSG_RESULT([$with_ping6_command])
1192         fi
1194 fi
1196 if test "x$with_ping6_command" != "x"; then
1197         AC_DEFINE_UNQUOTED(PING6_COMMAND,"$with_ping6_command",
1198                 [path and args for ICMPv6 ping command])
1199 else
1200         AC_MSG_RESULT([none])
1201 fi
1203 if test "x$ac_cv_ping6_packets_first" != "xno"; then
1204         AC_DEFINE(PING6_PACKETS_FIRST,1,
1205                 [Define if packet count must precede host])
1206 fi
1207 fi
1209 AC_PATH_PROG(PATH_TO_NSLOOKUP,nslookup)
1211 AC_MSG_CHECKING(for nslookup syntax)
1212 if test -n "$PATH_TO_NSLOOKUP"
1213 then
1214         if $PATH_TO_NSLOOKUP -sil 127.0.0.1 2>&1 | grep ["Invalid option: sil"] >/dev/null
1215         then
1216                 ac_cv_nslookup_command="$PATH_TO_NSLOOKUP"
1217                 AC_MSG_RESULT([$ac_cv_nslookup_command])
1219         else
1220                 ac_cv_nslookup_command="$PATH_TO_NSLOOKUP -sil"
1221                 AC_MSG_RESULT([$ac_cv_nslookup_command])
1223         fi
1224         EXTRAS="$EXTRAS check_dns"
1226 else
1227         AC_MSG_WARN([nslookup command not found])
1228 fi
1230 AC_DEFINE_UNQUOTED(NSLOOKUP_COMMAND,"$ac_cv_nslookup_command",
1231         [path and args for nslookup])
1233 AC_PATH_PROG(PATH_TO_HOST,host)
1234 if test -n "$ac_cv_path_PATH_TO_HOST"
1235 then
1236         EXTRAS="$EXTRAS check_dns"
1237 fi
1239 AC_PATH_PROG(PATH_TO_UPTIME,uptime)
1240 AC_DEFINE_UNQUOTED(PATH_TO_UPTIME,"$PATH_TO_UPTIME",[path to uptime binary])
1242 AC_PATH_PROG(PATH_TO_RPCINFO,rpcinfo)
1243 AC_DEFINE_UNQUOTED(PATH_TO_RPCINFO,"$PATH_TO_RPCINFO",[path to rpcinfo binary])
1245 AC_PATH_PROG(PATH_TO_NTPDATE,ntpdate)
1246 AC_PATH_PROGS(PATH_TO_NTPDC,ntpdc xntpdc)
1247 AC_PATH_PROGS(PATH_TO_NTPQ,ntpq)
1248 if (test -x "$PATH_TO_NTPDATE" || test -x "$PATH_TO_NTPQ")
1249 then
1250         AC_DEFINE_UNQUOTED(PATH_TO_NTPQ,"$PATH_TO_NTPQ",[path to ntpq binary])
1251         AC_DEFINE_UNQUOTED(PATH_TO_NTPDATE,"$PATH_TO_NTPDATE",[path to ntpdate binary])
1252 else
1253         AC_MSG_WARN([Install NTP programs (http://www.ntp.org) if you want to monitor time synchronization])
1254 fi
1256 AC_PATH_PROG(PATH_TO_LMSTAT,lmstat)
1257 if test -x "$PATH_TO_LMSTAT"
1258 then
1259         AC_DEFINE_UNQUOTED(PATH_TO_LMSTAT,"$PATH_TO_LMSTAT",[path to lmstat])
1260 else
1261         AC_MSG_WARN([Get lmstat from Globetrotter Software to monitor flexlm licenses])
1262 fi
1264 AC_PATH_PROG(PATH_TO_SMBCLIENT,smbclient)
1265 if test -x "$PATH_TO_SMBCLIENT"
1266 then
1267         AC_DEFINE_UNQUOTED(PATH_TO_SMBCLIENT,"$PATH_TO_SMBCLIENT",[path to smbclient binary])
1268 else
1269         AC_MSG_WARN([Get smbclient from Samba.org to monitor SMB shares])
1270 fi
1273 AC_PATH_PROG(PATH_TO_WHO,who)
1275 if [$PATH_TO_WHO -q 2>/dev/null | egrep -i "^# users=[0-9]+$" >/dev/null]
1276 then
1277         ac_cv_path_to_who="$PATH_TO_WHO -q"
1278 else
1279         ac_cv_path_to_who="$PATH_TO_WHO"
1280 fi
1282 AC_DEFINE_UNQUOTED(WHO_COMMAND,"$ac_cv_path_to_who",
1283         [path and arguments for invoking 'who'])
1285 AC_PATH_PROG(PATH_TO_SNMPGET,snmpget)
1286 if test -x "$PATH_TO_SNMPGET"
1287 then
1288         AC_DEFINE_UNQUOTED(PATH_TO_SNMPGET,"$PATH_TO_SNMPGET",[path to snmpget binary])
1289         EXTRAS="$EXTRAS check_hpjd check_snmp"
1290 else
1291         AC_MSG_WARN([Get snmpget from http://net-snmp.sourceforge.net to make check_hpjd and check_snmp plugins])
1292 fi
1294 AC_PATH_PROG(PATH_TO_SNMPGETNEXT,snmpgetnext)
1295 if test -x "$PATH_TO_SNMPGETNEXT"
1296 then
1297         AC_DEFINE_UNQUOTED(PATH_TO_SNMPGETNEXT,"$PATH_TO_SNMPGETNEXT",[path to snmpgetnext binary])
1298 fi
1300 if ( $PERL -M"Net::SNMP 3.6" -e 'exit' 2>/dev/null  )
1301 then
1302         AC_MSG_CHECKING(for Net::SNMP perl module)
1303         AC_MSG_RESULT([found])
1304 else
1305         AC_MSG_WARN([Tried $PERL - install Net::SNMP perl module if you want to use the perl snmp plugins])
1306 fi
1308 AC_PATH_PROG(PATH_TO_QUAKESTAT,quakestat)
1309 AC_PATH_PROG(PATH_TO_QSTAT,qstat)
1311 if test -x "$PATH_TO_QUAKESTAT"
1312 then
1313         ac_cv_path_to_qstat="$PATH_TO_QUAKESTAT"
1314         EXTRAS="$EXTRAS check_game"
1316 elif test -x "$PATH_TO_QSTAT"
1317 then
1318         ac_cv_path_to_qstat="$PATH_TO_QSTAT"
1319         EXTRAS="$EXTRAS check_game"
1320 else
1321         AC_MSG_WARN([Get qstat from http://www.activesw.com/people/steve/qstat.html in order to make check_game plugin])
1322 fi
1324 if test $ac_cv_path_to_qstat 
1325 then
1326         AC_DEFINE_UNQUOTED(PATH_TO_QSTAT,"$ac_cv_path_to_qstat",
1327                 [path to qstat/quakestat])
1328 fi
1330 AC_PATH_PROG(PATH_TO_FPING,fping)
1331 if test -x "$PATH_TO_FPING"
1332 then
1333         AC_DEFINE_UNQUOTED(PATH_TO_FPING,"$PATH_TO_FPING",[path to fping])
1334         EXTRAS="$EXTRAS check_fping"
1335 else
1336         AC_MSG_WARN([Get fping from http://www.fping.com in order to make check_fping plugin])
1337 fi
1339 AC_PATH_PROG(PATH_TO_SSH,ssh)
1341 if test -x "$PATH_TO_SSH"
1342 then
1343         AC_DEFINE_UNQUOTED(SSH_COMMAND,"$PATH_TO_SSH",[path to ssh binary])
1344         EXTRAS="$EXTRAS check_by_ssh"
1345 else
1346         AC_MSG_WARN([Get ssh in order to make check_by_ssh plugin])
1347 fi
1350 AC_PATH_PROG(PATH_TO_MAILQ,mailq)
1351 if test -x "$PATH_TO_MAILQ"
1352 then
1353         AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_MAILQ",[path to mailq])
1354 else
1355         AC_MSG_WARN([Could not find mailq or eqivalent])
1356 fi
1358 dnl SWAP info required is amount allocated/available and amount free
1359 dnl The plugin works through all the swap devices and adds up the total swap
1360 dnl available.
1362 dnl dunno why this does not work below - use hack (kbd)
1363 dnl fine on linux, broken on solaris
1364 dnl if /bin/test -e "/proc/meminfo"
1366 AC_PATH_PROG(PATH_TO_SWAP,swap)
1367 AC_PATH_PROG(PATH_TO_SWAPINFO,swapinfo)
1369 AC_MSG_CHECKING(for how to check memory)
1370 if [cat /proc/meminfo > /dev/null 2>&1]
1371 then
1372         AC_MSG_RESULT([found /proc/meminfo])
1373         AC_DEFINE(HAVE_PROC_MEMINFO,1,[Define if we have /proc/meminfo])
1374         AC_DEFINE_UNQUOTED(PROC_MEMINFO,"/proc/meminfo",[path to /proc/meminfo if name changes])
1375         EXTRAS="$EXTRAS check_swap"
1377 elif [$PATH_TO_SWAP -l 2>&1 >/dev/null]
1378 then
1379         ac_cv_have_swap=yes
1380         ac_cv_swap_command="$PATH_TO_SWAP -l"
1381         if [$PATH_TO_SWAP -l 2>/dev/null | \
1382                 egrep -i "^lswap +path +pri +swaplo +blocks +free +maxswap" \
1383                 >/dev/null]
1384         then
1385                 ac_cv_swap_format=[" %*d %*s %*d,%*d %*d %*d %d %d"]
1386                 AC_MSG_RESULT([using IRIX format swap])
1388         elif [$PATH_TO_SWAP -l 2>/dev/null | egrep -i "^swapfile +dev +swaplo +blocks +free" >/dev/null]
1389         then
1390                 ac_cv_swap_format=["%*s %*[[0-9,-]] %*d %d %d"]
1391                 AC_MSG_RESULT([using Solaris format swap])
1393         elif [$PATH_TO_SWAP -l 2>/dev/null | egrep -i "^path +dev +swaplo +blocks +free" >/dev/null]
1394         then
1395                 ac_cv_swap_format=["%*s %*[[0-9,-]] %*d %d %d"]
1396                 AC_MSG_RESULT([using Unixware format swap])
1398         fi
1399         EXTRAS="$EXTRAS check_swap"
1401 elif [$PATH_TO_SWAPINFO -k 2>&1 | egrep -i "^Device" >/dev/null]
1402 then
1403         ac_cv_have_swap=yes
1404         ac_cv_swap_command="$PATH_TO_SWAPINFO -k"
1406         if [$PATH_TO_SWAPINFO -k 2>/dev/null | egrep -i "^Device +1K-blocks +Used +Avail" >/dev/null]
1407         then
1408                 ac_cv_swap_format=["%*s %d %*d %d"]
1409                 AC_MSG_RESULT([using FreeBSD format swapinfo])
1410         fi
1411         EXTRAS="$EXTRAS check_swap"
1413 elif [$PATH_TO_SWAPINFO -dfM 2>/dev/null | egrep -i "^TYPE +AVAIL +USED +FREE" >/dev/null]
1414 then
1415         ac_cv_have_swap=yes
1416         ac_cv_swap_command="$PATH_TO_SWAPINFO -dfM",
1417         ac_cv_swap_format=["%*s %d %*d %d"]
1418         AC_MSG_RESULT([using HP-UX format swapinfo])
1419 fi
1421 if test x$ac_cv_have_swap != x 
1422 then
1423         AC_DEFINE(HAVE_SWAP,1,[Define if swap/swapinfo command is found])
1424 fi
1425 AC_DEFINE_UNQUOTED(SWAP_FORMAT,"$ac_cv_swap_format",
1426         [Format string for parsing swap output])
1427 if test "x$ac_cv_swap_command" != "x" 
1428 then
1429         AC_DEFINE_UNQUOTED(SWAP_COMMAND,"$ac_cv_swap_command",
1430                 [Path to swap/swapinfo binary, with any args])
1431 fi
1433 AC_PATH_PROG(PATH_TO_DIG,dig)
1434 AC_DEFINE_UNQUOTED(PATH_TO_DIG,"$PATH_TO_DIG",[Path to dig command, if present])
1435 if test -n "$PATH_TO_DIG"; then
1436         EXTRAS="$EXTRAS check_dig"
1437 fi
1439 if test -f plugins/check_nt.c ; then
1440   EXTRAS="$EXTRAS check_nt"
1441 elif test -f ../plugins/check_nt.c ; then
1442   EXTRAS="$EXTRAS check_nt"
1443 fi
1445 AC_MSG_CHECKING(for va_list)
1446 AC_TRY_COMPILE([#ifdef __STDC__
1447                 #include <stdio.h>
1448                 #include <stdlib.h>
1449                 #include <stdarg.h>
1450                 #else
1451                 #include <sys/types.h>
1452                 #include <stdio.h>
1453                 #include <varargs.h>
1454                 #endif],
1455                 [va_list args;],
1456                 [AC_MSG_RESULT(yes)],
1457                 [NEED_VA_LIST=-DNEED_VA_LIST AC_SUBST(NEED_VA_LIST) AC_MSG_RESULT(no)])
1459 AC_SUBST(EXTRAS)
1460 AC_SUBST(DEPLIBS)
1462 AC_DEFINE_UNQUOTED(PACKAGE_VERSION,"${VERSION}",[package version])
1464 AC_OUTPUT(Makefile subst lib/Makefile plugins/Makefile plugins-scripts/Makefile plugins-scripts/subst plugins-scripts/utils.pm plugins-scripts/utils.sh command.cfg test.pl,echo timestamp > plugins/stamp-h1;echo timestamp > plugins/stamp-h2;echo timestamp > plugins/stamp-h3;echo timestamp > plugins/stamp-h4;echo timestamp > plugins/stamp-h5;echo timestamp > plugins/stamp-h6;PATH=.:..:$PATH subst.sh command.cfg)
1466 ACX_FEATURE([with],[cgiurl])
1467 ACX_FEATURE([with],[nagios-user])
1468 ACX_FEATURE([with],[nagios-group])
1469 ACX_FEATURE([with],[trusted-path])
1470 ACX_FEATURE([with],[df-command])
1471 ACX_FEATURE([with],[ping-command])
1472 ACX_FEATURE([with],[ping6-command])
1473 ACX_FEATURE([with],[lwres])
1474 ACX_FEATURE([with],[ipv6])
1475 ACX_FEATURE([enable],[emulate-getaddrinfo])