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
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=pst3
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 sun*)
149 AC_DEFINE(__EXTENSIONS__,1,[Sun's netdb.h needs this for getaddrinfo])
150 ;;
151 osf*)
152 AC_DEFINE(_OSF_SOURCE,1,[OSF needs this for getaddrinfo])
153 ;;
154 esac
156 dnl
157 dnl Checks for libraries.
158 dnl
160 AC_CHECK_LIB(dce,main,SOCKETLIBS="$SOCKETLIBS -ldce")
161 AC_CHECK_LIB(nsl,main,SOCKETLIBS="$SOCKETLIBS -lnsl")
162 AC_CHECK_LIB(socket,socket,SOCKETLIBS="$SOCKETLIBS -lsocket")
163 AC_CHECK_LIB(resolv,main,SOCKETLIBS="$SOCKETLIBS -lresolv")
164 AC_SUBST(SOCKETLIBS)
166 dnl
167 dnl check for math-related functions needing -lm
168 AC_CHECK_HEADERS(math.h)
169 AC_CHECK_LIB(m,floor,MATHLIBS="-lm")
170 AC_SUBST(MATHLIBS)
172 dnl Check for libtap, to run perl-like tests
173 AC_CHECK_LIB(tap, plan_tests,
174 EXTRA_TEST=test_utils
175 AC_SUBST(EXTRA_TEST)
176 )
178 dnl Check for PostgreSQL libraries
179 _SAVEDLIBS="$LIBS"
180 _SAVEDCPPFLAGS="$CPPFLAGS"
181 AC_ARG_WITH(pgsql,
182 ACX_HELP_STRING([--with-pgsql=DIR],
183 [sets path to pgsql installation]),
184 PGSQL=$withval,)
185 AC_CHECK_LIB(crypt,main)
186 if test "$ac_cv_lib_crypt_main" = "yes"; then
187 if test -n "$PGSQL"; then
188 LDFLAGS="$LDFLAGS -L$PGSQL/lib"
189 CPPFLAGS="$CPPFLAGS -I$PGSQL/include"
190 fi
191 AC_CHECK_LIB(pq,PQsetdbLogin,,,-lcrypt)
192 if test "$ac_cv_lib_pq_PQsetdbLogin" = "yes"; then
193 AC_CHECK_HEADERS(pgsql/libpq-fe.h)
194 AC_CHECK_HEADERS(postgresql/libpq-fe.h)
195 AC_CHECK_HEADERS(libpq-fe.h)
196 if [[ -n "$PGSQL" -a "$ac_cv_header_libpq_fe_h" = "yes" ]]; then
197 PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
198 PGINCLUDE="-I$PGSQL/include"
199 elif test "$ac_cv_header_pgsql_libpq_fe_h" = "yes"; then
200 PGLIBS="-lpq -lcrypt"
201 PGINCLUDE="-I/usr/include/pgsql"
202 elif test "$ac_cv_header_postgresql_libpq_fe_h" = "yes"; then
203 PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
204 PGINCLUDE="-I/usr/include/postgresql"
205 elif test "$ac_cv_header_libpq_fe_h" = "yes"; then
206 PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
207 PGINCLUDE="-I$PGSQL/include"
208 fi
209 if test -z "$PGINCLUDE"; then
210 AC_MSG_WARN([Skipping PostgreSQL plugin (check_pgsql)])
211 AC_MSG_WARN([install PostgreSQL headers to compile this plugin (see REQUIREMENTS).])
212 else
213 AC_SUBST(PGLIBS)
214 AC_SUBST(PGINCLUDE)
215 EXTRAS="$EXTRAS check_pgsql"
216 fi
217 else
218 AC_MSG_WARN([Skipping PostgreSQL plugin (check_pgsql)])
219 AC_MSG_WARN([LIBS="$LIBS" CPPFLAGS="$CPPFLAGS"])
220 AC_MSG_WARN([install PostgreSQL libs to compile this plugin (see REQUIREMENTS).])
221 fi
222 else
223 AC_MSG_WARN([Skipping PostgreSQL plugin (check_pgsql)])
224 AC_MSG_WARN([install lib crypt and PostgreSQL libs to compile this plugin (see REQUIREMENTS).])
225 fi
226 LIBS="$_SAVEDLIBS"
227 CPPFLAGS="$_SAVEDCPPFLAGS"
229 dnl Check for radius libraries
230 _SAVEDLIBS="$LIBS"
231 AC_CHECK_LIB(radiusclient,rc_read_config)
232 if test "$ac_cv_lib_radiusclient_rc_read_config" = "yes"; then
233 EXTRAS="$EXTRAS check_radius"
234 RADIUSLIBS="-lradiusclient"
235 AC_SUBST(RADIUSLIBS)
236 else
237 AC_MSG_WARN([Skipping radius plugin])
238 AC_MSG_WARN([install radius libs to compile this plugin (see REQUIREMENTS).])
239 fi
240 LIBS="$_SAVEDLIBS"
242 dnl Check for LDAP libraries
243 _SAVEDLIBS="$LIBS"
244 AC_CHECK_LIB(ldap,main,,,-llber)
245 if test "$ac_cv_lib_ldap_main" = "yes"; then
246 LDAPLIBS="-lldap -llber"\
247 LDAPINCLUDE="-I/usr/include/ldap"
248 AC_SUBST(LDAPLIBS)
249 AC_SUBST(LDAPINCLUDE)
250 AC_CHECK_FUNCS(ldap_set_option)
251 EXTRAS="$EXTRAS check_ldap"
252 AC_CHECK_FUNCS(ldap_init ldap_set_option ldap_get_option ldap_start_tls_s)
253 else
254 AC_MSG_WARN([Skipping LDAP plugin])
255 AC_MSG_WARN([install LDAP libs to compile this plugin (see REQUIREMENTS).])
256 fi
257 LIBS="$_SAVEDLIBS"
259 dnl Check for mysql libraries
260 AC_ARG_WITH(mysql,
261 ACX_HELP_STRING([--with-mysql=DIR],
262 [Compiles mysql plugins. Expects DIR/bin/mysql_config]),
263 with_mysql=$withval,
264 with_mysql=no)
265 if test $with_mysql != "no" ; then
266 if test -x $with_mysql/bin/mysql_config ; then
267 MYSQLCONFIG="$with_mysql/bin/mysql_config"
268 else
269 AC_PATH_PROG(MYSQLCONFIG, mysql_config)
270 fi
271 if test -z "$MYSQLCONFIG"; then
272 with_mysql="not found"
273 AC_MSG_WARN([Skipping mysql plugin])
274 AC_MSG_WARN([install mysql client libs to compile this plugin (see REQUIREMENTS).])
275 else
276 with_mysql=$MYSQLCONFIG
277 EXTRAS="$EXTRAS check_mysql check_mysql_query"
278 MYSQLINCLUDE=`$MYSQLCONFIG --include`
279 MYSQLLIBS=`$MYSQLCONFIG --libs`
280 MYSQLCFLAGS=`$MYSQLCONFIG --cflags`
281 AC_SUBST(MYSQLINCLUDE)
282 AC_SUBST(MYSQLLIBS)
283 AC_SUBST(MYSQLCFLAGS)
284 fi
285 fi
287 AC_CHECK_HEADERS(unistd.h)
289 dnl Check for AF_INET6 support - unistd.h required for Darwin
290 AC_CACHE_CHECK([for IPv6 support], with_ipv6, [
291 AC_TRY_COMPILE([#ifdef HAVE_UNISTD_H
292 #include <unistd.h>
293 #endif
294 #include <netinet/in.h>
295 #include <sys/socket.h>],
296 [struct sockaddr_in6 sin6;
297 void *p;
299 sin6.sin6_family = AF_INET6;
300 sin6.sin6_port = 587;
301 p = &sin6.sin6_addr;],
302 [with_ipv6=yes],
303 [with_ipv6=no])
304 ])
306 if test x"$with_ipv6" != xno ; then
307 AC_DEFINE(USE_IPV6,1,[Enable IPv6 support])
308 fi
310 dnl #########################################################################
311 dnl Check if Posix getaddrinfo() is available. It is also possible to use
312 dnl the version from the lwres library distributed with BIND.
313 dnl #########################################################################
314 AC_ARG_ENABLE([emulate-getaddrinfo],
315 ACX_HELP_STRING([--enable-emulate-getaddrinfo],
316 [enable getaddrinfo emulation (default=no)]),
317 ,
318 enable_emulate_getaddrinfo=no)
320 AC_ARG_WITH(lwres,
321 ACX_HELP_STRING([--with-lwres=DIR],
322 [use lwres library for getaddrinfo (default=no)]),
323 ,
324 with_lwres=no)
326 dnl ## enable force to test getaddrinfo.c
327 if test x$enable_emulate_getaddrinfo = xforce ; then
328 enable_emulate_getaddrinfo=yes
329 have_getaddrinfo=no
330 else
332 have_getaddrinfo=no
333 if test x$with_lwres != xno ; then
334 if test "$with_lwres" != yes ; then
335 CPPFLAGS="-I${with_lwres}/include $CPPFLAGS"
336 LDFLAGS="-L${with_lwres}/lib $LDFLAGS"
337 fi
338 AC_CHECK_HEADERS(lwres/netdb.h, ,
339 [AC_MSG_ERROR([cannot find <lwres/netdb.h>])])
340 AC_CHECK_LIB(lwres, lwres_getaddrinfo, ,
341 [AC_MSG_ERROR([cannot find the lwres library])],
342 -lnsl -lpthread)
343 have_getaddrinfo=yes
344 fi
346 if test x$have_getaddrinfo != xyes ; then
347 AC_SEARCH_LIBS(getaddrinfo, socket resolv bind nsl c_r cr, have_getaddrinfo=yes)
348 fi
350 dnl # Special nonsense for systems that actually have getaddrinfo but
351 dnl # redefine the name to something else, e.g. OSF
352 if test x$have_getaddrinfo != xyes ; then
353 AC_MSG_CHECKING(if getaddrinfo is redefined in netdb.h)
354 AC_TRY_LINK([
355 # include <netdb.h>
356 ], [
357 struct addrinfo hints, *res;
358 int err;
360 err = getaddrinfo ("host", "service", &hints, &res);
361 ], [
362 have_getaddrinfo=yes
363 AC_MSG_RESULT(yes)
364 ], [AC_MSG_RESULT(no)])
365 fi
367 fi
369 if test x$have_getaddrinfo != xno ; then
370 if test x$enable_emulate_getaddrinfo != xno ; then
371 AC_MSG_ERROR([getaddrinfo found but emulate-getaddrinfo was enabled])
372 fi
373 AC_DEFINE(HAVE_GETADDRINFO, 1,
374 [Does system provide RFC 2553/Posix getaddrinfo?])
375 else
376 if test x$enable_emulate_getaddrinfo != xyes ; then
377 dnl AC_MSG_ERROR([getaddrinfo not found: try --with-lwres or --enable-emulate-getaddrinfo])
378 enable_emulate_getaddrinfo=yes
379 AC_MSG_WARN([enabling getaddrinfo emulation])
380 fi
381 EXTRA_NETOBJS="$EXTRA_NETOBJS getaddrinfo.o"
382 fi
384 if test x"$enable_emulate_getaddrinfo" != xno ; then
385 have_resolver=no
387 dnl Try for getipnodebyname
388 AC_SEARCH_LIBS(getipnodebyname, resolv bind nsl c_r cr, have_resolver=yes)
389 if test x"$have_resolver" != xno ; then
390 AC_DEFINE(HAVE_GETIPNODEBYNAME, 1,
391 [Set when getipnodebyname is available])
392 fi
394 dnl Try for gethostbyname_r
395 if test x"$have_resolver" = xno ; then
396 AC_SEARCH_LIBS(gethostbyname_r, resolv bind nsl c_r cr,
397 [have_resolver=yes
398 ACX_WHICH_GETHOSTBYNAME_R])
399 fi
401 dnl Try for gethostbyname
402 if test x"$have_resolver" = xno ; then
403 if test x"$enable_pthreads" != xno ; then
404 AC_MSG_WARN([using threads but cannot find gethostbyname_r or getipnodebyname])
405 fi
406 AC_SEARCH_LIBS(gethostbyname, resolv bind nsl, ,
407 [AC_MSG_ERROR([cannot find gethostbyname])])
408 fi
409 EXTRA_NETOBJS="$EXTRA_NETOBJS gethostbyname.o"
411 fi
413 dnl Checks for Kerberos. Must come before openssl checks for Redhat EL 3
414 AC_CHECK_HEADERS(krb5.h,FOUNDINCLUDE=yes,FOUNDINCLUDE=no)
415 if test "$FOUNDINCLUDE" = "no"; then
416 _SAVEDCPPFLAGS="$CPPFLAGS"
417 CPPFLAGS="$_SAVEDCPPFLAGS -I/usr/kerberos/include"
418 unset ac_cv_header_krb5_h
419 AC_CHECK_HEADERS(krb5.h,
420 KRB5INCLUDE="-I/usr/kerberos/include"
421 FOUNDINCLUDE=yes,
422 FOUNDINCLUDE=no)
423 fi
424 AC_SUBST(KRBINCLUDE)
425 if test "$FOUNDINCLUDE" = "no"; then
426 CPPFLAGS="$_SAVEDCPPFLAGS"
427 fi
430 dnl openssl detection/configuration
431 if ! test x"$with_openssl" = x"no"; then
432 dnl Check for OpenSSL location if it wasn't already specified
433 if ! test -d "$with_openssl"; then
434 for d in $OPENSSL_DIRS; do
435 if test -x ${d}/bin/openssl || test -x ${d}/sbin/openssl ; then
436 with_openssl=$d
437 fi
438 done
439 fi
441 _SAVEDCPPFLAGS="$CPPFLAGS"
442 _SAVEDLDFLAGS="$LDFLAGS"
443 dnl Check for OpenSSL header files
444 unset FOUNDINCLUDE
445 if test x"$with_openssl" != x"/usr" ; then
446 CPPFLAGS="$CPPFLAGS -I$with_openssl/include"
447 LDFLAGS="$LDFLAGS -R$with_openssl/lib"
448 fi
450 dnl check for openssl in $dir/include/openssl
451 AC_CHECK_HEADERS(openssl/ssl.h openssl/x509.h openssl/rsa.h openssl/pem.h openssl/crypto.h openssl/err.h,
452 SSLINCLUDE="-I$with_openssl/include"
453 FOUNDINCLUDE=yes,
454 FOUNDINCLUDE=no)
455 dnl else check to see if $dir/include has it
456 if test "$FOUNDINCLUDE" = "no"; then
457 AC_CHECK_HEADERS(ssl.h x509.h rsa.h pem.h crypto.h err.h,
458 SSLINCLUDE="-I$with_openssl/include"
459 FOUNDINCLUDE=yes,
460 FOUNDINCLUDE=no)
461 fi
462 AC_SUBST(SSLINCLUDE)
463 dnl if we didn't find it, reset CPPFLAGS
464 if test "$FOUNDINCLUDE" = "no"; then
465 CPPFLAGS="$_SAVEDCPPFLAGS"
466 LDFLAGS="$_SAVEDLDFLAGS"
467 fi
469 dnl Check for crypto lib
470 _SAVEDLIBS="$LIBS"
471 LIBS="-L${with_openssl}/lib"
472 AC_CHECK_LIB(crypto,CRYPTO_lock)
473 if test "$ac_cv_lib_crypto_CRYPTO_lock" = "yes"; then
474 dnl Check for SSL lib
475 AC_CHECK_LIB(ssl,main, SSLLIBS="-lssl -lcrypto",,-lcrypto)
476 fi
477 LIBS="$_SAVEDLIBS"
479 dnl test headers and libs to decide whether check_http should use SSL
480 if test "$ac_cv_lib_crypto_CRYPTO_lock" = "yes"; then
481 if test "$ac_cv_lib_ssl_main" = "yes"; then
482 if test "$FOUNDINCLUDE" = "yes"; then
483 FOUNDOPENSSL="yes"
484 fi
485 fi
486 fi
487 fi
490 dnl check for gnutls if openssl isn't found (or is disabled)
491 if test ! "$FOUNDOPENSSL" = "yes" && test ! "$with_gnutls" = "no"; then
492 if test ! "$with_gnutls" = ""; then
493 CPPFLAGS="$CPPFLAGS -I${with_gnutls}/include"
494 elif test ! "$LIBGNUTLS_CONFIG" = ""; then
495 CPPFLAGS="$CPPFLAGS -I`$LIBGNUTLS_CONFIG --prefix`"
496 fi
497 AC_CHECK_HEADERS([gnutls/openssl.h],FOUNDGNUTLS="yes",)
498 if test "$FOUNDGNUTLS" = "yes"; then
499 AC_CHECK_LIB(gnutls-openssl,main,SSLLIBS="-lgnutls-openssl")
500 fi
501 fi
502 dnl end check for gnutls
504 if test "$FOUNDOPENSSL" = "yes" || test "$FOUNDGNUTLS" = "yes"; then
505 check_tcp_ssl="check_simap check_spop check_jabber check_nntps check_ssmtp"
506 AC_SUBST(check_tcp_ssl)
507 AC_SUBST(SSLLIBS)
508 AC_DEFINE(HAVE_SSL,1,[Define if SSL libraries are found])
509 if test "$FOUNDOPENSSL" = "yes"; then
510 AC_DEFINE(USE_OPENSSL,1,[Define if using OpenSSL libraries])
511 with_openssl="yes"
512 with_gnutls="no"
513 else
514 AC_DEFINE(USE_GNUTLS,1,[Define if using gnutls libraries])
515 with_gnutls="yes"
516 with_openssl="no"
517 fi
518 else
519 dnl else deliberately disabled or no ssl support available
520 AC_MSG_WARN([OpenSSL or GnuTLS libs could not be found or were disabled])
521 with_openssl="no"
522 with_gnutls="no"
523 fi
525 dnl
526 dnl Checks for header files.
527 dnl
529 AC_HEADER_STDC
530 AC_HEADER_TIME
531 AC_HEADER_SYS_WAIT
532 AC_CHECK_HEADERS(signal.h strings.h string.h syslog.h uio.h errno.h regex.h sys/types.h sys/time.h sys/socket.h sys/loadavg.h sys/un.h)
533 AC_CHECK_HEADERS(features.h stdarg.h sys/unistd.h ctype.h stdlib.h)
535 dnl Checks for typedefs, structures, and compiler characteristics.
536 AC_C_CONST
537 AC_STRUCT_TM
538 AC_TYPE_PID_T
539 AC_TYPE_SIZE_T
540 AC_TYPE_SIGNAL
542 AC_CACHE_CHECK([for va_copy],ac_cv_HAVE_VA_COPY,[
543 AC_TRY_LINK([#include <stdarg.h>
544 va_list ap1,ap2;], [va_copy(ap1,ap2);],
545 ac_cv_HAVE_VA_COPY=yes,
546 ac_cv_HAVE_VA_COPY=no)])
547 if test x"$ac_cv_HAVE_VA_COPY" = x"yes"; then
548 AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available])
549 else
550 AC_CACHE_CHECK([for __va_copy],ac_cv_HAVE___VA_COPY,[
551 AC_TRY_LINK([#include <stdarg.h>
552 va_list ap1,ap2;], [__va_copy(ap1,ap2);],
553 ac_cv_HAVE___VA_COPY=yes,
554 ac_cv_HAVE___VA_COPY=no)])
555 if test x"$ac_cv_HAVE___VA_COPY" = x"yes"; then
556 AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available])
557 fi
558 fi
560 AC_CHECK_FUNCS(vsnprintf snprintf asprintf vasprintf)
561 AC_CACHE_CHECK([for C99 vsnprintf],ac_cv_HAVE_C99_VSNPRINTF,[
562 AC_TRY_RUN([
563 #include <sys/types.h>
564 #include <stdarg.h>
565 void foo(const char *format, ...) {
566 va_list ap;
567 int len;
568 char buf[5];
570 va_start(ap, format);
571 len = vsnprintf(buf, 0, format, ap);
572 va_end(ap);
573 if (len != 5) exit(1);
575 va_start(ap, format);
576 len = vsnprintf(0, 0, format, ap);
577 va_end(ap);
578 if (len != 5) exit(1);
580 if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
582 exit(0);
583 }
584 main() { foo("hello"); }
585 ],
586 ac_cv_HAVE_C99_VSNPRINTF=yes,ac_cv_HAVE_C99_VSNPRINTF=no,ac_cv_HAVE_C99_VSNPRINTF=cross)])
587 if test x"$ac_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
588 AC_DEFINE(HAVE_C99_VSNPRINTF,1,[Define if system has C99 compatible vsnprintf])
589 fi
591 AC_TRY_COMPILE([#include <sys/time.h>],
592 [struct timeval *tv;
593 struct timezone *tz;],
594 AC_DEFINE(HAVE_STRUCT_TIMEVAL,1,[Define if we have a timeval structure])
595 AC_TRY_COMPILE([#include <sys/time.h>],
596 [struct timeval *tv;
597 struct timezone *tz;
598 gettimeofday(tv, tz);],
599 AC_DEFINE(HAVE_GETTIMEOFDAY,1,[Define if gettimeofday is found]),
600 AC_DEFINE(NEED_GETTIMEOFDAY,1,[Define if gettimeofday is needed])))
602 dnl Checks for library functions.
603 AC_CHECK_FUNCS(memmove select socket strdup strstr strtod strtol strtoul floor)
604 AC_CHECK_FUNCS(basename)
606 AC_MSG_CHECKING(return type of socket size)
607 AC_TRY_COMPILE([#include <stdlib.h>
608 #include <sys/types.h>
609 #include <sys/socket.h>],
610 [int a = send(1, (const void *) buffer, (size_t *) 0, (int *) 0);],
611 ac_cv_socket_size_type=["size_t"]
612 AC_MSG_RESULT(size_t),
613 ac_cv_socket_size_type=["int"]
614 AC_MSG_RESULT(int))
616 AC_DEFINE_UNQUOTED(SOCKET_SIZE_TYPE, $ac_cv_socket_size_type ,
617 [Define type of socket size])
619 AC_ARG_WITH(proc-loadavg,
620 ACX_HELP_STRING([--with-proc-loadavg=PATH],
621 [path to /proc/loadavg or equivalent]),
622 ac_cv_proc_loadavg=$withval)
623 AC_MSG_CHECKING([for /proc/loadavg])
624 if test -n "$ac_cv_proc_loadavg"; then
625 AC_MSG_RESULT([(command line) $ac_cv_proc_loadavg])
626 elif test -f "/proc/loadavg"; then
627 AC_MSG_RESULT([found /proc/loadavg])
628 ac_cv_proc_loadavg="/proc/loadavg"
629 else
630 AC_MSG_RESULT([no])
631 fi
633 if test -n "$ac_cv_proc_loadavg"; then
634 AC_DEFINE(HAVE_PROC_LOADAVG,1,[Define if /proc/loadavg or similar exists])
635 AC_DEFINE_UNQUOTED(PROC_LOADAVG,"/proc/loadavg",[Location of /proc/loadavg])
636 fi
638 dnl #### Process table test
640 AC_PATH_PROG(PATH_TO_PS,ps)
642 AC_MSG_CHECKING(for ps syntax)
643 AC_ARG_WITH(ps_command,
644 ACX_HELP_STRING([--with-ps-command=PATH],
645 [Verbatim command to execute for ps]),
646 PS_COMMAND=$withval)
647 AC_ARG_WITH(ps_format,
648 ACX_HELP_STRING([--with-ps-format=FORMAT],
649 [Format string for scanning ps output]),
650 PS_FORMAT=$withval)
651 AC_ARG_WITH(ps_cols,
652 ACX_HELP_STRING([--with-ps-cols=NUM],
653 [Number of columns in ps command]),
654 PS_COLS=$withval)
655 AC_ARG_WITH(ps_varlist,
656 ACX_HELP_STRING([--with-ps-varlist=LIST],
657 [Variable list for sscanf of 'ps' output]),
658 PS_VARLIST=$withval)
660 if test -n "$PS_COMMAND" && test -n "$PS_FORMAT" && test -n "$PS_COLS" && test -n "$PS_VARLIST"; then
661 ac_cv_ps_command="$PS_COMMAND"
662 ac_cv_ps_format="$PS_FORMAT"
663 ac_cv_ps_varlist="$PS_VARLIST"
664 ac_cv_ps_cols="$PS_COLS"
665 AC_MSG_RESULT([(command-line) $ac_cv_ps_command])
667 dnl Now using the pst3/kmem hack for solaris systems to avoid truncation
668 elif test "$ac_cv_uname_s" = "SunOS"; then
669 #
670 # this is a very, very ugly hack, to hardcode the location for plugins
671 #
672 if test "$libexecdir" = '${exec_prefix}/libexec'; then
673 if test "$exec_prefix" = "NONE"; then
674 if test "$prefix" = "NONE"; then
675 pst3="$ac_default_prefix/libexec/pst3"
676 else
677 pst3="$prefix/libexec/pst3"
678 fi
679 else
680 pst3="$exec_prefix/libexec/pst3"
681 fi
682 else
683 pst3="$libexecdir/pst3"
684 fi
685 ac_cv_ps_command="$pst3"
686 ac_cv_ps_format="%s %d %d %d %d %f %s %n"
687 ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
688 ac_cv_ps_cols=8
689 AC_MSG_RESULT([using nagios-plugins internal ps for solaris])
690 EXTRAS_ROOT="$EXTRAS_ROOT pst3"
692 dnl Some gnu/linux systems (debian for one) don't like -axwo and need axwo.
693 dnl so test for this first...
694 elif ps axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
695 egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null
696 then
697 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
698 ac_cv_ps_command="$PATH_TO_PS axwo 'stat uid pid ppid vsz rss pcpu comm args'"
699 ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
700 ac_cv_ps_cols=9
701 AC_MSG_RESULT([$ac_cv_ps_command])
703 dnl For OpenBSD 3.2 & 3.3. Must come before ps -weo
704 dnl Should also work for FreeBSD 5.2.1 and 5.3
705 dnl STAT UCOMM VSZ RSS USER PPID COMMAND
706 elif ps -axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
707 egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null
708 then
709 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
710 ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid pid ppid vsz rss pcpu comm args'"
711 ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
712 ac_cv_ps_cols=9
713 AC_MSG_RESULT([$ac_cv_ps_command])
715 dnl Some *BSDs have different format for ps. This is mainly to catch FreeBSD 4.
716 dnl Limitation: Only first 16 chars returned for ucomm field
717 dnl Must come before ps -weo
718 elif ps -axwo 'stat uid pid ppid vsz rss pcpu ucomm command' 2>/dev/null | \
719 egrep -i ["^ *STAT +UID +PID +PPID +VSZ +RSS +%CPU +UCOMM +COMMAND"] > /dev/null
720 then
721 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
722 ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid pid ppid vsz rss pcpu ucomm command'"
723 ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
724 ac_cv_ps_cols=9
725 AC_MSG_RESULT([$ac_cv_ps_command])
727 dnl STAT UCOMM VSZ RSS USER UID PPID COMMAND
728 elif ps -weo 'stat comm vsz rss user uid pid ppid etime args' 2>/dev/null | \
729 egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[ID]+ +P[PID]+ +[ELAPSD]+ +[RGSCOMDNA]+"] >/dev/null
730 then
731 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procetime,procprog,&pos]"
732 ac_cv_ps_command="$PATH_TO_PS -weo 'stat uid pid ppid vsz rss pcpu etime comm args'"
733 ac_cv_ps_format="%s %d %d %d %d %d %f %s %s %n"
734 ac_cv_ps_cols=10
735 AC_MSG_RESULT([$ac_cv_ps_command])
737 dnl FreeBSD
738 elif ps waxco 'state command vsz rss uid user pid ppid' 2>/dev/null | \
739 egrep -i ["^STAT +COMMAND +VSZ +RSS +UID +USER +PID +PPID"] >/dev/null
740 then
741 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
742 ac_cv_ps_command="$PATH_TO_PS waxco 'state uid pid ppid vsz rss pcpu command command'"
743 ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
744 ac_cv_ps_cols=9
745 AC_MSG_RESULT([$ac_cv_ps_command])
747 dnl BSD-like mode in RH 6.1
748 elif ps waxno 'state comm vsz rss uid user pid ppid args' 2>/dev/null | \
749 egrep -i ["^S +COMMAND +VSZ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
750 then
751 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
752 ac_cv_ps_command="$PATH_TO_PS waxno 'state uid pid ppid vsz rss pcpu comm args'"
753 ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
754 ac_cv_ps_cols=9
755 AC_MSG_RESULT([$ac_cv_ps_command])
757 dnl SunOS 4.1.3:
758 dnl F UID PID PPID CP PRI NI SZ RSS WCHAN STAT TT TIME COMMAND
759 dnl Need the head -1 otherwise test will work because arguments are found
760 elif ps -laxnwww 2>/dev/null | head -1 | \
761 egrep -i ["^ *F(LAGS)? +UID +PID +PPID +CP +PRI +NI +(SZ)|(VSZ)|(SIZE) +RSS +WCHAN +STAT? +TTY? +TIME +COMMAND"] >/dev/null
762 then
763 ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]"
764 ac_cv_ps_command="$PATH_TO_PS -laxnwww"
765 ac_cv_ps_format="%*s %d %d %d %*s %*s %*s %d %d %*s %s %*s %*s %n%s"
766 ac_cv_ps_cols=9
767 AC_MSG_RESULT([$ac_cv_ps_command])
769 dnl Debian Linux / procps v1.2.9:
770 dnl FLAGS UID PID PPID PRI NI SIZE RSS WCHAN STA TTY TIME COMMAND
771 dnl 100 0 1 0 0 0 776 76 c0131c8c S ffff 0:11 init [2]
772 dnl
773 elif ps laxnwww 2>/dev/null | \
774 egrep -i ["^ *F(LAGS)? +UID +PID +PPID +PRI +NI +(VSZ)|(SIZE) +RSS +WCHAN +STAT? TTY +TIME +COMMAND"] >/dev/null
775 then
776 ac_cv_ps_varlist="[&procuid,&procpid,&procppid,procstat,&procvsz,&procrss,&pos,procprog]"
777 ac_cv_ps_command="$PATH_TO_PS laxnwww"
778 ac_cv_ps_format="%*s %d %d %d %*s %*s %d %d %*s %s %*s %*s %n%s"
779 ac_cv_ps_cols=9
780 AC_MSG_RESULT([$ac_cv_ps_command])
782 dnl OpenBSD (needs to come early because -exo appears to work, but does not give all procs)
783 elif ps -axo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
784 egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[PID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null
785 then
786 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
787 ac_cv_ps_command="$PATH_TO_PS -axo 'stat uid pid ppid vsz rss pcpu comm args'"
788 ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
789 ac_cv_ps_cols=9
790 AC_MSG_RESULT([$ac_cv_ps_command])
792 dnl Tru64 - needs %*[ +<>] in PS_FORMAT.
793 dnl Has /usr/bin/ps and /sbin/ps - force sbin version
794 dnl Can't use vsize and rssize because comes back with text (eg, 1.5M instead
795 dnl of 1500). Will need big changes to check_procs to support
796 elif /sbin/ps -eo 'stat uid pid ppid pcpu etime comm args' 2>/dev/null | \
797 egrep -i ["^ *S +[UID]+ +[PID]+ +[PID]+ +[%CPU]+ +[ELAPSD]+ +[COMMAND]+ +[COMMAND]+"] > /dev/null
798 then
799 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procpcpu,procetime,procprog,&pos]"
800 ac_cv_ps_command="/sbin/ps -eo 'stat uid pid ppid pcpu etime comm args'"
801 ac_cv_ps_format=["%s%*[ +<>] %d %d %d %f %s %s %n"]
802 ac_cv_ps_cols=8
803 AC_MSG_RESULT([$ac_cv_ps_command])
805 elif ps -eo 's comm vsz rss user uid pid ppid args' 2>/dev/null | \
806 egrep -i ["^S[TAUES]* +C[OMDNA]+ +[VSIZE]+ +U[SER]+ +U[ID]+ +P[PID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null
807 then
808 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
809 ac_cv_ps_command="$PATH_TO_PS -eo 's uid pid ppid vsz rss pcpu comm args'"
810 ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
811 ac_cv_ps_cols=9
812 AC_MSG_RESULT([$ac_cv_ps_command])
814 dnl AIX 4.3.3 and 5.1 do not have an rss field
815 elif ps -eo 'stat uid pid ppid vsz pcpu comm args' 2>/dev/null | \
816 egrep -i ["^ *S[TAUES]* +UID +PID +PPID +VSZ +%CPU +COMMAND +COMMAND"] >/dev/null
817 then
818 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procpcpu,procprog,&pos]"
819 ac_cv_ps_command="$PATH_TO_PS -eo 'stat uid pid ppid vsz pcpu comm args'"
820 ac_cv_ps_format="%s %d %d %d %d %f %s %n"
821 ac_cv_ps_cols=8
822 AC_MSG_RESULT([$ac_cv_ps_command - with no RSS])
824 dnl Solaris 2.6
825 elif ps -Ao 's comm vsz rss uid user pid ppid args' 2>/dev/null | \
826 egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
827 then
828 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
829 ac_cv_ps_command="$PATH_TO_PS -Ao 's uid pid ppid vsz rss pcpu comm args'"
830 # There must be no space between the %s and %n due to a wierd problem in sscanf where
831 # it will return %n as longer than the line length
832 ac_cv_ps_format="%s %d %d %d %d %d %f %s%n"
833 ac_cv_ps_cols=9
834 AC_MSG_RESULT([$ac_cv_ps_command])
836 elif ps -Ao 'status comm vsz rss uid user pid ppid args' 2>/dev/null | \
837 egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
838 then
839 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
840 ac_cv_ps_command="$PATH_TO_PS -Ao 'status uid pid ppid vsz rss pcpu comm args'"
841 ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
842 ac_cv_ps_cols=9
843 AC_MSG_RESULT([$ac_cv_ps_command])
845 elif ps -Ao 'state comm vsz rss uid user pid ppid args' 2>/dev/null | \
846 egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
847 then
848 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
849 ac_cv_ps_command="$PATH_TO_PS -Ao 'state uid pid ppid vsz rss pcpu comm args'"
850 ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
851 ac_cv_ps_cols=9
852 AC_MSG_RESULT([$ac_cv_ps_command])
854 dnl wonder who takes state instead of stat
855 elif ps -ao 'state command vsz rss user pid ppid args' 2>/dev/null | \
856 egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
857 then
858 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
859 ac_cv_ps_command="$PATH_TO_PS -ao 'state uid pid ppid vsz rss pcpu command args'"
860 ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
861 ac_cv_ps_cols=8
862 AC_MSG_RESULT([$ac_cv_ps_command])
864 dnl IRIX 53
865 elif ps -el 2>/dev/null | \
866 egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
867 then
868 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&pos,procprog]"
869 ac_cv_ps_command="$PATH_TO_PS -el (IRIX 53)"
870 ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %d %d %*s %*s %*s %n%s"
871 ac_cv_ps_cols=8
872 AC_MSG_RESULT([$ac_cv_ps_command])
874 dnl IRIX 63
875 elif ps -el 2>/dev/null | \
876 egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +ADDR +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
877 then
878 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
879 ac_cv_ps_command="$PATH_TO_PS -el (IRIX 63)"
880 ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
881 ac_cv_ps_cols=6
882 AC_MSG_RESULT([$ac_cv_ps_command])
884 dnl AIX 4.1:
885 dnl F S UID PID PPID C PRI NI ADDR SZ RSS WCHAN TTY TIME CMD
886 dnl 303 A 0 0 0 120 16 -- 1c07 20 24 - 0:45 swapper
887 elif ps -el 2>/dev/null | \
888 egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +ADDR +SZ +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
889 then
890 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
891 ac_cv_ps_command="$PATH_TO_PS -el (AIX 4.1 and HP-UX)"
892 ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
893 ac_cv_ps_cols=6
894 AC_MSG_RESULT([$ac_cv_ps_command])
896 dnl AIX?
897 elif ps glaxen 2>/dev/null | \
898 egrep -i ["^ *F +UID +PID +PPID +PRI +NI +VSZ +RSS +WCHAN +STAT +TTY +TIME +COMMAND"] >/dev/null
899 then
900 ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]"
901 ac_cv_ps_command="$PATH_TO_PS glaxen"
902 ac_cv_ps_format="%*s %d %d %d %*s %*s %d %d %*s %s %*s %*s %n%s"
903 ac_cv_ps_cols=8
904 AC_MSG_RESULT([$ac_cv_ps_command])
906 dnl MacOSX / Darwin
907 dnl TODO: MacOSX has commands with spaces which will cause problems to PS_FORMAT
908 dnl Some truncation will happen in UCOMM column
909 dnl STAT VSZ RSS UID PPID %CPU UCOMM COMMAND
910 dnl Ss 52756 22496 501 1 6.9 Window Manager /System/Library/CoreServices/WindowServer -daemon
911 elif ps wwaxo 'state vsz rss uid pid ppid pcpu ucomm command' 2>/dev/null | \
912 egrep -i ["^STAT +VSZ +RSS +UID +PPID +%CPU +UCOMM +COMMAND"] >/dev/null
913 then
914 ac_cv_ps_command="$PATH_TO_PS wwaxo 'state vsz rss uid pid ppid pcpu ucomm command'"
915 ac_cv_ps_varlist="[procstat,&procvsz,&procrss,&procuid,&procpid,&procppid,&procpcpu,procprog,&pos]"
916 ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
917 ac_cv_ps_cols=8
918 AC_MSG_RESULT([$ac_cv_ps_command])
920 dnl UnixWare
921 elif ps -Al 2>/dev/null | \
922 egrep -i ["^ *F +S +UID +PID +PPID +CLS +PRI +NI +C +ADDR +SZ +WCHAN +TTY +TIME +COMD"] >/dev/null
923 then
924 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
925 ac_cv_ps_command="$PATH_TO_PS -Al"
926 ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
927 ac_cv_ps_cols=8
928 AC_MSG_RESULT([$ac_cv_ps_command])
930 else
931 AC_MSG_WARN([unable to find usable ps syntax - check_procs and check_nagios will not be compiled])
932 fi
934 if test -n "$ac_cv_ps_varlist" ; then
935 AC_DEFINE_UNQUOTED(PS_VARLIST,$ac_cv_ps_varlist,
936 [Variable list for sscanf of 'ps' output])
937 AC_DEFINE_UNQUOTED(PS_COMMAND,"$ac_cv_ps_command",
938 [Verbatim command to execute for ps in check_procs])
939 AC_DEFINE_UNQUOTED(PS_FORMAT,"$ac_cv_ps_format",
940 [Format string for scanning ps output in check_procs])
941 AC_DEFINE_UNQUOTED(PS_COLS,$ac_cv_ps_cols,
942 [Number of columns in ps command])
943 EXTRAS="$EXTRAS check_procs check_nagios"
944 if echo "$ac_cv_ps_varlist" | grep -q "procetime"; then
945 AC_DEFINE(PS_USES_PROCETIME,"yes",
946 [Whether the ps utility uses the "procetime" field])
947 fi
948 fi
950 AC_PATH_PROG(PATH_TO_PING,ping)
951 AC_PATH_PROG(PATH_TO_PING6,ping6)
953 AC_ARG_WITH(ping_command,
954 ACX_HELP_STRING([--with-ping-command=SYNTAX],
955 [sets syntax for ICMP ping]),
956 with_ping_command=$withval,)
958 AC_MSG_CHECKING(for ICMP ping syntax)
959 ac_cv_ping_packets_first=no
960 ac_cv_ping_has_timeout=no
961 if test -n "$with_ping_command"
962 then
963 AC_MSG_RESULT([(command-line) $with_ping_command])
964 if test -n "$ac_cv_ping_packets_first"
965 then
966 ac_cv_ping_packets_first=yes
967 ac_cv_ping_has_timeout=yes
968 fi
970 elif [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
971 $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
972 egrep -i "^round-trip|^rtt" >/dev/null
973 then
974 with_ping_command="$PATH_TO_PING -n -U -c %d %s"
975 ac_cv_ping_packets_first=yes
976 AC_MSG_RESULT([$with_ping_command])
978 elif $PATH_TO_PING -n -U -w 10 -c 1 127.0.0.1 2>/dev/null | \
979 egrep -i "^round-trip|^rtt" >/dev/null
980 then
981 with_ping_command="$PATH_TO_PING -n -U -w %d -c %d %s"
982 ac_cv_ping_packets_first=yes
983 ac_cv_ping_has_timeout=yes
984 AC_MSG_RESULT([$with_ping_command])
986 elif $PATH_TO_PING -n -U -c 1 127.0.0.1 2>/dev/null | \
987 egrep -i "^round-trip|^rtt" >/dev/null
988 then
989 with_ping_command="$PATH_TO_PING -n -U -c %d %s"
990 ac_cv_ping_packets_first=yes
991 AC_MSG_RESULT([$with_ping_command])
993 elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \
994 egrep -i "^round-trip|^rtt" >/dev/null
995 then
996 with_ping_command="$PATH_TO_PING -n -c %d %s"
997 ac_cv_ping_packets_first=yes
998 AC_MSG_RESULT([$with_ping_command])
1000 elif $PATH_TO_PING -n 127.0.0.1 -c 1 2>/dev/null | \
1001 egrep -i "^round-trip|^rtt" >/dev/null
1002 then
1003 with_ping_command="$PATH_TO_PING -n %s -c %d"
1004 AC_MSG_RESULT([$with_ping_command])
1006 elif $PATH_TO_PING 127.0.0.1 -n 1 2>/dev/null | \
1007 egrep -i "^round-trip|^rtt" >/dev/null
1008 then
1009 with_ping_command="$PATH_TO_PING %s -n %d"
1010 AC_MSG_RESULT([$with_ping_command])
1012 elif $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
1013 egrep -i "^round-trip|^rtt" >/dev/null
1014 then
1015 with_ping_command="$PATH_TO_PING -n -s %s 56 %d"
1016 AC_MSG_RESULT([$with_ping_command])
1018 elif $PATH_TO_PING -n -h 127.0.0.1 -s 56 -c 1 2>/dev/null | \
1019 egrep -i "^round-trip|^rtt" >/dev/null
1020 then
1021 with_ping_command="$PATH_TO_PING -n -h %s -s 56 -c %d"
1022 AC_MSG_RESULT([$with_ping_command])
1024 elif $PATH_TO_PING -n -s 56 -c 1 127.0.0.1 2>/dev/null | \
1025 egrep -i "^round-trip|^rtt" >/dev/null
1026 then
1027 with_ping_command="$PATH_TO_PING -n -s 56 -c %d %s"
1028 ac_cv_ping_packets_first=yes
1029 AC_MSG_RESULT([$with_ping_command])
1031 elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \
1032 egrep -i "^round-trip|^rtt" >/dev/null
1033 then
1034 with_ping_command="$PATH_TO_PING -n -c %d %s"
1035 ac_cv_ping_packets_first=yes
1036 AC_MSG_RESULT([$with_ping_command])
1038 else
1039 AC_MSG_WARN([unable to find usable ping syntax])
1040 fi
1042 AC_DEFINE_UNQUOTED(PING_COMMAND,"$with_ping_command",
1043 [path and args for ICMP ping command])
1045 if test "x$ac_cv_ping_packets_first" != "xno"
1046 then
1047 AC_DEFINE(PING_PACKETS_FIRST,1,
1048 [Define if packet count must precede host])
1049 fi
1051 if test "x$ac_cv_ping_has_timeout" != "xno"
1052 then
1053 AC_DEFINE(PING_HAS_TIMEOUT,1,
1054 [Define if ping has its own timeout option that should be set])
1055 fi
1057 AC_ARG_WITH(ping6_command,
1058 ACX_HELP_STRING([--with-ping6-command=SYNTAX],
1059 [sets syntax for ICMPv6 ping]),
1060 with_ping6_command=$withval,)
1062 if test x"$with_ipv6" != xno ; then
1063 AC_MSG_CHECKING(for ICMPv6 ping syntax)
1064 ac_cv_ping6_packets_first=no
1065 if test -n "$with_ping6_command"
1066 then
1067 AC_MSG_RESULT([(command-line) $with_ping6_command])
1068 if test -n "$ac_cv_ping6_packets_first"
1069 then
1070 ac_cv_ping6_packets_first=yes
1071 fi
1073 elif test "x$PATH_TO_PING6" != "x"; then
1074 if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
1075 $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \
1076 egrep -i "^round-trip|^rtt" >/dev/null
1077 then
1078 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s"
1079 ac_cv_ping6_packets_first=yes
1080 AC_MSG_RESULT([$with_ping6_command])
1082 elif $PATH_TO_PING6 -n -U -w 10 -c 1 ::1 2>/dev/null | \
1083 egrep -i "^round-trip|^rtt" >/dev/null
1084 then
1085 with_ping6_command="$PATH_TO_PING6 -n -U -w %d -c %d %s"
1086 ac_cv_ping6_packets_first=yes
1087 ac_cv_ping_has_timeout=yes
1088 AC_MSG_RESULT([$with_ping6_command])
1090 elif $PATH_TO_PING6 -n -U -c 1 ::1 2>/dev/null | \
1091 egrep -i "^round-trip|^rtt" >/dev/null
1092 then
1093 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s"
1094 ac_cv_ping6_packets_first=yes
1095 AC_MSG_RESULT([$with_ping6_command])
1097 elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \
1098 egrep -i "^round-trip|^rtt" >/dev/null
1099 then
1100 with_ping6_command="$PATH_TO_PING6 -n -c %d %s"
1101 ac_cv_ping6_packets_first=yes
1102 AC_MSG_RESULT([$with_ping6_command])
1104 elif $PATH_TO_PING6 -n ::1 -c 1 2>/dev/null | \
1105 egrep -i "^round-trip|^rtt" >/dev/null
1106 then
1107 with_ping6_command="$PATH_TO_PING6 -n %s -c %d"
1108 AC_MSG_RESULT([$with_ping6_command])
1110 elif $PATH_TO_PING6 ::1 -n 1 2>/dev/null | \
1111 egrep -i "^round-trip|^rtt" >/dev/null
1112 then
1113 with_ping6_command="$PATH_TO_PING6 %s -n %d"
1114 AC_MSG_RESULT([$with_ping6_command])
1116 elif $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \
1117 egrep -i "^round-trip|^rtt" >/dev/null
1118 then
1119 with_ping6_command="$PATH_TO_PING6 -n -s %s 56 %d"
1120 AC_MSG_RESULT([$with_ping6_command])
1122 elif $PATH_TO_PING6 -n -h ::1 -s 56 -c 1 2>/dev/null | \
1123 egrep -i "^round-trip|^rtt" >/dev/null
1124 then
1125 with_ping6_command="$PATH_TO_PING6 -n -h %s -s 56 -c %d"
1126 AC_MSG_RESULT([$with_ping6_command])
1128 elif $PATH_TO_PING6 -n -s 56 -c 1 ::1 2>/dev/null | \
1129 egrep -i "^round-trip|^rtt" >/dev/null
1130 then
1131 with_ping6_command="$PATH_TO_PING6 -n -s 56 -c %d %s"
1132 ac_cv_ping6_packets_first=yes
1133 AC_MSG_RESULT([$with_ping_command])
1135 elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \
1136 egrep -i "^round-trip|^rtt" >/dev/null
1137 then
1138 with_ping6_command="$PATH_TO_PING6 -n -c %d %s"
1139 ac_cv_ping6_packets_first=yes
1140 AC_MSG_RESULT([$with_ping6_command])
1142 fi
1144 elif test "x$PATH_TO_PING" != "x"; then
1145 if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
1146 $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \
1147 egrep -i "^round-trip|^rtt" >/dev/null
1148 then
1149 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s"
1150 ac_cv_ping6_packets_first=yes
1151 AC_MSG_RESULT([$with_ping6_command])
1153 elif $PATH_TO_PING -A inet6 -n -U -c 1 ::1 2>/dev/null | \
1154 egrep -i "^round-trip|^rtt" >/dev/null
1155 then
1156 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s"
1157 ac_cv_ping6_packets_first=yes
1158 AC_MSG_RESULT([$with_ping6_command])
1160 elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \
1161 egrep -i "^round-trip|^rtt" >/dev/null
1162 then
1163 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s"
1164 ac_cv_ping6_packets_first=yes
1165 AC_MSG_RESULT([$with_ping6_command])
1167 elif $PATH_TO_PING -A inet6 -n ::1 -c 1 2>/dev/null | \
1168 egrep -i "^round-trip|^rtt" >/dev/null
1169 then
1170 with_ping6_command="$PATH_TO_PING -A inet6 -n %s -c %d"
1171 AC_MSG_RESULT([$with_ping6_command])
1173 elif $PATH_TO_PING -A inet6 ::1 -n 1 2>/dev/null | \
1174 egrep -i "^round-trip|^rtt" >/dev/null
1175 then
1176 with_ping6_command="$PATH_TO_PING -A inet6 %s -n %d"
1177 AC_MSG_RESULT([$with_ping6_command])
1179 elif $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \
1180 egrep -i "^round-trip|^rtt" >/dev/null
1181 then
1182 with_ping6_command="$PATH_TO_PING -A inet6 -n -s %s 56 %d"
1183 AC_MSG_RESULT([$with_ping6_command])
1185 elif $PATH_TO_PING -A inet6 -n -h ::1 -s 56 -c 1 2>/dev/null | \
1186 egrep -i "^round-trip|^rtt" >/dev/null
1187 then
1188 with_ping6_command="$PATH_TO_PING -A inet6 -n -h %s -s 56 -c %d"
1189 AC_MSG_RESULT([$with_ping6_command])
1191 elif $PATH_TO_PING -A inet6 -n -s 56 -c 1 ::1 2>/dev/null | \
1192 egrep -i "^round-trip|^rtt" >/dev/null
1193 then
1194 with_ping6_command="$PATH_TO_PING -A inet6 -n -s 56 -c %d %s"
1195 ac_cv_ping6_packets_first=yes
1196 AC_MSG_RESULT([$with_ping_command])
1198 elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \
1199 egrep -i "^round-trip|^rtt" >/dev/null
1200 then
1201 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s"
1202 ac_cv_ping6_packets_first=yes
1203 AC_MSG_RESULT([$with_ping6_command])
1205 fi
1207 fi
1209 if test "x$with_ping6_command" != "x"; then
1210 AC_DEFINE_UNQUOTED(PING6_COMMAND,"$with_ping6_command",
1211 [path and args for ICMPv6 ping command])
1212 else
1213 AC_MSG_RESULT([none])
1214 fi
1216 if test "x$ac_cv_ping6_packets_first" != "xno"; then
1217 AC_DEFINE(PING6_PACKETS_FIRST,1,
1218 [Define if packet count must precede host])
1219 fi
1220 fi
1223 AC_ARG_WITH(nslookup_command,
1224 ACX_HELP_STRING([--with-nslookup-command=PATH],
1225 [sets path to nslookup executable]),
1226 ac_cv_nslookup_command=$withval)
1227 if test -n "$ac_cv_nslookup_command"; then
1228 AC_MSG_NOTICE([Using specific nslookup at $ac_cv_nslookup_command])
1229 else
1230 AC_PATH_PROG(PATH_TO_NSLOOKUP,nslookup)
1231 if test -n "$PATH_TO_NSLOOKUP"
1232 then
1233 AC_MSG_CHECKING(for nslookup syntax)
1234 if $PATH_TO_NSLOOKUP -sil 127.0.0.1 2>&1 | grep ["Invalid option: sil"] >/dev/null
1235 then
1236 ac_cv_nslookup_command="$PATH_TO_NSLOOKUP"
1237 AC_MSG_RESULT([$ac_cv_nslookup_command])
1239 else
1240 ac_cv_nslookup_command="$PATH_TO_NSLOOKUP -sil"
1241 AC_MSG_RESULT([$ac_cv_nslookup_command])
1243 fi
1244 else
1245 AC_MSG_WARN([nslookup command not found])
1246 fi
1247 fi
1249 if test -n "$ac_cv_nslookup_command"; then
1250 EXTRAS="$EXTRAS check_dns"
1251 AC_DEFINE_UNQUOTED(NSLOOKUP_COMMAND,"$ac_cv_nslookup_command", [path and args for nslookup])
1252 fi
1254 AC_PATH_PROG(PATH_TO_UPTIME,uptime)
1255 AC_ARG_WITH(uptime_command,
1256 ACX_HELP_STRING([--with-uptime-command=PATH],
1257 [sets path to uptime]), PATH_TO_UPTIME=$withval)
1258 AC_DEFINE_UNQUOTED(PATH_TO_UPTIME,"$PATH_TO_UPTIME",[path to uptime binary])
1260 AC_PATH_PROG(PATH_TO_RPCINFO,rpcinfo)
1261 AC_ARG_WITH(rpcinfo_command,
1262 ACX_HELP_STRING([--with-rpcinfo-command=PATH],
1263 [sets path to rpcinfo]), PATH_TO_RPCINFO=$withval)
1264 AC_DEFINE_UNQUOTED(PATH_TO_RPCINFO,"$PATH_TO_RPCINFO",[path to rpcinfo binary])
1266 AC_PATH_PROG(PATH_TO_NTPDATE,ntpdate)
1267 AC_ARG_WITH(ntpdate_command,
1268 ACX_HELP_STRING([--with-ntpdate-command=PATH],
1269 [sets path to ntpdate]), PATH_TO_NTPDATE=$withval)
1270 AC_PATH_PROGS(PATH_TO_NTPDC,ntpdc xntpdc)
1271 AC_PATH_PROGS(PATH_TO_NTPQ,ntpq)
1272 if (test -n "$PATH_TO_NTPDATE" || test -n "$PATH_TO_NTPQ")
1273 then
1274 AC_DEFINE_UNQUOTED(PATH_TO_NTPQ,"$PATH_TO_NTPQ",[path to ntpq binary])
1275 AC_DEFINE_UNQUOTED(PATH_TO_NTPDATE,"$PATH_TO_NTPDATE",[path to ntpdate binary])
1276 else
1277 AC_MSG_WARN([Install NTP programs (http://www.ntp.org) if you want to monitor time synchronization])
1278 fi
1280 AC_PATH_PROG(PATH_TO_LMSTAT,lmstat)
1281 if test -x "$PATH_TO_LMSTAT"
1282 then
1283 AC_DEFINE_UNQUOTED(PATH_TO_LMSTAT,"$PATH_TO_LMSTAT",[path to lmstat])
1284 else
1285 AC_MSG_WARN([Get lmstat from Globetrotter Software to monitor flexlm licenses])
1286 fi
1288 AC_PATH_PROG(PATH_TO_SMBCLIENT,smbclient)
1289 AC_ARG_WITH(smbclient_command,
1290 ACX_HELP_STRING([--with-smbclient-command=PATH],
1291 [sets path to smbclient]),
1292 PATH_TO_SMBCLIENT=$withval)
1293 if test -n "$PATH_TO_SMBCLIENT"
1294 then
1295 AC_DEFINE_UNQUOTED(PATH_TO_SMBCLIENT,"$PATH_TO_SMBCLIENT",[path to smbclient binary])
1296 else
1297 AC_MSG_WARN([Get smbclient from Samba.org to monitor SMB shares])
1298 fi
1301 AC_PATH_PROG(PATH_TO_WHO,who)
1303 if [$PATH_TO_WHO -q 2>/dev/null | egrep -i "^# users=[0-9]+$" >/dev/null]
1304 then
1305 ac_cv_path_to_who="$PATH_TO_WHO -q"
1306 else
1307 ac_cv_path_to_who="$PATH_TO_WHO"
1308 fi
1310 AC_DEFINE_UNQUOTED(WHO_COMMAND,"$ac_cv_path_to_who",
1311 [path and arguments for invoking 'who'])
1313 AC_PATH_PROG(PATH_TO_SNMPGET,snmpget)
1314 AC_ARG_WITH(snmpget_command,
1315 ACX_HELP_STRING([--with-snmpget-command=PATH],
1316 [Path to snmpget command]),
1317 PATH_TO_SNMPGET=$withval)
1318 if test -n "$PATH_TO_SNMPGET"
1319 then
1320 AC_DEFINE_UNQUOTED(PATH_TO_SNMPGET,"$PATH_TO_SNMPGET",[path to snmpget binary])
1321 EXTRAS="$EXTRAS check_hpjd check_snmp"
1322 else
1323 AC_MSG_WARN([Get snmpget from http://net-snmp.sourceforge.net to make check_hpjd and check_snmp plugins])
1324 fi
1326 AC_PATH_PROG(PATH_TO_SNMPGETNEXT,snmpgetnext)
1327 AC_ARG_WITH(snmpgetnext_command,
1328 ACX_HELP_STRING([--with-snmpgetnext-command=PATH],
1329 [Path to snmpgetnext command]),
1330 PATH_TO_SNMPGETNEXT=$withval)
1331 if test -n "$PATH_TO_SNMPGETNEXT"
1332 then
1333 AC_DEFINE_UNQUOTED(PATH_TO_SNMPGETNEXT,"$PATH_TO_SNMPGETNEXT",[path to snmpgetnext binary])
1334 fi
1336 if ( $PERL -M"Net::SNMP 3.6" -e 'exit' 2>/dev/null )
1337 then
1338 AC_MSG_CHECKING(for Net::SNMP perl module)
1339 AC_MSG_RESULT([found])
1340 else
1341 AC_MSG_WARN([Tried $PERL - install Net::SNMP perl module if you want to use the perl snmp plugins])
1342 fi
1344 AC_PATH_PROG(PATH_TO_QUAKESTAT,quakestat)
1345 AC_PATH_PROG(PATH_TO_QSTAT,qstat)
1346 AC_ARG_WITH(qstat_command,
1347 ACX_HELP_STRING([--with-qstat-command=PATH],
1348 [Path to qstat command]), PATH_TO_QSTAT=$withval)
1350 if test -x "$PATH_TO_QUAKESTAT"
1351 then
1352 ac_cv_path_to_qstat="$PATH_TO_QUAKESTAT"
1353 EXTRAS="$EXTRAS check_game"
1355 elif test -n "$PATH_TO_QSTAT"
1356 then
1357 ac_cv_path_to_qstat="$PATH_TO_QSTAT"
1358 EXTRAS="$EXTRAS check_game"
1359 else
1360 AC_MSG_WARN([Get qstat from http://www.activesw.com/people/steve/qstat.html in order to make check_game plugin])
1361 fi
1363 if test $ac_cv_path_to_qstat
1364 then
1365 AC_DEFINE_UNQUOTED(PATH_TO_QSTAT,"$ac_cv_path_to_qstat",
1366 [path to qstat/quakestat])
1367 fi
1369 AC_PATH_PROG(PATH_TO_FPING,fping)
1370 AC_ARG_WITH(fping_command,
1371 ACX_HELP_STRING([--with-fping-command=PATH],
1372 [Path to fping command]), PATH_TO_FPING=$withval)
1373 if test -n "$PATH_TO_FPING"
1374 then
1375 AC_DEFINE_UNQUOTED(PATH_TO_FPING,"$PATH_TO_FPING",[path to fping])
1376 EXTRAS="$EXTRAS check_fping"
1377 else
1378 AC_MSG_WARN([Get fping from http://www.fping.com in order to make check_fping plugin])
1379 fi
1381 AC_PATH_PROG(PATH_TO_SSH,ssh)
1382 AC_ARG_WITH(ssh_command,
1383 ACX_HELP_STRING([--with-ssh-command=PATH],
1384 [sets path for ssh]), PATH_TO_SSH=$withval)
1385 if test -n "$PATH_TO_SSH"
1386 then
1387 AC_DEFINE_UNQUOTED(SSH_COMMAND,"$PATH_TO_SSH",[path to ssh binary])
1388 EXTRAS="$EXTRAS check_by_ssh"
1389 else
1390 AC_MSG_WARN([Get ssh in order to make check_by_ssh plugin])
1391 fi
1394 AC_PATH_PROG(PATH_TO_MAILQ,mailq)
1395 AC_ARG_WITH(mailq_command,
1396 ACX_HELP_STRING([--with-mailq-command=PATH],
1397 [sets path to mailq]), PATH_TO_MAILQ=$withval)
1398 if test -n "$PATH_TO_MAILQ"
1399 then
1400 AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_MAILQ",[path to mailq])
1401 else
1402 AC_MSG_WARN([Could not find mailq or eqivalent])
1403 fi
1405 AC_PATH_PROG(PATH_TO_QMAIL_QSTAT,qmail-qstat)
1406 if test -x "$PATH_TO_QMAIL_QSTAT"
1407 then
1408 AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_QMAIL_QSTAT",[path to qmail-qstat])
1409 else
1410 AC_MSG_WARN([Could not find qmail-qstat or eqivalent])
1411 fi
1413 dnl SWAP info required is amount allocated/available and amount free
1414 dnl The plugin works through all the swap devices and adds up the total swap
1415 dnl available.
1416 AC_PATH_PROG(PATH_TO_SWAP,swap)
1417 if (test -n "$PATH_TO_SWAP")
1418 then
1419 AC_MSG_CHECKING([for $PATH_TO_SWAP format])
1420 if [$PATH_TO_SWAP -l 2>&1 >/dev/null]
1421 then
1422 ac_cv_have_swap=yes
1423 ac_cv_swap_command="$PATH_TO_SWAP -l"
1424 if [$PATH_TO_SWAP -l 2>/dev/null | \
1425 egrep -i "^lswap +path +pri +swaplo +blocks +free +maxswap" \
1426 >/dev/null]
1427 then
1428 ac_cv_swap_format=[" %*d %*s %*d,%*d %*d %*d %f %f"]
1429 ac_cv_swap_conv=2048
1430 AC_MSG_RESULT([using IRIX format swap])
1432 elif [$PATH_TO_SWAP -l 2>/dev/null | egrep -i "^path +dev +swaplo +blocks +free" >/dev/null]
1433 then
1434 ac_cv_swap_format=["%*s %*[0-9,-] %*d %f %f"]
1435 ac_cv_swap_conv=2048
1436 AC_MSG_RESULT([using Unixware format swap])
1437 else
1438 dnl if we don't know what format swap's output is
1439 dnl we might as well pretend we didn't see it
1440 ac_cv_have_swap=""
1441 ac_cv_swap_command=""
1442 fi
1443 fi
1444 dnl end if for PATH_TO_SWAP
1445 fi
1447 AC_PATH_PROG(PATH_TO_SWAPINFO,swapinfo)
1448 if (test -n "$PATH_TO_SWAPINFO")
1449 then
1450 AC_MSG_CHECKING([for $PATH_TO_SWAPINFO format])
1451 if [$PATH_TO_SWAPINFO -k 2>&1 | egrep -i "^Device" >/dev/null]
1452 then
1453 ac_cv_have_swap=yes
1454 ac_cv_swap_command="$PATH_TO_SWAPINFO -k"
1456 if [$PATH_TO_SWAPINFO -k 2>/dev/null | egrep -i "^Device +1K-blocks +Used +Avail" >/dev/null]
1457 then
1458 ac_cv_swap_format=["%*s %f %*d %f"]
1459 ac_cv_swap_conv=1024
1460 AC_MSG_RESULT([using FreeBSD format swapinfo])
1461 fi
1463 elif [$PATH_TO_SWAPINFO -dfM 2>/dev/null | egrep -i "^TYPE +AVAIL +USED +FREE" >/dev/null]
1464 then
1465 ac_cv_have_swap=yes
1466 ac_cv_swap_command="$PATH_TO_SWAPINFO -dfM",
1467 ac_cv_swap_format=["%*s %f %*d %f"]
1468 ac_cv_swap_conv=1024
1469 AC_MSG_RESULT([using HP-UX format swapinfo])
1470 fi
1471 dnl end if for PATH_TO_SWAPINFO
1472 fi
1474 AC_PATH_PROG(PATH_TO_LSPS,lsps)
1475 if (test -n "$PATH_TO_LSPS")
1476 then
1477 AC_MSG_CHECKING([for $PATH_TO_LSPS format])
1478 if [$PATH_TO_LSPS -a 2>/dev/null | egrep -i "^Page Space" > /dev/null]
1479 then
1480 ac_cv_have_swap=yes
1481 ac_cv_swap_command="$PATH_TO_LSPS -a"
1482 ac_cv_swap_format=["%*s %*s %*s %f%*s %f %*s"]
1483 ac_cv_swap_conv=1
1484 AC_MSG_RESULT([using AIX lsps])
1485 fi
1486 dnl end if for PATH_TO_SWAPINFO
1487 fi
1489 dnl
1490 dnl test for swapctl system call, both the 2-arg and 3-arg variants
1491 dnl fwict, the 2-arg is an SVR4 standard, whereas the 3-arg is shared
1492 dnl in the various BSD's
1493 dnl
1495 AC_CHECK_HEADERS([sys/stat.h sys/param.h])
1496 AC_CHECK_HEADERS([sys/swap.h], [], [], [
1497 #ifdef HAVE_SYS_PARAM_H
1498 #include <sys/param.h>
1499 #endif
1500 ])
1501 AC_CHECK_DECLS([swapctl],,,[
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 ])
1508 AC_CHECK_TYPES([swaptbl_t, swapent_t],,,[
1509 #include <sys/types.h>
1510 #include <sys/param.h>
1511 #include <sys/stat.h>
1512 #include <sys/swap.h>
1513 ])
1514 AC_CHECK_MEMBERS([struct swapent.se_nblks],,,[
1515 #include <unistd.h>
1516 #include <sys/types.h>
1517 #include <sys/param.h>
1518 #include <sys/stat.h>
1519 #include <sys/swap.h>
1520 ])
1522 if test "$ac_cv_have_decl_swapctl" = "yes";
1523 then
1524 EXTRAS="$EXTRAS check_swap"
1525 AC_MSG_CHECKING([for 2-arg (SVR4) swapctl])
1526 if test "$ac_cv_type_swaptbl_t" = "yes" -a \
1527 "$ac_cv_type_swapent_t" = "yes";
1528 then
1529 AC_MSG_RESULT([yes])
1530 ac_cv_check_swap_swapctl_svr4="1";
1531 AC_DEFINE([CHECK_SWAP_SWAPCTL_SVR4],1,
1532 [Define if 2-argument SVR4 swapctl exists])
1533 else
1534 AC_MSG_RESULT([no])
1535 AC_MSG_CHECKING([for 3-arg (*BSD) swapctl])
1536 if test "$ac_cv_member_struct_swapent_se_nblks" = "yes";
1537 then
1538 AC_MSG_RESULT([yes])
1539 AC_DEFINE([CHECK_SWAP_SWAPCTL_BSD],1,
1540 [Define if 3-argument BSD swapctl exists])
1541 else
1542 AC_MSG_RESULT([no])
1543 fi
1544 fi
1545 AC_MSG_CHECKING([for whether swapctl uses blocks or pages])
1546 if test "$ac_cv_check_swap_swapctl_svr4" = "1";
1547 then
1548 dnl
1549 dnl the SVR4 spec returns values in pages
1550 dnl
1551 AC_MSG_RESULT([page])
1552 AC_CHECK_DECLS([sysconf])
1553 AC_MSG_CHECKING([for system page size])
1554 if test "$ac_cv_have_decl_sysconf" = "yes";
1555 then
1556 AC_MSG_RESULT([determined by sysconf(3)])
1557 ac_cv_swap_conv="(1048576/sysconf(_SC_PAGESIZE))"
1558 else
1559 AC_MSG_WARN([don't know. guessing 4096k])
1560 ac_cv_swap_conv=256
1561 fi
1562 else
1563 dnl
1564 dnl the BSD spec returns values in blocks
1565 dnl
1566 AC_MSG_RESULT([blocks (assuming 512b)])
1567 ac_cv_swap_conv=2048
1568 fi
1569 AC_DEFINE_UNQUOTED(SWAP_CONVERSION,$ac_cv_swap_conv,
1570 [Conversion factor to MB])
1571 fi
1572 dnl
1573 dnl end tests for the swapctl system calls
1574 dnl
1577 if test "x$ac_cv_have_swap" != "x"
1578 then
1579 AC_DEFINE(HAVE_SWAP,1,[Define if swap/swapinfo command is found])
1580 EXTRAS="$EXTRAS check_swap"
1581 fi
1582 if test "x$ac_cv_swap_command" != "x"
1583 then
1584 AC_DEFINE_UNQUOTED(SWAP_COMMAND,"$ac_cv_swap_command",
1585 [Path to swap/swapinfo binary, with any args])
1586 AC_DEFINE_UNQUOTED(SWAP_FORMAT,"$ac_cv_swap_format",
1587 [Format string for parsing swap output])
1588 AC_DEFINE_UNQUOTED(SWAP_CONVERSION,$ac_cv_swap_conv,
1589 [Conversion factor to MB])
1590 fi
1592 AC_ARG_WITH(proc-meminfo,
1593 ACX_HELP_STRING([--with-proc-meminfo=PATH],
1594 [path to /proc/meminfo or equivalent]),
1595 ac_cv_proc_meminfo=$withval)
1596 dnl dunno why this does not work below - use hack (kbd)
1597 dnl fine on linux, broken on solaris
1598 dnl if /bin/test -e "/proc/meminfo"
1599 AC_MSG_CHECKING([for /proc/meminfo])
1600 if test -n "$ac_cv_proc_meminfo"; then
1601 AC_MSG_RESULT([(command line) $ac_cv_proc_meminfo])
1602 elif [cat /proc/meminfo > /dev/null 2>&1]; then
1603 AC_MSG_RESULT([found /proc/meminfo])
1604 ac_cv_proc_meminfo="/proc/meminfo"
1605 else
1606 AC_MSG_RESULT([no])
1607 fi
1609 if test -n "$ac_cv_proc_meminfo"; then
1610 AC_DEFINE(HAVE_PROC_MEMINFO,1,[Define if we have /proc/meminfo])
1611 AC_DEFINE_UNQUOTED(PROC_MEMINFO,"$ac_cv_proc_meminfo",[path to /proc/meminfo if name changes])
1612 EXTRAS="$EXTRAS check_swap"
1613 fi
1615 AC_PATH_PROG(PATH_TO_DIG,dig)
1616 AC_ARG_WITH(dig_command,
1617 ACX_HELP_STRING([--with-dig-command=PATH],
1618 [Path to dig command]), PATH_TO_DIG=$withval)
1619 if test -n "$PATH_TO_DIG"; then
1620 EXTRAS="$EXTRAS check_dig"
1621 AC_DEFINE_UNQUOTED(PATH_TO_DIG,"$PATH_TO_DIG",[Path to dig command, if present])
1622 fi
1624 if test -f plugins/check_nt.c ; then
1625 EXTRAS="$EXTRAS check_nt"
1626 elif test -f ../plugins/check_nt.c ; then
1627 EXTRAS="$EXTRAS check_nt"
1628 fi
1630 AC_MSG_CHECKING(for va_list)
1631 AC_TRY_COMPILE([#ifdef __STDC__
1632 #include <stdio.h>
1633 #include <stdlib.h>
1634 #include <stdarg.h>
1635 #else
1636 #include <sys/types.h>
1637 #include <stdio.h>
1638 #include <varargs.h>
1639 #endif],
1640 [va_list args;],
1641 [AC_MSG_RESULT(yes)],
1642 [NEED_VA_LIST=-DNEED_VA_LIST AC_SUBST(NEED_VA_LIST) AC_MSG_RESULT(no)])
1644 case $host in
1645 *bsd*)
1646 AC_DEFINE(__bsd__,1,[bsd specific code in check_dhcp.c])
1647 ;;
1648 *linux*)
1649 AC_DEFINE(__linux__,1,[sun specific code in check_dhcp.c])
1650 ;;
1651 *sun* | solaris*)
1652 AC_DEFINE(__sun__,1,[sun specific code in check_dhcp.c])
1653 ;;
1654 *hpux*)
1655 AC_DEFINE(__hpux__,1,[hpux specific code in check_dhcp.c])
1656 ;;
1657 esac
1659 AC_SUBST(EXTRAS)
1660 AC_SUBST(EXTRAS_ROOT)
1661 AC_SUBST(EXTRA_NETOBJS)
1662 AC_SUBST(DEPLIBS)
1664 AM_GNU_GETTEXT([no-libtool], [need-ngettext])
1665 AM_GNU_GETTEXT_VERSION(0.11.5)
1667 dnl Check for Redhat spopen problem
1668 dnl Wierd problem where ECHILD is returned from a wait call in error
1669 dnl Only appears to affect nslookup and dig calls. Only affects redhat around
1670 dnl 2.6.9-11 (okay in 2.6.9-5). Redhat investigating root cause
1671 dnl We patch plugins/popen.c
1672 dnl Need to add smp because uname different on those
1673 dnl Can force patch to be applied with --enable-redhat-pthread-workaround
1674 AC_ARG_ENABLE(redhat-pthread-workaround,
1675 AC_HELP_STRING([--enable-redhat-pthread-workaround],
1676 [force Redhat patch to be applied (default: test system)]),
1677 [ac_cv_enable_redhat_pthread_workaround=$enableval],
1678 [ac_cv_enable_redhat_pthread_workaround=test])
1679 if test "$ac_cv_enable_redhat_pthread_workaround" = "test" ; then
1680 if echo $ac_cv_uname_r | egrep "\.EL(smp)?$" >/dev/null 2>&1 ; then
1681 AC_MSG_CHECKING(for redhat spopen problem)
1682 ( cd config_test && make && make test ) > /dev/null 2>&1
1683 if test $? -eq 0 ; then
1684 AC_MSG_RESULT(okay)
1685 else
1686 AC_MSG_RESULT(error)
1687 AC_DEFINE(REDHAT_SPOPEN_ERROR, 1, [Workaround on redhat in spopen])
1688 fi
1689 fi
1690 elif test "$ac_cv_enable_redhat_pthread_workaround" = "yes" ; then
1691 AC_DEFINE(REDHAT_SPOPEN_ERROR, 1, [Forced workaround on redhat in spopen])
1692 fi
1694 dnl External libraries - see ACKNOWLEDGEMENTS
1695 np_COREUTILS
1696 np_CURL
1698 AC_OUTPUT(
1699 Makefile
1700 lib/Makefile
1701 m4/Makefile
1702 plugins/Makefile
1703 plugins/tests/Makefile
1704 plugins-root/Makefile
1705 plugins-scripts/Makefile
1706 plugins-scripts/subst
1707 plugins-scripts/utils.pm
1708 plugins-scripts/utils.sh
1709 command.cfg
1710 test.pl
1711 pkg/solaris/pkginfo
1712 intl/Makefile
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 dnl ACX_FEATURE([with],[dig-command])
1722 dnl ACX_FEATURE([with],[fping-command])
1723 dnl ACX_FEATURE([with],[mailq-command])
1724 dnl ACX_FEATURE([with],[nslookup-command])
1725 dnl ACX_FEATURE([with],[ntpdate-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])