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