Code

parse_ini now reads the default section if the request one can't be found.
[nagiosplug.git] / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2 AC_REVISION ($Revision$)
3 AC_PREREQ(2.59)
4 AC_INIT(nagios-plugins,1.4.11)
5 AC_CONFIG_SRCDIR(NPTest.pm)
6 AC_CONFIG_FILES(gl/Makefile)
7 AC_CONFIG_AUX_DIR(build-aux)
8 AM_INIT_AUTOMAKE([1.8.3])
9 AM_CONFIG_HEADER(config.h)
10 AC_CANONICAL_HOST
12 RELEASE=1
13 AC_SUBST(RELEASE)
15 AC_PREFIX_DEFAULT(/usr/local/nagios)
17 dnl Deprecated configure options
20 dnl Append user (-o), group (-g), mode (-m) to install command
21 dnl There is an assumption that this is possible with ./configure's chosen install command
22 extra_install_args=""
23 AC_ARG_WITH(nagios_user,
24         ACX_HELP_STRING([--with-nagios-user=USER],
25                 [Installs executables with this user. Defaults to install user]),
26         extra_install_args="-o $withval")
27 AC_ARG_WITH(nagios_group,
28         ACX_HELP_STRING([--with-nagios-group=GROUP],
29                 [Installs executables with this group. Defaults to install user]),
30         extra_install_args="$extra_install_args -g $withval")
31 AC_ARG_WITH(world_permissions,
32         ACX_HELP_STRING([--without-world-permissions],
33                 [Installs executables without world permissions]))
35 if test "x$with_world_permissions" = xno ; then
36         extra_install_args="$extra_install_args -m 0550"
37 fi
39 INSTALL="$INSTALL $extra_install_args"
40 INSTALL_STRIP_PROGRAM="$INSTALL_STRIP_PROGRAM $extra_install_args"
41 AC_SUBST(INSTALL)
43 AC_PROG_CC
44 gl_EARLY
45 AC_PROG_GCC_TRADITIONAL
46 AC_PROG_LIBTOOL
48 AM_PROG_CC_C_O
50 AC_FUNC_ERROR_AT_LINE
51 AC_SYS_LARGEFILE
53 ifdef([AC_FUNC_STRTOD],[AC_FUNC_STRTOD],[AM_FUNC_STRTOD])
55 PLUGIN_TEST=`echo $srcdir/plugins/t/*.t|sed -e 's,\.*/plugins/,,g'`
56 AC_SUBST(PLUGIN_TEST)dnl
58 SCRIPT_TEST=`echo $srcdir/plugins-scripts/t/*.t|sed -e 's,\.*/plugins-scripts/,,g'`
59 AC_SUBST(SCRIPT_TEST)dnl
61 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"
62 AC_SUBST(WARRANTY)
64 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"
65 AC_SUBST(SUPPORT)
67 dnl CGIURL has changed for Nagios with 1.0 beta
68 AC_ARG_WITH(cgiurl,
69         ACX_HELP_STRING([--with-cgiurl=DIR],
70                 [sets URL for cgi programs]),
71         with_cgiurl=$withval,
72         with_cgiurl=/nagios/cgi-bin)
73 CGIURL="$with_cgiurl"
74 AC_DEFINE_UNQUOTED(CGIURL,"$CGIURL",[URL of CGI programs])
76 AC_ARG_WITH(trusted_path,
77         ACX_HELP_STRING([--with-trusted-path=PATH],
78                 [sets trusted path for executables called by scripts (default=/bin:/sbin:/usr/bin:/usr/sbin)]),
79         with_trusted_path=$withval,
80         with_trusted_path=/bin:/sbin:/usr/bin:/usr/sbin)
81 AC_SUBST(with_trusted_path)
83 EXTRAS=
84 EXTRAS_ROOT=
85 dnl PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/etc:/usr/local/bin:/usr/local/sbin:$PATH
87 LDFLAGS="$LDFLAGS -L."
89 ac_cv_uname_m=`uname -m`
90 ac_cv_uname_s=`uname -s`
91 ac_cv_uname_r=`uname -r`
92 ac_cv_uname_v=`uname -v`
94 PKG_ARCH=`uname -p`
95 REV_DATESTAMP=`date '+%Y.%m.%d.%H.%M'`
96 REV_TIMESTAMP=`date '+%Y%m%d%H%M%S'`
98 AC_SUBST(PKG_ARCH)
99 AC_SUBST(REV_DATESTAMP)
100 AC_SUBST(REV_TIMESTAMP)
102 dnl Checks for programs.
103 AC_PATH_PROG(PYTHON,python)
104 AC_PATH_PROG(SH,sh)
105 AC_PATH_PROG(PERL,perl)
106 AC_PATH_PROG(LIBGNUTLS_CONFIG,libgnutls-config)
107 AC_PATH_PROG(HOSTNAME,hostname)
108 AC_PATH_PROG(BASENAME,basename)
110 dnl allow them to override the path of perl
111 AC_ARG_WITH(perl,
112         ACX_HELP_STRING([--with-perl=PATH],
113                         [sets path to perl executable]),
114                         with_perl=$withval,with_perl=$PERL)
115 AC_SUBST(PERL, $with_perl)
117 dnl openssl/gnutls
118 AC_ARG_WITH(openssl,
119             AC_HELP_STRING([--with-openssl=DIR], 
120                            [path to openssl installation]),)
122 AC_ARG_WITH(gnutls,
123             ACX_HELP_STRING([--with-gnutls=PATH],
124                             [path to gnutls installation root]),)
126 dnl you can only have one or the other
127 if test ! "$with_openssl" = "" && test ! "$with_openssl" = "no"; then
128         with_gnutls="no"
129 fi
130 if test ! "$with_gnutls" = "" && test ! "$with_gnutls" = "no"; then
131         with_openssl="no"
132 fi
134 dnl list of possible dirs to try to autodetect openssl
135 dnl if $dir/include exists, we consider it found
136 dnl the order should allow locally installed versions to override distros' ones
137 OPENSSL_DIRS="/usr /usr/local /usr/slocal /usr/local/openssl /usr/local/ssl \
138               /opt /opt/openssl"
141 dnl
142 dnl Checks for libraries.
143 dnl
145 AC_CHECK_LIB(dce,main,SOCKETLIBS="$SOCKETLIBS -ldce")
146 AC_CHECK_LIB(nsl,main,SOCKETLIBS="$SOCKETLIBS -lnsl")
147 AC_CHECK_LIB(socket,socket,SOCKETLIBS="$SOCKETLIBS -lsocket")
148 AC_CHECK_LIB(resolv,main,SOCKETLIBS="$SOCKETLIBS -lresolv")
149 AC_SUBST(SOCKETLIBS)
151 dnl
152 dnl check for math-related functions needing -lm
153 AC_CHECK_HEADERS(math.h)
154 AC_CHECK_LIB(m,floor,MATHLIBS="-lm")
155 AC_SUBST(MATHLIBS)
157 dnl Check for libtap, to run perl-like tests
158 AC_CHECK_LIB(tap, plan_tests, 
159         EXTRA_TEST="test_utils test_disk test_tcp test_cmd test_base64"
160         AC_SUBST(EXTRA_TEST)
161         )
163 dnl Check for PostgreSQL libraries
164 _SAVEDLIBS="$LIBS"
165 _SAVEDCPPFLAGS="$CPPFLAGS"
166 AC_ARG_WITH(pgsql,
167         ACX_HELP_STRING([--with-pgsql=DIR],
168                 [sets path to pgsql installation]),
169         PGSQL=$withval,)
170 AC_CHECK_LIB(crypt,main)
171 if test "$ac_cv_lib_crypt_main" = "yes"; then
172   if test -n "$PGSQL"; then
173     LDFLAGS="$LDFLAGS -L$PGSQL/lib"
174     CPPFLAGS="$CPPFLAGS -I$PGSQL/include"
175   fi
176   AC_CHECK_LIB(pq,PQsetdbLogin,,,-lcrypt)
177   if test "$ac_cv_lib_pq_PQsetdbLogin" = "yes"; then
178     AC_CHECK_HEADERS(pgsql/libpq-fe.h)
179     AC_CHECK_HEADERS(postgresql/libpq-fe.h)
180     AC_CHECK_HEADERS(libpq-fe.h)
181     if [[ -n "$PGSQL" -a "$ac_cv_header_libpq_fe_h" = "yes" ]]; then
182       PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
183       PGINCLUDE="-I$PGSQL/include"
184     elif test  "$ac_cv_header_pgsql_libpq_fe_h" = "yes"; then
185       PGLIBS="-lpq -lcrypt"
186       PGINCLUDE="-I/usr/include/pgsql"
187     elif test  "$ac_cv_header_postgresql_libpq_fe_h" = "yes"; then
188       PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
189       PGINCLUDE="-I/usr/include/postgresql"
190     elif test  "$ac_cv_header_libpq_fe_h" = "yes"; then
191       PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
192       PGINCLUDE="-I$PGSQL/include"
193     fi
194     if test -z "$PGINCLUDE"; then
195       AC_MSG_WARN([Skipping PostgreSQL plugin (check_pgsql)])
196       AC_MSG_WARN([install PostgreSQL headers to compile this plugin (see REQUIREMENTS).])
197     else
198       AC_SUBST(PGLIBS)
199       AC_SUBST(PGINCLUDE)
200       EXTRAS="$EXTRAS check_pgsql"
201     fi
202   else
203     AC_MSG_WARN([Skipping PostgreSQL plugin (check_pgsql)])
204     AC_MSG_WARN([LIBS="$LIBS" CPPFLAGS="$CPPFLAGS"])
205     AC_MSG_WARN([install PostgreSQL libs to compile this plugin (see REQUIREMENTS).])
206   fi
207 else
208   AC_MSG_WARN([Skipping PostgreSQL plugin (check_pgsql)])
209   AC_MSG_WARN([install lib crypt and PostgreSQL libs to compile this plugin (see REQUIREMENTS).])
210 fi
211 LIBS="$_SAVEDLIBS"
212 CPPFLAGS="$_SAVEDCPPFLAGS"
214 dnl Check for radius libraries
215 _SAVEDLIBS="$LIBS"
216 AC_CHECK_LIB(radiusclient,rc_read_config)
217 if test "$ac_cv_lib_radiusclient_rc_read_config" = "yes"; then
218   EXTRAS="$EXTRAS check_radius"
219         RADIUSLIBS="-lradiusclient"
220   AC_SUBST(RADIUSLIBS)
221 else
222   AC_CHECK_LIB(radiusclient-ng,rc_read_config)
223   if test "$ac_cv_lib_radiusclient_ng_rc_read_config" = "yes"; then
224     EXTRAS="$EXTRAS check_radius"
225           RADIUSLIBS="-lradiusclient-ng"
226     AC_SUBST(RADIUSLIBS)
227   else
228     AC_MSG_WARN([Skipping radius plugin])
229     AC_MSG_WARN([install radius libs to compile this plugin (see REQUIREMENTS).])
230   fi
231 fi
232 LIBS="$_SAVEDLIBS"
234 dnl Check for LDAP libraries
235 _SAVEDLIBS="$LIBS"
236 AC_CHECK_LIB(ldap,main,,,-llber)
237 if test "$ac_cv_lib_ldap_main" = "yes"; then
238   LDAPLIBS="-lldap -llber"\
239   LDAPINCLUDE="-I/usr/include/ldap"
240   AC_SUBST(LDAPLIBS)
241   AC_SUBST(LDAPINCLUDE)
242   AC_CHECK_FUNCS(ldap_set_option)
243   EXTRAS="$EXTRAS check_ldap"
244         AC_CHECK_FUNCS(ldap_init ldap_set_option ldap_get_option ldap_start_tls_s)
245 else
246   AC_MSG_WARN([Skipping LDAP plugin])
247   AC_MSG_WARN([install LDAP libs to compile this plugin (see REQUIREMENTS).])
248 fi
249 LIBS="$_SAVEDLIBS"
251 dnl Check for headers used by check_ide_smart
252 AC_CHECK_HEADER(linux/hdreg.h, FOUNDINCLUDE=yes, FOUNDINCLUDE=no)
253 if test "$FOUNDINCLUDE" = "yes" ; then
254         AC_CHECK_HEADER(linux/types.h, FOUNDINCLUDE=yes, FOUNDINCLUDE=no)
255 fi
257 if test "$FOUNDINCLUDE" = "yes" ; then
258         EXTRAS="$EXTRAS check_ide_smart"
259 else
260         AC_MSG_WARN([Skipping check_ide_smart plugin.]) 
261         AC_MSG_WARN([check_ide_smart is linux specific. It requires linux/hdreg.h and linux/types.h.]) 
262 fi
264 dnl Check for mysql libraries
265 np_mysqlclient
266 if test $with_mysql = "no" ; then
267   AC_MSG_WARN([Skipping mysql plugin])
268   AC_MSG_WARN([install mysql client libs to compile this plugin (see REQUIREMENTS).])
269 else
270   EXTRAS="$EXTRAS check_mysql check_mysql_query"
271   MYSQLINCLUDE="$np_mysql_include"
272   MYSQLLIBS="$np_mysql_libs"
273   MYSQLCFLAGS="$np_mysql_cflags"
274   AC_SUBST(MYSQLINCLUDE)
275   AC_SUBST(MYSQLLIBS)
276   AC_SUBST(MYSQLCFLAGS)
277 fi
279 AC_ARG_WITH([ipv6],
280         [AS_HELP_STRING([--with-ipv6], [support IPv6 @<:@default=check@:>@])],
281         [], [with_ipv6=check])
283 dnl Check for AF_INET6 support - unistd.h required for Darwin
284 if test "$with_ipv6" != "no"; then
285         AC_CACHE_CHECK([for IPv6 support], np_cv_sys_ipv6, [
286                 AC_TRY_COMPILE(
287                         [#ifdef HAVE_UNISTD_H
288                         #include <unistd.h>
289                         #endif
290                         #include <netinet/in.h>
291                         #include <sys/socket.h>],
292                         [struct sockaddr_in6 sin6;
293                         void *p;
295                         sin6.sin6_family = AF_INET6;
296                         sin6.sin6_port = 587;
297                         p = &sin6.sin6_addr;],
298                         [np_cv_sys_ipv6=yes],
299                         [np_cv_sys_ipv6=no])
300                 ])
301         if test "$np_cv_sys_ipv6" = "no" -a "$with_ipv6" != "check"; then
302                 AC_MSG_FAILURE([--with-ipv6 was given, but test for IPv6 support failed])
303         fi
304         if test "$np_cv_sys_ipv6" = "yes"; then
305                 AC_DEFINE(USE_IPV6,1,[Enable IPv6 support])
306         fi
307         with_ipv6="$np_cv_sys_ipv6"
308 fi
311 dnl Checks for Kerberos. Must come before openssl checks for Redhat EL 3
312 AC_CHECK_HEADERS(krb5.h,FOUNDINCLUDE=yes,FOUNDINCLUDE=no)
313 if test "$FOUNDINCLUDE" = "no"; then
314   _SAVEDCPPFLAGS="$CPPFLAGS"
315   CPPFLAGS="$_SAVEDCPPFLAGS -I/usr/kerberos/include"
316   unset ac_cv_header_krb5_h
317   AC_CHECK_HEADERS(krb5.h,
318                    KRB5INCLUDE="-I/usr/kerberos/include"
319                    FOUNDINCLUDE=yes,
320                    FOUNDINCLUDE=no)
321 fi
322 AC_SUBST(KRBINCLUDE)
323 if test "$FOUNDINCLUDE" = "no"; then
324   CPPFLAGS="$_SAVEDCPPFLAGS"
325 fi
328 dnl openssl detection/configuration
329 if ! test x"$with_openssl" = x"no"; then
330         dnl Check for OpenSSL location if it wasn't already specified
331         if ! test -d "$with_openssl"; then
332                 for d in $OPENSSL_DIRS; do
333                         if test -x ${d}/bin/openssl || test -x ${d}/sbin/openssl ; then
334                                 with_openssl=$d
335                         fi
336                 done
337         fi
339         _SAVEDCPPFLAGS="$CPPFLAGS"
340         _SAVEDLDFLAGS="$LDFLAGS"
341         dnl Check for OpenSSL header files
342         unset FOUNDINCLUDE
343         if test x"$with_openssl" != x"/usr" ; then
344                 CPPFLAGS="$CPPFLAGS -I$with_openssl/include"
345                 LDFLAGS="$LDFLAGS -L$with_openssl/lib"
346         fi
348         dnl check for openssl in $dir/include/openssl
349         AC_CHECK_HEADERS(openssl/ssl.h openssl/x509.h openssl/rsa.h openssl/pem.h openssl/crypto.h openssl/err.h,
350                          SSLINCLUDE="-I$with_openssl/include"
351                          FOUNDINCLUDE=yes,
352                          FOUNDINCLUDE=no)
353         dnl else check to see if $dir/include has it
354         if test "$FOUNDINCLUDE" = "no"; then
355                 AC_CHECK_HEADERS(ssl.h x509.h rsa.h pem.h crypto.h err.h,
356                                  SSLINCLUDE="-I$with_openssl/include"
357                                  FOUNDINCLUDE=yes,
358                                  FOUNDINCLUDE=no)
359         fi
360         AC_SUBST(SSLINCLUDE)
361         dnl if we didn't find it, reset CPPFLAGS
362         if test "$FOUNDINCLUDE" = "no"; then
363                 CPPFLAGS="$_SAVEDCPPFLAGS"
364                 LDFLAGS="$_SAVEDLDFLAGS"
365         fi
367         dnl Check for crypto lib
368         _SAVEDLIBS="$LIBS"
369         LIBS="-L${with_openssl}/lib"
370         AC_CHECK_LIB(crypto,CRYPTO_lock)
371         if test "$ac_cv_lib_crypto_CRYPTO_lock" = "yes"; then
372                 dnl Check for SSL lib
373                 AC_CHECK_LIB(ssl,main, SSLLIBS="-lssl -lcrypto",,-lcrypto)
374         fi
375         LIBS="$_SAVEDLIBS"
377         dnl test headers and libs to decide whether check_http should use SSL
378         if test "$ac_cv_lib_crypto_CRYPTO_lock" = "yes"; then
379                 if test "$ac_cv_lib_ssl_main" = "yes"; then
380                         if test "$FOUNDINCLUDE" = "yes"; then
381                                 FOUNDOPENSSL="yes"
382                         fi
383                 fi
384         fi
385 fi
388 dnl check for gnutls if openssl isn't found (or is disabled)
389 if test ! "$FOUNDOPENSSL" = "yes" && test ! "$with_gnutls" = "no"; then
390         if test ! "$with_gnutls" = ""; then
391                 CPPFLAGS="$CPPFLAGS -I${with_gnutls}/include"
392         elif test ! "$LIBGNUTLS_CONFIG" = ""; then
393                 CPPFLAGS="$CPPFLAGS -I`$LIBGNUTLS_CONFIG --prefix`"
394         fi
395         AC_CHECK_HEADERS([gnutls/openssl.h],FOUNDGNUTLS="yes",)
396         if test "$FOUNDGNUTLS" = "yes"; then
397                 AC_CHECK_LIB(gnutls-openssl,main,SSLLIBS="-lgnutls-openssl")
398         fi
399 fi
400 dnl end check for gnutls
402 if test "$FOUNDOPENSSL" = "yes" || test "$FOUNDGNUTLS" = "yes"; then
403         check_tcp_ssl="check_simap check_spop check_jabber check_nntps check_ssmtp"
404         AC_SUBST(check_tcp_ssl)
405         AC_SUBST(SSLLIBS)
406         AC_DEFINE(HAVE_SSL,1,[Define if SSL libraries are found])
407         if test "$FOUNDOPENSSL" = "yes"; then
408                 AC_DEFINE(USE_OPENSSL,1,[Define if using OpenSSL libraries])
409                 with_openssl="yes"
410                 with_gnutls="no"
411         else
412                 AC_DEFINE(USE_GNUTLS,1,[Define if using gnutls libraries])
413                 with_gnutls="yes"
414                 with_openssl="no"
415         fi
416 else
417         dnl else deliberately disabled or no ssl support available
418         AC_MSG_WARN([OpenSSL or GnuTLS libs could not be found or were disabled])
419         with_openssl="no"
420         with_gnutls="no"
421 fi
423 dnl
424 dnl Checks for header files.
425 dnl
427 AC_HEADER_TIME
428 AC_HEADER_SYS_WAIT
429 AC_CHECK_HEADERS(signal.h syslog.h uio.h errno.h sys/time.h sys/socket.h sys/un.h sys/poll.h)
430 AC_CHECK_HEADERS(features.h stdarg.h sys/unistd.h ctype.h)
432 dnl Checks for typedefs, structures, and compiler characteristics.
433 AC_C_CONST
434 AC_STRUCT_TM
435 AC_TYPE_PID_T
436 AC_TYPE_SIZE_T
437 AC_TYPE_SIGNAL
438 AC_TYPE_MBSTATE_T
440 AC_CACHE_CHECK([for va_copy],ac_cv_HAVE_VA_COPY,[
441 AC_TRY_LINK([#include <stdarg.h>
442 va_list ap1,ap2;], [va_copy(ap1,ap2);],
443 ac_cv_HAVE_VA_COPY=yes,
444 ac_cv_HAVE_VA_COPY=no)])
445 if test x"$ac_cv_HAVE_VA_COPY" = x"yes"; then
446     AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available])
447 else    
448     AC_CACHE_CHECK([for __va_copy],ac_cv_HAVE___VA_COPY,[
449     AC_TRY_LINK([#include <stdarg.h>
450     va_list ap1,ap2;], [__va_copy(ap1,ap2);],
451     ac_cv_HAVE___VA_COPY=yes,
452     ac_cv_HAVE___VA_COPY=no)])
453     if test x"$ac_cv_HAVE___VA_COPY" = x"yes"; then
454         AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available])
455     fi
456 fi
458 AC_TRY_COMPILE([#include <sys/time.h>],
459                [struct timeval *tv;
460                 struct timezone *tz;],
461                AC_DEFINE(HAVE_STRUCT_TIMEVAL,1,[Define if we have a timeval structure])
462                AC_TRY_COMPILE([#include <sys/time.h>],
463                               [struct timeval *tv;
464                                struct timezone *tz;
465                                gettimeofday(tv, tz);],
466                               AC_DEFINE(HAVE_GETTIMEOFDAY,1,[Define if gettimeofday is found]),
467                               AC_DEFINE(NEED_GETTIMEOFDAY,1,[Define if gettimeofday is needed])))
469 dnl Checks for library functions.
470 AC_CHECK_FUNCS(memmove select socket strdup strstr strtol strtoul floor)
471 AC_CHECK_FUNCS(poll)
473 AC_MSG_CHECKING(return type of socket size)
474 AC_TRY_COMPILE([#include <stdlib.h>
475                 #include <sys/types.h>
476                 #include <sys/socket.h>],
477                [int a = send(1, (const void *) buffer, (size_t *) 0, (int *) 0);],
478                ac_cv_socket_size_type=["size_t"]
479                 AC_MSG_RESULT(size_t),
480                ac_cv_socket_size_type=["int"]
481                 AC_MSG_RESULT(int))
483 AC_DEFINE_UNQUOTED(SOCKET_SIZE_TYPE, $ac_cv_socket_size_type ,
484         [Define type of socket size])
487 dnl #### Process table test
489 AC_PATH_PROG(PATH_TO_PS,ps)
491 AC_MSG_CHECKING(for ps syntax)
492 AC_ARG_WITH(ps_command,
493             ACX_HELP_STRING([--with-ps-command=PATH], 
494                             [Verbatim command to execute for ps]),
495             PS_COMMAND=$withval)
496 AC_ARG_WITH(ps_format,
497             ACX_HELP_STRING([--with-ps-format=FORMAT],
498                             [Format string for scanning ps output]),
499             PS_FORMAT=$withval)
500 AC_ARG_WITH(ps_cols,
501             ACX_HELP_STRING([--with-ps-cols=NUM], 
502                             [Number of columns in ps command]),
503             PS_COLS=$withval)
504 AC_ARG_WITH(ps_varlist,
505             ACX_HELP_STRING([--with-ps-varlist=LIST],
506                             [Variable list for sscanf of 'ps' output]),
507             PS_VARLIST=$withval)
509 if test -n "$PS_COMMAND" && test -n "$PS_FORMAT" && test -n "$PS_COLS" && test -n "$PS_VARLIST"; then 
510         ac_cv_ps_command="$PS_COMMAND"
511         ac_cv_ps_format="$PS_FORMAT"
512         ac_cv_ps_varlist="$PS_VARLIST"
513         ac_cv_ps_cols="$PS_COLS"
514         AC_MSG_RESULT([(command-line) $ac_cv_ps_command])
516 dnl Now using the pst3/kmem hack for solaris systems to avoid truncation
517 elif test "$ac_cv_uname_s" = "SunOS"; then
518         #
519         # this is a very, very ugly hack, to hardcode the location for plugins
520         #
521         if test "$libexecdir" = '${exec_prefix}/libexec'; then
522                 if test "$exec_prefix" = "NONE"; then
523                         if test "$prefix" = "NONE"; then
524                                 pst3="$ac_default_prefix/libexec/pst3"
525                         else
526                                 pst3="$prefix/libexec/pst3"
527                         fi
528                 else
529                         pst3="$exec_prefix/libexec/pst3"
530                 fi
531         else
532                 pst3="$libexecdir/pst3"
533         fi
534         ac_cv_ps_command="$pst3"
535         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
536         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
537         ac_cv_ps_cols=9
538         AC_MSG_RESULT([using nagios-plugins internal ps command (pst3) for solaris])
539         if test `isainfo -b` = 64 ; then
540                 PST3CFLAGS="-m64"
541                 AC_SUBST(PST3CFLAGS)
542                 AC_MSG_NOTICE([using 64bit pst3])       
543         else
544                 AC_MSG_NOTICE([using 32bit pst3])
545         fi
546         EXTRAS_ROOT="$EXTRAS_ROOT pst3"
548 dnl Removing this for the moment - Ton
549 dnl Using /usr/ucb/ps on Solaris systems, to avoid truncation
550 dnl Limitation that command name is not available
551 dnl elif test "$ac_cv_uname_s" = "SunOS" && /usr/ucb/ps -alxwwn 2>/dev/null | \
552 dnl     egrep -i ["^ *F +UID +PID +PPID +%C +PRI +NI +SZ +RSS +WCHAN +S +TT +TIME +COMMAND"] > /dev/null
553 dnl then
554 dnl     ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procpcpu,&procvsz,&procrss,procstat,&pos]"
555 dnl     ac_cv_ps_command="/usr/ucb/ps -alxwwn"
556 dnl     ac_cv_ps_format=["%*s %d %d %d %d %*d %*d %d %d%*[ 0123456789abcdef]%[OSRZT]%*s %*s %n"]
557 dnl     ac_cv_ps_cols=8
558 dnl     AC_MSG_RESULT([$ac_cv_ps_command])
560 dnl Some gnu/linux systems (debian for one) don't like -axwo and need axwo.
561 dnl so test for this first...
562 elif ps axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
563         egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null
564 then
565         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
566         ac_cv_ps_command="$PATH_TO_PS axwo 'stat uid pid ppid vsz rss pcpu comm args'"
567         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
568         ac_cv_ps_cols=9
569         AC_MSG_RESULT([$ac_cv_ps_command])
571 dnl For OpenBSD 3.2 & 3.3. Must come before ps -weo
572 dnl Should also work for FreeBSD 5.2.1 and 5.3
573 dnl  STAT UCOMM              VSZ   RSS USER      PPID COMMAND
574 elif ps -axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
575         egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null
576 then
577         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
578         ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid pid ppid vsz rss pcpu comm args'"
579         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
580         ac_cv_ps_cols=9
581         AC_MSG_RESULT([$ac_cv_ps_command])
583 dnl Some *BSDs have different format for ps. This is mainly to catch FreeBSD 4. 
584 dnl Limitation: Only first 16 chars returned for ucomm field
585 dnl Must come before ps -weo
586 elif ps -axwo 'stat uid pid ppid vsz rss pcpu ucomm command' 2>/dev/null | \
587         egrep -i ["^ *STAT +UID +PID +PPID +VSZ +RSS +%CPU +UCOMM +COMMAND"] > /dev/null
588 then
589         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
590         ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid pid ppid vsz rss pcpu ucomm command'"
591         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
592         ac_cv_ps_cols=9
593         AC_MSG_RESULT([$ac_cv_ps_command])
595 dnl  STAT UCOMM              VSZ   RSS USER       UID  PPID COMMAND
596 elif ps -weo 'stat comm vsz rss user uid pid ppid etime args' 2>/dev/null | \
597         egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[ID]+ +P[PID]+ +[ELAPSD]+ +[RGSCOMDNA]+"] >/dev/null
598 then
599         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procetime,procprog,&pos]"
600         ac_cv_ps_command="$PATH_TO_PS -weo 'stat uid pid ppid vsz rss pcpu etime comm args'"
601         ac_cv_ps_format="%s %d %d %d %d %d %f %s %s %n"
602         ac_cv_ps_cols=10
603         AC_MSG_RESULT([$ac_cv_ps_command])
605 dnl FreeBSD
606 elif ps waxco 'state command vsz rss uid user pid ppid' 2>/dev/null | \
607         egrep -i ["^STAT +COMMAND +VSZ +RSS +UID +USER +PID +PPID"] >/dev/null
608 then
609         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
610         ac_cv_ps_command="$PATH_TO_PS waxco 'state uid pid ppid vsz rss pcpu command command'"
611         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
612         ac_cv_ps_cols=9
613         AC_MSG_RESULT([$ac_cv_ps_command])
615 dnl BSD-like mode in RH 6.1
616 elif ps waxno 'state comm vsz rss uid user pid ppid args' 2>/dev/null | \
617         egrep -i ["^S +COMMAND +VSZ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
618 then
619         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
620         ac_cv_ps_command="$PATH_TO_PS waxno 'state uid pid ppid vsz rss pcpu comm args'"
621         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
622         ac_cv_ps_cols=9
623         AC_MSG_RESULT([$ac_cv_ps_command])
625 dnl SunOS 4.1.3:
626 dnl  F  UID  PID  PPID  CP  PRI  NI  SZ  RSS  WCHAN  STAT  TT  TIME  COMMAND
627 dnl Need the head -1 otherwise test will work because arguments are found
628 elif ps -laxnwww 2>/dev/null | head -1 | \
629         egrep -i ["^ *F(LAGS)? +UID +PID +PPID +CP +PRI +NI +(SZ)|(VSZ)|(SIZE) +RSS +WCHAN +STAT? +TTY? +TIME +COMMAND"] >/dev/null
630 then
631         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]"
632         ac_cv_ps_command="$PATH_TO_PS -laxnwww"
633         ac_cv_ps_format="%*s %d %d %d %*s %*s %*s %d %d %*s %s %*s %*s %n%s"
634         ac_cv_ps_cols=9
635         AC_MSG_RESULT([$ac_cv_ps_command])
637 dnl Debian Linux / procps v1.2.9:
638 dnl  FLAGS   UID   PID  PPID PRI  NI   SIZE   RSS WCHAN       STA TTY TIME COMMAND
639 dnl    100     0     1     0   0   0    776    76  c0131c8c   S  ffff  0:11 init [2]
640 dnl
641 elif ps laxnwww 2>/dev/null | \
642         egrep -i ["^ *F(LAGS)? +UID +PID +PPID +PRI +NI +(VSZ)|(SIZE) +RSS +WCHAN +STAT? TTY +TIME +COMMAND"] >/dev/null
643 then
644         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,procstat,&procvsz,&procrss,&pos,procprog]"
645         ac_cv_ps_command="$PATH_TO_PS laxnwww"
646         ac_cv_ps_format="%*s %d %d %d %*s %*s %d %d %*s %s %*s %*s %n%s"
647         ac_cv_ps_cols=9
648         AC_MSG_RESULT([$ac_cv_ps_command])
650 dnl OpenBSD (needs to come early because -exo appears to work, but does not give all procs)
651 elif ps -axo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
652         egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[PID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null
653 then
654         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
655         ac_cv_ps_command="$PATH_TO_PS -axo 'stat uid pid ppid vsz rss pcpu comm args'"
656         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
657         ac_cv_ps_cols=9
658         AC_MSG_RESULT([$ac_cv_ps_command])
660 dnl Tru64 - needs %*[ +<>] in PS_FORMAT. 
661 dnl Has /usr/bin/ps and /sbin/ps - force sbin version
662 dnl Can't use vsize and rssize because comes back with text (eg, 1.5M instead 
663 dnl of 1500). Will need big changes to check_procs to support
664 elif /sbin/ps -eo 'stat uid pid ppid pcpu etime comm args' 2>/dev/null | \
665         egrep -i ["^ *S +[UID]+ +[PID]+ +[PID]+ +[%CPU]+ +[ELAPSD]+ +[COMMAND]+ +[COMMAND]+"] > /dev/null
666 then
667         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procpcpu,procetime,procprog,&pos]"
668         ac_cv_ps_command="/sbin/ps -eo 'stat uid pid ppid pcpu etime comm args'"
669         ac_cv_ps_format=["%s%*[ +<>] %d %d %d %f %s %s %n"]
670         ac_cv_ps_cols=8
671         AC_MSG_RESULT([$ac_cv_ps_command])
673 elif ps -eo 's comm vsz rss user uid pid ppid args' 2>/dev/null | \
674         egrep -i ["^S[TAUES]* +C[OMDNA]+ +[VSIZE]+ +U[SER]+ +U[ID]+ +P[PID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null
675 then
676         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
677         ac_cv_ps_command="$PATH_TO_PS -eo 's uid pid ppid vsz rss pcpu comm args'"
678         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
679         ac_cv_ps_cols=9
680         AC_MSG_RESULT([$ac_cv_ps_command])
682 dnl AIX 4.3.3 and 5.1 do not have an rss field
683 elif ps -eo 'stat uid pid ppid vsz pcpu comm args' 2>/dev/null | \
684         egrep -i ["^ *S[TAUES]* +UID +PID +PPID +VSZ +%CPU +COMMAND +COMMAND"] >/dev/null
685 then
686         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procpcpu,procprog,&pos]"
687         ac_cv_ps_command="$PATH_TO_PS -eo 'stat uid pid ppid vsz pcpu comm args'"
688         ac_cv_ps_format="%s %d %d %d %d %f %s %n"
689         ac_cv_ps_cols=8
690         AC_MSG_RESULT([$ac_cv_ps_command - with no RSS])
692 dnl Solaris 2.6
693 elif ps -Ao 's comm vsz rss uid user pid ppid args' 2>/dev/null | \
694         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
695 then
696         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
697         ac_cv_ps_command="$PATH_TO_PS -Ao 's uid pid ppid vsz rss pcpu comm args'"
698         # There must be no space between the %s and %n due to a wierd problem in sscanf where
699         # it will return %n as longer than the line length
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 elif ps -Ao 'status comm vsz rss uid user pid ppid args' 2>/dev/null | \
705         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
706 then
707         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
708         ac_cv_ps_command="$PATH_TO_PS -Ao 'status uid pid ppid vsz rss pcpu comm args'"
709         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
710         ac_cv_ps_cols=9
711         AC_MSG_RESULT([$ac_cv_ps_command])
713 elif ps -Ao 'state comm vsz rss uid user pid ppid args' 2>/dev/null | \
714         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
715 then
716         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
717         ac_cv_ps_command="$PATH_TO_PS -Ao 'state uid pid ppid vsz rss pcpu comm args'"
718         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
719         ac_cv_ps_cols=9
720         AC_MSG_RESULT([$ac_cv_ps_command])
722 dnl wonder who takes state instead of stat
723 elif ps -ao 'state command vsz rss user pid ppid args' 2>/dev/null | \
724         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
725 then
726         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
727         ac_cv_ps_command="$PATH_TO_PS -ao 'state uid pid ppid vsz rss pcpu command args'"
728         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
729         ac_cv_ps_cols=8
730         AC_MSG_RESULT([$ac_cv_ps_command])
732 dnl IRIX 53
733 elif ps -el 2>/dev/null | \
734         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
735 then
736         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&pos,procprog]"
737         ac_cv_ps_command="$PATH_TO_PS -el (IRIX 53)"
738         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %d %d %*s %*s %*s %n%s"
739         ac_cv_ps_cols=8
740         AC_MSG_RESULT([$ac_cv_ps_command])
742 dnl IRIX 63
743 elif ps -el 2>/dev/null | \
744         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +ADDR +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
745 then
746         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
747         ac_cv_ps_command="$PATH_TO_PS -el (IRIX 63)"
748         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
749         ac_cv_ps_cols=6
750         AC_MSG_RESULT([$ac_cv_ps_command])
752 dnl AIX 4.1:
753 dnl     F S      UID   PID  PPID   C PRI NI ADDR  SZ  RSS   WCHAN    TTY  TIME CMD
754 dnl    303 A        0     0     0 120  16 -- 1c07  20   24              -  0:45 swapper
755 elif ps -el 2>/dev/null | \
756         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +ADDR +SZ +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
757 then
758         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
759         ac_cv_ps_command="$PATH_TO_PS -el (AIX 4.1 and HP-UX)"
760         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
761         ac_cv_ps_cols=6
762         AC_MSG_RESULT([$ac_cv_ps_command])
764 dnl AIX?
765 elif ps glaxen 2>/dev/null | \
766         egrep -i ["^ *F +UID +PID +PPID +PRI +NI +VSZ +RSS +WCHAN +STAT +TTY +TIME +COMMAND"] >/dev/null
767 then
768         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]"
769         ac_cv_ps_command="$PATH_TO_PS glaxen"
770         ac_cv_ps_format="%*s %d %d %d %*s %*s %d %d %*s %s %*s %*s %n%s"
771         ac_cv_ps_cols=8
772         AC_MSG_RESULT([$ac_cv_ps_command])
774 dnl MacOSX / Darwin
775 dnl TODO: MacOSX has commands with spaces which will cause problems to PS_FORMAT
776 dnl Some truncation will happen in UCOMM column
777 dnl STAT      VSZ    RSS   UID  PPID %CPU UCOMM            COMMAND
778 dnl Ss      52756  22496   501     1   6.9 Window Manager   /System/Library/CoreServices/WindowServer -daemon
779 elif ps wwaxo 'state vsz rss uid pid ppid pcpu ucomm command' 2>/dev/null | \
780         egrep -i ["^STAT +VSZ +RSS +UID +PPID +%CPU +UCOMM +COMMAND"] >/dev/null
781 then
782         ac_cv_ps_command="$PATH_TO_PS wwaxo 'state vsz rss uid pid ppid pcpu ucomm command'"
783         ac_cv_ps_varlist="[procstat,&procvsz,&procrss,&procuid,&procpid,&procppid,&procpcpu,procprog,&pos]"
784         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
785         ac_cv_ps_cols=8
786         AC_MSG_RESULT([$ac_cv_ps_command])
788 dnl UnixWare 
789 elif ps -Al 2>/dev/null | \
790         egrep -i ["^ *F +S +UID +PID +PPID +CLS +PRI +NI +C +ADDR +SZ +WCHAN +TTY +TIME +COMD"] >/dev/null
791 then
792         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
793         ac_cv_ps_command="$PATH_TO_PS -Al"
794         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
795         ac_cv_ps_cols=8
796         AC_MSG_RESULT([$ac_cv_ps_command])
798 else
799         AC_MSG_WARN([unable to find usable ps syntax - check_procs and check_nagios will not be compiled])
800 fi
802 if test -n "$ac_cv_ps_varlist" ; then
803         AC_DEFINE_UNQUOTED(PS_VARLIST,$ac_cv_ps_varlist,
804                 [Variable list for sscanf of 'ps' output])
805         AC_DEFINE_UNQUOTED(PS_COMMAND,"$ac_cv_ps_command",
806                 [Verbatim command to execute for ps in check_procs])
807         AC_DEFINE_UNQUOTED(PS_FORMAT,"$ac_cv_ps_format",
808                 [Format string for scanning ps output in check_procs])
809         AC_DEFINE_UNQUOTED(PS_COLS,$ac_cv_ps_cols,
810                 [Number of columns in ps command])
811         EXTRAS="$EXTRAS check_procs check_nagios"
812         if echo "$ac_cv_ps_varlist" | grep "procetime" >/dev/null; then
813                 AC_DEFINE(PS_USES_PROCETIME,"yes",
814                           [Whether the ps utility uses the "procetime" field])
815         fi
816 fi
818 AC_PATH_PROG(PATH_TO_PING,ping)
819 AC_PATH_PROG(PATH_TO_PING6,ping6)
821 AC_ARG_WITH(ping_command,
822         ACX_HELP_STRING([--with-ping-command=SYNTAX],
823                 [sets syntax for ICMP ping]),
824         with_ping_command=$withval,)
826 AC_MSG_CHECKING(for ICMP ping syntax)
827 ac_cv_ping_packets_first=no
828 ac_cv_ping_has_timeout=no
829 if test -n "$with_ping_command"
830 then
831         AC_MSG_RESULT([(command-line) $with_ping_command])
832         if test -n "$ac_cv_ping_packets_first"
833         then
834                 ac_cv_ping_packets_first=yes
835                 ac_cv_ping_has_timeout=yes
836         fi
838 elif [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
839         $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
840         egrep -i "^round-trip|^rtt" >/dev/null
841 then
842         with_ping_command="$PATH_TO_PING -n -U -c %d %s"
843         ac_cv_ping_packets_first=yes
844         AC_MSG_RESULT([$with_ping_command])
846 elif $PATH_TO_PING -n -U -w 10 -c 1 127.0.0.1 2>/dev/null | \
847         egrep -i "^round-trip|^rtt" >/dev/null
848 then
849         with_ping_command="$PATH_TO_PING -n -U -w %d -c %d %s"
850         ac_cv_ping_packets_first=yes
851   ac_cv_ping_has_timeout=yes
852         AC_MSG_RESULT([$with_ping_command])
854 elif $PATH_TO_PING -n -U -c 1 127.0.0.1 2>/dev/null | \
855         egrep -i "^round-trip|^rtt" >/dev/null
856 then
857         with_ping_command="$PATH_TO_PING -n -U -c %d %s"
858         ac_cv_ping_packets_first=yes
859         AC_MSG_RESULT([$with_ping_command])
861 elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \
862         egrep -i "^round-trip|^rtt" >/dev/null
863 then
864         with_ping_command="$PATH_TO_PING -n -c %d %s"
865         ac_cv_ping_packets_first=yes
866         AC_MSG_RESULT([$with_ping_command])
868 elif $PATH_TO_PING -n 127.0.0.1 -c 1 2>/dev/null | \
869         egrep -i "^round-trip|^rtt" >/dev/null
870 then
871         with_ping_command="$PATH_TO_PING -n %s -c %d"
872         AC_MSG_RESULT([$with_ping_command])
874 elif $PATH_TO_PING 127.0.0.1 -n 1 2>/dev/null | \
875         egrep -i "^round-trip|^rtt" >/dev/null
876 then
877         with_ping_command="$PATH_TO_PING %s -n %d"
878         AC_MSG_RESULT([$with_ping_command])
880 elif $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
881         egrep -i "^round-trip|^rtt" >/dev/null
882 then
883         with_ping_command="$PATH_TO_PING -n -s %s 56 %d"
884         AC_MSG_RESULT([$with_ping_command])
886 elif $PATH_TO_PING -n -h 127.0.0.1 -s 56 -c 1 2>/dev/null | \
887         egrep -i "^round-trip|^rtt" >/dev/null
888 then
889         with_ping_command="$PATH_TO_PING -n -h %s -s 56 -c %d"
890         AC_MSG_RESULT([$with_ping_command])
892 elif $PATH_TO_PING -n -s 56 -c 1 127.0.0.1 2>/dev/null | \
893         egrep -i "^round-trip|^rtt" >/dev/null
894 then
895         with_ping_command="$PATH_TO_PING -n -s 56 -c %d %s"
896         ac_cv_ping_packets_first=yes
897         AC_MSG_RESULT([$with_ping_command])
899 elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \
900         egrep -i "^round-trip|^rtt" >/dev/null
901 then
902         with_ping_command="$PATH_TO_PING -n -c %d %s"
903         ac_cv_ping_packets_first=yes
904         AC_MSG_RESULT([$with_ping_command])
906 else
907         AC_MSG_WARN([unable to find usable ping syntax])
908 fi
910 AC_DEFINE_UNQUOTED(PING_COMMAND,"$with_ping_command",
911         [path and args for ICMP ping command])
913 if test "x$ac_cv_ping_packets_first" != "xno"
914 then
915         AC_DEFINE(PING_PACKETS_FIRST,1,
916                 [Define if packet count must precede host])
917 fi
919 if test "x$ac_cv_ping_has_timeout" != "xno"
920 then
921         AC_DEFINE(PING_HAS_TIMEOUT,1,
922                 [Define if ping has its own timeout option that should be set])
923 fi
925 AC_ARG_WITH(ping6_command,
926         ACX_HELP_STRING([--with-ping6-command=SYNTAX],
927                 [sets syntax for ICMPv6 ping]),
928         with_ping6_command=$withval,)
930 if test x"$with_ipv6" != xno ; then
931 AC_MSG_CHECKING(for ICMPv6 ping syntax)
932 ac_cv_ping6_packets_first=no
933 if test -n "$with_ping6_command"
934 then
935         AC_MSG_RESULT([(command-line) $with_ping6_command])
936         if test -n "$ac_cv_ping6_packets_first"
937         then
938                 ac_cv_ping6_packets_first=yes
939         fi
941 elif test "x$PATH_TO_PING6" != "x"; then
942         if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
943                 $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \
944                 egrep -i "^round-trip|^rtt" >/dev/null
945         then
946                 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s"
947                 ac_cv_ping6_packets_first=yes
948                 AC_MSG_RESULT([$with_ping6_command])
950         elif $PATH_TO_PING6 -n -U -w 10 -c 1 ::1 2>/dev/null | \
951                 egrep -i "^round-trip|^rtt" >/dev/null
952         then
953                 with_ping6_command="$PATH_TO_PING6 -n -U -w %d -c %d %s"
954                 ac_cv_ping6_packets_first=yes
955                 ac_cv_ping_has_timeout=yes
956                 AC_MSG_RESULT([$with_ping6_command])
958         elif $PATH_TO_PING6 -n -U -c 1 ::1 2>/dev/null | \
959                 egrep -i "^round-trip|^rtt" >/dev/null
960         then
961                 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s"
962                 ac_cv_ping6_packets_first=yes
963                 AC_MSG_RESULT([$with_ping6_command])
965         elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \
966                 egrep -i "^round-trip|^rtt" >/dev/null
967         then
968                 with_ping6_command="$PATH_TO_PING6 -n -c %d %s"
969                 ac_cv_ping6_packets_first=yes
970                 AC_MSG_RESULT([$with_ping6_command])
972         elif $PATH_TO_PING6 -n ::1 -c 1 2>/dev/null | \
973                 egrep -i "^round-trip|^rtt" >/dev/null
974         then
975                 with_ping6_command="$PATH_TO_PING6 -n %s -c %d"
976                 AC_MSG_RESULT([$with_ping6_command])
978         elif $PATH_TO_PING6 ::1 -n 1 2>/dev/null | \
979                 egrep -i "^round-trip|^rtt" >/dev/null
980         then
981                 with_ping6_command="$PATH_TO_PING6 %s -n %d"
982                 AC_MSG_RESULT([$with_ping6_command])
984         elif $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \
985                 egrep -i "^round-trip|^rtt" >/dev/null
986         then
987                 with_ping6_command="$PATH_TO_PING6 -n -s %s 56 %d"
988                 AC_MSG_RESULT([$with_ping6_command])
990         elif $PATH_TO_PING6 -n -h ::1 -s 56 -c 1 2>/dev/null | \
991                 egrep -i "^round-trip|^rtt" >/dev/null
992         then
993                 with_ping6_command="$PATH_TO_PING6 -n -h %s -s 56 -c %d"
994                 AC_MSG_RESULT([$with_ping6_command])
996         elif $PATH_TO_PING6 -n -s 56 -c 1 ::1 2>/dev/null | \
997                 egrep -i "^round-trip|^rtt" >/dev/null
998         then
999                 with_ping6_command="$PATH_TO_PING6 -n -s 56 -c %d %s"
1000                 ac_cv_ping6_packets_first=yes
1001                 AC_MSG_RESULT([$with_ping_command])
1003         elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \
1004                 egrep -i "^round-trip|^rtt" >/dev/null
1005         then
1006                 with_ping6_command="$PATH_TO_PING6 -n -c %d %s"
1007                 ac_cv_ping6_packets_first=yes
1008                 AC_MSG_RESULT([$with_ping6_command])
1010         fi
1012 elif test "x$PATH_TO_PING" != "x"; then
1013         if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
1014                 $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \
1015                 egrep -i "^round-trip|^rtt" >/dev/null
1016         then
1017                 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s"
1018                 ac_cv_ping6_packets_first=yes
1019                 AC_MSG_RESULT([$with_ping6_command])
1021         elif $PATH_TO_PING -A inet6 -n -U -c 1 ::1 2>/dev/null | \
1022                 egrep -i "^round-trip|^rtt" >/dev/null
1023         then
1024                 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s"
1025                 ac_cv_ping6_packets_first=yes
1026                 AC_MSG_RESULT([$with_ping6_command])
1028         elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \
1029                 egrep -i "^round-trip|^rtt" >/dev/null
1030         then
1031                 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s"
1032                 ac_cv_ping6_packets_first=yes
1033                 AC_MSG_RESULT([$with_ping6_command])
1035         elif $PATH_TO_PING -A inet6 -n ::1 -c 1 2>/dev/null | \
1036                 egrep -i "^round-trip|^rtt" >/dev/null
1037         then
1038                 with_ping6_command="$PATH_TO_PING -A inet6 -n %s -c %d"
1039                 AC_MSG_RESULT([$with_ping6_command])
1041         elif $PATH_TO_PING -A inet6 ::1 -n 1 2>/dev/null | \
1042                 egrep -i "^round-trip|^rtt" >/dev/null
1043         then
1044                 with_ping6_command="$PATH_TO_PING -A inet6 %s -n %d"
1045                 AC_MSG_RESULT([$with_ping6_command])
1047         elif $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \
1048                 egrep -i "^round-trip|^rtt" >/dev/null
1049         then
1050                 with_ping6_command="$PATH_TO_PING -A inet6 -n -s %s 56 %d"
1051                 AC_MSG_RESULT([$with_ping6_command])
1053         elif $PATH_TO_PING -A inet6 -n -h ::1 -s 56 -c 1 2>/dev/null | \
1054                 egrep -i "^round-trip|^rtt" >/dev/null
1055         then
1056                 with_ping6_command="$PATH_TO_PING -A inet6 -n -h %s -s 56 -c %d"
1057                 AC_MSG_RESULT([$with_ping6_command])
1059         elif $PATH_TO_PING -A inet6 -n -s 56 -c 1 ::1 2>/dev/null | \
1060                 egrep -i "^round-trip|^rtt" >/dev/null
1061         then
1062                 with_ping6_command="$PATH_TO_PING -A inet6 -n -s 56 -c %d %s"
1063                 ac_cv_ping6_packets_first=yes
1064                 AC_MSG_RESULT([$with_ping_command])
1066         elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \
1067                 egrep -i "^round-trip|^rtt" >/dev/null
1068         then
1069                 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s"
1070                 ac_cv_ping6_packets_first=yes
1071                 AC_MSG_RESULT([$with_ping6_command])
1073         fi
1075 fi
1077 if test "x$with_ping6_command" != "x"; then
1078         AC_DEFINE_UNQUOTED(PING6_COMMAND,"$with_ping6_command",
1079                 [path and args for ICMPv6 ping command])
1080 else
1081         AC_MSG_RESULT([none])
1082 fi
1084 if test "x$ac_cv_ping6_packets_first" != "xno"; then
1085         AC_DEFINE(PING6_PACKETS_FIRST,1,
1086                 [Define if packet count must precede host])
1087 fi
1088 fi
1091 AC_ARG_WITH(nslookup_command,
1092             ACX_HELP_STRING([--with-nslookup-command=PATH],
1093                             [sets path to nslookup executable]),
1094             ac_cv_nslookup_command=$withval)
1095 if test -n "$ac_cv_nslookup_command"; then
1096         AC_MSG_NOTICE([Using specific nslookup at $ac_cv_nslookup_command])
1097 else
1098         AC_PATH_PROG(PATH_TO_NSLOOKUP,nslookup)
1099         if test -n "$PATH_TO_NSLOOKUP"
1100         then
1101                 AC_MSG_CHECKING(for nslookup syntax)
1102                 if $PATH_TO_NSLOOKUP -sil 127.0.0.1 2>&1 | grep ["Invalid option: sil"] >/dev/null
1103                 then
1104                         ac_cv_nslookup_command="$PATH_TO_NSLOOKUP"
1105                         AC_MSG_RESULT([$ac_cv_nslookup_command])
1107                 else
1108                         ac_cv_nslookup_command="$PATH_TO_NSLOOKUP -sil"
1109                         AC_MSG_RESULT([$ac_cv_nslookup_command])
1111                 fi
1112         else
1113                 AC_MSG_WARN([nslookup command not found])
1114         fi
1115 fi
1117 if test -n "$ac_cv_nslookup_command"; then
1118         EXTRAS="$EXTRAS check_dns"
1119         AC_DEFINE_UNQUOTED(NSLOOKUP_COMMAND,"$ac_cv_nslookup_command", [path and args for nslookup])
1120 fi
1122 AC_MSG_CHECKING([for number of cpus])
1123 AC_TRY_COMPILE([#include <unistd.h>],
1124         [sysconf(_SC_NPROCESSORS_CONF) > 0;],
1125         AC_DEFINE(HAVE_SYSCONF__SC_NPROCESSORS_CONF,1,[Define if sysconf returns number of cpus])
1126         AC_MSG_RESULT([sysconf(_SC_NPROCESSORS_CONF)]),
1127         AC_MSG_RESULT([cannot calculate])
1128         )
1130 AC_PATH_PROG(PATH_TO_UPTIME,uptime)
1131 AC_ARG_WITH(uptime_command,
1132             ACX_HELP_STRING([--with-uptime-command=PATH],
1133                             [sets path to uptime]), PATH_TO_UPTIME=$withval)
1134 AC_DEFINE_UNQUOTED(PATH_TO_UPTIME,"$PATH_TO_UPTIME",[path to uptime binary])
1136 AC_PATH_PROG(PATH_TO_RPCINFO,rpcinfo)
1137 AC_ARG_WITH(rpcinfo_command,
1138             ACX_HELP_STRING([--with-rpcinfo-command=PATH],
1139                             [sets path to rpcinfo]), PATH_TO_RPCINFO=$withval)
1140 AC_DEFINE_UNQUOTED(PATH_TO_RPCINFO,"$PATH_TO_RPCINFO",[path to rpcinfo binary])
1142 AC_PATH_PROG(PATH_TO_LMSTAT,lmstat)
1143 if test -x "$PATH_TO_LMSTAT"
1144 then
1145         AC_DEFINE_UNQUOTED(PATH_TO_LMSTAT,"$PATH_TO_LMSTAT",[path to lmstat])
1146 else
1147         AC_MSG_WARN([Get lmstat from Globetrotter Software to monitor flexlm licenses])
1148 fi
1150 AC_PATH_PROG(PATH_TO_SMBCLIENT,smbclient)
1151 AC_ARG_WITH(smbclient_command,
1152             ACX_HELP_STRING([--with-smbclient-command=PATH],
1153                             [sets path to smbclient]), 
1154             PATH_TO_SMBCLIENT=$withval)
1155 if test -n "$PATH_TO_SMBCLIENT"
1156 then
1157         AC_DEFINE_UNQUOTED(PATH_TO_SMBCLIENT,"$PATH_TO_SMBCLIENT",[path to smbclient binary])
1158 else
1159         AC_MSG_WARN([Get smbclient from Samba.org to monitor SMB shares])
1160 fi
1163 AC_PATH_PROG(PATH_TO_WHO,who)
1165 if [$PATH_TO_WHO -q 2>/dev/null | egrep -i "^# users=[0-9]+$" >/dev/null]
1166 then
1167         ac_cv_path_to_who="$PATH_TO_WHO -q"
1168 else
1169         ac_cv_path_to_who="$PATH_TO_WHO"
1170 fi
1172 AC_DEFINE_UNQUOTED(WHO_COMMAND,"$ac_cv_path_to_who",
1173         [path and arguments for invoking 'who'])
1175 AC_PATH_PROG(PATH_TO_SNMPGET,snmpget)
1176 AC_ARG_WITH(snmpget_command,
1177             ACX_HELP_STRING([--with-snmpget-command=PATH],
1178                             [Path to snmpget command]),
1179             PATH_TO_SNMPGET=$withval)
1180 if test -n "$PATH_TO_SNMPGET"
1181 then
1182         AC_DEFINE_UNQUOTED(PATH_TO_SNMPGET,"$PATH_TO_SNMPGET",[path to snmpget binary])
1183         EXTRAS="$EXTRAS check_hpjd check_snmp"
1184 else
1185         AC_MSG_WARN([Get snmpget from http://net-snmp.sourceforge.net to make check_hpjd and check_snmp plugins])
1186 fi
1188 AC_PATH_PROG(PATH_TO_SNMPGETNEXT,snmpgetnext)
1189 AC_ARG_WITH(snmpgetnext_command,
1190             ACX_HELP_STRING([--with-snmpgetnext-command=PATH],
1191                             [Path to snmpgetnext command]),
1192             PATH_TO_SNMPGETNEXT=$withval)
1193 if test -n "$PATH_TO_SNMPGETNEXT"
1194 then
1195         AC_DEFINE_UNQUOTED(PATH_TO_SNMPGETNEXT,"$PATH_TO_SNMPGETNEXT",[path to snmpgetnext binary])
1196 fi
1198 if ( $PERL -M"Net::SNMP 3.6" -e 'exit' 2>/dev/null  )
1199 then
1200         AC_MSG_CHECKING(for Net::SNMP perl module)
1201         AC_MSG_RESULT([found])
1202 else
1203         AC_MSG_WARN([Tried $PERL - install Net::SNMP perl module if you want to use the perl snmp plugins])
1204 fi
1206 AC_PATH_PROG(PATH_TO_QUAKESTAT,quakestat)
1207 AC_PATH_PROG(PATH_TO_QSTAT,qstat)
1208 AC_ARG_WITH(qstat_command,
1209             ACX_HELP_STRING([--with-qstat-command=PATH], 
1210                             [Path to qstat command]), PATH_TO_QSTAT=$withval)
1212 if test -x "$PATH_TO_QUAKESTAT"
1213 then
1214         ac_cv_path_to_qstat="$PATH_TO_QUAKESTAT"
1215         EXTRAS="$EXTRAS check_game"
1217 elif test -n "$PATH_TO_QSTAT"
1218 then
1219         ac_cv_path_to_qstat="$PATH_TO_QSTAT"
1220         EXTRAS="$EXTRAS check_game"
1221 else
1222         AC_MSG_WARN([Get qstat from http://www.activesw.com/people/steve/qstat.html in order to make check_game plugin])
1223 fi
1225 if test $ac_cv_path_to_qstat 
1226 then
1227         AC_DEFINE_UNQUOTED(PATH_TO_QSTAT,"$ac_cv_path_to_qstat",
1228                 [path to qstat/quakestat])
1229 fi
1231 AC_PATH_PROG(PATH_TO_FPING,fping)
1232 AC_ARG_WITH(fping_command,
1233             ACX_HELP_STRING([--with-fping-command=PATH],
1234                             [Path to fping command]), PATH_TO_FPING=$withval)
1235 if test -n "$PATH_TO_FPING"
1236 then
1237         AC_DEFINE_UNQUOTED(PATH_TO_FPING,"$PATH_TO_FPING",[path to fping])
1238         EXTRAS="$EXTRAS check_fping"
1239 else
1240         AC_MSG_WARN([Get fping from http://www.fping.com in order to make check_fping plugin])
1241 fi
1243 AC_PATH_PROG(PATH_TO_SSH,ssh)
1244 AC_ARG_WITH(ssh_command,
1245             ACX_HELP_STRING([--with-ssh-command=PATH],
1246                             [sets path for ssh]), PATH_TO_SSH=$withval)
1247 if test -n "$PATH_TO_SSH"
1248 then
1249         AC_DEFINE_UNQUOTED(SSH_COMMAND,"$PATH_TO_SSH",[path to ssh binary])
1250         EXTRAS="$EXTRAS check_by_ssh"
1251 else
1252         AC_MSG_WARN([Get ssh in order to make check_by_ssh plugin])
1253 fi
1256 AC_PATH_PROG(PATH_TO_MAILQ,mailq)
1257 AC_ARG_WITH(mailq_command,
1258             ACX_HELP_STRING([--with-mailq-command=PATH],
1259                             [sets path to mailq]), PATH_TO_MAILQ=$withval)
1260 if test -n "$PATH_TO_MAILQ"
1261 then
1262         AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_MAILQ",[path to mailq])
1263 else
1264         AC_MSG_WARN([Could not find mailq or eqivalent])
1265 fi
1267 AC_PATH_PROG(PATH_TO_QMAIL_QSTAT,qmail-qstat)
1268 if test -x "$PATH_TO_QMAIL_QSTAT"
1269 then
1270         AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_QMAIL_QSTAT",[path to qmail-qstat])
1271 else
1272         AC_MSG_WARN([Could not find qmail-qstat or eqivalent])
1273 fi
1275 dnl SWAP info required is amount allocated/available and amount free
1276 dnl The plugin works through all the swap devices and adds up the total swap
1277 dnl available.
1278 AC_PATH_PROG(PATH_TO_SWAP,swap)
1279 if (test -n "$PATH_TO_SWAP")
1280 then
1281 AC_MSG_CHECKING([for $PATH_TO_SWAP format])
1282 if [$PATH_TO_SWAP -l 2>&1 >/dev/null]
1283 then
1284         ac_cv_have_swap=yes
1285         ac_cv_swap_command="$PATH_TO_SWAP -l"
1286         if [$PATH_TO_SWAP -l 2>/dev/null | \
1287                 egrep -i "^lswap +path +pri +swaplo +blocks +free +maxswap" \
1288                 >/dev/null]
1289         then
1290                 ac_cv_swap_format=[" %*d %*s %*d,%*d %*d %*d %f %f"]
1291                 ac_cv_swap_conv=2048
1292                 AC_MSG_RESULT([using IRIX format swap])
1294         elif [$PATH_TO_SWAP -l 2>/dev/null | egrep -i "^path +dev +swaplo +blocks +free" >/dev/null]
1295         then
1296                 ac_cv_swap_format=["%*s %*[0-9,-] %*d %f %f"]
1297                 ac_cv_swap_conv=2048
1298                 AC_MSG_RESULT([using Unixware format swap])
1299         else
1300                 dnl if we don't know what format swap's output is
1301                 dnl we might as well pretend we didn't see it
1302                 ac_cv_have_swap=""
1303                 ac_cv_swap_command=""
1304         fi
1305 fi
1306 dnl end if for PATH_TO_SWAP
1307 fi
1309 AC_PATH_PROG(PATH_TO_SWAPINFO,swapinfo)
1310 if (test -n "$PATH_TO_SWAPINFO")
1311 then
1312 AC_MSG_CHECKING([for $PATH_TO_SWAPINFO format])
1313 if [$PATH_TO_SWAPINFO -k 2>&1 | egrep -i "^Device" >/dev/null]
1314 then
1315         ac_cv_have_swap=yes
1316         ac_cv_swap_command="$PATH_TO_SWAPINFO -k"
1318         if [$PATH_TO_SWAPINFO -k 2>/dev/null | egrep -i "^Device +1K-blocks +Used +Avail" >/dev/null]
1319         then
1320                 ac_cv_swap_format=["%*s %f %*d %f"]
1321                 ac_cv_swap_conv=1024
1322                 AC_MSG_RESULT([using FreeBSD format swapinfo])
1323         fi
1325 elif [$PATH_TO_SWAPINFO -dfM 2>/dev/null | egrep -i "^TYPE +AVAIL +USED +FREE" >/dev/null]
1326 then
1327         ac_cv_have_swap=yes
1328         ac_cv_swap_command="$PATH_TO_SWAPINFO -dfM"
1329         ac_cv_swap_format=["%*s %f %*d %f"]
1330         ac_cv_swap_conv=1024
1331         AC_MSG_RESULT([using HP-UX format swapinfo])
1332 fi
1333 dnl end if for PATH_TO_SWAPINFO
1334 fi
1336 AC_PATH_PROG(PATH_TO_LSPS,lsps)
1337 if (test -n "$PATH_TO_LSPS")
1338 then
1339 AC_MSG_CHECKING([for $PATH_TO_LSPS format])
1340 if [$PATH_TO_LSPS -a 2>/dev/null | egrep -i "^Page Space" > /dev/null]
1341 then
1342         ac_cv_have_swap=yes
1343         ac_cv_swap_command="$PATH_TO_LSPS -a"
1344         ac_cv_swap_format=["%*s %*s %*s %f%*s %f %*s"]
1345         ac_cv_swap_conv=1
1346         AC_MSG_RESULT([using AIX lsps])
1347 fi
1348 dnl end if for PATH_TO_SWAPINFO
1349 fi
1351 dnl
1352 dnl test for swapctl system call, both the 2-arg and 3-arg variants
1353 dnl fwict, the 2-arg is an SVR4 standard, whereas the 3-arg is shared
1354 dnl in the various BSD's
1355 dnl
1357 AC_CHECK_HEADERS([sys/stat.h sys/param.h])
1358 AC_CHECK_HEADERS([sys/swap.h], [], [], [
1359 #ifdef HAVE_SYS_PARAM_H
1360 #include <sys/param.h>
1361 #endif
1362 ])
1363 AC_CHECK_DECLS([swapctl],,,[
1364                #include <unistd.h>
1365                #include <sys/types.h>
1366                #include <sys/param.h>
1367                #include <sys/stat.h>
1368                #include <sys/swap.h>
1369                ])
1370 AC_CHECK_TYPES([swaptbl_t, swapent_t],,,[
1371                #include <sys/types.h>
1372                #include <sys/param.h>
1373                #include <sys/stat.h>
1374                #include <sys/swap.h>
1375                ])
1376 AC_CHECK_MEMBERS([struct swapent.se_nblks],,,[
1377                #include <unistd.h>
1378                #include <sys/types.h>
1379                #include <sys/param.h>
1380                #include <sys/stat.h>
1381                #include <sys/swap.h>
1382                ])
1384 if test "$ac_cv_have_decl_swapctl" = "yes"; 
1385 then
1386         EXTRAS="$EXTRAS check_swap"
1387         AC_MSG_CHECKING([for 2-arg (SVR4) swapctl])
1388         if test "$ac_cv_type_swaptbl_t" = "yes" -a \
1389                 "$ac_cv_type_swapent_t" = "yes"; 
1390         then
1391                 AC_MSG_RESULT([yes])
1392                 ac_cv_check_swap_swapctl_svr4="1";
1393                 AC_DEFINE([CHECK_SWAP_SWAPCTL_SVR4],1,
1394                           [Define if 2-argument SVR4 swapctl exists])
1395         else
1396                 AC_MSG_RESULT([no])
1397                 AC_MSG_CHECKING([for 3-arg (*BSD) swapctl])
1398                 if test "$ac_cv_member_struct_swapent_se_nblks" = "yes"; 
1399                 then
1400                         AC_MSG_RESULT([yes])
1401                         AC_DEFINE([CHECK_SWAP_SWAPCTL_BSD],1,
1402                                   [Define if 3-argument BSD swapctl exists])
1403                 else
1404                         AC_MSG_RESULT([no])
1405                 fi
1406         fi
1407         AC_MSG_CHECKING([for whether swapctl uses blocks or pages])
1408         if test "$ac_cv_check_swap_swapctl_svr4" = "1";
1409         then
1410                 dnl
1411                 dnl the SVR4 spec returns values in pages
1412                 dnl
1413                 AC_MSG_RESULT([page])
1414                 AC_CHECK_DECLS([sysconf])
1415                 AC_MSG_CHECKING([for system page size])
1416                 if test "$ac_cv_have_decl_sysconf" = "yes";
1417                 then
1418                         AC_MSG_RESULT([determined by sysconf(3)])
1419                         ac_cv_swap_conv="(1048576/sysconf(_SC_PAGESIZE))"
1420                 else
1421                         AC_MSG_WARN([don't know. guessing 4096k])
1422                         ac_cv_swap_conv=256
1423                 fi
1424         else
1425                 dnl
1426                 dnl the BSD spec returns values in blocks
1427                 dnl
1428                 AC_MSG_RESULT([blocks (assuming 512b)])
1429                 ac_cv_swap_conv=2048
1430         fi
1431         AC_DEFINE_UNQUOTED(SWAP_CONVERSION,$ac_cv_swap_conv,
1432                 [Conversion factor to MB])
1433 fi
1434 dnl
1435 dnl end tests for the swapctl system calls
1436 dnl
1439 if test "x$ac_cv_have_swap" != "x" 
1440 then
1441         AC_DEFINE(HAVE_SWAP,1,[Define if swap/swapinfo command is found])
1442         EXTRAS="$EXTRAS check_swap"
1443 fi
1444 if test "x$ac_cv_swap_command" != "x" 
1445 then
1446         AC_DEFINE_UNQUOTED(SWAP_COMMAND,"$ac_cv_swap_command",
1447                 [Path to swap/swapinfo binary, with any args])
1448         AC_DEFINE_UNQUOTED(SWAP_FORMAT,"$ac_cv_swap_format",
1449                 [Format string for parsing swap output])
1450         AC_DEFINE_UNQUOTED(SWAP_CONVERSION,$ac_cv_swap_conv,
1451                 [Conversion factor to MB])
1452 fi
1454 AC_ARG_WITH(proc-meminfo,
1455             ACX_HELP_STRING([--with-proc-meminfo=PATH],
1456                             [path to /proc/meminfo or equivalent]),
1457                             ac_cv_proc_meminfo=$withval)
1458 dnl dunno why this does not work below - use hack (kbd)
1459 dnl fine on linux, broken on solaris
1460 dnl if /bin/test -e "/proc/meminfo"
1461 AC_MSG_CHECKING([for /proc/meminfo])
1462 if test -n "$ac_cv_proc_meminfo"; then
1463         AC_MSG_RESULT([(command line) $ac_cv_proc_meminfo])
1464 elif [cat /proc/meminfo > /dev/null 2>&1]; then
1465         AC_MSG_RESULT([found /proc/meminfo])
1466         ac_cv_proc_meminfo="/proc/meminfo"
1467 else
1468         AC_MSG_RESULT([no])
1469 fi
1471 if test -n "$ac_cv_proc_meminfo"; then
1472         AC_DEFINE(HAVE_PROC_MEMINFO,1,[Define if we have /proc/meminfo])
1473         AC_DEFINE_UNQUOTED(PROC_MEMINFO,"$ac_cv_proc_meminfo",[path to /proc/meminfo if name changes])
1474         EXTRAS="$EXTRAS check_swap"
1475 fi
1477 AC_PATH_PROG(PATH_TO_DIG,dig)
1478 AC_ARG_WITH(dig_command,
1479             ACX_HELP_STRING([--with-dig-command=PATH],
1480                             [Path to dig command]), PATH_TO_DIG=$withval)
1481 if test -n "$PATH_TO_DIG"; then
1482         EXTRAS="$EXTRAS check_dig"
1483         AC_DEFINE_UNQUOTED(PATH_TO_DIG,"$PATH_TO_DIG",[Path to dig command, if present])
1484 fi
1486 AC_PATH_PROG(PATH_TO_APTGET,apt-get)
1487 AC_ARG_WITH(apt-get_command,
1488             ACX_HELP_STRING([--with-apt-get-command=PATH],
1489                             [Path to apt-get command]), 
1490                             with_apt_get_command=$withval,
1491                             with_apt_get_command=$PATH_TO_APTGET)
1492 AC_DEFINE_UNQUOTED(PATH_TO_APTGET,"$PATH_TO_APTGET",[Path to apt-get command, if present])
1493 if test -n "$PATH_TO_APTGET" ; then
1494         EXTRAS="$EXTRAS check_apt"
1495 fi
1498 if test -f plugins/check_nt.c ; then
1499   EXTRAS="$EXTRAS check_nt"
1500 elif test -f ../plugins/check_nt.c ; then
1501   EXTRAS="$EXTRAS check_nt"
1502 fi
1505 dnl used in check_dhcp
1506 AC_CHECK_HEADERS(sys/sockio.h)
1508 case $host in
1509         *bsd*)
1510                 AC_DEFINE(__bsd__,1,[bsd specific code in check_dhcp.c])
1511         ;;
1512         *linux*)
1513                 AC_DEFINE(__linux__,1,[sun specific code in check_dhcp.c])
1514         ;;
1515         *sun* | solaris*)
1516                 AC_DEFINE(__sun__,1,[sun specific code in check_dhcp.c])
1517         ;;
1518         *hpux*)  
1519                 AC_DEFINE(__hpux__,1,[hpux specific code in check_dhcp.c])
1520         ;;
1521 esac
1523 AC_SUBST(EXTRAS)
1524 AC_SUBST(EXTRAS_ROOT)
1525 AC_SUBST(EXTRA_NETOBJS)
1526 AC_SUBST(DEPLIBS)
1528 AM_GNU_GETTEXT([external], [need-ngettext])
1529 AM_GNU_GETTEXT_VERSION(0.15)
1531 dnl Check for Redhat spopen problem
1532 dnl Wierd problem where ECHILD is returned from a wait call in error
1533 dnl Only appears to affect nslookup and dig calls. Only affects redhat around
1534 dnl 2.6.9-11 (okay in 2.6.9-5). Redhat investigating root cause
1535 dnl We patch plugins/popen.c
1536 dnl Need to add smp because uname different on those
1537 dnl Can force patch to be applied with --enable-redhat-pthread-workaround
1538 AC_ARG_ENABLE(redhat-pthread-workaround, 
1539         AC_HELP_STRING([--enable-redhat-pthread-workaround], 
1540                 [force Redhat patch to be applied (default: test system)]),
1541         [ac_cv_enable_redhat_pthread_workaround=$enableval],
1542         [ac_cv_enable_redhat_pthread_workaround=test])
1543 if test "$ac_cv_enable_redhat_pthread_workaround" = "test" ; then
1544         if echo $ac_cv_uname_r | egrep "\.EL(smp)?$" >/dev/null 2>&1 ; then
1545                 AC_MSG_NOTICE([See http://nagiosplugins.org/faq/compile/configure_appears_to_hang if this next part takes a long time])
1546                 AC_MSG_CHECKING(for redhat spopen problem)
1547                 ( cd config_test && make && make test ) > /dev/null 2>&1
1548                 if test $? -eq 0 ; then
1549                         AC_MSG_RESULT(okay)
1550                 else
1551                         AC_MSG_RESULT(error)
1552                         AC_DEFINE(REDHAT_SPOPEN_ERROR, 1, [Workaround on redhat in spopen])
1553                 fi
1554         fi
1555 elif test "$ac_cv_enable_redhat_pthread_workaround" = "yes" ; then
1556         AC_DEFINE(REDHAT_SPOPEN_ERROR, 1, [Forced workaround on redhat in spopen])
1557 fi
1559 dnl Perl modules
1560 AC_ARG_ENABLE(perl-modules,
1561         AC_HELP_STRING([--enable-perl-modules], 
1562                 [Enables installation of Nagios::Plugin and its dependencies (default: no)]),
1563         [enable_perl_modules=$enableval],
1564         [enable_perl_modules=no])
1565 if test "$enable_perl_modules" = "yes" ; then
1566   AC_SUBST(PERLMODS_DIR,perlmods)
1567 fi
1569 dnl External libraries - see ACKNOWLEDGEMENTS
1570 gl_INIT
1572 dnl Some helpful common compile errors checked here
1573 if test "$ac_cv_uname_s" = 'SunOS' -a \( "x$ac_cv_prog_ac_ct_AR" = "x" -o "$ac_cv_prog_ac_ct_AR" = 'false' \) ; then
1574         AC_MSG_ERROR(No ar found for Solaris - is /usr/ccs/bin in PATH?)
1575 fi
1577 AC_OUTPUT(
1578   Makefile 
1579   lib/Makefile 
1580   plugins/Makefile 
1581   lib/tests/Makefile
1582   plugins-root/Makefile
1583   plugins-scripts/Makefile 
1584   plugins-scripts/subst 
1585   plugins-scripts/utils.pm 
1586   plugins-scripts/utils.sh 
1587   perlmods/Makefile
1588   command.cfg 
1589   test.pl 
1590   pkg/solaris/pkginfo 
1591   po/Makefile.in 
1595 dnl the ones below that are commented out need to be cleaned up 
1596 dnl in the configure code above to use with_foo instead of ac_cv_foo
1597 dnl if we want them to show up here.  it'd also make the code cleaner.
1598 dnl i'll get to that on another rainy day :) -sf
1599 ACX_FEATURE([with],[apt-get-command])
1600 dnl ACX_FEATURE([with],[dig-command])
1601 dnl ACX_FEATURE([with],[fping-command])
1602 dnl ACX_FEATURE([with],[mailq-command])
1603 dnl ACX_FEATURE([with],[nslookup-command])
1604 ACX_FEATURE([with],[ping6-command])
1605 ACX_FEATURE([with],[ping-command])
1606 dnl ACX_FEATURE([with],[qstat-command])
1607 dnl ACX_FEATURE([with],[rpcinfo-command])
1608 dnl ACX_FEATURE([with],[smbclient-command])
1609 dnl ACX_FEATURE([with],[snmpget-command])
1610 dnl ACX_FEATURE([with],[snmpgetnext-command])
1611 dnl ACX_FEATURE([with],[ssh-command])
1612 dnl ACX_FEATURE([with],[uptime-command])
1614 dnl ACX_FEATURE([with],[proc-meminfo])
1615 dnl ACX_FEATURE([with],[ps-command])
1616 dnl ACX_FEATURE([with],[ps-format])
1617 dnl ACX_FEATURE([with],[ps-cols])
1618 dnl ACX_FEATURE([with],[ps-varlist])
1620 ACX_FEATURE([with],[ipv6])
1621 ACX_FEATURE([with],[mysql])
1622 ACX_FEATURE([with],[openssl])
1623 ACX_FEATURE([with],[gnutls])
1624 ACX_FEATURE([with],[perl])
1625 ACX_FEATURE([enable],[perl-modules])
1626 ACX_FEATURE([with],[cgiurl])
1627 ACX_FEATURE([with],[trusted-path])