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.3)
5 AC_CONFIG_SRCDIR(NPTest.pm)
6 AM_INIT_AUTOMAKE([1.8.3])
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 Deprecated configure options
17 dnl Figure out how to invoke "install" and what install options to use.
18 AC_PROG_INSTALL
19 AC_SUBST(INSTALL)
21 dnl Must come very early on due to coreutils requirement
22 dnl Takes care of AC_GNU_SOURCE, AC_AIX and AC_MINIX
23 gl_USE_SYSTEM_EXTENSIONS
25 AC_PROG_CC
26 AC_PROG_CPP
27 AC_PROG_GCC_TRADITIONAL
28 AC_PROG_LIBTOOL
30 AC_PROG_MAKE_SET
31 AC_PROG_AWK
33 AC_FUNC_MALLOC
34 AC_FUNC_REALLOC
35 AC_FUNC_ERROR_AT_LINE
37 AC_CONFIG_LIBOBJ_DIR(lib)
38 AC_FUNC_GETLOADAVG([lib])
40 ifdef([AC_FUNC_STRTOD],[AC_FUNC_STRTOD],[AM_FUNC_STRTOD])
41 dnl AM_WITH_REGEX
43 PLUGIN_TEST=`echo $srcdir/plugins/t/*.t|sed -e 's,\.*/plugins/,,g'`
44 AC_SUBST(PLUGIN_TEST)dnl
46 SCRIPT_TEST=`echo $srcdir/plugins-scripts/t/*.t|sed -e 's,\.*/plugins-scripts/,,g'`
47 AC_SUBST(SCRIPT_TEST)dnl
49 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"
50 AC_SUBST(WARRANTY)
52 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"
53 AC_SUBST(SUPPORT)
55 dnl CGIURL has changed for Nagios with 1.0 beta
56 AC_ARG_WITH(cgiurl,
57 ACX_HELP_STRING([--with-cgiurl=DIR],
58 [sets URL for cgi programs]),
59 with_cgiurl=$withval,
60 with_cgiurl=/nagios/cgi-bin)
61 CGIURL="$with_cgiurl"
62 AC_DEFINE_UNQUOTED(CGIURL,"$CGIURL",[URL of CGI programs])
64 AC_ARG_WITH(nagios_user,
65 ACX_HELP_STRING([--with-nagios-user=USER],
66 [set user name to run nagios]),
67 with_nagios_user=$withval,
68 with_nagios_user=nagios)
69 AC_ARG_WITH(nagios_group,
70 ACX_HELP_STRING([--with-nagios-group=GROUP],
71 [set group name to run nagios]),
72 with_nagios_group=$withval,
73 with_nagios_group=nagios)
74 AC_SUBST(with_nagios_user)
75 AC_SUBST(with_nagios_group)
76 INSTALL_OPTS="-o $with_nagios_user -g $with_nagios_group"
77 AC_SUBST(INSTALL_OPTS)
79 AC_ARG_WITH(trusted_path,
80 ACX_HELP_STRING([--with-trusted-path=PATH],
81 [sets trusted path for executables called by scripts (default=/bin:/sbin:/usr/bin:/usr/sbin)]),
82 with_trusted_path=$withval,
83 with_trusted_path=/bin:/sbin:/usr/bin:/usr/sbin)
84 AC_SUBST(with_trusted_path)
86 EXTRAS=
87 EXTRAS_ROOT=
88 dnl PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/etc:/usr/local/bin:/usr/local/sbin:$PATH
90 LDFLAGS="$LDFLAGS -L."
92 ac_cv_uname_m=`uname -m`
93 ac_cv_uname_s=`uname -s`
94 ac_cv_uname_r=`uname -r`
95 ac_cv_uname_v=`uname -v`
97 PKG_ARCH=`uname -p`
98 REV_DATESTAMP=`date '+%Y.%m.%d.%H.%M'`
99 REV_TIMESTAMP=`date '+%Y%m%d%H%M%S'`
101 AC_SUBST(PKG_ARCH)
102 AC_SUBST(REV_DATESTAMP)
103 AC_SUBST(REV_TIMESTAMP)
105 dnl Checks for programs.
106 AC_PATH_PROG(PYTHON,python)
107 AC_PATH_PROG(SH,sh)
108 AC_PATH_PROG(PERL,perl)
109 AC_PATH_PROG(LIBGNUTLS_CONFIG,libgnutls-config)
110 AC_PATH_PROG(HOSTNAME,hostname)
111 AC_PATH_PROG(BASENAME,basename)
113 dnl allow them to override the path of perl
114 AC_ARG_WITH(perl,
115 ACX_HELP_STRING([--with-perl=PATH],
116 [sets path to perl executable]),
117 with_perl=$withval,with_perl=$PERL)
118 AC_SUBST(PERL, $with_perl)
120 dnl openssl/gnutls
121 AC_ARG_WITH(openssl,
122 AC_HELP_STRING([--with-openssl=DIR],
123 [path to openssl installation]),)
125 AC_ARG_WITH(gnutls,
126 ACX_HELP_STRING([--with-gnutls=PATH],
127 [path to gnutls installation root]),)
129 dnl you can only have one or the other
130 if test ! "$with_openssl" = "" && test ! "$with_openssl" = "no"; then
131 with_gnutls="no"
132 fi
133 if test ! "$with_gnutls" = "" && test ! "$with_gnutls" = "no"; then
134 with_openssl="no"
135 fi
137 dnl list of possible dirs to try to autodetect openssl
138 dnl if $dir/include exists, we consider it found
139 dnl the order should allow locally installed versions to override distros' ones
140 OPENSSL_DIRS="/usr /usr/local /usr/slocal /usr/local/openssl /usr/local/ssl \
141 /opt /opt/openssl"
143 dnl
144 dnl Check for miscellaneous stuff
145 dnl
147 case $host_vender-$host_os in
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_ARG_WITH(mysql,
258 ACX_HELP_STRING([--with-mysql=DIR],
259 [Compiles mysql plugins. Expects DIR/bin/mysql_config]),
260 with_mysql=$withval,
261 with_mysql=no)
262 if test $with_mysql != "no" ; then
263 if test -x $with_mysql/bin/mysql_config ; then
264 MYSQLCONFIG="$with_mysql/bin/mysql_config"
265 else
266 AC_PATH_PROG(MYSQLCONFIG, mysql_config)
267 fi
268 if test -z "$MYSQLCONFIG"; then
269 with_mysql="not found"
270 AC_MSG_WARN([Skipping mysql plugin])
271 AC_MSG_WARN([install mysql client libs to compile this plugin (see REQUIREMENTS).])
272 else
273 with_mysql=$MYSQLCONFIG
274 EXTRAS="$EXTRAS check_mysql check_mysql_query"
275 MYSQLINCLUDE=`$MYSQLCONFIG --include`
276 MYSQLLIBS=`$MYSQLCONFIG --libs`
277 MYSQLCFLAGS=`$MYSQLCONFIG --cflags`
278 AC_SUBST(MYSQLINCLUDE)
279 AC_SUBST(MYSQLLIBS)
280 AC_SUBST(MYSQLCFLAGS)
281 fi
282 fi
284 AC_CHECK_HEADERS(unistd.h)
286 dnl Check for AF_INET6 support - unistd.h required for Darwin
287 AC_CACHE_CHECK([for IPv6 support], with_ipv6, [
288 AC_TRY_COMPILE([#ifdef HAVE_UNISTD_H
289 #include <unistd.h>
290 #endif
291 #include <netinet/in.h>
292 #include <sys/socket.h>],
293 [struct sockaddr_in6 sin6;
294 void *p;
296 sin6.sin6_family = AF_INET6;
297 sin6.sin6_port = 587;
298 p = &sin6.sin6_addr;],
299 [with_ipv6=yes],
300 [with_ipv6=no])
301 ])
303 if test x"$with_ipv6" != xno ; then
304 AC_DEFINE(USE_IPV6,1,[Enable IPv6 support])
305 fi
307 dnl #########################################################################
308 dnl Check if Posix getaddrinfo() is available. It is also possible to use
309 dnl the version from the lwres library distributed with BIND.
310 dnl #########################################################################
311 AC_ARG_ENABLE([emulate-getaddrinfo],
312 ACX_HELP_STRING([--enable-emulate-getaddrinfo],
313 [enable getaddrinfo emulation (default=no)]),
314 ,
315 enable_emulate_getaddrinfo=no)
317 AC_ARG_WITH(lwres,
318 ACX_HELP_STRING([--with-lwres=DIR],
319 [use lwres library for getaddrinfo (default=no)]),
320 ,
321 with_lwres=no)
323 dnl ## enable force to test getaddrinfo.c
324 if test x$enable_emulate_getaddrinfo = xforce ; then
325 enable_emulate_getaddrinfo=yes
326 have_getaddrinfo=no
327 else
329 have_getaddrinfo=no
330 if test x$with_lwres != xno ; then
331 if test "$with_lwres" != yes ; then
332 CPPFLAGS="-I${with_lwres}/include $CPPFLAGS"
333 LDFLAGS="-L${with_lwres}/lib $LDFLAGS"
334 fi
335 AC_CHECK_HEADERS(lwres/netdb.h, ,
336 [AC_MSG_ERROR([cannot find <lwres/netdb.h>])])
337 AC_CHECK_LIB(lwres, lwres_getaddrinfo, ,
338 [AC_MSG_ERROR([cannot find the lwres library])],
339 -lnsl -lpthread)
340 have_getaddrinfo=yes
341 fi
343 if test x$have_getaddrinfo != xyes ; then
344 AC_SEARCH_LIBS(getaddrinfo, socket resolv bind nsl c_r cr, have_getaddrinfo=yes)
345 fi
347 dnl # Special nonsense for systems that actually have getaddrinfo but
348 dnl # redefine the name to something else, e.g. OSF
349 if test x$have_getaddrinfo != xyes ; then
350 AC_MSG_CHECKING(if getaddrinfo is redefined in netdb.h)
351 AC_TRY_LINK([
352 # include <netdb.h>
353 ], [
354 struct addrinfo hints, *res;
355 int err;
357 err = getaddrinfo ("host", "service", &hints, &res);
358 ], [
359 have_getaddrinfo=yes
360 AC_MSG_RESULT(yes)
361 ], [AC_MSG_RESULT(no)])
362 fi
364 fi
366 if test x$have_getaddrinfo != xno ; then
367 if test x$enable_emulate_getaddrinfo != xno ; then
368 AC_MSG_ERROR([getaddrinfo found but emulate-getaddrinfo was enabled])
369 fi
370 AC_DEFINE(HAVE_GETADDRINFO, 1,
371 [Does system provide RFC 2553/Posix getaddrinfo?])
372 else
373 if test x$enable_emulate_getaddrinfo != xyes ; then
374 dnl AC_MSG_ERROR([getaddrinfo not found: try --with-lwres or --enable-emulate-getaddrinfo])
375 enable_emulate_getaddrinfo=yes
376 AC_MSG_WARN([enabling getaddrinfo emulation])
377 fi
378 EXTRA_NETOBJS="$EXTRA_NETOBJS getaddrinfo.o"
379 fi
381 if test x"$enable_emulate_getaddrinfo" != xno ; then
382 have_resolver=no
384 dnl Try for getipnodebyname
385 AC_SEARCH_LIBS(getipnodebyname, resolv bind nsl c_r cr, have_resolver=yes)
386 if test x"$have_resolver" != xno ; then
387 AC_DEFINE(HAVE_GETIPNODEBYNAME, 1,
388 [Set when getipnodebyname is available])
389 fi
391 dnl Try for gethostbyname_r
392 if test x"$have_resolver" = xno ; then
393 AC_SEARCH_LIBS(gethostbyname_r, resolv bind nsl c_r cr,
394 [have_resolver=yes
395 ACX_WHICH_GETHOSTBYNAME_R])
396 fi
398 dnl Try for gethostbyname
399 if test x"$have_resolver" = xno ; then
400 if test x"$enable_pthreads" != xno ; then
401 AC_MSG_WARN([using threads but cannot find gethostbyname_r or getipnodebyname])
402 fi
403 AC_SEARCH_LIBS(gethostbyname, resolv bind nsl, ,
404 [AC_MSG_ERROR([cannot find gethostbyname])])
405 fi
406 EXTRA_NETOBJS="$EXTRA_NETOBJS gethostbyname.o"
408 fi
410 dnl Checks for Kerberos. Must come before openssl checks for Redhat EL 3
411 AC_CHECK_HEADERS(krb5.h,FOUNDINCLUDE=yes,FOUNDINCLUDE=no)
412 if test "$FOUNDINCLUDE" = "no"; then
413 _SAVEDCPPFLAGS="$CPPFLAGS"
414 CPPFLAGS="$_SAVEDCPPFLAGS -I/usr/kerberos/include"
415 unset ac_cv_header_krb5_h
416 AC_CHECK_HEADERS(krb5.h,
417 KRB5INCLUDE="-I/usr/kerberos/include"
418 FOUNDINCLUDE=yes,
419 FOUNDINCLUDE=no)
420 fi
421 AC_SUBST(KRBINCLUDE)
422 if test "$FOUNDINCLUDE" = "no"; then
423 CPPFLAGS="$_SAVEDCPPFLAGS"
424 fi
427 dnl openssl detection/configuration
428 if ! test x"$with_openssl" = x"no"; then
429 dnl Check for OpenSSL location if it wasn't already specified
430 if ! test -d "$with_openssl"; then
431 for d in $OPENSSL_DIRS; do
432 if test -x ${d}/bin/openssl || test -x ${d}/sbin/openssl ; then
433 with_openssl=$d
434 fi
435 done
436 fi
438 _SAVEDCPPFLAGS="$CPPFLAGS"
439 _SAVEDLDFLAGS="$LDFLAGS"
440 dnl Check for OpenSSL header files
441 unset FOUNDINCLUDE
442 if test x"$with_openssl" != x"/usr" ; then
443 CPPFLAGS="$CPPFLAGS -I$with_openssl/include"
444 # Need both to find ssl libraries and to load at runtime
445 LDFLAGS="$LDFLAGS -L$with_openssl/lib -R$with_openssl/lib"
446 fi
448 dnl check for openssl in $dir/include/openssl
449 AC_CHECK_HEADERS(openssl/ssl.h openssl/x509.h openssl/rsa.h openssl/pem.h openssl/crypto.h openssl/err.h,
450 SSLINCLUDE="-I$with_openssl/include"
451 FOUNDINCLUDE=yes,
452 FOUNDINCLUDE=no)
453 dnl else check to see if $dir/include has it
454 if test "$FOUNDINCLUDE" = "no"; then
455 AC_CHECK_HEADERS(ssl.h x509.h rsa.h pem.h crypto.h err.h,
456 SSLINCLUDE="-I$with_openssl/include"
457 FOUNDINCLUDE=yes,
458 FOUNDINCLUDE=no)
459 fi
460 AC_SUBST(SSLINCLUDE)
461 dnl if we didn't find it, reset CPPFLAGS
462 if test "$FOUNDINCLUDE" = "no"; then
463 CPPFLAGS="$_SAVEDCPPFLAGS"
464 LDFLAGS="$_SAVEDLDFLAGS"
465 fi
467 dnl Check for crypto lib
468 _SAVEDLIBS="$LIBS"
469 LIBS="-L${with_openssl}/lib"
470 AC_CHECK_LIB(crypto,CRYPTO_lock)
471 if test "$ac_cv_lib_crypto_CRYPTO_lock" = "yes"; then
472 dnl Check for SSL lib
473 AC_CHECK_LIB(ssl,main, SSLLIBS="-lssl -lcrypto",,-lcrypto)
474 fi
475 LIBS="$_SAVEDLIBS"
477 dnl test headers and libs to decide whether check_http should use SSL
478 if test "$ac_cv_lib_crypto_CRYPTO_lock" = "yes"; then
479 if test "$ac_cv_lib_ssl_main" = "yes"; then
480 if test "$FOUNDINCLUDE" = "yes"; then
481 FOUNDOPENSSL="yes"
482 fi
483 fi
484 fi
485 fi
488 dnl check for gnutls if openssl isn't found (or is disabled)
489 if test ! "$FOUNDOPENSSL" = "yes" && test ! "$with_gnutls" = "no"; then
490 if test ! "$with_gnutls" = ""; then
491 CPPFLAGS="$CPPFLAGS -I${with_gnutls}/include"
492 elif test ! "$LIBGNUTLS_CONFIG" = ""; then
493 CPPFLAGS="$CPPFLAGS -I`$LIBGNUTLS_CONFIG --prefix`"
494 fi
495 AC_CHECK_HEADERS([gnutls/openssl.h],FOUNDGNUTLS="yes",)
496 if test "$FOUNDGNUTLS" = "yes"; then
497 AC_CHECK_LIB(gnutls-openssl,main,SSLLIBS="-lgnutls-openssl")
498 fi
499 fi
500 dnl end check for gnutls
502 if test "$FOUNDOPENSSL" = "yes" || test "$FOUNDGNUTLS" = "yes"; then
503 check_tcp_ssl="check_simap check_spop check_jabber check_nntps check_ssmtp"
504 AC_SUBST(check_tcp_ssl)
505 AC_SUBST(SSLLIBS)
506 AC_DEFINE(HAVE_SSL,1,[Define if SSL libraries are found])
507 if test "$FOUNDOPENSSL" = "yes"; then
508 AC_DEFINE(USE_OPENSSL,1,[Define if using OpenSSL libraries])
509 with_openssl="yes"
510 with_gnutls="no"
511 else
512 AC_DEFINE(USE_GNUTLS,1,[Define if using gnutls libraries])
513 with_gnutls="yes"
514 with_openssl="no"
515 fi
516 else
517 dnl else deliberately disabled or no ssl support available
518 AC_MSG_WARN([OpenSSL or GnuTLS libs could not be found or were disabled])
519 with_openssl="no"
520 with_gnutls="no"
521 fi
523 dnl
524 dnl Checks for header files.
525 dnl
527 AC_HEADER_STDC
528 AC_HEADER_TIME
529 AC_HEADER_SYS_WAIT
530 AC_CHECK_HEADERS(signal.h strings.h string.h syslog.h uio.h errno.h sys/types.h sys/time.h sys/socket.h sys/loadavg.h sys/un.h sys/poll.h)
531 AC_CHECK_HEADERS(features.h stdarg.h sys/unistd.h ctype.h stdlib.h)
532 AC_CHECK_HEADERS(regex.h,FOUNDREGEX=yes,FOUNDREGEX=no)
534 dnl Checks for typedefs, structures, and compiler characteristics.
535 AC_C_CONST
536 AC_STRUCT_TM
537 AC_TYPE_PID_T
538 AC_TYPE_SIZE_T
539 AC_TYPE_SIGNAL
541 AC_CACHE_CHECK([for va_copy],ac_cv_HAVE_VA_COPY,[
542 AC_TRY_LINK([#include <stdarg.h>
543 va_list ap1,ap2;], [va_copy(ap1,ap2);],
544 ac_cv_HAVE_VA_COPY=yes,
545 ac_cv_HAVE_VA_COPY=no)])
546 if test x"$ac_cv_HAVE_VA_COPY" = x"yes"; then
547 AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available])
548 else
549 AC_CACHE_CHECK([for __va_copy],ac_cv_HAVE___VA_COPY,[
550 AC_TRY_LINK([#include <stdarg.h>
551 va_list ap1,ap2;], [__va_copy(ap1,ap2);],
552 ac_cv_HAVE___VA_COPY=yes,
553 ac_cv_HAVE___VA_COPY=no)])
554 if test x"$ac_cv_HAVE___VA_COPY" = x"yes"; then
555 AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available])
556 fi
557 fi
559 AC_CHECK_FUNCS(vsnprintf snprintf asprintf vasprintf)
560 AC_CACHE_CHECK([for C99 vsnprintf],ac_cv_HAVE_C99_VSNPRINTF,[
561 AC_TRY_RUN([
562 #include <sys/types.h>
563 #include <stdarg.h>
564 void foo(const char *format, ...) {
565 va_list ap;
566 int len;
567 char buf[5];
569 va_start(ap, format);
570 len = vsnprintf(buf, 0, format, ap);
571 va_end(ap);
572 if (len != 5) exit(1);
574 va_start(ap, format);
575 len = vsnprintf(0, 0, format, ap);
576 va_end(ap);
577 if (len != 5) exit(1);
579 if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
581 exit(0);
582 }
583 main() { foo("hello"); }
584 ],
585 ac_cv_HAVE_C99_VSNPRINTF=yes,ac_cv_HAVE_C99_VSNPRINTF=no,ac_cv_HAVE_C99_VSNPRINTF=cross)])
586 if test x"$ac_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
587 AC_DEFINE(HAVE_C99_VSNPRINTF,1,[Define if system has C99 compatible vsnprintf])
588 fi
590 AC_TRY_COMPILE([#include <sys/time.h>],
591 [struct timeval *tv;
592 struct timezone *tz;],
593 AC_DEFINE(HAVE_STRUCT_TIMEVAL,1,[Define if we have a timeval structure])
594 AC_TRY_COMPILE([#include <sys/time.h>],
595 [struct timeval *tv;
596 struct timezone *tz;
597 gettimeofday(tv, tz);],
598 AC_DEFINE(HAVE_GETTIMEOFDAY,1,[Define if gettimeofday is found]),
599 AC_DEFINE(NEED_GETTIMEOFDAY,1,[Define if gettimeofday is needed])))
601 dnl Checks for library functions.
602 AC_CHECK_FUNCS(memmove select socket strdup strstr strtod strtol strtoul floor)
603 AC_CHECK_FUNCS(basename poll)
605 AC_MSG_CHECKING(return type of socket size)
606 AC_TRY_COMPILE([#include <stdlib.h>
607 #include <sys/types.h>
608 #include <sys/socket.h>],
609 [int a = send(1, (const void *) buffer, (size_t *) 0, (int *) 0);],
610 ac_cv_socket_size_type=["size_t"]
611 AC_MSG_RESULT(size_t),
612 ac_cv_socket_size_type=["int"]
613 AC_MSG_RESULT(int))
615 AC_DEFINE_UNQUOTED(SOCKET_SIZE_TYPE, $ac_cv_socket_size_type ,
616 [Define type of socket size])
618 AC_ARG_WITH(proc-loadavg,
619 ACX_HELP_STRING([--with-proc-loadavg=PATH],
620 [path to /proc/loadavg or equivalent]),
621 ac_cv_proc_loadavg=$withval)
622 AC_MSG_CHECKING([for /proc/loadavg])
623 if test -n "$ac_cv_proc_loadavg"; then
624 AC_MSG_RESULT([(command line) $ac_cv_proc_loadavg])
625 elif test -f "/proc/loadavg"; then
626 AC_MSG_RESULT([found /proc/loadavg])
627 ac_cv_proc_loadavg="/proc/loadavg"
628 else
629 AC_MSG_RESULT([no])
630 fi
632 if test -n "$ac_cv_proc_loadavg"; then
633 AC_DEFINE(HAVE_PROC_LOADAVG,1,[Define if /proc/loadavg or similar exists])
634 AC_DEFINE_UNQUOTED(PROC_LOADAVG,"/proc/loadavg",[Location of /proc/loadavg])
635 fi
637 dnl #### Process table test
639 AC_PATH_PROG(PATH_TO_PS,ps)
641 AC_MSG_CHECKING(for ps syntax)
642 AC_ARG_WITH(ps_command,
643 ACX_HELP_STRING([--with-ps-command=PATH],
644 [Verbatim command to execute for ps]),
645 PS_COMMAND=$withval)
646 AC_ARG_WITH(ps_format,
647 ACX_HELP_STRING([--with-ps-format=FORMAT],
648 [Format string for scanning ps output]),
649 PS_FORMAT=$withval)
650 AC_ARG_WITH(ps_cols,
651 ACX_HELP_STRING([--with-ps-cols=NUM],
652 [Number of columns in ps command]),
653 PS_COLS=$withval)
654 AC_ARG_WITH(ps_varlist,
655 ACX_HELP_STRING([--with-ps-varlist=LIST],
656 [Variable list for sscanf of 'ps' output]),
657 PS_VARLIST=$withval)
659 if test -n "$PS_COMMAND" && test -n "$PS_FORMAT" && test -n "$PS_COLS" && test -n "$PS_VARLIST"; then
660 ac_cv_ps_command="$PS_COMMAND"
661 ac_cv_ps_format="$PS_FORMAT"
662 ac_cv_ps_varlist="$PS_VARLIST"
663 ac_cv_ps_cols="$PS_COLS"
664 AC_MSG_RESULT([(command-line) $ac_cv_ps_command])
666 dnl Now using the pst3/kmem hack for solaris systems to avoid truncation
667 elif test "$ac_cv_uname_s" = "SunOS"; then
668 #
669 # this is a very, very ugly hack, to hardcode the location for plugins
670 #
671 if test "$libexecdir" = '${exec_prefix}/libexec'; then
672 if test "$exec_prefix" = "NONE"; then
673 if test "$prefix" = "NONE"; then
674 pst3="$ac_default_prefix/libexec/pst3"
675 else
676 pst3="$prefix/libexec/pst3"
677 fi
678 else
679 pst3="$exec_prefix/libexec/pst3"
680 fi
681 else
682 pst3="$libexecdir/pst3"
683 fi
684 ac_cv_ps_command="$pst3"
685 ac_cv_ps_format="%s %d %d %d %d %f %s %n"
686 ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
687 ac_cv_ps_cols=8
688 AC_MSG_RESULT([using nagios-plugins internal ps for solaris])
689 EXTRAS_ROOT="$EXTRAS_ROOT pst3"
691 dnl Some gnu/linux systems (debian for one) don't like -axwo and need axwo.
692 dnl so test for this first...
693 elif ps axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
694 egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null
695 then
696 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
697 ac_cv_ps_command="$PATH_TO_PS axwo 'stat uid pid ppid vsz rss pcpu comm args'"
698 ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
699 ac_cv_ps_cols=9
700 AC_MSG_RESULT([$ac_cv_ps_command])
702 dnl For OpenBSD 3.2 & 3.3. Must come before ps -weo
703 dnl Should also work for FreeBSD 5.2.1 and 5.3
704 dnl STAT UCOMM VSZ RSS USER PPID COMMAND
705 elif ps -axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
706 egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null
707 then
708 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
709 ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid pid ppid vsz rss pcpu comm args'"
710 ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
711 ac_cv_ps_cols=9
712 AC_MSG_RESULT([$ac_cv_ps_command])
714 dnl Some *BSDs have different format for ps. This is mainly to catch FreeBSD 4.
715 dnl Limitation: Only first 16 chars returned for ucomm field
716 dnl Must come before ps -weo
717 elif ps -axwo 'stat uid pid ppid vsz rss pcpu ucomm command' 2>/dev/null | \
718 egrep -i ["^ *STAT +UID +PID +PPID +VSZ +RSS +%CPU +UCOMM +COMMAND"] > /dev/null
719 then
720 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
721 ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid pid ppid vsz rss pcpu ucomm command'"
722 ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
723 ac_cv_ps_cols=9
724 AC_MSG_RESULT([$ac_cv_ps_command])
726 dnl STAT UCOMM VSZ RSS USER UID PPID COMMAND
727 elif ps -weo 'stat comm vsz rss user uid pid ppid etime args' 2>/dev/null | \
728 egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[ID]+ +P[PID]+ +[ELAPSD]+ +[RGSCOMDNA]+"] >/dev/null
729 then
730 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procetime,procprog,&pos]"
731 ac_cv_ps_command="$PATH_TO_PS -weo 'stat uid pid ppid vsz rss pcpu etime comm args'"
732 ac_cv_ps_format="%s %d %d %d %d %d %f %s %s %n"
733 ac_cv_ps_cols=10
734 AC_MSG_RESULT([$ac_cv_ps_command])
736 dnl FreeBSD
737 elif ps waxco 'state command vsz rss uid user pid ppid' 2>/dev/null | \
738 egrep -i ["^STAT +COMMAND +VSZ +RSS +UID +USER +PID +PPID"] >/dev/null
739 then
740 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
741 ac_cv_ps_command="$PATH_TO_PS waxco 'state uid pid ppid vsz rss pcpu command command'"
742 ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
743 ac_cv_ps_cols=9
744 AC_MSG_RESULT([$ac_cv_ps_command])
746 dnl BSD-like mode in RH 6.1
747 elif ps waxno 'state comm vsz rss uid user pid ppid args' 2>/dev/null | \
748 egrep -i ["^S +COMMAND +VSZ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
749 then
750 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
751 ac_cv_ps_command="$PATH_TO_PS waxno 'state uid pid ppid vsz rss pcpu comm args'"
752 ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
753 ac_cv_ps_cols=9
754 AC_MSG_RESULT([$ac_cv_ps_command])
756 dnl SunOS 4.1.3:
757 dnl F UID PID PPID CP PRI NI SZ RSS WCHAN STAT TT TIME COMMAND
758 dnl Need the head -1 otherwise test will work because arguments are found
759 elif ps -laxnwww 2>/dev/null | head -1 | \
760 egrep -i ["^ *F(LAGS)? +UID +PID +PPID +CP +PRI +NI +(SZ)|(VSZ)|(SIZE) +RSS +WCHAN +STAT? +TTY? +TIME +COMMAND"] >/dev/null
761 then
762 ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]"
763 ac_cv_ps_command="$PATH_TO_PS -laxnwww"
764 ac_cv_ps_format="%*s %d %d %d %*s %*s %*s %d %d %*s %s %*s %*s %n%s"
765 ac_cv_ps_cols=9
766 AC_MSG_RESULT([$ac_cv_ps_command])
768 dnl Debian Linux / procps v1.2.9:
769 dnl FLAGS UID PID PPID PRI NI SIZE RSS WCHAN STA TTY TIME COMMAND
770 dnl 100 0 1 0 0 0 776 76 c0131c8c S ffff 0:11 init [2]
771 dnl
772 elif ps laxnwww 2>/dev/null | \
773 egrep -i ["^ *F(LAGS)? +UID +PID +PPID +PRI +NI +(VSZ)|(SIZE) +RSS +WCHAN +STAT? TTY +TIME +COMMAND"] >/dev/null
774 then
775 ac_cv_ps_varlist="[&procuid,&procpid,&procppid,procstat,&procvsz,&procrss,&pos,procprog]"
776 ac_cv_ps_command="$PATH_TO_PS laxnwww"
777 ac_cv_ps_format="%*s %d %d %d %*s %*s %d %d %*s %s %*s %*s %n%s"
778 ac_cv_ps_cols=9
779 AC_MSG_RESULT([$ac_cv_ps_command])
781 dnl OpenBSD (needs to come early because -exo appears to work, but does not give all procs)
782 elif ps -axo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
783 egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[PID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null
784 then
785 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
786 ac_cv_ps_command="$PATH_TO_PS -axo 'stat uid pid ppid vsz rss pcpu comm args'"
787 ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
788 ac_cv_ps_cols=9
789 AC_MSG_RESULT([$ac_cv_ps_command])
791 dnl Tru64 - needs %*[ +<>] in PS_FORMAT.
792 dnl Has /usr/bin/ps and /sbin/ps - force sbin version
793 dnl Can't use vsize and rssize because comes back with text (eg, 1.5M instead
794 dnl of 1500). Will need big changes to check_procs to support
795 elif /sbin/ps -eo 'stat uid pid ppid pcpu etime comm args' 2>/dev/null | \
796 egrep -i ["^ *S +[UID]+ +[PID]+ +[PID]+ +[%CPU]+ +[ELAPSD]+ +[COMMAND]+ +[COMMAND]+"] > /dev/null
797 then
798 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procpcpu,procetime,procprog,&pos]"
799 ac_cv_ps_command="/sbin/ps -eo 'stat uid pid ppid pcpu etime comm args'"
800 ac_cv_ps_format=["%s%*[ +<>] %d %d %d %f %s %s %n"]
801 ac_cv_ps_cols=8
802 AC_MSG_RESULT([$ac_cv_ps_command])
804 elif ps -eo 's comm vsz rss user uid pid ppid args' 2>/dev/null | \
805 egrep -i ["^S[TAUES]* +C[OMDNA]+ +[VSIZE]+ +U[SER]+ +U[ID]+ +P[PID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null
806 then
807 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
808 ac_cv_ps_command="$PATH_TO_PS -eo 's uid pid ppid vsz rss pcpu comm args'"
809 ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
810 ac_cv_ps_cols=9
811 AC_MSG_RESULT([$ac_cv_ps_command])
813 dnl AIX 4.3.3 and 5.1 do not have an rss field
814 elif ps -eo 'stat uid pid ppid vsz pcpu comm args' 2>/dev/null | \
815 egrep -i ["^ *S[TAUES]* +UID +PID +PPID +VSZ +%CPU +COMMAND +COMMAND"] >/dev/null
816 then
817 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procpcpu,procprog,&pos]"
818 ac_cv_ps_command="$PATH_TO_PS -eo 'stat uid pid ppid vsz pcpu comm args'"
819 ac_cv_ps_format="%s %d %d %d %d %f %s %n"
820 ac_cv_ps_cols=8
821 AC_MSG_RESULT([$ac_cv_ps_command - with no RSS])
823 dnl Solaris 2.6
824 elif ps -Ao 's comm vsz rss uid user pid ppid args' 2>/dev/null | \
825 egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
826 then
827 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
828 ac_cv_ps_command="$PATH_TO_PS -Ao 's uid pid ppid vsz rss pcpu comm args'"
829 # There must be no space between the %s and %n due to a wierd problem in sscanf where
830 # it will return %n as longer than the line length
831 ac_cv_ps_format="%s %d %d %d %d %d %f %s%n"
832 ac_cv_ps_cols=9
833 AC_MSG_RESULT([$ac_cv_ps_command])
835 elif ps -Ao 'status comm vsz rss uid user pid ppid args' 2>/dev/null | \
836 egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
837 then
838 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
839 ac_cv_ps_command="$PATH_TO_PS -Ao 'status uid pid ppid vsz rss pcpu comm args'"
840 ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
841 ac_cv_ps_cols=9
842 AC_MSG_RESULT([$ac_cv_ps_command])
844 elif ps -Ao 'state comm vsz rss uid user pid ppid args' 2>/dev/null | \
845 egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
846 then
847 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
848 ac_cv_ps_command="$PATH_TO_PS -Ao 'state uid pid ppid vsz rss pcpu comm args'"
849 ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
850 ac_cv_ps_cols=9
851 AC_MSG_RESULT([$ac_cv_ps_command])
853 dnl wonder who takes state instead of stat
854 elif ps -ao 'state command vsz rss user pid ppid args' 2>/dev/null | \
855 egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
856 then
857 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
858 ac_cv_ps_command="$PATH_TO_PS -ao 'state uid pid ppid vsz rss pcpu command args'"
859 ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
860 ac_cv_ps_cols=8
861 AC_MSG_RESULT([$ac_cv_ps_command])
863 dnl IRIX 53
864 elif ps -el 2>/dev/null | \
865 egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
866 then
867 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&pos,procprog]"
868 ac_cv_ps_command="$PATH_TO_PS -el (IRIX 53)"
869 ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %d %d %*s %*s %*s %n%s"
870 ac_cv_ps_cols=8
871 AC_MSG_RESULT([$ac_cv_ps_command])
873 dnl IRIX 63
874 elif ps -el 2>/dev/null | \
875 egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +ADDR +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
876 then
877 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
878 ac_cv_ps_command="$PATH_TO_PS -el (IRIX 63)"
879 ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
880 ac_cv_ps_cols=6
881 AC_MSG_RESULT([$ac_cv_ps_command])
883 dnl AIX 4.1:
884 dnl F S UID PID PPID C PRI NI ADDR SZ RSS WCHAN TTY TIME CMD
885 dnl 303 A 0 0 0 120 16 -- 1c07 20 24 - 0:45 swapper
886 elif ps -el 2>/dev/null | \
887 egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +ADDR +SZ +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
888 then
889 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
890 ac_cv_ps_command="$PATH_TO_PS -el (AIX 4.1 and HP-UX)"
891 ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
892 ac_cv_ps_cols=6
893 AC_MSG_RESULT([$ac_cv_ps_command])
895 dnl AIX?
896 elif ps glaxen 2>/dev/null | \
897 egrep -i ["^ *F +UID +PID +PPID +PRI +NI +VSZ +RSS +WCHAN +STAT +TTY +TIME +COMMAND"] >/dev/null
898 then
899 ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]"
900 ac_cv_ps_command="$PATH_TO_PS glaxen"
901 ac_cv_ps_format="%*s %d %d %d %*s %*s %d %d %*s %s %*s %*s %n%s"
902 ac_cv_ps_cols=8
903 AC_MSG_RESULT([$ac_cv_ps_command])
905 dnl MacOSX / Darwin
906 dnl TODO: MacOSX has commands with spaces which will cause problems to PS_FORMAT
907 dnl Some truncation will happen in UCOMM column
908 dnl STAT VSZ RSS UID PPID %CPU UCOMM COMMAND
909 dnl Ss 52756 22496 501 1 6.9 Window Manager /System/Library/CoreServices/WindowServer -daemon
910 elif ps wwaxo 'state vsz rss uid pid ppid pcpu ucomm command' 2>/dev/null | \
911 egrep -i ["^STAT +VSZ +RSS +UID +PPID +%CPU +UCOMM +COMMAND"] >/dev/null
912 then
913 ac_cv_ps_command="$PATH_TO_PS wwaxo 'state vsz rss uid pid ppid pcpu ucomm command'"
914 ac_cv_ps_varlist="[procstat,&procvsz,&procrss,&procuid,&procpid,&procppid,&procpcpu,procprog,&pos]"
915 ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
916 ac_cv_ps_cols=8
917 AC_MSG_RESULT([$ac_cv_ps_command])
919 dnl UnixWare
920 elif ps -Al 2>/dev/null | \
921 egrep -i ["^ *F +S +UID +PID +PPID +CLS +PRI +NI +C +ADDR +SZ +WCHAN +TTY +TIME +COMD"] >/dev/null
922 then
923 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
924 ac_cv_ps_command="$PATH_TO_PS -Al"
925 ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
926 ac_cv_ps_cols=8
927 AC_MSG_RESULT([$ac_cv_ps_command])
929 else
930 AC_MSG_WARN([unable to find usable ps syntax - check_procs and check_nagios will not be compiled])
931 fi
933 if test -n "$ac_cv_ps_varlist" ; then
934 AC_DEFINE_UNQUOTED(PS_VARLIST,$ac_cv_ps_varlist,
935 [Variable list for sscanf of 'ps' output])
936 AC_DEFINE_UNQUOTED(PS_COMMAND,"$ac_cv_ps_command",
937 [Verbatim command to execute for ps in check_procs])
938 AC_DEFINE_UNQUOTED(PS_FORMAT,"$ac_cv_ps_format",
939 [Format string for scanning ps output in check_procs])
940 AC_DEFINE_UNQUOTED(PS_COLS,$ac_cv_ps_cols,
941 [Number of columns in ps command])
942 EXTRAS="$EXTRAS check_procs check_nagios"
943 if echo "$ac_cv_ps_varlist" | grep -q "procetime"; then
944 AC_DEFINE(PS_USES_PROCETIME,"yes",
945 [Whether the ps utility uses the "procetime" field])
946 fi
947 fi
949 AC_PATH_PROG(PATH_TO_PING,ping)
950 AC_PATH_PROG(PATH_TO_PING6,ping6)
952 AC_ARG_WITH(ping_command,
953 ACX_HELP_STRING([--with-ping-command=SYNTAX],
954 [sets syntax for ICMP ping]),
955 with_ping_command=$withval,)
957 AC_MSG_CHECKING(for ICMP ping syntax)
958 ac_cv_ping_packets_first=no
959 ac_cv_ping_has_timeout=no
960 if test -n "$with_ping_command"
961 then
962 AC_MSG_RESULT([(command-line) $with_ping_command])
963 if test -n "$ac_cv_ping_packets_first"
964 then
965 ac_cv_ping_packets_first=yes
966 ac_cv_ping_has_timeout=yes
967 fi
969 elif [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
970 $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
971 egrep -i "^round-trip|^rtt" >/dev/null
972 then
973 with_ping_command="$PATH_TO_PING -n -U -c %d %s"
974 ac_cv_ping_packets_first=yes
975 AC_MSG_RESULT([$with_ping_command])
977 elif $PATH_TO_PING -n -U -w 10 -c 1 127.0.0.1 2>/dev/null | \
978 egrep -i "^round-trip|^rtt" >/dev/null
979 then
980 with_ping_command="$PATH_TO_PING -n -U -w %d -c %d %s"
981 ac_cv_ping_packets_first=yes
982 ac_cv_ping_has_timeout=yes
983 AC_MSG_RESULT([$with_ping_command])
985 elif $PATH_TO_PING -n -U -c 1 127.0.0.1 2>/dev/null | \
986 egrep -i "^round-trip|^rtt" >/dev/null
987 then
988 with_ping_command="$PATH_TO_PING -n -U -c %d %s"
989 ac_cv_ping_packets_first=yes
990 AC_MSG_RESULT([$with_ping_command])
992 elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \
993 egrep -i "^round-trip|^rtt" >/dev/null
994 then
995 with_ping_command="$PATH_TO_PING -n -c %d %s"
996 ac_cv_ping_packets_first=yes
997 AC_MSG_RESULT([$with_ping_command])
999 elif $PATH_TO_PING -n 127.0.0.1 -c 1 2>/dev/null | \
1000 egrep -i "^round-trip|^rtt" >/dev/null
1001 then
1002 with_ping_command="$PATH_TO_PING -n %s -c %d"
1003 AC_MSG_RESULT([$with_ping_command])
1005 elif $PATH_TO_PING 127.0.0.1 -n 1 2>/dev/null | \
1006 egrep -i "^round-trip|^rtt" >/dev/null
1007 then
1008 with_ping_command="$PATH_TO_PING %s -n %d"
1009 AC_MSG_RESULT([$with_ping_command])
1011 elif $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
1012 egrep -i "^round-trip|^rtt" >/dev/null
1013 then
1014 with_ping_command="$PATH_TO_PING -n -s %s 56 %d"
1015 AC_MSG_RESULT([$with_ping_command])
1017 elif $PATH_TO_PING -n -h 127.0.0.1 -s 56 -c 1 2>/dev/null | \
1018 egrep -i "^round-trip|^rtt" >/dev/null
1019 then
1020 with_ping_command="$PATH_TO_PING -n -h %s -s 56 -c %d"
1021 AC_MSG_RESULT([$with_ping_command])
1023 elif $PATH_TO_PING -n -s 56 -c 1 127.0.0.1 2>/dev/null | \
1024 egrep -i "^round-trip|^rtt" >/dev/null
1025 then
1026 with_ping_command="$PATH_TO_PING -n -s 56 -c %d %s"
1027 ac_cv_ping_packets_first=yes
1028 AC_MSG_RESULT([$with_ping_command])
1030 elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \
1031 egrep -i "^round-trip|^rtt" >/dev/null
1032 then
1033 with_ping_command="$PATH_TO_PING -n -c %d %s"
1034 ac_cv_ping_packets_first=yes
1035 AC_MSG_RESULT([$with_ping_command])
1037 else
1038 AC_MSG_WARN([unable to find usable ping syntax])
1039 fi
1041 AC_DEFINE_UNQUOTED(PING_COMMAND,"$with_ping_command",
1042 [path and args for ICMP ping command])
1044 if test "x$ac_cv_ping_packets_first" != "xno"
1045 then
1046 AC_DEFINE(PING_PACKETS_FIRST,1,
1047 [Define if packet count must precede host])
1048 fi
1050 if test "x$ac_cv_ping_has_timeout" != "xno"
1051 then
1052 AC_DEFINE(PING_HAS_TIMEOUT,1,
1053 [Define if ping has its own timeout option that should be set])
1054 fi
1056 AC_ARG_WITH(ping6_command,
1057 ACX_HELP_STRING([--with-ping6-command=SYNTAX],
1058 [sets syntax for ICMPv6 ping]),
1059 with_ping6_command=$withval,)
1061 if test x"$with_ipv6" != xno ; then
1062 AC_MSG_CHECKING(for ICMPv6 ping syntax)
1063 ac_cv_ping6_packets_first=no
1064 if test -n "$with_ping6_command"
1065 then
1066 AC_MSG_RESULT([(command-line) $with_ping6_command])
1067 if test -n "$ac_cv_ping6_packets_first"
1068 then
1069 ac_cv_ping6_packets_first=yes
1070 fi
1072 elif test "x$PATH_TO_PING6" != "x"; then
1073 if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
1074 $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \
1075 egrep -i "^round-trip|^rtt" >/dev/null
1076 then
1077 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s"
1078 ac_cv_ping6_packets_first=yes
1079 AC_MSG_RESULT([$with_ping6_command])
1081 elif $PATH_TO_PING6 -n -U -w 10 -c 1 ::1 2>/dev/null | \
1082 egrep -i "^round-trip|^rtt" >/dev/null
1083 then
1084 with_ping6_command="$PATH_TO_PING6 -n -U -w %d -c %d %s"
1085 ac_cv_ping6_packets_first=yes
1086 ac_cv_ping_has_timeout=yes
1087 AC_MSG_RESULT([$with_ping6_command])
1089 elif $PATH_TO_PING6 -n -U -c 1 ::1 2>/dev/null | \
1090 egrep -i "^round-trip|^rtt" >/dev/null
1091 then
1092 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s"
1093 ac_cv_ping6_packets_first=yes
1094 AC_MSG_RESULT([$with_ping6_command])
1096 elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \
1097 egrep -i "^round-trip|^rtt" >/dev/null
1098 then
1099 with_ping6_command="$PATH_TO_PING6 -n -c %d %s"
1100 ac_cv_ping6_packets_first=yes
1101 AC_MSG_RESULT([$with_ping6_command])
1103 elif $PATH_TO_PING6 -n ::1 -c 1 2>/dev/null | \
1104 egrep -i "^round-trip|^rtt" >/dev/null
1105 then
1106 with_ping6_command="$PATH_TO_PING6 -n %s -c %d"
1107 AC_MSG_RESULT([$with_ping6_command])
1109 elif $PATH_TO_PING6 ::1 -n 1 2>/dev/null | \
1110 egrep -i "^round-trip|^rtt" >/dev/null
1111 then
1112 with_ping6_command="$PATH_TO_PING6 %s -n %d"
1113 AC_MSG_RESULT([$with_ping6_command])
1115 elif $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \
1116 egrep -i "^round-trip|^rtt" >/dev/null
1117 then
1118 with_ping6_command="$PATH_TO_PING6 -n -s %s 56 %d"
1119 AC_MSG_RESULT([$with_ping6_command])
1121 elif $PATH_TO_PING6 -n -h ::1 -s 56 -c 1 2>/dev/null | \
1122 egrep -i "^round-trip|^rtt" >/dev/null
1123 then
1124 with_ping6_command="$PATH_TO_PING6 -n -h %s -s 56 -c %d"
1125 AC_MSG_RESULT([$with_ping6_command])
1127 elif $PATH_TO_PING6 -n -s 56 -c 1 ::1 2>/dev/null | \
1128 egrep -i "^round-trip|^rtt" >/dev/null
1129 then
1130 with_ping6_command="$PATH_TO_PING6 -n -s 56 -c %d %s"
1131 ac_cv_ping6_packets_first=yes
1132 AC_MSG_RESULT([$with_ping_command])
1134 elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \
1135 egrep -i "^round-trip|^rtt" >/dev/null
1136 then
1137 with_ping6_command="$PATH_TO_PING6 -n -c %d %s"
1138 ac_cv_ping6_packets_first=yes
1139 AC_MSG_RESULT([$with_ping6_command])
1141 fi
1143 elif test "x$PATH_TO_PING" != "x"; then
1144 if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
1145 $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \
1146 egrep -i "^round-trip|^rtt" >/dev/null
1147 then
1148 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -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 -U -c 1 ::1 2>/dev/null | \
1153 egrep -i "^round-trip|^rtt" >/dev/null
1154 then
1155 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s"
1156 ac_cv_ping6_packets_first=yes
1157 AC_MSG_RESULT([$with_ping6_command])
1159 elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \
1160 egrep -i "^round-trip|^rtt" >/dev/null
1161 then
1162 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s"
1163 ac_cv_ping6_packets_first=yes
1164 AC_MSG_RESULT([$with_ping6_command])
1166 elif $PATH_TO_PING -A inet6 -n ::1 -c 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 -c %d"
1170 AC_MSG_RESULT([$with_ping6_command])
1172 elif $PATH_TO_PING -A inet6 ::1 -n 1 2>/dev/null | \
1173 egrep -i "^round-trip|^rtt" >/dev/null
1174 then
1175 with_ping6_command="$PATH_TO_PING -A inet6 %s -n %d"
1176 AC_MSG_RESULT([$with_ping6_command])
1178 elif $PATH_TO_PING -A inet6 -n -s ::1 56 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 %s 56 %d"
1182 AC_MSG_RESULT([$with_ping6_command])
1184 elif $PATH_TO_PING -A inet6 -n -h ::1 -s 56 -c 1 2>/dev/null | \
1185 egrep -i "^round-trip|^rtt" >/dev/null
1186 then
1187 with_ping6_command="$PATH_TO_PING -A inet6 -n -h %s -s 56 -c %d"
1188 AC_MSG_RESULT([$with_ping6_command])
1190 elif $PATH_TO_PING -A inet6 -n -s 56 -c 1 ::1 2>/dev/null | \
1191 egrep -i "^round-trip|^rtt" >/dev/null
1192 then
1193 with_ping6_command="$PATH_TO_PING -A inet6 -n -s 56 -c %d %s"
1194 ac_cv_ping6_packets_first=yes
1195 AC_MSG_RESULT([$with_ping_command])
1197 elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \
1198 egrep -i "^round-trip|^rtt" >/dev/null
1199 then
1200 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s"
1201 ac_cv_ping6_packets_first=yes
1202 AC_MSG_RESULT([$with_ping6_command])
1204 fi
1206 fi
1208 if test "x$with_ping6_command" != "x"; then
1209 AC_DEFINE_UNQUOTED(PING6_COMMAND,"$with_ping6_command",
1210 [path and args for ICMPv6 ping command])
1211 else
1212 AC_MSG_RESULT([none])
1213 fi
1215 if test "x$ac_cv_ping6_packets_first" != "xno"; then
1216 AC_DEFINE(PING6_PACKETS_FIRST,1,
1217 [Define if packet count must precede host])
1218 fi
1219 fi
1222 AC_ARG_WITH(nslookup_command,
1223 ACX_HELP_STRING([--with-nslookup-command=PATH],
1224 [sets path to nslookup executable]),
1225 ac_cv_nslookup_command=$withval)
1226 if test -n "$ac_cv_nslookup_command"; then
1227 AC_MSG_NOTICE([Using specific nslookup at $ac_cv_nslookup_command])
1228 else
1229 AC_PATH_PROG(PATH_TO_NSLOOKUP,nslookup)
1230 if test -n "$PATH_TO_NSLOOKUP"
1231 then
1232 AC_MSG_CHECKING(for nslookup syntax)
1233 if $PATH_TO_NSLOOKUP -sil 127.0.0.1 2>&1 | grep ["Invalid option: sil"] >/dev/null
1234 then
1235 ac_cv_nslookup_command="$PATH_TO_NSLOOKUP"
1236 AC_MSG_RESULT([$ac_cv_nslookup_command])
1238 else
1239 ac_cv_nslookup_command="$PATH_TO_NSLOOKUP -sil"
1240 AC_MSG_RESULT([$ac_cv_nslookup_command])
1242 fi
1243 else
1244 AC_MSG_WARN([nslookup command not found])
1245 fi
1246 fi
1248 if test -n "$ac_cv_nslookup_command"; then
1249 EXTRAS="$EXTRAS check_dns"
1250 AC_DEFINE_UNQUOTED(NSLOOKUP_COMMAND,"$ac_cv_nslookup_command", [path and args for nslookup])
1251 fi
1253 AC_PATH_PROG(PATH_TO_UPTIME,uptime)
1254 AC_ARG_WITH(uptime_command,
1255 ACX_HELP_STRING([--with-uptime-command=PATH],
1256 [sets path to uptime]), PATH_TO_UPTIME=$withval)
1257 AC_DEFINE_UNQUOTED(PATH_TO_UPTIME,"$PATH_TO_UPTIME",[path to uptime binary])
1259 AC_PATH_PROG(PATH_TO_RPCINFO,rpcinfo)
1260 AC_ARG_WITH(rpcinfo_command,
1261 ACX_HELP_STRING([--with-rpcinfo-command=PATH],
1262 [sets path to rpcinfo]), PATH_TO_RPCINFO=$withval)
1263 AC_DEFINE_UNQUOTED(PATH_TO_RPCINFO,"$PATH_TO_RPCINFO",[path to rpcinfo binary])
1265 AC_PATH_PROG(PATH_TO_LMSTAT,lmstat)
1266 if test -x "$PATH_TO_LMSTAT"
1267 then
1268 AC_DEFINE_UNQUOTED(PATH_TO_LMSTAT,"$PATH_TO_LMSTAT",[path to lmstat])
1269 else
1270 AC_MSG_WARN([Get lmstat from Globetrotter Software to monitor flexlm licenses])
1271 fi
1273 AC_PATH_PROG(PATH_TO_SMBCLIENT,smbclient)
1274 AC_ARG_WITH(smbclient_command,
1275 ACX_HELP_STRING([--with-smbclient-command=PATH],
1276 [sets path to smbclient]),
1277 PATH_TO_SMBCLIENT=$withval)
1278 if test -n "$PATH_TO_SMBCLIENT"
1279 then
1280 AC_DEFINE_UNQUOTED(PATH_TO_SMBCLIENT,"$PATH_TO_SMBCLIENT",[path to smbclient binary])
1281 else
1282 AC_MSG_WARN([Get smbclient from Samba.org to monitor SMB shares])
1283 fi
1286 AC_PATH_PROG(PATH_TO_WHO,who)
1288 if [$PATH_TO_WHO -q 2>/dev/null | egrep -i "^# users=[0-9]+$" >/dev/null]
1289 then
1290 ac_cv_path_to_who="$PATH_TO_WHO -q"
1291 else
1292 ac_cv_path_to_who="$PATH_TO_WHO"
1293 fi
1295 AC_DEFINE_UNQUOTED(WHO_COMMAND,"$ac_cv_path_to_who",
1296 [path and arguments for invoking 'who'])
1298 AC_PATH_PROG(PATH_TO_SNMPGET,snmpget)
1299 AC_ARG_WITH(snmpget_command,
1300 ACX_HELP_STRING([--with-snmpget-command=PATH],
1301 [Path to snmpget command]),
1302 PATH_TO_SNMPGET=$withval)
1303 if test -n "$PATH_TO_SNMPGET"
1304 then
1305 AC_DEFINE_UNQUOTED(PATH_TO_SNMPGET,"$PATH_TO_SNMPGET",[path to snmpget binary])
1306 EXTRAS="$EXTRAS check_hpjd check_snmp"
1307 else
1308 AC_MSG_WARN([Get snmpget from http://net-snmp.sourceforge.net to make check_hpjd and check_snmp plugins])
1309 fi
1311 AC_PATH_PROG(PATH_TO_SNMPGETNEXT,snmpgetnext)
1312 AC_ARG_WITH(snmpgetnext_command,
1313 ACX_HELP_STRING([--with-snmpgetnext-command=PATH],
1314 [Path to snmpgetnext command]),
1315 PATH_TO_SNMPGETNEXT=$withval)
1316 if test -n "$PATH_TO_SNMPGETNEXT"
1317 then
1318 AC_DEFINE_UNQUOTED(PATH_TO_SNMPGETNEXT,"$PATH_TO_SNMPGETNEXT",[path to snmpgetnext binary])
1319 fi
1321 if ( $PERL -M"Net::SNMP 3.6" -e 'exit' 2>/dev/null )
1322 then
1323 AC_MSG_CHECKING(for Net::SNMP perl module)
1324 AC_MSG_RESULT([found])
1325 else
1326 AC_MSG_WARN([Tried $PERL - install Net::SNMP perl module if you want to use the perl snmp plugins])
1327 fi
1329 AC_PATH_PROG(PATH_TO_QUAKESTAT,quakestat)
1330 AC_PATH_PROG(PATH_TO_QSTAT,qstat)
1331 AC_ARG_WITH(qstat_command,
1332 ACX_HELP_STRING([--with-qstat-command=PATH],
1333 [Path to qstat command]), PATH_TO_QSTAT=$withval)
1335 if test -x "$PATH_TO_QUAKESTAT"
1336 then
1337 ac_cv_path_to_qstat="$PATH_TO_QUAKESTAT"
1338 EXTRAS="$EXTRAS check_game"
1340 elif test -n "$PATH_TO_QSTAT"
1341 then
1342 ac_cv_path_to_qstat="$PATH_TO_QSTAT"
1343 EXTRAS="$EXTRAS check_game"
1344 else
1345 AC_MSG_WARN([Get qstat from http://www.activesw.com/people/steve/qstat.html in order to make check_game plugin])
1346 fi
1348 if test $ac_cv_path_to_qstat
1349 then
1350 AC_DEFINE_UNQUOTED(PATH_TO_QSTAT,"$ac_cv_path_to_qstat",
1351 [path to qstat/quakestat])
1352 fi
1354 AC_PATH_PROG(PATH_TO_FPING,fping)
1355 AC_ARG_WITH(fping_command,
1356 ACX_HELP_STRING([--with-fping-command=PATH],
1357 [Path to fping command]), PATH_TO_FPING=$withval)
1358 if test -n "$PATH_TO_FPING"
1359 then
1360 AC_DEFINE_UNQUOTED(PATH_TO_FPING,"$PATH_TO_FPING",[path to fping])
1361 EXTRAS="$EXTRAS check_fping"
1362 else
1363 AC_MSG_WARN([Get fping from http://www.fping.com in order to make check_fping plugin])
1364 fi
1366 AC_PATH_PROG(PATH_TO_SSH,ssh)
1367 AC_ARG_WITH(ssh_command,
1368 ACX_HELP_STRING([--with-ssh-command=PATH],
1369 [sets path for ssh]), PATH_TO_SSH=$withval)
1370 if test -n "$PATH_TO_SSH"
1371 then
1372 AC_DEFINE_UNQUOTED(SSH_COMMAND,"$PATH_TO_SSH",[path to ssh binary])
1373 EXTRAS="$EXTRAS check_by_ssh"
1374 else
1375 AC_MSG_WARN([Get ssh in order to make check_by_ssh plugin])
1376 fi
1379 AC_PATH_PROG(PATH_TO_MAILQ,mailq)
1380 AC_ARG_WITH(mailq_command,
1381 ACX_HELP_STRING([--with-mailq-command=PATH],
1382 [sets path to mailq]), PATH_TO_MAILQ=$withval)
1383 if test -n "$PATH_TO_MAILQ"
1384 then
1385 AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_MAILQ",[path to mailq])
1386 else
1387 AC_MSG_WARN([Could not find mailq or eqivalent])
1388 fi
1390 AC_PATH_PROG(PATH_TO_QMAIL_QSTAT,qmail-qstat)
1391 if test -x "$PATH_TO_QMAIL_QSTAT"
1392 then
1393 AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_QMAIL_QSTAT",[path to qmail-qstat])
1394 else
1395 AC_MSG_WARN([Could not find qmail-qstat or eqivalent])
1396 fi
1398 dnl SWAP info required is amount allocated/available and amount free
1399 dnl The plugin works through all the swap devices and adds up the total swap
1400 dnl available.
1401 AC_PATH_PROG(PATH_TO_SWAP,swap)
1402 if (test -n "$PATH_TO_SWAP")
1403 then
1404 AC_MSG_CHECKING([for $PATH_TO_SWAP format])
1405 if [$PATH_TO_SWAP -l 2>&1 >/dev/null]
1406 then
1407 ac_cv_have_swap=yes
1408 ac_cv_swap_command="$PATH_TO_SWAP -l"
1409 if [$PATH_TO_SWAP -l 2>/dev/null | \
1410 egrep -i "^lswap +path +pri +swaplo +blocks +free +maxswap" \
1411 >/dev/null]
1412 then
1413 ac_cv_swap_format=[" %*d %*s %*d,%*d %*d %*d %f %f"]
1414 ac_cv_swap_conv=2048
1415 AC_MSG_RESULT([using IRIX format swap])
1417 elif [$PATH_TO_SWAP -l 2>/dev/null | egrep -i "^path +dev +swaplo +blocks +free" >/dev/null]
1418 then
1419 ac_cv_swap_format=["%*s %*[0-9,-] %*d %f %f"]
1420 ac_cv_swap_conv=2048
1421 AC_MSG_RESULT([using Unixware format swap])
1422 else
1423 dnl if we don't know what format swap's output is
1424 dnl we might as well pretend we didn't see it
1425 ac_cv_have_swap=""
1426 ac_cv_swap_command=""
1427 fi
1428 fi
1429 dnl end if for PATH_TO_SWAP
1430 fi
1432 AC_PATH_PROG(PATH_TO_SWAPINFO,swapinfo)
1433 if (test -n "$PATH_TO_SWAPINFO")
1434 then
1435 AC_MSG_CHECKING([for $PATH_TO_SWAPINFO format])
1436 if [$PATH_TO_SWAPINFO -k 2>&1 | egrep -i "^Device" >/dev/null]
1437 then
1438 ac_cv_have_swap=yes
1439 ac_cv_swap_command="$PATH_TO_SWAPINFO -k"
1441 if [$PATH_TO_SWAPINFO -k 2>/dev/null | egrep -i "^Device +1K-blocks +Used +Avail" >/dev/null]
1442 then
1443 ac_cv_swap_format=["%*s %f %*d %f"]
1444 ac_cv_swap_conv=1024
1445 AC_MSG_RESULT([using FreeBSD format swapinfo])
1446 fi
1448 elif [$PATH_TO_SWAPINFO -dfM 2>/dev/null | egrep -i "^TYPE +AVAIL +USED +FREE" >/dev/null]
1449 then
1450 ac_cv_have_swap=yes
1451 ac_cv_swap_command="$PATH_TO_SWAPINFO -dfM",
1452 ac_cv_swap_format=["%*s %f %*d %f"]
1453 ac_cv_swap_conv=1024
1454 AC_MSG_RESULT([using HP-UX format swapinfo])
1455 fi
1456 dnl end if for PATH_TO_SWAPINFO
1457 fi
1459 AC_PATH_PROG(PATH_TO_LSPS,lsps)
1460 if (test -n "$PATH_TO_LSPS")
1461 then
1462 AC_MSG_CHECKING([for $PATH_TO_LSPS format])
1463 if [$PATH_TO_LSPS -a 2>/dev/null | egrep -i "^Page Space" > /dev/null]
1464 then
1465 ac_cv_have_swap=yes
1466 ac_cv_swap_command="$PATH_TO_LSPS -a"
1467 ac_cv_swap_format=["%*s %*s %*s %f%*s %f %*s"]
1468 ac_cv_swap_conv=1
1469 AC_MSG_RESULT([using AIX lsps])
1470 fi
1471 dnl end if for PATH_TO_SWAPINFO
1472 fi
1474 dnl
1475 dnl test for swapctl system call, both the 2-arg and 3-arg variants
1476 dnl fwict, the 2-arg is an SVR4 standard, whereas the 3-arg is shared
1477 dnl in the various BSD's
1478 dnl
1480 AC_CHECK_HEADERS([sys/stat.h sys/param.h])
1481 AC_CHECK_HEADERS([sys/swap.h], [], [], [
1482 #ifdef HAVE_SYS_PARAM_H
1483 #include <sys/param.h>
1484 #endif
1485 ])
1486 AC_CHECK_DECLS([swapctl],,,[
1487 #include <unistd.h>
1488 #include <sys/types.h>
1489 #include <sys/param.h>
1490 #include <sys/stat.h>
1491 #include <sys/swap.h>
1492 ])
1493 AC_CHECK_TYPES([swaptbl_t, swapent_t],,,[
1494 #include <sys/types.h>
1495 #include <sys/param.h>
1496 #include <sys/stat.h>
1497 #include <sys/swap.h>
1498 ])
1499 AC_CHECK_MEMBERS([struct swapent.se_nblks],,,[
1500 #include <unistd.h>
1501 #include <sys/types.h>
1502 #include <sys/param.h>
1503 #include <sys/stat.h>
1504 #include <sys/swap.h>
1505 ])
1507 if test "$ac_cv_have_decl_swapctl" = "yes";
1508 then
1509 EXTRAS="$EXTRAS check_swap"
1510 AC_MSG_CHECKING([for 2-arg (SVR4) swapctl])
1511 if test "$ac_cv_type_swaptbl_t" = "yes" -a \
1512 "$ac_cv_type_swapent_t" = "yes";
1513 then
1514 AC_MSG_RESULT([yes])
1515 ac_cv_check_swap_swapctl_svr4="1";
1516 AC_DEFINE([CHECK_SWAP_SWAPCTL_SVR4],1,
1517 [Define if 2-argument SVR4 swapctl exists])
1518 else
1519 AC_MSG_RESULT([no])
1520 AC_MSG_CHECKING([for 3-arg (*BSD) swapctl])
1521 if test "$ac_cv_member_struct_swapent_se_nblks" = "yes";
1522 then
1523 AC_MSG_RESULT([yes])
1524 AC_DEFINE([CHECK_SWAP_SWAPCTL_BSD],1,
1525 [Define if 3-argument BSD swapctl exists])
1526 else
1527 AC_MSG_RESULT([no])
1528 fi
1529 fi
1530 AC_MSG_CHECKING([for whether swapctl uses blocks or pages])
1531 if test "$ac_cv_check_swap_swapctl_svr4" = "1";
1532 then
1533 dnl
1534 dnl the SVR4 spec returns values in pages
1535 dnl
1536 AC_MSG_RESULT([page])
1537 AC_CHECK_DECLS([sysconf])
1538 AC_MSG_CHECKING([for system page size])
1539 if test "$ac_cv_have_decl_sysconf" = "yes";
1540 then
1541 AC_MSG_RESULT([determined by sysconf(3)])
1542 ac_cv_swap_conv="(1048576/sysconf(_SC_PAGESIZE))"
1543 else
1544 AC_MSG_WARN([don't know. guessing 4096k])
1545 ac_cv_swap_conv=256
1546 fi
1547 else
1548 dnl
1549 dnl the BSD spec returns values in blocks
1550 dnl
1551 AC_MSG_RESULT([blocks (assuming 512b)])
1552 ac_cv_swap_conv=2048
1553 fi
1554 AC_DEFINE_UNQUOTED(SWAP_CONVERSION,$ac_cv_swap_conv,
1555 [Conversion factor to MB])
1556 fi
1557 dnl
1558 dnl end tests for the swapctl system calls
1559 dnl
1562 if test "x$ac_cv_have_swap" != "x"
1563 then
1564 AC_DEFINE(HAVE_SWAP,1,[Define if swap/swapinfo command is found])
1565 EXTRAS="$EXTRAS check_swap"
1566 fi
1567 if test "x$ac_cv_swap_command" != "x"
1568 then
1569 AC_DEFINE_UNQUOTED(SWAP_COMMAND,"$ac_cv_swap_command",
1570 [Path to swap/swapinfo binary, with any args])
1571 AC_DEFINE_UNQUOTED(SWAP_FORMAT,"$ac_cv_swap_format",
1572 [Format string for parsing swap output])
1573 AC_DEFINE_UNQUOTED(SWAP_CONVERSION,$ac_cv_swap_conv,
1574 [Conversion factor to MB])
1575 fi
1577 AC_ARG_WITH(proc-meminfo,
1578 ACX_HELP_STRING([--with-proc-meminfo=PATH],
1579 [path to /proc/meminfo or equivalent]),
1580 ac_cv_proc_meminfo=$withval)
1581 dnl dunno why this does not work below - use hack (kbd)
1582 dnl fine on linux, broken on solaris
1583 dnl if /bin/test -e "/proc/meminfo"
1584 AC_MSG_CHECKING([for /proc/meminfo])
1585 if test -n "$ac_cv_proc_meminfo"; then
1586 AC_MSG_RESULT([(command line) $ac_cv_proc_meminfo])
1587 elif [cat /proc/meminfo > /dev/null 2>&1]; then
1588 AC_MSG_RESULT([found /proc/meminfo])
1589 ac_cv_proc_meminfo="/proc/meminfo"
1590 else
1591 AC_MSG_RESULT([no])
1592 fi
1594 if test -n "$ac_cv_proc_meminfo"; then
1595 AC_DEFINE(HAVE_PROC_MEMINFO,1,[Define if we have /proc/meminfo])
1596 AC_DEFINE_UNQUOTED(PROC_MEMINFO,"$ac_cv_proc_meminfo",[path to /proc/meminfo if name changes])
1597 EXTRAS="$EXTRAS check_swap"
1598 fi
1600 AC_PATH_PROG(PATH_TO_DIG,dig)
1601 AC_ARG_WITH(dig_command,
1602 ACX_HELP_STRING([--with-dig-command=PATH],
1603 [Path to dig command]), PATH_TO_DIG=$withval)
1604 if test -n "$PATH_TO_DIG"; then
1605 EXTRAS="$EXTRAS check_dig"
1606 AC_DEFINE_UNQUOTED(PATH_TO_DIG,"$PATH_TO_DIG",[Path to dig command, if present])
1607 fi
1609 AC_PATH_PROG(PATH_TO_APTGET,apt-get)
1610 AC_ARG_WITH(apt-get_command,
1611 ACX_HELP_STRING([--with-apt-get-command=PATH],
1612 [Path to apt-get command]),
1613 with_apt_get_command=$withval,
1614 with_apt_get_command=$PATH_TO_APTGET)
1615 AC_DEFINE_UNQUOTED(PATH_TO_APTGET,"$PATH_TO_APTGET",[Path to apt-get command, if present])
1616 # check_apt needs regex support
1617 if test -n "$PATH_TO_APTGET" && test "$FOUNDREGEX" = "yes"; then
1618 EXTRAS="$EXTRAS check_apt"
1619 fi
1622 if test -f plugins/check_nt.c ; then
1623 EXTRAS="$EXTRAS check_nt"
1624 elif test -f ../plugins/check_nt.c ; then
1625 EXTRAS="$EXTRAS check_nt"
1626 fi
1628 AC_MSG_CHECKING(for va_list)
1629 AC_TRY_COMPILE([#ifdef __STDC__
1630 #include <stdio.h>
1631 #include <stdlib.h>
1632 #include <stdarg.h>
1633 #else
1634 #include <sys/types.h>
1635 #include <stdio.h>
1636 #include <varargs.h>
1637 #endif],
1638 [va_list args;],
1639 [AC_MSG_RESULT(yes)],
1640 [NEED_VA_LIST=-DNEED_VA_LIST AC_SUBST(NEED_VA_LIST) AC_MSG_RESULT(no)])
1642 case $host in
1643 *bsd*)
1644 AC_DEFINE(__bsd__,1,[bsd specific code in check_dhcp.c])
1645 ;;
1646 *linux*)
1647 AC_DEFINE(__linux__,1,[sun specific code in check_dhcp.c])
1648 ;;
1649 *sun* | solaris*)
1650 AC_DEFINE(__sun__,1,[sun specific code in check_dhcp.c])
1651 ;;
1652 *hpux*)
1653 AC_DEFINE(__hpux__,1,[hpux specific code in check_dhcp.c])
1654 ;;
1655 esac
1657 AC_SUBST(EXTRAS)
1658 AC_SUBST(EXTRAS_ROOT)
1659 AC_SUBST(EXTRA_NETOBJS)
1660 AC_SUBST(DEPLIBS)
1662 AM_GNU_GETTEXT([external], [need-ngettext])
1663 AM_GNU_GETTEXT_VERSION(0.11.5)
1665 dnl Check for Redhat spopen problem
1666 dnl Wierd problem where ECHILD is returned from a wait call in error
1667 dnl Only appears to affect nslookup and dig calls. Only affects redhat around
1668 dnl 2.6.9-11 (okay in 2.6.9-5). Redhat investigating root cause
1669 dnl We patch plugins/popen.c
1670 dnl Need to add smp because uname different on those
1671 dnl Can force patch to be applied with --enable-redhat-pthread-workaround
1672 AC_ARG_ENABLE(redhat-pthread-workaround,
1673 AC_HELP_STRING([--enable-redhat-pthread-workaround],
1674 [force Redhat patch to be applied (default: test system)]),
1675 [ac_cv_enable_redhat_pthread_workaround=$enableval],
1676 [ac_cv_enable_redhat_pthread_workaround=test])
1677 if test "$ac_cv_enable_redhat_pthread_workaround" = "test" ; then
1678 if echo $ac_cv_uname_r | egrep "\.EL(smp)?$" >/dev/null 2>&1 ; then
1679 AC_MSG_CHECKING(for redhat spopen problem)
1680 ( cd config_test && make && make test ) > /dev/null 2>&1
1681 if test $? -eq 0 ; then
1682 AC_MSG_RESULT(okay)
1683 else
1684 AC_MSG_RESULT(error)
1685 AC_DEFINE(REDHAT_SPOPEN_ERROR, 1, [Workaround on redhat in spopen])
1686 fi
1687 fi
1688 elif test "$ac_cv_enable_redhat_pthread_workaround" = "yes" ; then
1689 AC_DEFINE(REDHAT_SPOPEN_ERROR, 1, [Forced workaround on redhat in spopen])
1690 fi
1692 dnl External libraries - see ACKNOWLEDGEMENTS
1693 np_COREUTILS
1694 np_CURL
1696 AC_OUTPUT(
1697 Makefile
1698 lib/Makefile
1699 m4/Makefile
1700 plugins/Makefile
1701 plugins/tests/Makefile
1702 plugins-root/Makefile
1703 plugins-scripts/Makefile
1704 plugins-scripts/subst
1705 plugins-scripts/utils.pm
1706 plugins-scripts/utils.sh
1707 command.cfg
1708 test.pl
1709 pkg/solaris/pkginfo
1710 po/Makefile.in
1711 )
1714 dnl the ones below that are commented out need to be cleaned up
1715 dnl in the configure code above to use with_foo instead of ac_cv_foo
1716 dnl if we want them to show up here. it'd also make the code cleaner.
1717 dnl i'll get to that on another rainy day :) -sf
1718 ACX_FEATURE([with],[apt-get-command])
1719 dnl ACX_FEATURE([with],[dig-command])
1720 dnl ACX_FEATURE([with],[fping-command])
1721 dnl ACX_FEATURE([with],[mailq-command])
1722 dnl ACX_FEATURE([with],[nslookup-command])
1723 ACX_FEATURE([with],[ping6-command])
1724 ACX_FEATURE([with],[ping-command])
1725 dnl ACX_FEATURE([with],[qstat-command])
1726 dnl ACX_FEATURE([with],[rpcinfo-command])
1727 dnl ACX_FEATURE([with],[smbclient-command])
1728 dnl ACX_FEATURE([with],[snmpget-command])
1729 dnl ACX_FEATURE([with],[snmpgetnext-command])
1730 dnl ACX_FEATURE([with],[ssh-command])
1731 dnl ACX_FEATURE([with],[uptime-command])
1733 dnl ACX_FEATURE([with],[proc-loadavg])
1734 dnl ACX_FEATURE([with],[proc-meminfo])
1735 dnl ACX_FEATURE([with],[ps-command])
1736 dnl ACX_FEATURE([with],[ps-format])
1737 dnl ACX_FEATURE([with],[ps-cols])
1738 dnl ACX_FEATURE([with],[ps-varlist])
1740 ACX_FEATURE([with],[lwres])
1741 ACX_FEATURE([with],[ipv6])
1742 ACX_FEATURE([with],[mysql])
1743 ACX_FEATURE([with],[openssl])
1744 ACX_FEATURE([with],[gnutls])
1745 ACX_FEATURE([enable],[emulate-getaddrinfo])
1746 ACX_FEATURE([with],[perl])
1747 ACX_FEATURE([with],[cgiurl])
1748 ACX_FEATURE([with],[nagios-user])
1749 ACX_FEATURE([with],[nagios-group])
1750 ACX_FEATURE([with],[trusted-path])