Code

Add AC_SYS_LARGEFILE to configure.in (check_disk should now work with large file...
[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
439 AC_CACHE_CHECK([for va_copy],ac_cv_HAVE_VA_COPY,[
440 AC_TRY_LINK([#include <stdarg.h>
441 va_list ap1,ap2;], [va_copy(ap1,ap2);],
442 ac_cv_HAVE_VA_COPY=yes,
443 ac_cv_HAVE_VA_COPY=no)])
444 if test x"$ac_cv_HAVE_VA_COPY" = x"yes"; then
445     AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available])
446 else    
447     AC_CACHE_CHECK([for __va_copy],ac_cv_HAVE___VA_COPY,[
448     AC_TRY_LINK([#include <stdarg.h>
449     va_list ap1,ap2;], [__va_copy(ap1,ap2);],
450     ac_cv_HAVE___VA_COPY=yes,
451     ac_cv_HAVE___VA_COPY=no)])
452     if test x"$ac_cv_HAVE___VA_COPY" = x"yes"; then
453         AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available])
454     fi
455 fi
457 AC_TRY_COMPILE([#include <sys/time.h>],
458                [struct timeval *tv;
459                 struct timezone *tz;],
460                AC_DEFINE(HAVE_STRUCT_TIMEVAL,1,[Define if we have a timeval structure])
461                AC_TRY_COMPILE([#include <sys/time.h>],
462                               [struct timeval *tv;
463                                struct timezone *tz;
464                                gettimeofday(tv, tz);],
465                               AC_DEFINE(HAVE_GETTIMEOFDAY,1,[Define if gettimeofday is found]),
466                               AC_DEFINE(NEED_GETTIMEOFDAY,1,[Define if gettimeofday is needed])))
468 dnl Checks for library functions.
469 AC_CHECK_FUNCS(memmove select socket strdup strstr strtol strtoul floor)
470 AC_CHECK_FUNCS(poll)
472 AC_MSG_CHECKING(return type of socket size)
473 AC_TRY_COMPILE([#include <stdlib.h>
474                 #include <sys/types.h>
475                 #include <sys/socket.h>],
476                [int a = send(1, (const void *) buffer, (size_t *) 0, (int *) 0);],
477                ac_cv_socket_size_type=["size_t"]
478                 AC_MSG_RESULT(size_t),
479                ac_cv_socket_size_type=["int"]
480                 AC_MSG_RESULT(int))
482 AC_DEFINE_UNQUOTED(SOCKET_SIZE_TYPE, $ac_cv_socket_size_type ,
483         [Define type of socket size])
486 dnl #### Process table test
488 AC_PATH_PROG(PATH_TO_PS,ps)
490 AC_MSG_CHECKING(for ps syntax)
491 AC_ARG_WITH(ps_command,
492             ACX_HELP_STRING([--with-ps-command=PATH], 
493                             [Verbatim command to execute for ps]),
494             PS_COMMAND=$withval)
495 AC_ARG_WITH(ps_format,
496             ACX_HELP_STRING([--with-ps-format=FORMAT],
497                             [Format string for scanning ps output]),
498             PS_FORMAT=$withval)
499 AC_ARG_WITH(ps_cols,
500             ACX_HELP_STRING([--with-ps-cols=NUM], 
501                             [Number of columns in ps command]),
502             PS_COLS=$withval)
503 AC_ARG_WITH(ps_varlist,
504             ACX_HELP_STRING([--with-ps-varlist=LIST],
505                             [Variable list for sscanf of 'ps' output]),
506             PS_VARLIST=$withval)
508 if test -n "$PS_COMMAND" && test -n "$PS_FORMAT" && test -n "$PS_COLS" && test -n "$PS_VARLIST"; then 
509         ac_cv_ps_command="$PS_COMMAND"
510         ac_cv_ps_format="$PS_FORMAT"
511         ac_cv_ps_varlist="$PS_VARLIST"
512         ac_cv_ps_cols="$PS_COLS"
513         AC_MSG_RESULT([(command-line) $ac_cv_ps_command])
515 dnl Using /usr/ucb/ps on Solaris systems, to avoid truncation
516 dnl Limitation that command name is not available
517 elif test "$ac_cv_uname_s" = "SunOS" && /usr/ucb/ps -alxwwn 2>/dev/null | \
518         egrep -i ["^ *F +UID +PID +PPID +%C +PRI +NI +SZ +RSS +WCHAN +S +TT +TIME +COMMAND"] > /dev/null
519 then
520         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procpcpu,&procvsz,&procrss,procstat,&pos]"
521         ac_cv_ps_command="/usr/ucb/ps -alxwwn"
522         ac_cv_ps_format=["%*s %d %d %d %d %*d %*d %d %d%*[ 0123456789abcdef]%[OSRZT]%*s %*s %n"]
523         ac_cv_ps_cols=8
524         AC_MSG_RESULT([$ac_cv_ps_command])
526 dnl Some gnu/linux systems (debian for one) don't like -axwo and need axwo.
527 dnl so test for this first...
528 elif ps axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
529         egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null
530 then
531         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
532         ac_cv_ps_command="$PATH_TO_PS axwo 'stat uid pid ppid vsz rss pcpu comm args'"
533         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
534         ac_cv_ps_cols=9
535         AC_MSG_RESULT([$ac_cv_ps_command])
537 dnl For OpenBSD 3.2 & 3.3. Must come before ps -weo
538 dnl Should also work for FreeBSD 5.2.1 and 5.3
539 dnl  STAT UCOMM              VSZ   RSS USER      PPID COMMAND
540 elif ps -axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
541         egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null
542 then
543         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
544         ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid pid ppid vsz rss pcpu comm args'"
545         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
546         ac_cv_ps_cols=9
547         AC_MSG_RESULT([$ac_cv_ps_command])
549 dnl Some *BSDs have different format for ps. This is mainly to catch FreeBSD 4. 
550 dnl Limitation: Only first 16 chars returned for ucomm field
551 dnl Must come before ps -weo
552 elif ps -axwo 'stat uid pid ppid vsz rss pcpu ucomm command' 2>/dev/null | \
553         egrep -i ["^ *STAT +UID +PID +PPID +VSZ +RSS +%CPU +UCOMM +COMMAND"] > /dev/null
554 then
555         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
556         ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid pid ppid vsz rss pcpu ucomm command'"
557         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
558         ac_cv_ps_cols=9
559         AC_MSG_RESULT([$ac_cv_ps_command])
561 dnl  STAT UCOMM              VSZ   RSS USER       UID  PPID COMMAND
562 elif ps -weo 'stat comm vsz rss user uid pid ppid etime args' 2>/dev/null | \
563         egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[ID]+ +P[PID]+ +[ELAPSD]+ +[RGSCOMDNA]+"] >/dev/null
564 then
565         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procetime,procprog,&pos]"
566         ac_cv_ps_command="$PATH_TO_PS -weo 'stat uid pid ppid vsz rss pcpu etime comm args'"
567         ac_cv_ps_format="%s %d %d %d %d %d %f %s %s %n"
568         ac_cv_ps_cols=10
569         AC_MSG_RESULT([$ac_cv_ps_command])
571 dnl FreeBSD
572 elif ps waxco 'state command vsz rss uid user pid ppid' 2>/dev/null | \
573         egrep -i ["^STAT +COMMAND +VSZ +RSS +UID +USER +PID +PPID"] >/dev/null
574 then
575         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
576         ac_cv_ps_command="$PATH_TO_PS waxco 'state uid pid ppid vsz rss pcpu command command'"
577         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
578         ac_cv_ps_cols=9
579         AC_MSG_RESULT([$ac_cv_ps_command])
581 dnl BSD-like mode in RH 6.1
582 elif ps waxno 'state comm vsz rss uid user pid ppid args' 2>/dev/null | \
583         egrep -i ["^S +COMMAND +VSZ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
584 then
585         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
586         ac_cv_ps_command="$PATH_TO_PS waxno 'state uid pid ppid vsz rss pcpu comm args'"
587         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
588         ac_cv_ps_cols=9
589         AC_MSG_RESULT([$ac_cv_ps_command])
591 dnl SunOS 4.1.3:
592 dnl  F  UID  PID  PPID  CP  PRI  NI  SZ  RSS  WCHAN  STAT  TT  TIME  COMMAND
593 dnl Need the head -1 otherwise test will work because arguments are found
594 elif ps -laxnwww 2>/dev/null | head -1 | \
595         egrep -i ["^ *F(LAGS)? +UID +PID +PPID +CP +PRI +NI +(SZ)|(VSZ)|(SIZE) +RSS +WCHAN +STAT? +TTY? +TIME +COMMAND"] >/dev/null
596 then
597         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]"
598         ac_cv_ps_command="$PATH_TO_PS -laxnwww"
599         ac_cv_ps_format="%*s %d %d %d %*s %*s %*s %d %d %*s %s %*s %*s %n%s"
600         ac_cv_ps_cols=9
601         AC_MSG_RESULT([$ac_cv_ps_command])
603 dnl Debian Linux / procps v1.2.9:
604 dnl  FLAGS   UID   PID  PPID PRI  NI   SIZE   RSS WCHAN       STA TTY TIME COMMAND
605 dnl    100     0     1     0   0   0    776    76  c0131c8c   S  ffff  0:11 init [2]
606 dnl
607 elif ps laxnwww 2>/dev/null | \
608         egrep -i ["^ *F(LAGS)? +UID +PID +PPID +PRI +NI +(VSZ)|(SIZE) +RSS +WCHAN +STAT? TTY +TIME +COMMAND"] >/dev/null
609 then
610         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,procstat,&procvsz,&procrss,&pos,procprog]"
611         ac_cv_ps_command="$PATH_TO_PS laxnwww"
612         ac_cv_ps_format="%*s %d %d %d %*s %*s %d %d %*s %s %*s %*s %n%s"
613         ac_cv_ps_cols=9
614         AC_MSG_RESULT([$ac_cv_ps_command])
616 dnl OpenBSD (needs to come early because -exo appears to work, but does not give all procs)
617 elif ps -axo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
618         egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[PID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null
619 then
620         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
621         ac_cv_ps_command="$PATH_TO_PS -axo 'stat uid pid ppid vsz rss pcpu comm args'"
622         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
623         ac_cv_ps_cols=9
624         AC_MSG_RESULT([$ac_cv_ps_command])
626 dnl Tru64 - needs %*[ +<>] in PS_FORMAT. 
627 dnl Has /usr/bin/ps and /sbin/ps - force sbin version
628 dnl Can't use vsize and rssize because comes back with text (eg, 1.5M instead 
629 dnl of 1500). Will need big changes to check_procs to support
630 elif /sbin/ps -eo 'stat uid pid ppid pcpu etime comm args' 2>/dev/null | \
631         egrep -i ["^ *S +[UID]+ +[PID]+ +[PID]+ +[%CPU]+ +[ELAPSD]+ +[COMMAND]+ +[COMMAND]+"] > /dev/null
632 then
633         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procpcpu,procetime,procprog,&pos]"
634         ac_cv_ps_command="/sbin/ps -eo 'stat uid pid ppid pcpu etime comm args'"
635         ac_cv_ps_format=["%s%*[ +<>] %d %d %d %f %s %s %n"]
636         ac_cv_ps_cols=8
637         AC_MSG_RESULT([$ac_cv_ps_command])
639 elif ps -eo 's comm vsz rss user uid pid ppid args' 2>/dev/null | \
640         egrep -i ["^S[TAUES]* +C[OMDNA]+ +[VSIZE]+ +U[SER]+ +U[ID]+ +P[PID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null
641 then
642         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
643         ac_cv_ps_command="$PATH_TO_PS -eo 's uid pid ppid vsz rss pcpu comm args'"
644         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
645         ac_cv_ps_cols=9
646         AC_MSG_RESULT([$ac_cv_ps_command])
648 dnl AIX 4.3.3 and 5.1 do not have an rss field
649 elif ps -eo 'stat uid pid ppid vsz pcpu comm args' 2>/dev/null | \
650         egrep -i ["^ *S[TAUES]* +UID +PID +PPID +VSZ +%CPU +COMMAND +COMMAND"] >/dev/null
651 then
652         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procpcpu,procprog,&pos]"
653         ac_cv_ps_command="$PATH_TO_PS -eo 'stat uid pid ppid vsz pcpu comm args'"
654         ac_cv_ps_format="%s %d %d %d %d %f %s %n"
655         ac_cv_ps_cols=8
656         AC_MSG_RESULT([$ac_cv_ps_command - with no RSS])
658 dnl Solaris 2.6
659 elif ps -Ao 's comm vsz rss uid user pid ppid args' 2>/dev/null | \
660         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
661 then
662         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
663         ac_cv_ps_command="$PATH_TO_PS -Ao 's uid pid ppid vsz rss pcpu comm args'"
664         # There must be no space between the %s and %n due to a wierd problem in sscanf where
665         # it will return %n as longer than the line length
666         ac_cv_ps_format="%s %d %d %d %d %d %f %s%n"
667         ac_cv_ps_cols=9
668         AC_MSG_RESULT([$ac_cv_ps_command])
670 elif ps -Ao 'status comm vsz rss uid user pid ppid args' 2>/dev/null | \
671         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
672 then
673         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
674         ac_cv_ps_command="$PATH_TO_PS -Ao 'status uid pid ppid vsz rss pcpu comm args'"
675         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
676         ac_cv_ps_cols=9
677         AC_MSG_RESULT([$ac_cv_ps_command])
679 elif ps -Ao 'state comm vsz rss uid user pid ppid args' 2>/dev/null | \
680         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
681 then
682         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
683         ac_cv_ps_command="$PATH_TO_PS -Ao 'state uid pid ppid vsz rss pcpu comm args'"
684         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
685         ac_cv_ps_cols=9
686         AC_MSG_RESULT([$ac_cv_ps_command])
688 dnl wonder who takes state instead of stat
689 elif ps -ao 'state command vsz rss user pid ppid args' 2>/dev/null | \
690         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
691 then
692         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
693         ac_cv_ps_command="$PATH_TO_PS -ao 'state uid pid ppid vsz rss pcpu command args'"
694         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
695         ac_cv_ps_cols=8
696         AC_MSG_RESULT([$ac_cv_ps_command])
698 dnl IRIX 53
699 elif ps -el 2>/dev/null | \
700         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
701 then
702         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&pos,procprog]"
703         ac_cv_ps_command="$PATH_TO_PS -el (IRIX 53)"
704         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %d %d %*s %*s %*s %n%s"
705         ac_cv_ps_cols=8
706         AC_MSG_RESULT([$ac_cv_ps_command])
708 dnl IRIX 63
709 elif ps -el 2>/dev/null | \
710         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +ADDR +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
711 then
712         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
713         ac_cv_ps_command="$PATH_TO_PS -el (IRIX 63)"
714         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
715         ac_cv_ps_cols=6
716         AC_MSG_RESULT([$ac_cv_ps_command])
718 dnl AIX 4.1:
719 dnl     F S      UID   PID  PPID   C PRI NI ADDR  SZ  RSS   WCHAN    TTY  TIME CMD
720 dnl    303 A        0     0     0 120  16 -- 1c07  20   24              -  0:45 swapper
721 elif ps -el 2>/dev/null | \
722         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +ADDR +SZ +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
723 then
724         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
725         ac_cv_ps_command="$PATH_TO_PS -el (AIX 4.1 and HP-UX)"
726         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
727         ac_cv_ps_cols=6
728         AC_MSG_RESULT([$ac_cv_ps_command])
730 dnl AIX?
731 elif ps glaxen 2>/dev/null | \
732         egrep -i ["^ *F +UID +PID +PPID +PRI +NI +VSZ +RSS +WCHAN +STAT +TTY +TIME +COMMAND"] >/dev/null
733 then
734         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]"
735         ac_cv_ps_command="$PATH_TO_PS glaxen"
736         ac_cv_ps_format="%*s %d %d %d %*s %*s %d %d %*s %s %*s %*s %n%s"
737         ac_cv_ps_cols=8
738         AC_MSG_RESULT([$ac_cv_ps_command])
740 dnl MacOSX / Darwin
741 dnl TODO: MacOSX has commands with spaces which will cause problems to PS_FORMAT
742 dnl Some truncation will happen in UCOMM column
743 dnl STAT      VSZ    RSS   UID  PPID %CPU UCOMM            COMMAND
744 dnl Ss      52756  22496   501     1   6.9 Window Manager   /System/Library/CoreServices/WindowServer -daemon
745 elif ps wwaxo 'state vsz rss uid pid ppid pcpu ucomm command' 2>/dev/null | \
746         egrep -i ["^STAT +VSZ +RSS +UID +PPID +%CPU +UCOMM +COMMAND"] >/dev/null
747 then
748         ac_cv_ps_command="$PATH_TO_PS wwaxo 'state vsz rss uid pid ppid pcpu ucomm command'"
749         ac_cv_ps_varlist="[procstat,&procvsz,&procrss,&procuid,&procpid,&procppid,&procpcpu,procprog,&pos]"
750         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
751         ac_cv_ps_cols=8
752         AC_MSG_RESULT([$ac_cv_ps_command])
754 dnl UnixWare 
755 elif ps -Al 2>/dev/null | \
756         egrep -i ["^ *F +S +UID +PID +PPID +CLS +PRI +NI +C +ADDR +SZ +WCHAN +TTY +TIME +COMD"] >/dev/null
757 then
758         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
759         ac_cv_ps_command="$PATH_TO_PS -Al"
760         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
761         ac_cv_ps_cols=8
762         AC_MSG_RESULT([$ac_cv_ps_command])
764 else
765         AC_MSG_WARN([unable to find usable ps syntax - check_procs and check_nagios will not be compiled])
766 fi
768 if test -n "$ac_cv_ps_varlist" ; then
769         AC_DEFINE_UNQUOTED(PS_VARLIST,$ac_cv_ps_varlist,
770                 [Variable list for sscanf of 'ps' output])
771         AC_DEFINE_UNQUOTED(PS_COMMAND,"$ac_cv_ps_command",
772                 [Verbatim command to execute for ps in check_procs])
773         AC_DEFINE_UNQUOTED(PS_FORMAT,"$ac_cv_ps_format",
774                 [Format string for scanning ps output in check_procs])
775         AC_DEFINE_UNQUOTED(PS_COLS,$ac_cv_ps_cols,
776                 [Number of columns in ps command])
777         EXTRAS="$EXTRAS check_procs check_nagios"
778         if echo "$ac_cv_ps_varlist" | grep "procetime" >/dev/null; then
779                 AC_DEFINE(PS_USES_PROCETIME,"yes",
780                           [Whether the ps utility uses the "procetime" field])
781         fi
782 fi
784 AC_PATH_PROG(PATH_TO_PING,ping)
785 AC_PATH_PROG(PATH_TO_PING6,ping6)
787 AC_ARG_WITH(ping_command,
788         ACX_HELP_STRING([--with-ping-command=SYNTAX],
789                 [sets syntax for ICMP ping]),
790         with_ping_command=$withval,)
792 AC_MSG_CHECKING(for ICMP ping syntax)
793 ac_cv_ping_packets_first=no
794 ac_cv_ping_has_timeout=no
795 if test -n "$with_ping_command"
796 then
797         AC_MSG_RESULT([(command-line) $with_ping_command])
798         if test -n "$ac_cv_ping_packets_first"
799         then
800                 ac_cv_ping_packets_first=yes
801                 ac_cv_ping_has_timeout=yes
802         fi
804 elif [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
805         $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
806         egrep -i "^round-trip|^rtt" >/dev/null
807 then
808         with_ping_command="$PATH_TO_PING -n -U -c %d %s"
809         ac_cv_ping_packets_first=yes
810         AC_MSG_RESULT([$with_ping_command])
812 elif $PATH_TO_PING -n -U -w 10 -c 1 127.0.0.1 2>/dev/null | \
813         egrep -i "^round-trip|^rtt" >/dev/null
814 then
815         with_ping_command="$PATH_TO_PING -n -U -w %d -c %d %s"
816         ac_cv_ping_packets_first=yes
817   ac_cv_ping_has_timeout=yes
818         AC_MSG_RESULT([$with_ping_command])
820 elif $PATH_TO_PING -n -U -c 1 127.0.0.1 2>/dev/null | \
821         egrep -i "^round-trip|^rtt" >/dev/null
822 then
823         with_ping_command="$PATH_TO_PING -n -U -c %d %s"
824         ac_cv_ping_packets_first=yes
825         AC_MSG_RESULT([$with_ping_command])
827 elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \
828         egrep -i "^round-trip|^rtt" >/dev/null
829 then
830         with_ping_command="$PATH_TO_PING -n -c %d %s"
831         ac_cv_ping_packets_first=yes
832         AC_MSG_RESULT([$with_ping_command])
834 elif $PATH_TO_PING -n 127.0.0.1 -c 1 2>/dev/null | \
835         egrep -i "^round-trip|^rtt" >/dev/null
836 then
837         with_ping_command="$PATH_TO_PING -n %s -c %d"
838         AC_MSG_RESULT([$with_ping_command])
840 elif $PATH_TO_PING 127.0.0.1 -n 1 2>/dev/null | \
841         egrep -i "^round-trip|^rtt" >/dev/null
842 then
843         with_ping_command="$PATH_TO_PING %s -n %d"
844         AC_MSG_RESULT([$with_ping_command])
846 elif $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
847         egrep -i "^round-trip|^rtt" >/dev/null
848 then
849         with_ping_command="$PATH_TO_PING -n -s %s 56 %d"
850         AC_MSG_RESULT([$with_ping_command])
852 elif $PATH_TO_PING -n -h 127.0.0.1 -s 56 -c 1 2>/dev/null | \
853         egrep -i "^round-trip|^rtt" >/dev/null
854 then
855         with_ping_command="$PATH_TO_PING -n -h %s -s 56 -c %d"
856         AC_MSG_RESULT([$with_ping_command])
858 elif $PATH_TO_PING -n -s 56 -c 1 127.0.0.1 2>/dev/null | \
859         egrep -i "^round-trip|^rtt" >/dev/null
860 then
861         with_ping_command="$PATH_TO_PING -n -s 56 -c %d %s"
862         ac_cv_ping_packets_first=yes
863         AC_MSG_RESULT([$with_ping_command])
865 elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \
866         egrep -i "^round-trip|^rtt" >/dev/null
867 then
868         with_ping_command="$PATH_TO_PING -n -c %d %s"
869         ac_cv_ping_packets_first=yes
870         AC_MSG_RESULT([$with_ping_command])
872 else
873         AC_MSG_WARN([unable to find usable ping syntax])
874 fi
876 AC_DEFINE_UNQUOTED(PING_COMMAND,"$with_ping_command",
877         [path and args for ICMP ping command])
879 if test "x$ac_cv_ping_packets_first" != "xno"
880 then
881         AC_DEFINE(PING_PACKETS_FIRST,1,
882                 [Define if packet count must precede host])
883 fi
885 if test "x$ac_cv_ping_has_timeout" != "xno"
886 then
887         AC_DEFINE(PING_HAS_TIMEOUT,1,
888                 [Define if ping has its own timeout option that should be set])
889 fi
891 AC_ARG_WITH(ping6_command,
892         ACX_HELP_STRING([--with-ping6-command=SYNTAX],
893                 [sets syntax for ICMPv6 ping]),
894         with_ping6_command=$withval,)
896 if test x"$with_ipv6" != xno ; then
897 AC_MSG_CHECKING(for ICMPv6 ping syntax)
898 ac_cv_ping6_packets_first=no
899 if test -n "$with_ping6_command"
900 then
901         AC_MSG_RESULT([(command-line) $with_ping6_command])
902         if test -n "$ac_cv_ping6_packets_first"
903         then
904                 ac_cv_ping6_packets_first=yes
905         fi
907 elif test "x$PATH_TO_PING6" != "x"; then
908         if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
909                 $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \
910                 egrep -i "^round-trip|^rtt" >/dev/null
911         then
912                 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s"
913                 ac_cv_ping6_packets_first=yes
914                 AC_MSG_RESULT([$with_ping6_command])
916         elif $PATH_TO_PING6 -n -U -w 10 -c 1 ::1 2>/dev/null | \
917                 egrep -i "^round-trip|^rtt" >/dev/null
918         then
919                 with_ping6_command="$PATH_TO_PING6 -n -U -w %d -c %d %s"
920                 ac_cv_ping6_packets_first=yes
921                 ac_cv_ping_has_timeout=yes
922                 AC_MSG_RESULT([$with_ping6_command])
924         elif $PATH_TO_PING6 -n -U -c 1 ::1 2>/dev/null | \
925                 egrep -i "^round-trip|^rtt" >/dev/null
926         then
927                 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s"
928                 ac_cv_ping6_packets_first=yes
929                 AC_MSG_RESULT([$with_ping6_command])
931         elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \
932                 egrep -i "^round-trip|^rtt" >/dev/null
933         then
934                 with_ping6_command="$PATH_TO_PING6 -n -c %d %s"
935                 ac_cv_ping6_packets_first=yes
936                 AC_MSG_RESULT([$with_ping6_command])
938         elif $PATH_TO_PING6 -n ::1 -c 1 2>/dev/null | \
939                 egrep -i "^round-trip|^rtt" >/dev/null
940         then
941                 with_ping6_command="$PATH_TO_PING6 -n %s -c %d"
942                 AC_MSG_RESULT([$with_ping6_command])
944         elif $PATH_TO_PING6 ::1 -n 1 2>/dev/null | \
945                 egrep -i "^round-trip|^rtt" >/dev/null
946         then
947                 with_ping6_command="$PATH_TO_PING6 %s -n %d"
948                 AC_MSG_RESULT([$with_ping6_command])
950         elif $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \
951                 egrep -i "^round-trip|^rtt" >/dev/null
952         then
953                 with_ping6_command="$PATH_TO_PING6 -n -s %s 56 %d"
954                 AC_MSG_RESULT([$with_ping6_command])
956         elif $PATH_TO_PING6 -n -h ::1 -s 56 -c 1 2>/dev/null | \
957                 egrep -i "^round-trip|^rtt" >/dev/null
958         then
959                 with_ping6_command="$PATH_TO_PING6 -n -h %s -s 56 -c %d"
960                 AC_MSG_RESULT([$with_ping6_command])
962         elif $PATH_TO_PING6 -n -s 56 -c 1 ::1 2>/dev/null | \
963                 egrep -i "^round-trip|^rtt" >/dev/null
964         then
965                 with_ping6_command="$PATH_TO_PING6 -n -s 56 -c %d %s"
966                 ac_cv_ping6_packets_first=yes
967                 AC_MSG_RESULT([$with_ping_command])
969         elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \
970                 egrep -i "^round-trip|^rtt" >/dev/null
971         then
972                 with_ping6_command="$PATH_TO_PING6 -n -c %d %s"
973                 ac_cv_ping6_packets_first=yes
974                 AC_MSG_RESULT([$with_ping6_command])
976         fi
978 elif test "x$PATH_TO_PING" != "x"; then
979         if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
980                 $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \
981                 egrep -i "^round-trip|^rtt" >/dev/null
982         then
983                 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s"
984                 ac_cv_ping6_packets_first=yes
985                 AC_MSG_RESULT([$with_ping6_command])
987         elif $PATH_TO_PING -A inet6 -n -U -c 1 ::1 2>/dev/null | \
988                 egrep -i "^round-trip|^rtt" >/dev/null
989         then
990                 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s"
991                 ac_cv_ping6_packets_first=yes
992                 AC_MSG_RESULT([$with_ping6_command])
994         elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \
995                 egrep -i "^round-trip|^rtt" >/dev/null
996         then
997                 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s"
998                 ac_cv_ping6_packets_first=yes
999                 AC_MSG_RESULT([$with_ping6_command])
1001         elif $PATH_TO_PING -A inet6 -n ::1 -c 1 2>/dev/null | \
1002                 egrep -i "^round-trip|^rtt" >/dev/null
1003         then
1004                 with_ping6_command="$PATH_TO_PING -A inet6 -n %s -c %d"
1005                 AC_MSG_RESULT([$with_ping6_command])
1007         elif $PATH_TO_PING -A inet6 ::1 -n 1 2>/dev/null | \
1008                 egrep -i "^round-trip|^rtt" >/dev/null
1009         then
1010                 with_ping6_command="$PATH_TO_PING -A inet6 %s -n %d"
1011                 AC_MSG_RESULT([$with_ping6_command])
1013         elif $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \
1014                 egrep -i "^round-trip|^rtt" >/dev/null
1015         then
1016                 with_ping6_command="$PATH_TO_PING -A inet6 -n -s %s 56 %d"
1017                 AC_MSG_RESULT([$with_ping6_command])
1019         elif $PATH_TO_PING -A inet6 -n -h ::1 -s 56 -c 1 2>/dev/null | \
1020                 egrep -i "^round-trip|^rtt" >/dev/null
1021         then
1022                 with_ping6_command="$PATH_TO_PING -A inet6 -n -h %s -s 56 -c %d"
1023                 AC_MSG_RESULT([$with_ping6_command])
1025         elif $PATH_TO_PING -A inet6 -n -s 56 -c 1 ::1 2>/dev/null | \
1026                 egrep -i "^round-trip|^rtt" >/dev/null
1027         then
1028                 with_ping6_command="$PATH_TO_PING -A inet6 -n -s 56 -c %d %s"
1029                 ac_cv_ping6_packets_first=yes
1030                 AC_MSG_RESULT([$with_ping_command])
1032         elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \
1033                 egrep -i "^round-trip|^rtt" >/dev/null
1034         then
1035                 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s"
1036                 ac_cv_ping6_packets_first=yes
1037                 AC_MSG_RESULT([$with_ping6_command])
1039         fi
1041 fi
1043 if test "x$with_ping6_command" != "x"; then
1044         AC_DEFINE_UNQUOTED(PING6_COMMAND,"$with_ping6_command",
1045                 [path and args for ICMPv6 ping command])
1046 else
1047         AC_MSG_RESULT([none])
1048 fi
1050 if test "x$ac_cv_ping6_packets_first" != "xno"; then
1051         AC_DEFINE(PING6_PACKETS_FIRST,1,
1052                 [Define if packet count must precede host])
1053 fi
1054 fi
1057 AC_ARG_WITH(nslookup_command,
1058             ACX_HELP_STRING([--with-nslookup-command=PATH],
1059                             [sets path to nslookup executable]),
1060             ac_cv_nslookup_command=$withval)
1061 if test -n "$ac_cv_nslookup_command"; then
1062         AC_MSG_NOTICE([Using specific nslookup at $ac_cv_nslookup_command])
1063 else
1064         AC_PATH_PROG(PATH_TO_NSLOOKUP,nslookup)
1065         if test -n "$PATH_TO_NSLOOKUP"
1066         then
1067                 AC_MSG_CHECKING(for nslookup syntax)
1068                 if $PATH_TO_NSLOOKUP -sil 127.0.0.1 2>&1 | grep ["Invalid option: sil"] >/dev/null
1069                 then
1070                         ac_cv_nslookup_command="$PATH_TO_NSLOOKUP"
1071                         AC_MSG_RESULT([$ac_cv_nslookup_command])
1073                 else
1074                         ac_cv_nslookup_command="$PATH_TO_NSLOOKUP -sil"
1075                         AC_MSG_RESULT([$ac_cv_nslookup_command])
1077                 fi
1078         else
1079                 AC_MSG_WARN([nslookup command not found])
1080         fi
1081 fi
1083 if test -n "$ac_cv_nslookup_command"; then
1084         EXTRAS="$EXTRAS check_dns"
1085         AC_DEFINE_UNQUOTED(NSLOOKUP_COMMAND,"$ac_cv_nslookup_command", [path and args for nslookup])
1086 fi
1088 AC_MSG_CHECKING([for number of cpus])
1089 AC_TRY_COMPILE([#include <unistd.h>],
1090         [sysconf(_SC_NPROCESSORS_CONF) > 0;],
1091         AC_DEFINE(HAVE_SYSCONF__SC_NPROCESSORS_CONF,1,[Define if sysconf returns number of cpus])
1092         AC_MSG_RESULT([sysconf(_SC_NPROCESSORS_CONF)]),
1093         AC_MSG_RESULT([cannot calculate])
1094         )
1096 AC_PATH_PROG(PATH_TO_UPTIME,uptime)
1097 AC_ARG_WITH(uptime_command,
1098             ACX_HELP_STRING([--with-uptime-command=PATH],
1099                             [sets path to uptime]), PATH_TO_UPTIME=$withval)
1100 AC_DEFINE_UNQUOTED(PATH_TO_UPTIME,"$PATH_TO_UPTIME",[path to uptime binary])
1102 AC_PATH_PROG(PATH_TO_RPCINFO,rpcinfo)
1103 AC_ARG_WITH(rpcinfo_command,
1104             ACX_HELP_STRING([--with-rpcinfo-command=PATH],
1105                             [sets path to rpcinfo]), PATH_TO_RPCINFO=$withval)
1106 AC_DEFINE_UNQUOTED(PATH_TO_RPCINFO,"$PATH_TO_RPCINFO",[path to rpcinfo binary])
1108 AC_PATH_PROG(PATH_TO_LMSTAT,lmstat)
1109 if test -x "$PATH_TO_LMSTAT"
1110 then
1111         AC_DEFINE_UNQUOTED(PATH_TO_LMSTAT,"$PATH_TO_LMSTAT",[path to lmstat])
1112 else
1113         AC_MSG_WARN([Get lmstat from Globetrotter Software to monitor flexlm licenses])
1114 fi
1116 AC_PATH_PROG(PATH_TO_SMBCLIENT,smbclient)
1117 AC_ARG_WITH(smbclient_command,
1118             ACX_HELP_STRING([--with-smbclient-command=PATH],
1119                             [sets path to smbclient]), 
1120             PATH_TO_SMBCLIENT=$withval)
1121 if test -n "$PATH_TO_SMBCLIENT"
1122 then
1123         AC_DEFINE_UNQUOTED(PATH_TO_SMBCLIENT,"$PATH_TO_SMBCLIENT",[path to smbclient binary])
1124 else
1125         AC_MSG_WARN([Get smbclient from Samba.org to monitor SMB shares])
1126 fi
1129 AC_PATH_PROG(PATH_TO_WHO,who)
1131 if [$PATH_TO_WHO -q 2>/dev/null | egrep -i "^# users=[0-9]+$" >/dev/null]
1132 then
1133         ac_cv_path_to_who="$PATH_TO_WHO -q"
1134 else
1135         ac_cv_path_to_who="$PATH_TO_WHO"
1136 fi
1138 AC_DEFINE_UNQUOTED(WHO_COMMAND,"$ac_cv_path_to_who",
1139         [path and arguments for invoking 'who'])
1141 AC_PATH_PROG(PATH_TO_SNMPGET,snmpget)
1142 AC_ARG_WITH(snmpget_command,
1143             ACX_HELP_STRING([--with-snmpget-command=PATH],
1144                             [Path to snmpget command]),
1145             PATH_TO_SNMPGET=$withval)
1146 if test -n "$PATH_TO_SNMPGET"
1147 then
1148         AC_DEFINE_UNQUOTED(PATH_TO_SNMPGET,"$PATH_TO_SNMPGET",[path to snmpget binary])
1149         EXTRAS="$EXTRAS check_hpjd check_snmp"
1150 else
1151         AC_MSG_WARN([Get snmpget from http://net-snmp.sourceforge.net to make check_hpjd and check_snmp plugins])
1152 fi
1154 AC_PATH_PROG(PATH_TO_SNMPGETNEXT,snmpgetnext)
1155 AC_ARG_WITH(snmpgetnext_command,
1156             ACX_HELP_STRING([--with-snmpgetnext-command=PATH],
1157                             [Path to snmpgetnext command]),
1158             PATH_TO_SNMPGETNEXT=$withval)
1159 if test -n "$PATH_TO_SNMPGETNEXT"
1160 then
1161         AC_DEFINE_UNQUOTED(PATH_TO_SNMPGETNEXT,"$PATH_TO_SNMPGETNEXT",[path to snmpgetnext binary])
1162 fi
1164 if ( $PERL -M"Net::SNMP 3.6" -e 'exit' 2>/dev/null  )
1165 then
1166         AC_MSG_CHECKING(for Net::SNMP perl module)
1167         AC_MSG_RESULT([found])
1168 else
1169         AC_MSG_WARN([Tried $PERL - install Net::SNMP perl module if you want to use the perl snmp plugins])
1170 fi
1172 AC_PATH_PROG(PATH_TO_QUAKESTAT,quakestat)
1173 AC_PATH_PROG(PATH_TO_QSTAT,qstat)
1174 AC_ARG_WITH(qstat_command,
1175             ACX_HELP_STRING([--with-qstat-command=PATH], 
1176                             [Path to qstat command]), PATH_TO_QSTAT=$withval)
1178 if test -x "$PATH_TO_QUAKESTAT"
1179 then
1180         ac_cv_path_to_qstat="$PATH_TO_QUAKESTAT"
1181         EXTRAS="$EXTRAS check_game"
1183 elif test -n "$PATH_TO_QSTAT"
1184 then
1185         ac_cv_path_to_qstat="$PATH_TO_QSTAT"
1186         EXTRAS="$EXTRAS check_game"
1187 else
1188         AC_MSG_WARN([Get qstat from http://www.activesw.com/people/steve/qstat.html in order to make check_game plugin])
1189 fi
1191 if test $ac_cv_path_to_qstat 
1192 then
1193         AC_DEFINE_UNQUOTED(PATH_TO_QSTAT,"$ac_cv_path_to_qstat",
1194                 [path to qstat/quakestat])
1195 fi
1197 AC_PATH_PROG(PATH_TO_FPING,fping)
1198 AC_ARG_WITH(fping_command,
1199             ACX_HELP_STRING([--with-fping-command=PATH],
1200                             [Path to fping command]), PATH_TO_FPING=$withval)
1201 if test -n "$PATH_TO_FPING"
1202 then
1203         AC_DEFINE_UNQUOTED(PATH_TO_FPING,"$PATH_TO_FPING",[path to fping])
1204         EXTRAS="$EXTRAS check_fping"
1205 else
1206         AC_MSG_WARN([Get fping from http://www.fping.com in order to make check_fping plugin])
1207 fi
1209 AC_PATH_PROG(PATH_TO_SSH,ssh)
1210 AC_ARG_WITH(ssh_command,
1211             ACX_HELP_STRING([--with-ssh-command=PATH],
1212                             [sets path for ssh]), PATH_TO_SSH=$withval)
1213 if test -n "$PATH_TO_SSH"
1214 then
1215         AC_DEFINE_UNQUOTED(SSH_COMMAND,"$PATH_TO_SSH",[path to ssh binary])
1216         EXTRAS="$EXTRAS check_by_ssh"
1217 else
1218         AC_MSG_WARN([Get ssh in order to make check_by_ssh plugin])
1219 fi
1222 AC_PATH_PROG(PATH_TO_MAILQ,mailq)
1223 AC_ARG_WITH(mailq_command,
1224             ACX_HELP_STRING([--with-mailq-command=PATH],
1225                             [sets path to mailq]), PATH_TO_MAILQ=$withval)
1226 if test -n "$PATH_TO_MAILQ"
1227 then
1228         AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_MAILQ",[path to mailq])
1229 else
1230         AC_MSG_WARN([Could not find mailq or eqivalent])
1231 fi
1233 AC_PATH_PROG(PATH_TO_QMAIL_QSTAT,qmail-qstat)
1234 if test -x "$PATH_TO_QMAIL_QSTAT"
1235 then
1236         AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_QMAIL_QSTAT",[path to qmail-qstat])
1237 else
1238         AC_MSG_WARN([Could not find qmail-qstat or eqivalent])
1239 fi
1241 dnl SWAP info required is amount allocated/available and amount free
1242 dnl The plugin works through all the swap devices and adds up the total swap
1243 dnl available.
1244 AC_PATH_PROG(PATH_TO_SWAP,swap)
1245 if (test -n "$PATH_TO_SWAP")
1246 then
1247 AC_MSG_CHECKING([for $PATH_TO_SWAP format])
1248 if [$PATH_TO_SWAP -l 2>&1 >/dev/null]
1249 then
1250         ac_cv_have_swap=yes
1251         ac_cv_swap_command="$PATH_TO_SWAP -l"
1252         if [$PATH_TO_SWAP -l 2>/dev/null | \
1253                 egrep -i "^lswap +path +pri +swaplo +blocks +free +maxswap" \
1254                 >/dev/null]
1255         then
1256                 ac_cv_swap_format=[" %*d %*s %*d,%*d %*d %*d %f %f"]
1257                 ac_cv_swap_conv=2048
1258                 AC_MSG_RESULT([using IRIX format swap])
1260         elif [$PATH_TO_SWAP -l 2>/dev/null | egrep -i "^path +dev +swaplo +blocks +free" >/dev/null]
1261         then
1262                 ac_cv_swap_format=["%*s %*[0-9,-] %*d %f %f"]
1263                 ac_cv_swap_conv=2048
1264                 AC_MSG_RESULT([using Unixware format swap])
1265         else
1266                 dnl if we don't know what format swap's output is
1267                 dnl we might as well pretend we didn't see it
1268                 ac_cv_have_swap=""
1269                 ac_cv_swap_command=""
1270         fi
1271 fi
1272 dnl end if for PATH_TO_SWAP
1273 fi
1275 AC_PATH_PROG(PATH_TO_SWAPINFO,swapinfo)
1276 if (test -n "$PATH_TO_SWAPINFO")
1277 then
1278 AC_MSG_CHECKING([for $PATH_TO_SWAPINFO format])
1279 if [$PATH_TO_SWAPINFO -k 2>&1 | egrep -i "^Device" >/dev/null]
1280 then
1281         ac_cv_have_swap=yes
1282         ac_cv_swap_command="$PATH_TO_SWAPINFO -k"
1284         if [$PATH_TO_SWAPINFO -k 2>/dev/null | egrep -i "^Device +1K-blocks +Used +Avail" >/dev/null]
1285         then
1286                 ac_cv_swap_format=["%*s %f %*d %f"]
1287                 ac_cv_swap_conv=1024
1288                 AC_MSG_RESULT([using FreeBSD format swapinfo])
1289         fi
1291 elif [$PATH_TO_SWAPINFO -dfM 2>/dev/null | egrep -i "^TYPE +AVAIL +USED +FREE" >/dev/null]
1292 then
1293         ac_cv_have_swap=yes
1294         ac_cv_swap_command="$PATH_TO_SWAPINFO -dfM"
1295         ac_cv_swap_format=["%*s %f %*d %f"]
1296         ac_cv_swap_conv=1024
1297         AC_MSG_RESULT([using HP-UX format swapinfo])
1298 fi
1299 dnl end if for PATH_TO_SWAPINFO
1300 fi
1302 AC_PATH_PROG(PATH_TO_LSPS,lsps)
1303 if (test -n "$PATH_TO_LSPS")
1304 then
1305 AC_MSG_CHECKING([for $PATH_TO_LSPS format])
1306 if [$PATH_TO_LSPS -a 2>/dev/null | egrep -i "^Page Space" > /dev/null]
1307 then
1308         ac_cv_have_swap=yes
1309         ac_cv_swap_command="$PATH_TO_LSPS -a"
1310         ac_cv_swap_format=["%*s %*s %*s %f%*s %f %*s"]
1311         ac_cv_swap_conv=1
1312         AC_MSG_RESULT([using AIX lsps])
1313 fi
1314 dnl end if for PATH_TO_SWAPINFO
1315 fi
1317 dnl
1318 dnl test for swapctl system call, both the 2-arg and 3-arg variants
1319 dnl fwict, the 2-arg is an SVR4 standard, whereas the 3-arg is shared
1320 dnl in the various BSD's
1321 dnl
1323 AC_CHECK_HEADERS([sys/stat.h sys/param.h])
1324 AC_CHECK_HEADERS([sys/swap.h], [], [], [
1325 #ifdef HAVE_SYS_PARAM_H
1326 #include <sys/param.h>
1327 #endif
1328 ])
1329 AC_CHECK_DECLS([swapctl],,,[
1330                #include <unistd.h>
1331                #include <sys/types.h>
1332                #include <sys/param.h>
1333                #include <sys/stat.h>
1334                #include <sys/swap.h>
1335                ])
1336 AC_CHECK_TYPES([swaptbl_t, swapent_t],,,[
1337                #include <sys/types.h>
1338                #include <sys/param.h>
1339                #include <sys/stat.h>
1340                #include <sys/swap.h>
1341                ])
1342 AC_CHECK_MEMBERS([struct swapent.se_nblks],,,[
1343                #include <unistd.h>
1344                #include <sys/types.h>
1345                #include <sys/param.h>
1346                #include <sys/stat.h>
1347                #include <sys/swap.h>
1348                ])
1350 if test "$ac_cv_have_decl_swapctl" = "yes"; 
1351 then
1352         EXTRAS="$EXTRAS check_swap"
1353         AC_MSG_CHECKING([for 2-arg (SVR4) swapctl])
1354         if test "$ac_cv_type_swaptbl_t" = "yes" -a \
1355                 "$ac_cv_type_swapent_t" = "yes"; 
1356         then
1357                 AC_MSG_RESULT([yes])
1358                 ac_cv_check_swap_swapctl_svr4="1";
1359                 AC_DEFINE([CHECK_SWAP_SWAPCTL_SVR4],1,
1360                           [Define if 2-argument SVR4 swapctl exists])
1361         else
1362                 AC_MSG_RESULT([no])
1363                 AC_MSG_CHECKING([for 3-arg (*BSD) swapctl])
1364                 if test "$ac_cv_member_struct_swapent_se_nblks" = "yes"; 
1365                 then
1366                         AC_MSG_RESULT([yes])
1367                         AC_DEFINE([CHECK_SWAP_SWAPCTL_BSD],1,
1368                                   [Define if 3-argument BSD swapctl exists])
1369                 else
1370                         AC_MSG_RESULT([no])
1371                 fi
1372         fi
1373         AC_MSG_CHECKING([for whether swapctl uses blocks or pages])
1374         if test "$ac_cv_check_swap_swapctl_svr4" = "1";
1375         then
1376                 dnl
1377                 dnl the SVR4 spec returns values in pages
1378                 dnl
1379                 AC_MSG_RESULT([page])
1380                 AC_CHECK_DECLS([sysconf])
1381                 AC_MSG_CHECKING([for system page size])
1382                 if test "$ac_cv_have_decl_sysconf" = "yes";
1383                 then
1384                         AC_MSG_RESULT([determined by sysconf(3)])
1385                         ac_cv_swap_conv="(1048576/sysconf(_SC_PAGESIZE))"
1386                 else
1387                         AC_MSG_WARN([don't know. guessing 4096k])
1388                         ac_cv_swap_conv=256
1389                 fi
1390         else
1391                 dnl
1392                 dnl the BSD spec returns values in blocks
1393                 dnl
1394                 AC_MSG_RESULT([blocks (assuming 512b)])
1395                 ac_cv_swap_conv=2048
1396         fi
1397         AC_DEFINE_UNQUOTED(SWAP_CONVERSION,$ac_cv_swap_conv,
1398                 [Conversion factor to MB])
1399 fi
1400 dnl
1401 dnl end tests for the swapctl system calls
1402 dnl
1405 if test "x$ac_cv_have_swap" != "x" 
1406 then
1407         AC_DEFINE(HAVE_SWAP,1,[Define if swap/swapinfo command is found])
1408         EXTRAS="$EXTRAS check_swap"
1409 fi
1410 if test "x$ac_cv_swap_command" != "x" 
1411 then
1412         AC_DEFINE_UNQUOTED(SWAP_COMMAND,"$ac_cv_swap_command",
1413                 [Path to swap/swapinfo binary, with any args])
1414         AC_DEFINE_UNQUOTED(SWAP_FORMAT,"$ac_cv_swap_format",
1415                 [Format string for parsing swap output])
1416         AC_DEFINE_UNQUOTED(SWAP_CONVERSION,$ac_cv_swap_conv,
1417                 [Conversion factor to MB])
1418 fi
1420 AC_ARG_WITH(proc-meminfo,
1421             ACX_HELP_STRING([--with-proc-meminfo=PATH],
1422                             [path to /proc/meminfo or equivalent]),
1423                             ac_cv_proc_meminfo=$withval)
1424 dnl dunno why this does not work below - use hack (kbd)
1425 dnl fine on linux, broken on solaris
1426 dnl if /bin/test -e "/proc/meminfo"
1427 AC_MSG_CHECKING([for /proc/meminfo])
1428 if test -n "$ac_cv_proc_meminfo"; then
1429         AC_MSG_RESULT([(command line) $ac_cv_proc_meminfo])
1430 elif [cat /proc/meminfo > /dev/null 2>&1]; then
1431         AC_MSG_RESULT([found /proc/meminfo])
1432         ac_cv_proc_meminfo="/proc/meminfo"
1433 else
1434         AC_MSG_RESULT([no])
1435 fi
1437 if test -n "$ac_cv_proc_meminfo"; then
1438         AC_DEFINE(HAVE_PROC_MEMINFO,1,[Define if we have /proc/meminfo])
1439         AC_DEFINE_UNQUOTED(PROC_MEMINFO,"$ac_cv_proc_meminfo",[path to /proc/meminfo if name changes])
1440         EXTRAS="$EXTRAS check_swap"
1441 fi
1443 AC_PATH_PROG(PATH_TO_DIG,dig)
1444 AC_ARG_WITH(dig_command,
1445             ACX_HELP_STRING([--with-dig-command=PATH],
1446                             [Path to dig command]), PATH_TO_DIG=$withval)
1447 if test -n "$PATH_TO_DIG"; then
1448         EXTRAS="$EXTRAS check_dig"
1449         AC_DEFINE_UNQUOTED(PATH_TO_DIG,"$PATH_TO_DIG",[Path to dig command, if present])
1450 fi
1452 AC_PATH_PROG(PATH_TO_APTGET,apt-get)
1453 AC_ARG_WITH(apt-get_command,
1454             ACX_HELP_STRING([--with-apt-get-command=PATH],
1455                             [Path to apt-get command]), 
1456                             with_apt_get_command=$withval,
1457                             with_apt_get_command=$PATH_TO_APTGET)
1458 AC_DEFINE_UNQUOTED(PATH_TO_APTGET,"$PATH_TO_APTGET",[Path to apt-get command, if present])
1459 if test -n "$PATH_TO_APTGET" ; then
1460         EXTRAS="$EXTRAS check_apt"
1461 fi
1464 if test -f plugins/check_nt.c ; then
1465   EXTRAS="$EXTRAS check_nt"
1466 elif test -f ../plugins/check_nt.c ; then
1467   EXTRAS="$EXTRAS check_nt"
1468 fi
1471 dnl used in check_dhcp
1472 AC_CHECK_HEADERS(sys/sockio.h)
1474 case $host in
1475         *bsd*)
1476                 AC_DEFINE(__bsd__,1,[bsd specific code in check_dhcp.c])
1477         ;;
1478         *linux*)
1479                 AC_DEFINE(__linux__,1,[sun specific code in check_dhcp.c])
1480         ;;
1481         *sun* | solaris*)
1482                 AC_DEFINE(__sun__,1,[sun specific code in check_dhcp.c])
1483         ;;
1484         *hpux*)  
1485                 AC_DEFINE(__hpux__,1,[hpux specific code in check_dhcp.c])
1486         ;;
1487 esac
1489 AC_SUBST(EXTRAS)
1490 AC_SUBST(EXTRAS_ROOT)
1491 AC_SUBST(EXTRA_NETOBJS)
1492 AC_SUBST(DEPLIBS)
1494 AM_GNU_GETTEXT([external], [need-ngettext])
1495 AM_GNU_GETTEXT_VERSION(0.15)
1497 dnl Check for Redhat spopen problem
1498 dnl Wierd problem where ECHILD is returned from a wait call in error
1499 dnl Only appears to affect nslookup and dig calls. Only affects redhat around
1500 dnl 2.6.9-11 (okay in 2.6.9-5). Redhat investigating root cause
1501 dnl We patch plugins/popen.c
1502 dnl Need to add smp because uname different on those
1503 dnl Can force patch to be applied with --enable-redhat-pthread-workaround
1504 AC_ARG_ENABLE(redhat-pthread-workaround, 
1505         AC_HELP_STRING([--enable-redhat-pthread-workaround], 
1506                 [force Redhat patch to be applied (default: test system)]),
1507         [ac_cv_enable_redhat_pthread_workaround=$enableval],
1508         [ac_cv_enable_redhat_pthread_workaround=test])
1509 if test "$ac_cv_enable_redhat_pthread_workaround" = "test" ; then
1510         if echo $ac_cv_uname_r | egrep "\.EL(smp)?$" >/dev/null 2>&1 ; then
1511                 AC_MSG_CHECKING(for redhat spopen problem)
1512                 ( cd config_test && make && make test ) > /dev/null 2>&1
1513                 if test $? -eq 0 ; then
1514                         AC_MSG_RESULT(okay)
1515                 else
1516                         AC_MSG_RESULT(error)
1517                         AC_DEFINE(REDHAT_SPOPEN_ERROR, 1, [Workaround on redhat in spopen])
1518                 fi
1519         fi
1520 elif test "$ac_cv_enable_redhat_pthread_workaround" = "yes" ; then
1521         AC_DEFINE(REDHAT_SPOPEN_ERROR, 1, [Forced workaround on redhat in spopen])
1522 fi
1524 dnl Perl modules
1525 AC_ARG_ENABLE(perl-modules,
1526         AC_HELP_STRING([--enable-perl-modules], 
1527                 [Enables installation of Nagios::Plugin and its dependencies (default: no)]),
1528         [enable_perl_modules=$enableval],
1529         [enable_perl_modules=no])
1530 if test "$enable_perl_modules" = "yes" ; then
1531   AC_SUBST(PERLMODS_DIR,perlmods)
1532 fi
1534 dnl External libraries - see ACKNOWLEDGEMENTS
1535 gl_INIT
1537 dnl Some helpful common compile errors checked here
1538 if test "$ac_cv_uname_s" = 'SunOS' -a "$ac_cv_prog_ac_ct_AR" = 'false' ; then
1539         AC_MSG_ERROR(No ar found for Solaris - is /usr/ccs/bin in PATH?)
1540 fi
1542 AC_OUTPUT(
1543   Makefile 
1544   lib/Makefile 
1545   plugins/Makefile 
1546   lib/tests/Makefile
1547   plugins-root/Makefile
1548   plugins-scripts/Makefile 
1549   plugins-scripts/subst 
1550   plugins-scripts/utils.pm 
1551   plugins-scripts/utils.sh 
1552   perlmods/Makefile
1553   command.cfg 
1554   test.pl 
1555   pkg/solaris/pkginfo 
1556   po/Makefile.in 
1560 dnl the ones below that are commented out need to be cleaned up 
1561 dnl in the configure code above to use with_foo instead of ac_cv_foo
1562 dnl if we want them to show up here.  it'd also make the code cleaner.
1563 dnl i'll get to that on another rainy day :) -sf
1564 ACX_FEATURE([with],[apt-get-command])
1565 dnl ACX_FEATURE([with],[dig-command])
1566 dnl ACX_FEATURE([with],[fping-command])
1567 dnl ACX_FEATURE([with],[mailq-command])
1568 dnl ACX_FEATURE([with],[nslookup-command])
1569 ACX_FEATURE([with],[ping6-command])
1570 ACX_FEATURE([with],[ping-command])
1571 dnl ACX_FEATURE([with],[qstat-command])
1572 dnl ACX_FEATURE([with],[rpcinfo-command])
1573 dnl ACX_FEATURE([with],[smbclient-command])
1574 dnl ACX_FEATURE([with],[snmpget-command])
1575 dnl ACX_FEATURE([with],[snmpgetnext-command])
1576 dnl ACX_FEATURE([with],[ssh-command])
1577 dnl ACX_FEATURE([with],[uptime-command])
1579 dnl ACX_FEATURE([with],[proc-meminfo])
1580 dnl ACX_FEATURE([with],[ps-command])
1581 dnl ACX_FEATURE([with],[ps-format])
1582 dnl ACX_FEATURE([with],[ps-cols])
1583 dnl ACX_FEATURE([with],[ps-varlist])
1585 ACX_FEATURE([with],[ipv6])
1586 ACX_FEATURE([with],[mysql])
1587 ACX_FEATURE([with],[openssl])
1588 ACX_FEATURE([with],[gnutls])
1589 ACX_FEATURE([with],[perl])
1590 ACX_FEATURE([enable],[perl-modules])
1591 ACX_FEATURE([with],[cgiurl])
1592 ACX_FEATURE([with],[trusted-path])