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