Code

afde8374028730e9dc76172bbfae12eddc42b43c
[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.12)
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 INI Parsing
158 AC_ARG_ENABLE(extra-opts,
159   AC_HELP_STRING([--enable-extra-opts], 
160                 [Enables parsing of plugins ini config files for extra options (default: no)]),
161         [enable_extra_opts=$enableval],
162         [enable_extra_opts=no])
163 AM_CONDITIONAL([USE_PARSE_INI],[test "$enable_extra_opts" = "yes"])
164 if test "$enable_extra_opts" = "yes" ; then
165         EXTRA_TEST="$EXTRA_TEST test_ini test_opts"
166         AC_SUBST(EXTRA_TEST)
167         AC_DEFINE(NP_EXTRA_OPTS,[1],[Enable INI file parsing.])
168 fi
170 dnl Check for PostgreSQL libraries
171 _SAVEDLIBS="$LIBS"
172 _SAVEDCPPFLAGS="$CPPFLAGS"
173 AC_ARG_WITH(pgsql,
174         ACX_HELP_STRING([--with-pgsql=DIR],
175                 [sets path to pgsql installation]),
176         PGSQL=$withval,)
177 AC_CHECK_LIB(crypt,main)
178 if test "$ac_cv_lib_crypt_main" = "yes" -a "x$PGSQL" != "xno"; then
179   if test -n "$PGSQL"; then
180     LDFLAGS="$LDFLAGS -L$PGSQL/lib"
181     CPPFLAGS="$CPPFLAGS -I$PGSQL/include"
182   fi
183   AC_CHECK_LIB(pq,PQsetdbLogin,,,-lcrypt)
184   if test "$ac_cv_lib_pq_PQsetdbLogin" = "yes"; then
185     AC_CHECK_HEADERS(pgsql/libpq-fe.h)
186     AC_CHECK_HEADERS(postgresql/libpq-fe.h)
187     AC_CHECK_HEADERS(libpq-fe.h)
188     if [[ -n "$PGSQL" -a "$ac_cv_header_libpq_fe_h" = "yes" ]]; then
189       PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
190       PGINCLUDE="-I$PGSQL/include"
191     elif test  "$ac_cv_header_pgsql_libpq_fe_h" = "yes"; then
192       PGLIBS="-lpq -lcrypt"
193       PGINCLUDE="-I/usr/include/pgsql"
194     elif test  "$ac_cv_header_postgresql_libpq_fe_h" = "yes"; then
195       PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
196       PGINCLUDE="-I/usr/include/postgresql"
197     elif test  "$ac_cv_header_libpq_fe_h" = "yes"; then
198       PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
199       PGINCLUDE="-I$PGSQL/include"
200     fi
201     if test -z "$PGINCLUDE"; then
202       AC_MSG_WARN([Skipping PostgreSQL plugin (check_pgsql)])
203       AC_MSG_WARN([install PostgreSQL headers to compile this plugin (see REQUIREMENTS).])
204     else
205       AC_SUBST(PGLIBS)
206       AC_SUBST(PGINCLUDE)
207       EXTRAS="$EXTRAS check_pgsql"
208     fi
209   else
210     AC_MSG_WARN([Skipping PostgreSQL plugin (check_pgsql)])
211     AC_MSG_WARN([LIBS="$LIBS" CPPFLAGS="$CPPFLAGS"])
212     AC_MSG_WARN([install PostgreSQL libs to compile this plugin (see REQUIREMENTS).])
213   fi
214 else
215   AC_MSG_WARN([Skipping PostgreSQL plugin (check_pgsql)])
216   AC_MSG_WARN([install lib crypt and PostgreSQL libs to compile this plugin (see REQUIREMENTS).])
217 fi
218 LIBS="$_SAVEDLIBS"
219 CPPFLAGS="$_SAVEDCPPFLAGS"
221 dnl Check for radius libraries
222 _SAVEDLIBS="$LIBS"
223 AC_CHECK_LIB(radiusclient,rc_read_config)
224 if test "$ac_cv_lib_radiusclient_rc_read_config" = "yes"; then
225   EXTRAS="$EXTRAS check_radius"
226         RADIUSLIBS="-lradiusclient"
227   AC_SUBST(RADIUSLIBS)
228 else
229   AC_CHECK_LIB(radiusclient-ng,rc_read_config)
230   if test "$ac_cv_lib_radiusclient_ng_rc_read_config" = "yes"; then
231     EXTRAS="$EXTRAS check_radius"
232           RADIUSLIBS="-lradiusclient-ng"
233     AC_SUBST(RADIUSLIBS)
234   else
235     AC_MSG_WARN([Skipping radius plugin])
236     AC_MSG_WARN([install radius libs to compile this plugin (see REQUIREMENTS).])
237   fi
238 fi
239 LIBS="$_SAVEDLIBS"
241 dnl Check for LDAP libraries
242 _SAVEDLIBS="$LIBS"
243 AC_CHECK_LIB(ldap,main,,,-llber)
244 if test "$ac_cv_lib_ldap_main" = "yes"; then
245   LDAPLIBS="-lldap -llber"\
246   LDAPINCLUDE="-I/usr/include/ldap"
247   AC_SUBST(LDAPLIBS)
248   AC_SUBST(LDAPINCLUDE)
249   AC_CHECK_FUNCS(ldap_set_option)
250   EXTRAS="$EXTRAS check_ldap"
251         AC_CHECK_FUNCS(ldap_init ldap_set_option ldap_get_option ldap_start_tls_s)
252 else
253   AC_MSG_WARN([Skipping LDAP plugin])
254   AC_MSG_WARN([install LDAP libs to compile this plugin (see REQUIREMENTS).])
255 fi
256 LIBS="$_SAVEDLIBS"
258 dnl Check for headers used by check_ide_smart
259 AC_CHECK_HEADER(linux/hdreg.h, FOUNDINCLUDE=yes, FOUNDINCLUDE=no)
260 if test "$FOUNDINCLUDE" = "yes" ; then
261         AC_CHECK_HEADER(linux/types.h, FOUNDINCLUDE=yes, FOUNDINCLUDE=no)
262 fi
264 if test "$FOUNDINCLUDE" = "yes" ; then
265         EXTRAS="$EXTRAS check_ide_smart"
266 else
267         AC_MSG_WARN([Skipping check_ide_smart plugin.]) 
268         AC_MSG_WARN([check_ide_smart is linux specific. It requires linux/hdreg.h and linux/types.h.]) 
269 fi
271 dnl Check for mysql libraries
272 np_mysqlclient
273 if test $with_mysql = "no" ; then
274   AC_MSG_WARN([Skipping mysql plugin])
275   AC_MSG_WARN([install mysql client libs to compile this plugin (see REQUIREMENTS).])
276 else
277   EXTRAS="$EXTRAS check_mysql check_mysql_query"
278   MYSQLINCLUDE="$np_mysql_include"
279   MYSQLLIBS="$np_mysql_libs"
280   MYSQLCFLAGS="$np_mysql_cflags"
281   AC_SUBST(MYSQLINCLUDE)
282   AC_SUBST(MYSQLLIBS)
283   AC_SUBST(MYSQLCFLAGS)
284 fi
286 AC_ARG_WITH([ipv6],
287         [AS_HELP_STRING([--with-ipv6], [support IPv6 @<:@default=check@:>@])],
288         [], [with_ipv6=check])
290 dnl Check for AF_INET6 support - unistd.h required for Darwin
291 if test "$with_ipv6" != "no"; then
292         AC_CACHE_CHECK([for IPv6 support], np_cv_sys_ipv6, [
293                 AC_TRY_COMPILE(
294                         [#ifdef HAVE_UNISTD_H
295                         #include <unistd.h>
296                         #endif
297                         #include <netinet/in.h>
298                         #include <sys/socket.h>],
299                         [struct sockaddr_in6 sin6;
300                         void *p;
302                         sin6.sin6_family = AF_INET6;
303                         sin6.sin6_port = 587;
304                         p = &sin6.sin6_addr;],
305                         [np_cv_sys_ipv6=yes],
306                         [np_cv_sys_ipv6=no])
307                 ])
308         if test "$np_cv_sys_ipv6" = "no" -a "$with_ipv6" != "check"; then
309                 AC_MSG_FAILURE([--with-ipv6 was given, but test for IPv6 support failed])
310         fi
311         if test "$np_cv_sys_ipv6" = "yes"; then
312                 AC_DEFINE(USE_IPV6,1,[Enable IPv6 support])
313         fi
314         with_ipv6="$np_cv_sys_ipv6"
315 fi
318 dnl Checks for Kerberos. Must come before openssl checks for Redhat EL 3
319 AC_CHECK_HEADERS(krb5.h,FOUNDINCLUDE=yes,FOUNDINCLUDE=no)
320 if test "$FOUNDINCLUDE" = "no"; then
321   _SAVEDCPPFLAGS="$CPPFLAGS"
322   CPPFLAGS="$_SAVEDCPPFLAGS -I/usr/kerberos/include"
323   unset ac_cv_header_krb5_h
324   AC_CHECK_HEADERS(krb5.h,
325                    KRB5INCLUDE="-I/usr/kerberos/include"
326                    FOUNDINCLUDE=yes,
327                    FOUNDINCLUDE=no)
328 fi
329 AC_SUBST(KRBINCLUDE)
330 if test "$FOUNDINCLUDE" = "no"; then
331   CPPFLAGS="$_SAVEDCPPFLAGS"
332 fi
334 dnl *** The following block comes from wget configure.ac ***
335 dnl Unfortunately, as of this writing (OpenSSL 0.9.6), the libcrypto
336 dnl shared library doesn't record its dependency on libdl, so we
337 dnl need to check for it ourselves so we won't fail to link due to a
338 dnl lack of -ldl.  Most OSes use dlopen(), but HP-UX uses
339 dnl shl_load().
340 AC_CHECK_LIB(dl,dlopen)
341 AC_CHECK_LIB(dl,shl_load)
343 dnl openssl detection/configuration
344 if ! test x"$with_openssl" = x"no"; then
345         dnl Check for OpenSSL location if it wasn't already specified
346         if ! test -d "$with_openssl"; then
347                 for d in $OPENSSL_DIRS; do
348                         if test -x ${d}/bin/openssl || test -x ${d}/sbin/openssl ; then
349                                 with_openssl=$d
350                         fi
351                 done
352         fi
354         _SAVEDCPPFLAGS="$CPPFLAGS"
355         _SAVEDLDFLAGS="$LDFLAGS"
356         dnl Check for OpenSSL header files
357         unset FOUNDINCLUDE
358         if test x"$with_openssl" != x"/usr" ; then
359                 CPPFLAGS="$CPPFLAGS -I$with_openssl/include"
360                 LDFLAGS="$LDFLAGS -L$with_openssl/lib"
361         fi
363         dnl check for openssl in $dir/include/openssl
364         AC_CHECK_HEADERS(openssl/ssl.h openssl/x509.h openssl/rsa.h openssl/pem.h openssl/crypto.h openssl/err.h,
365                          SSLINCLUDE="-I$with_openssl/include"
366                          FOUNDINCLUDE=yes,
367                          FOUNDINCLUDE=no)
368         dnl else check to see if $dir/include has it
369         if test "$FOUNDINCLUDE" = "no"; then
370                 AC_CHECK_HEADERS(ssl.h x509.h rsa.h pem.h crypto.h err.h,
371                                  SSLINCLUDE="-I$with_openssl/include"
372                                  FOUNDINCLUDE=yes,
373                                  FOUNDINCLUDE=no)
374         fi
375         AC_SUBST(SSLINCLUDE)
376         dnl if we didn't find it, reset CPPFLAGS
377         if test "$FOUNDINCLUDE" = "no"; then
378                 CPPFLAGS="$_SAVEDCPPFLAGS"
379                 LDFLAGS="$_SAVEDLDFLAGS"
380         fi
382         dnl Check for crypto lib
383         _SAVEDLIBS="$LIBS"
384         LIBS="-L${with_openssl}/lib"
385         AC_CHECK_LIB(crypto,CRYPTO_lock)
386         if test "$ac_cv_lib_crypto_CRYPTO_lock" = "yes"; then
387                 dnl Check for SSL lib
388                 AC_CHECK_LIB(ssl,main, SSLLIBS="-lssl -lcrypto",,-lcrypto)
389         fi
390         LIBS="$_SAVEDLIBS"
392         dnl test headers and libs to decide whether check_http should use SSL
393         if test "$ac_cv_lib_crypto_CRYPTO_lock" = "yes"; then
394                 if test "$ac_cv_lib_ssl_main" = "yes"; then
395                         if test "$FOUNDINCLUDE" = "yes"; then
396                                 FOUNDOPENSSL="yes"
397                         fi
398                 fi
399         fi
400 fi
403 dnl check for gnutls if openssl isn't found (or is disabled)
404 if test ! "$FOUNDOPENSSL" = "yes" && test ! "$with_gnutls" = "no"; then
405         if test ! "$with_gnutls" = ""; then
406                 CPPFLAGS="$CPPFLAGS -I${with_gnutls}/include"
407         elif test ! "$LIBGNUTLS_CONFIG" = ""; then
408                 CPPFLAGS="$CPPFLAGS -I`$LIBGNUTLS_CONFIG --prefix`"
409         fi
410         AC_CHECK_HEADERS([gnutls/openssl.h],FOUNDGNUTLS="yes",)
411         if test "$FOUNDGNUTLS" = "yes"; then
412                 AC_CHECK_LIB(gnutls-openssl,main,SSLLIBS="-lgnutls-openssl")
413         fi
414 fi
415 dnl end check for gnutls
417 if test "$FOUNDOPENSSL" = "yes" || test "$FOUNDGNUTLS" = "yes"; then
418         check_tcp_ssl="check_simap check_spop check_jabber check_nntps check_ssmtp"
419         AC_SUBST(check_tcp_ssl)
420         AC_SUBST(SSLLIBS)
421         AC_DEFINE(HAVE_SSL,1,[Define if SSL libraries are found])
422         if test "$FOUNDOPENSSL" = "yes"; then
423                 AC_DEFINE(USE_OPENSSL,1,[Define if using OpenSSL libraries])
424                 with_openssl="yes"
425                 with_gnutls="no"
426         else
427                 AC_DEFINE(USE_GNUTLS,1,[Define if using gnutls libraries])
428                 with_gnutls="yes"
429                 with_openssl="no"
430         fi
431 else
432         dnl else deliberately disabled or no ssl support available
433         AC_MSG_WARN([OpenSSL or GnuTLS libs could not be found or were disabled])
434         with_openssl="no"
435         with_gnutls="no"
436 fi
438 dnl
439 dnl Checks for header files.
440 dnl
442 AC_HEADER_TIME
443 AC_HEADER_SYS_WAIT
444 AC_CHECK_HEADERS(signal.h syslog.h uio.h errno.h sys/time.h sys/socket.h sys/un.h sys/poll.h)
445 AC_CHECK_HEADERS(features.h stdarg.h sys/unistd.h ctype.h)
447 dnl Checks for typedefs, structures, and compiler characteristics.
448 AC_C_CONST
449 AC_STRUCT_TM
450 AC_TYPE_PID_T
451 AC_TYPE_SIZE_T
452 AC_TYPE_SIGNAL
453 AC_TYPE_MBSTATE_T
455 AC_CACHE_CHECK([for va_copy],ac_cv_HAVE_VA_COPY,[
456 AC_TRY_LINK([#include <stdarg.h>
457 va_list ap1,ap2;], [va_copy(ap1,ap2);],
458 ac_cv_HAVE_VA_COPY=yes,
459 ac_cv_HAVE_VA_COPY=no)])
460 if test x"$ac_cv_HAVE_VA_COPY" = x"yes"; then
461     AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available])
462 else    
463     AC_CACHE_CHECK([for __va_copy],ac_cv_HAVE___VA_COPY,[
464     AC_TRY_LINK([#include <stdarg.h>
465     va_list ap1,ap2;], [__va_copy(ap1,ap2);],
466     ac_cv_HAVE___VA_COPY=yes,
467     ac_cv_HAVE___VA_COPY=no)])
468     if test x"$ac_cv_HAVE___VA_COPY" = x"yes"; then
469         AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available])
470     fi
471 fi
473 AC_TRY_COMPILE([#include <sys/time.h>],
474                [struct timeval *tv;
475                 struct timezone *tz;],
476                AC_DEFINE(HAVE_STRUCT_TIMEVAL,1,[Define if we have a timeval structure])
477                AC_TRY_COMPILE([#include <sys/time.h>],
478                               [struct timeval *tv;
479                                struct timezone *tz;
480                                gettimeofday(tv, tz);],
481                               AC_DEFINE(HAVE_GETTIMEOFDAY,1,[Define if gettimeofday is found]),
482                               AC_DEFINE(NEED_GETTIMEOFDAY,1,[Define if gettimeofday is needed])))
484 dnl Checks for library functions.
485 AC_CHECK_FUNCS(memmove select socket strdup strstr strtol strtoul floor)
486 AC_CHECK_FUNCS(poll)
488 AC_MSG_CHECKING(return type of socket size)
489 AC_TRY_COMPILE([#include <stdlib.h>
490                 #include <sys/types.h>
491                 #include <sys/socket.h>],
492                [int a = send(1, (const void *) buffer, (size_t *) 0, (int *) 0);],
493                ac_cv_socket_size_type=["size_t"]
494                 AC_MSG_RESULT(size_t),
495                ac_cv_socket_size_type=["int"]
496                 AC_MSG_RESULT(int))
498 AC_DEFINE_UNQUOTED(SOCKET_SIZE_TYPE, $ac_cv_socket_size_type ,
499         [Define type of socket size])
502 dnl #### Process table test
504 AC_PATH_PROG(PATH_TO_PS,ps)
506 AC_MSG_CHECKING(for ps syntax)
507 AC_ARG_WITH(ps_command,
508             ACX_HELP_STRING([--with-ps-command=PATH], 
509                             [Verbatim command to execute for ps]),
510             PS_COMMAND=$withval)
511 AC_ARG_WITH(ps_format,
512             ACX_HELP_STRING([--with-ps-format=FORMAT],
513                             [Format string for scanning ps output]),
514             PS_FORMAT=$withval)
515 AC_ARG_WITH(ps_cols,
516             ACX_HELP_STRING([--with-ps-cols=NUM], 
517                             [Number of columns in ps command]),
518             PS_COLS=$withval)
519 AC_ARG_WITH(ps_varlist,
520             ACX_HELP_STRING([--with-ps-varlist=LIST],
521                             [Variable list for sscanf of 'ps' output]),
522             PS_VARLIST=$withval)
524 if test -n "$PS_COMMAND" && test -n "$PS_FORMAT" && test -n "$PS_COLS" && test -n "$PS_VARLIST"; then 
525         ac_cv_ps_command="$PS_COMMAND"
526         ac_cv_ps_format="$PS_FORMAT"
527         ac_cv_ps_varlist="$PS_VARLIST"
528         ac_cv_ps_cols="$PS_COLS"
529         AC_MSG_RESULT([(command-line) $ac_cv_ps_command])
531 dnl Now using the pst3/kmem hack for solaris systems to avoid truncation
532 elif test "$ac_cv_uname_s" = "SunOS"; then
533         #
534         # this is a very, very ugly hack, to hardcode the location for plugins
535         #
536         if test "$libexecdir" = '${exec_prefix}/libexec'; then
537                 if test "$exec_prefix" = "NONE"; then
538                         if test "$prefix" = "NONE"; then
539                                 pst3="$ac_default_prefix/libexec/pst3"
540                         else
541                                 pst3="$prefix/libexec/pst3"
542                         fi
543                 else
544                         pst3="$exec_prefix/libexec/pst3"
545                 fi
546         else
547                 pst3="$libexecdir/pst3"
548         fi
549         ac_cv_ps_command="$pst3"
550         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
551         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
552         ac_cv_ps_cols=9
553         AC_MSG_RESULT([using nagios-plugins internal ps command (pst3) for solaris])
554         if test `isainfo -b` = 64 ; then
555                 PST3CFLAGS="-m64"
556                 AC_SUBST(PST3CFLAGS)
557                 AC_MSG_NOTICE([using 64bit pst3])       
558         else
559                 AC_MSG_NOTICE([using 32bit pst3])
560         fi
561         EXTRAS_ROOT="$EXTRAS_ROOT pst3"
563 dnl Removing this for the moment - Ton
564 dnl Using /usr/ucb/ps on Solaris systems, to avoid truncation
565 dnl Limitation that command name is not available
566 dnl elif test "$ac_cv_uname_s" = "SunOS" && /usr/ucb/ps -alxwwn 2>/dev/null | \
567 dnl     egrep -i ["^ *F +UID +PID +PPID +%C +PRI +NI +SZ +RSS +WCHAN +S +TT +TIME +COMMAND"] > /dev/null
568 dnl then
569 dnl     ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procpcpu,&procvsz,&procrss,procstat,&pos]"
570 dnl     ac_cv_ps_command="/usr/ucb/ps -alxwwn"
571 dnl     ac_cv_ps_format=["%*s %d %d %d %d %*d %*d %d %d%*[ 0123456789abcdef]%[OSRZT]%*s %*s %n"]
572 dnl     ac_cv_ps_cols=8
573 dnl     AC_MSG_RESULT([$ac_cv_ps_command])
575 dnl Some gnu/linux systems (debian for one) don't like -axwo and need axwo.
576 dnl so test for this first...
577 elif ps axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
578         egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null
579 then
580         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
581         ac_cv_ps_command="$PATH_TO_PS axwo 'stat uid pid ppid vsz rss pcpu comm args'"
582         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
583         ac_cv_ps_cols=9
584         AC_MSG_RESULT([$ac_cv_ps_command])
586 dnl For OpenBSD 3.2 & 3.3. Must come before ps -weo
587 dnl Should also work for FreeBSD 5.2.1 and 5.3
588 dnl  STAT UCOMM              VSZ   RSS USER      PPID COMMAND
589 elif ps -axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
590         egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null
591 then
592         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
593         ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid pid ppid vsz rss pcpu comm args'"
594         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
595         ac_cv_ps_cols=9
596         AC_MSG_RESULT([$ac_cv_ps_command])
598 dnl Some *BSDs have different format for ps. This is mainly to catch FreeBSD 4. 
599 dnl Limitation: Only first 16 chars returned for ucomm field
600 dnl Must come before ps -weo
601 elif ps -axwo 'stat uid pid ppid vsz rss pcpu ucomm command' 2>/dev/null | \
602         egrep -i ["^ *STAT +UID +PID +PPID +VSZ +RSS +%CPU +UCOMM +COMMAND"] > /dev/null
603 then
604         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
605         ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid pid ppid vsz rss pcpu ucomm command'"
606         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
607         ac_cv_ps_cols=9
608         AC_MSG_RESULT([$ac_cv_ps_command])
610 dnl  STAT UCOMM              VSZ   RSS USER       UID  PPID COMMAND
611 elif ps -weo 'stat comm vsz rss user uid pid ppid etime args' 2>/dev/null | \
612         egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[ID]+ +P[PID]+ +[ELAPSD]+ +[RGSCOMDNA]+"] >/dev/null
613 then
614         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procetime,procprog,&pos]"
615         ac_cv_ps_command="$PATH_TO_PS -weo 'stat uid pid ppid vsz rss pcpu etime comm args'"
616         ac_cv_ps_format="%s %d %d %d %d %d %f %s %s %n"
617         ac_cv_ps_cols=10
618         AC_MSG_RESULT([$ac_cv_ps_command])
620 dnl FreeBSD
621 elif ps waxco 'state command vsz rss uid user pid ppid' 2>/dev/null | \
622         egrep -i ["^STAT +COMMAND +VSZ +RSS +UID +USER +PID +PPID"] >/dev/null
623 then
624         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
625         ac_cv_ps_command="$PATH_TO_PS waxco 'state uid pid ppid vsz rss pcpu command command'"
626         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
627         ac_cv_ps_cols=9
628         AC_MSG_RESULT([$ac_cv_ps_command])
630 dnl BSD-like mode in RH 6.1
631 elif ps waxno 'state comm vsz rss uid user pid ppid args' 2>/dev/null | \
632         egrep -i ["^S +COMMAND +VSZ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
633 then
634         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
635         ac_cv_ps_command="$PATH_TO_PS waxno 'state uid pid ppid vsz rss pcpu comm args'"
636         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
637         ac_cv_ps_cols=9
638         AC_MSG_RESULT([$ac_cv_ps_command])
640 dnl SunOS 4.1.3:
641 dnl  F  UID  PID  PPID  CP  PRI  NI  SZ  RSS  WCHAN  STAT  TT  TIME  COMMAND
642 dnl Need the head -1 otherwise test will work because arguments are found
643 elif ps -laxnwww 2>/dev/null | head -1 | \
644         egrep -i ["^ *F(LAGS)? +UID +PID +PPID +CP +PRI +NI +(SZ)|(VSZ)|(SIZE) +RSS +WCHAN +STAT? +TTY? +TIME +COMMAND"] >/dev/null
645 then
646         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]"
647         ac_cv_ps_command="$PATH_TO_PS -laxnwww"
648         ac_cv_ps_format="%*s %d %d %d %*s %*s %*s %d %d %*s %s %*s %*s %n%s"
649         ac_cv_ps_cols=9
650         AC_MSG_RESULT([$ac_cv_ps_command])
652 dnl Debian Linux / procps v1.2.9:
653 dnl  FLAGS   UID   PID  PPID PRI  NI   SIZE   RSS WCHAN       STA TTY TIME COMMAND
654 dnl    100     0     1     0   0   0    776    76  c0131c8c   S  ffff  0:11 init [2]
655 dnl
656 elif ps laxnwww 2>/dev/null | \
657         egrep -i ["^ *F(LAGS)? +UID +PID +PPID +PRI +NI +(VSZ)|(SIZE) +RSS +WCHAN +STAT? TTY +TIME +COMMAND"] >/dev/null
658 then
659         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,procstat,&procvsz,&procrss,&pos,procprog]"
660         ac_cv_ps_command="$PATH_TO_PS laxnwww"
661         ac_cv_ps_format="%*s %d %d %d %*s %*s %d %d %*s %s %*s %*s %n%s"
662         ac_cv_ps_cols=9
663         AC_MSG_RESULT([$ac_cv_ps_command])
665 dnl OpenBSD (needs to come early because -exo appears to work, but does not give all procs)
666 elif ps -axo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
667         egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[PID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null
668 then
669         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
670         ac_cv_ps_command="$PATH_TO_PS -axo 'stat uid pid ppid vsz rss pcpu comm args'"
671         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
672         ac_cv_ps_cols=9
673         AC_MSG_RESULT([$ac_cv_ps_command])
675 dnl Tru64 - needs %*[ +<>] in PS_FORMAT. 
676 dnl Has /usr/bin/ps and /sbin/ps - force sbin version
677 dnl Can't use vsize and rssize because comes back with text (eg, 1.5M instead 
678 dnl of 1500). Will need big changes to check_procs to support
679 elif /sbin/ps -eo 'stat uid pid ppid pcpu etime comm args' 2>/dev/null | \
680         egrep -i ["^ *S +[UID]+ +[PID]+ +[PID]+ +[%CPU]+ +[ELAPSD]+ +[COMMAND]+ +[COMMAND]+"] > /dev/null
681 then
682         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procpcpu,procetime,procprog,&pos]"
683         ac_cv_ps_command="/sbin/ps -eo 'stat uid pid ppid pcpu etime comm args'"
684         ac_cv_ps_format=["%s%*[ +<>] %d %d %d %f %s %s %n"]
685         ac_cv_ps_cols=8
686         AC_MSG_RESULT([$ac_cv_ps_command])
688 elif ps -eo 's comm vsz rss user uid pid ppid args' 2>/dev/null | \
689         egrep -i ["^S[TAUES]* +C[OMDNA]+ +[VSIZE]+ +U[SER]+ +U[ID]+ +P[PID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null
690 then
691         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
692         ac_cv_ps_command="$PATH_TO_PS -eo 's uid pid ppid vsz rss pcpu comm args'"
693         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
694         ac_cv_ps_cols=9
695         AC_MSG_RESULT([$ac_cv_ps_command])
697 dnl AIX 4.3.3 and 5.1 do not have an rss field
698 elif ps -eo 'stat uid pid ppid vsz pcpu comm args' 2>/dev/null | \
699         egrep -i ["^ *S[TAUES]* +UID +PID +PPID +VSZ +%CPU +COMMAND +COMMAND"] >/dev/null
700 then
701         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procpcpu,procprog,&pos]"
702         ac_cv_ps_command="$PATH_TO_PS -eo 'stat uid pid ppid vsz pcpu comm args'"
703         ac_cv_ps_format="%s %d %d %d %d %f %s %n"
704         ac_cv_ps_cols=8
705         AC_MSG_RESULT([$ac_cv_ps_command - with no RSS])
707 dnl Solaris 2.6
708 elif ps -Ao 's comm vsz rss uid user pid ppid args' 2>/dev/null | \
709         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
710 then
711         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
712         ac_cv_ps_command="$PATH_TO_PS -Ao 's uid pid ppid vsz rss pcpu comm args'"
713         # There must be no space between the %s and %n due to a wierd problem in sscanf where
714         # it will return %n as longer than the line length
715         ac_cv_ps_format="%s %d %d %d %d %d %f %s%n"
716         ac_cv_ps_cols=9
717         AC_MSG_RESULT([$ac_cv_ps_command])
719 elif ps -Ao 'status comm vsz rss uid user pid ppid args' 2>/dev/null | \
720         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
721 then
722         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
723         ac_cv_ps_command="$PATH_TO_PS -Ao 'status uid pid ppid vsz rss pcpu comm args'"
724         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
725         ac_cv_ps_cols=9
726         AC_MSG_RESULT([$ac_cv_ps_command])
728 elif ps -Ao 'state comm vsz rss uid user pid ppid args' 2>/dev/null | \
729         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
730 then
731         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
732         ac_cv_ps_command="$PATH_TO_PS -Ao 'state uid pid ppid vsz rss pcpu comm args'"
733         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
734         ac_cv_ps_cols=9
735         AC_MSG_RESULT([$ac_cv_ps_command])
737 dnl wonder who takes state instead of stat
738 elif ps -ao 'state command vsz rss user pid ppid args' 2>/dev/null | \
739         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
740 then
741         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
742         ac_cv_ps_command="$PATH_TO_PS -ao 'state uid pid ppid vsz rss pcpu command args'"
743         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
744         ac_cv_ps_cols=8
745         AC_MSG_RESULT([$ac_cv_ps_command])
747 dnl IRIX 53
748 elif ps -el 2>/dev/null | \
749         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
750 then
751         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&pos,procprog]"
752         ac_cv_ps_command="$PATH_TO_PS -el (IRIX 53)"
753         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %d %d %*s %*s %*s %n%s"
754         ac_cv_ps_cols=8
755         AC_MSG_RESULT([$ac_cv_ps_command])
757 dnl IRIX 63
758 elif ps -el 2>/dev/null | \
759         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +ADDR +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
760 then
761         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
762         ac_cv_ps_command="$PATH_TO_PS -el (IRIX 63)"
763         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
764         ac_cv_ps_cols=6
765         AC_MSG_RESULT([$ac_cv_ps_command])
767 dnl AIX 4.1:
768 dnl     F S      UID   PID  PPID   C PRI NI ADDR  SZ  RSS   WCHAN    TTY  TIME CMD
769 dnl    303 A        0     0     0 120  16 -- 1c07  20   24              -  0:45 swapper
770 elif ps -el 2>/dev/null | \
771         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +ADDR +SZ +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
772 then
773         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
774         ac_cv_ps_command="$PATH_TO_PS -el (AIX 4.1 and HP-UX)"
775         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
776         ac_cv_ps_cols=6
777         AC_MSG_RESULT([$ac_cv_ps_command])
779 dnl AIX?
780 elif ps glaxen 2>/dev/null | \
781         egrep -i ["^ *F +UID +PID +PPID +PRI +NI +VSZ +RSS +WCHAN +STAT +TTY +TIME +COMMAND"] >/dev/null
782 then
783         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]"
784         ac_cv_ps_command="$PATH_TO_PS glaxen"
785         ac_cv_ps_format="%*s %d %d %d %*s %*s %d %d %*s %s %*s %*s %n%s"
786         ac_cv_ps_cols=8
787         AC_MSG_RESULT([$ac_cv_ps_command])
789 dnl MacOSX / Darwin
790 dnl TODO: MacOSX has commands with spaces which will cause problems to PS_FORMAT
791 dnl Some truncation will happen in UCOMM column
792 dnl STAT      VSZ    RSS   UID  PPID %CPU UCOMM            COMMAND
793 dnl Ss      52756  22496   501     1   6.9 Window Manager   /System/Library/CoreServices/WindowServer -daemon
794 elif ps wwaxo 'state vsz rss uid pid ppid pcpu ucomm command' 2>/dev/null | \
795         egrep -i ["^STAT +VSZ +RSS +UID +PPID +%CPU +UCOMM +COMMAND"] >/dev/null
796 then
797         ac_cv_ps_command="$PATH_TO_PS wwaxo 'state vsz rss uid pid ppid pcpu ucomm command'"
798         ac_cv_ps_varlist="[procstat,&procvsz,&procrss,&procuid,&procpid,&procppid,&procpcpu,procprog,&pos]"
799         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
800         ac_cv_ps_cols=8
801         AC_MSG_RESULT([$ac_cv_ps_command])
803 dnl UnixWare 
804 elif ps -Al 2>/dev/null | \
805         egrep -i ["^ *F +S +UID +PID +PPID +CLS +PRI +NI +C +ADDR +SZ +WCHAN +TTY +TIME +COMD"] >/dev/null
806 then
807         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
808         ac_cv_ps_command="$PATH_TO_PS -Al"
809         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
810         ac_cv_ps_cols=8
811         AC_MSG_RESULT([$ac_cv_ps_command])
813 else
814         AC_MSG_WARN([unable to find usable ps syntax - check_procs and check_nagios will not be compiled])
815 fi
817 if test -n "$ac_cv_ps_varlist" ; then
818         AC_DEFINE_UNQUOTED(PS_VARLIST,$ac_cv_ps_varlist,
819                 [Variable list for sscanf of 'ps' output])
820         AC_DEFINE_UNQUOTED(PS_COMMAND,"$ac_cv_ps_command",
821                 [Verbatim command to execute for ps in check_procs])
822         AC_DEFINE_UNQUOTED(PS_FORMAT,"$ac_cv_ps_format",
823                 [Format string for scanning ps output in check_procs])
824         AC_DEFINE_UNQUOTED(PS_COLS,$ac_cv_ps_cols,
825                 [Number of columns in ps command])
826         EXTRAS="$EXTRAS check_procs check_nagios"
827         if echo "$ac_cv_ps_varlist" | grep "procetime" >/dev/null; then
828                 AC_DEFINE(PS_USES_PROCETIME,"yes",
829                           [Whether the ps utility uses the "procetime" field])
830         fi
831 fi
833 AC_PATH_PROG(PATH_TO_PING,ping)
834 AC_PATH_PROG(PATH_TO_PING6,ping6)
836 AC_ARG_WITH(ping_command,
837         ACX_HELP_STRING([--with-ping-command=SYNTAX],
838                 [sets syntax for ICMP ping]),
839         with_ping_command=$withval,)
841 AC_MSG_CHECKING(for ICMP ping syntax)
842 ac_cv_ping_packets_first=no
843 ac_cv_ping_has_timeout=no
844 if test -n "$with_ping_command"
845 then
846         AC_MSG_RESULT([(command-line) $with_ping_command])
847         if test -n "$ac_cv_ping_packets_first"
848         then
849                 ac_cv_ping_packets_first=yes
850                 ac_cv_ping_has_timeout=yes
851         fi
853 elif [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
854         $PATH_TO_PING -n -s 127.0.0.1 56 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 -U -w 10 -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 -U -w %d -c %d %s"
865         ac_cv_ping_packets_first=yes
866   ac_cv_ping_has_timeout=yes
867         AC_MSG_RESULT([$with_ping_command])
869 elif $PATH_TO_PING -n -U -c 1 127.0.0.1 2>/dev/null | \
870         egrep -i "^round-trip|^rtt" >/dev/null
871 then
872         with_ping_command="$PATH_TO_PING -n -U -c %d %s"
873         ac_cv_ping_packets_first=yes
874         AC_MSG_RESULT([$with_ping_command])
876 elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \
877         egrep -i "^round-trip|^rtt" >/dev/null
878 then
879         with_ping_command="$PATH_TO_PING -n -c %d %s"
880         ac_cv_ping_packets_first=yes
881         AC_MSG_RESULT([$with_ping_command])
883 elif $PATH_TO_PING -n 127.0.0.1 -c 1 2>/dev/null | \
884         egrep -i "^round-trip|^rtt" >/dev/null
885 then
886         with_ping_command="$PATH_TO_PING -n %s -c %d"
887         AC_MSG_RESULT([$with_ping_command])
889 elif $PATH_TO_PING 127.0.0.1 -n 1 2>/dev/null | \
890         egrep -i "^round-trip|^rtt" >/dev/null
891 then
892         with_ping_command="$PATH_TO_PING %s -n %d"
893         AC_MSG_RESULT([$with_ping_command])
895 elif $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
896         egrep -i "^round-trip|^rtt" >/dev/null
897 then
898         with_ping_command="$PATH_TO_PING -n -s %s 56 %d"
899         AC_MSG_RESULT([$with_ping_command])
901 elif $PATH_TO_PING -n -h 127.0.0.1 -s 56 -c 1 2>/dev/null | \
902         egrep -i "^round-trip|^rtt" >/dev/null
903 then
904         with_ping_command="$PATH_TO_PING -n -h %s -s 56 -c %d"
905         AC_MSG_RESULT([$with_ping_command])
907 elif $PATH_TO_PING -n -s 56 -c 1 127.0.0.1 2>/dev/null | \
908         egrep -i "^round-trip|^rtt" >/dev/null
909 then
910         with_ping_command="$PATH_TO_PING -n -s 56 -c %d %s"
911         ac_cv_ping_packets_first=yes
912         AC_MSG_RESULT([$with_ping_command])
914 elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \
915         egrep -i "^round-trip|^rtt" >/dev/null
916 then
917         with_ping_command="$PATH_TO_PING -n -c %d %s"
918         ac_cv_ping_packets_first=yes
919         AC_MSG_RESULT([$with_ping_command])
921 else
922         AC_MSG_WARN([unable to find usable ping syntax])
923 fi
925 AC_DEFINE_UNQUOTED(PING_COMMAND,"$with_ping_command",
926         [path and args for ICMP ping command])
928 if test "x$ac_cv_ping_packets_first" != "xno"
929 then
930         AC_DEFINE(PING_PACKETS_FIRST,1,
931                 [Define if packet count must precede host])
932 fi
934 if test "x$ac_cv_ping_has_timeout" != "xno"
935 then
936         AC_DEFINE(PING_HAS_TIMEOUT,1,
937                 [Define if ping has its own timeout option that should be set])
938 fi
940 AC_ARG_WITH(ping6_command,
941         ACX_HELP_STRING([--with-ping6-command=SYNTAX],
942                 [sets syntax for ICMPv6 ping]),
943         with_ping6_command=$withval,)
945 if test x"$with_ipv6" != xno ; then
946 AC_MSG_CHECKING(for ICMPv6 ping syntax)
947 ac_cv_ping6_packets_first=no
948 if test -n "$with_ping6_command"
949 then
950         AC_MSG_RESULT([(command-line) $with_ping6_command])
951         if test -n "$ac_cv_ping6_packets_first"
952         then
953                 ac_cv_ping6_packets_first=yes
954         fi
956 elif test "x$PATH_TO_PING6" != "x"; then
957         if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
958                 $PATH_TO_PING6 -n -s ::1 56 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 -U -w 10 -c 1 ::1 2>/dev/null | \
966                 egrep -i "^round-trip|^rtt" >/dev/null
967         then
968                 with_ping6_command="$PATH_TO_PING6 -n -U -w %d -c %d %s"
969                 ac_cv_ping6_packets_first=yes
970                 ac_cv_ping_has_timeout=yes
971                 AC_MSG_RESULT([$with_ping6_command])
973         elif $PATH_TO_PING6 -n -U -c 1 ::1 2>/dev/null | \
974                 egrep -i "^round-trip|^rtt" >/dev/null
975         then
976                 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s"
977                 ac_cv_ping6_packets_first=yes
978                 AC_MSG_RESULT([$with_ping6_command])
980         elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \
981                 egrep -i "^round-trip|^rtt" >/dev/null
982         then
983                 with_ping6_command="$PATH_TO_PING6 -n -c %d %s"
984                 ac_cv_ping6_packets_first=yes
985                 AC_MSG_RESULT([$with_ping6_command])
987         elif $PATH_TO_PING6 -n ::1 -c 1 2>/dev/null | \
988                 egrep -i "^round-trip|^rtt" >/dev/null
989         then
990                 with_ping6_command="$PATH_TO_PING6 -n %s -c %d"
991                 AC_MSG_RESULT([$with_ping6_command])
993         elif $PATH_TO_PING6 ::1 -n 1 2>/dev/null | \
994                 egrep -i "^round-trip|^rtt" >/dev/null
995         then
996                 with_ping6_command="$PATH_TO_PING6 %s -n %d"
997                 AC_MSG_RESULT([$with_ping6_command])
999         elif $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \
1000                 egrep -i "^round-trip|^rtt" >/dev/null
1001         then
1002                 with_ping6_command="$PATH_TO_PING6 -n -s %s 56 %d"
1003                 AC_MSG_RESULT([$with_ping6_command])
1005         elif $PATH_TO_PING6 -n -h ::1 -s 56 -c 1 2>/dev/null | \
1006                 egrep -i "^round-trip|^rtt" >/dev/null
1007         then
1008                 with_ping6_command="$PATH_TO_PING6 -n -h %s -s 56 -c %d"
1009                 AC_MSG_RESULT([$with_ping6_command])
1011         elif $PATH_TO_PING6 -n -s 56 -c 1 ::1 2>/dev/null | \
1012                 egrep -i "^round-trip|^rtt" >/dev/null
1013         then
1014                 with_ping6_command="$PATH_TO_PING6 -n -s 56 -c %d %s"
1015                 ac_cv_ping6_packets_first=yes
1016                 AC_MSG_RESULT([$with_ping_command])
1018         elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \
1019                 egrep -i "^round-trip|^rtt" >/dev/null
1020         then
1021                 with_ping6_command="$PATH_TO_PING6 -n -c %d %s"
1022                 ac_cv_ping6_packets_first=yes
1023                 AC_MSG_RESULT([$with_ping6_command])
1025         fi
1027 elif test "x$PATH_TO_PING" != "x"; then
1028         if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
1029                 $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \
1030                 egrep -i "^round-trip|^rtt" >/dev/null
1031         then
1032                 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s"
1033                 ac_cv_ping6_packets_first=yes
1034                 AC_MSG_RESULT([$with_ping6_command])
1036         elif $PATH_TO_PING -A inet6 -n -U -c 1 ::1 2>/dev/null | \
1037                 egrep -i "^round-trip|^rtt" >/dev/null
1038         then
1039                 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s"
1040                 ac_cv_ping6_packets_first=yes
1041                 AC_MSG_RESULT([$with_ping6_command])
1043         elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \
1044                 egrep -i "^round-trip|^rtt" >/dev/null
1045         then
1046                 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s"
1047                 ac_cv_ping6_packets_first=yes
1048                 AC_MSG_RESULT([$with_ping6_command])
1050         elif $PATH_TO_PING -A inet6 -n ::1 -c 1 2>/dev/null | \
1051                 egrep -i "^round-trip|^rtt" >/dev/null
1052         then
1053                 with_ping6_command="$PATH_TO_PING -A inet6 -n %s -c %d"
1054                 AC_MSG_RESULT([$with_ping6_command])
1056         elif $PATH_TO_PING -A inet6 ::1 -n 1 2>/dev/null | \
1057                 egrep -i "^round-trip|^rtt" >/dev/null
1058         then
1059                 with_ping6_command="$PATH_TO_PING -A inet6 %s -n %d"
1060                 AC_MSG_RESULT([$with_ping6_command])
1062         elif $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \
1063                 egrep -i "^round-trip|^rtt" >/dev/null
1064         then
1065                 with_ping6_command="$PATH_TO_PING -A inet6 -n -s %s 56 %d"
1066                 AC_MSG_RESULT([$with_ping6_command])
1068         elif $PATH_TO_PING -A inet6 -n -h ::1 -s 56 -c 1 2>/dev/null | \
1069                 egrep -i "^round-trip|^rtt" >/dev/null
1070         then
1071                 with_ping6_command="$PATH_TO_PING -A inet6 -n -h %s -s 56 -c %d"
1072                 AC_MSG_RESULT([$with_ping6_command])
1074         elif $PATH_TO_PING -A inet6 -n -s 56 -c 1 ::1 2>/dev/null | \
1075                 egrep -i "^round-trip|^rtt" >/dev/null
1076         then
1077                 with_ping6_command="$PATH_TO_PING -A inet6 -n -s 56 -c %d %s"
1078                 ac_cv_ping6_packets_first=yes
1079                 AC_MSG_RESULT([$with_ping_command])
1081         elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \
1082                 egrep -i "^round-trip|^rtt" >/dev/null
1083         then
1084                 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s"
1085                 ac_cv_ping6_packets_first=yes
1086                 AC_MSG_RESULT([$with_ping6_command])
1088         fi
1090 fi
1092 if test "x$with_ping6_command" != "x"; then
1093         AC_DEFINE_UNQUOTED(PING6_COMMAND,"$with_ping6_command",
1094                 [path and args for ICMPv6 ping command])
1095 else
1096         AC_MSG_RESULT([none])
1097 fi
1099 if test "x$ac_cv_ping6_packets_first" != "xno"; then
1100         AC_DEFINE(PING6_PACKETS_FIRST,1,
1101                 [Define if packet count must precede host])
1102 fi
1103 fi
1106 AC_ARG_WITH(nslookup_command,
1107             ACX_HELP_STRING([--with-nslookup-command=PATH],
1108                             [sets path to nslookup executable]),
1109             ac_cv_nslookup_command=$withval)
1110 if test -n "$ac_cv_nslookup_command"; then
1111         AC_MSG_NOTICE([Using specific nslookup at $ac_cv_nslookup_command])
1112 else
1113         AC_PATH_PROG(PATH_TO_NSLOOKUP,nslookup)
1114         if test -n "$PATH_TO_NSLOOKUP"
1115         then
1116                 AC_MSG_CHECKING(for nslookup syntax)
1117                 if $PATH_TO_NSLOOKUP -sil 127.0.0.1 2>&1 | grep ["Invalid option: sil"] >/dev/null
1118                 then
1119                         ac_cv_nslookup_command="$PATH_TO_NSLOOKUP"
1120                         AC_MSG_RESULT([$ac_cv_nslookup_command])
1122                 else
1123                         ac_cv_nslookup_command="$PATH_TO_NSLOOKUP -sil"
1124                         AC_MSG_RESULT([$ac_cv_nslookup_command])
1126                 fi
1127         else
1128                 AC_MSG_WARN([nslookup command not found])
1129         fi
1130 fi
1132 if test -n "$ac_cv_nslookup_command"; then
1133         EXTRAS="$EXTRAS check_dns"
1134         AC_DEFINE_UNQUOTED(NSLOOKUP_COMMAND,"$ac_cv_nslookup_command", [path and args for nslookup])
1135 fi
1137 AC_MSG_CHECKING([for number of cpus])
1138 AC_TRY_COMPILE([#include <unistd.h>],
1139         [sysconf(_SC_NPROCESSORS_CONF) > 0;],
1140         AC_DEFINE(HAVE_SYSCONF__SC_NPROCESSORS_CONF,1,[Define if sysconf returns number of cpus])
1141         AC_MSG_RESULT([sysconf(_SC_NPROCESSORS_CONF)]),
1142         AC_MSG_RESULT([cannot calculate])
1143         )
1145 AC_PATH_PROG(PATH_TO_UPTIME,uptime)
1146 AC_ARG_WITH(uptime_command,
1147             ACX_HELP_STRING([--with-uptime-command=PATH],
1148                             [sets path to uptime]), PATH_TO_UPTIME=$withval)
1149 AC_DEFINE_UNQUOTED(PATH_TO_UPTIME,"$PATH_TO_UPTIME",[path to uptime binary])
1151 AC_PATH_PROG(PATH_TO_RPCINFO,rpcinfo)
1152 AC_ARG_WITH(rpcinfo_command,
1153             ACX_HELP_STRING([--with-rpcinfo-command=PATH],
1154                             [sets path to rpcinfo]), PATH_TO_RPCINFO=$withval)
1155 AC_DEFINE_UNQUOTED(PATH_TO_RPCINFO,"$PATH_TO_RPCINFO",[path to rpcinfo binary])
1157 AC_PATH_PROG(PATH_TO_LMSTAT,lmstat)
1158 if test -x "$PATH_TO_LMSTAT"
1159 then
1160         AC_DEFINE_UNQUOTED(PATH_TO_LMSTAT,"$PATH_TO_LMSTAT",[path to lmstat])
1161 else
1162         AC_MSG_WARN([Get lmstat from Globetrotter Software to monitor flexlm licenses])
1163 fi
1165 AC_PATH_PROG(PATH_TO_SMBCLIENT,smbclient)
1166 AC_ARG_WITH(smbclient_command,
1167             ACX_HELP_STRING([--with-smbclient-command=PATH],
1168                             [sets path to smbclient]), 
1169             PATH_TO_SMBCLIENT=$withval)
1170 if test -n "$PATH_TO_SMBCLIENT"
1171 then
1172         AC_DEFINE_UNQUOTED(PATH_TO_SMBCLIENT,"$PATH_TO_SMBCLIENT",[path to smbclient binary])
1173 else
1174         AC_MSG_WARN([Get smbclient from Samba.org to monitor SMB shares])
1175 fi
1178 AC_PATH_PROG(PATH_TO_WHO,who)
1180 if [$PATH_TO_WHO -q 2>/dev/null | egrep -i "^# users=[0-9]+$" >/dev/null]
1181 then
1182         ac_cv_path_to_who="$PATH_TO_WHO -q"
1183 else
1184         ac_cv_path_to_who="$PATH_TO_WHO"
1185 fi
1187 AC_DEFINE_UNQUOTED(WHO_COMMAND,"$ac_cv_path_to_who",
1188         [path and arguments for invoking 'who'])
1190 AC_PATH_PROG(PATH_TO_SNMPGET,snmpget)
1191 AC_ARG_WITH(snmpget_command,
1192             ACX_HELP_STRING([--with-snmpget-command=PATH],
1193                             [Path to snmpget command]),
1194             PATH_TO_SNMPGET=$withval)
1195 if test -n "$PATH_TO_SNMPGET"
1196 then
1197         AC_DEFINE_UNQUOTED(PATH_TO_SNMPGET,"$PATH_TO_SNMPGET",[path to snmpget binary])
1198         EXTRAS="$EXTRAS check_hpjd check_snmp"
1199 else
1200         AC_MSG_WARN([Get snmpget from http://net-snmp.sourceforge.net to make check_hpjd and check_snmp plugins])
1201 fi
1203 AC_PATH_PROG(PATH_TO_SNMPGETNEXT,snmpgetnext)
1204 AC_ARG_WITH(snmpgetnext_command,
1205             ACX_HELP_STRING([--with-snmpgetnext-command=PATH],
1206                             [Path to snmpgetnext command]),
1207             PATH_TO_SNMPGETNEXT=$withval)
1208 if test -n "$PATH_TO_SNMPGETNEXT"
1209 then
1210         AC_DEFINE_UNQUOTED(PATH_TO_SNMPGETNEXT,"$PATH_TO_SNMPGETNEXT",[path to snmpgetnext binary])
1211 fi
1213 if ( $PERL -M"Net::SNMP 3.6" -e 'exit' 2>/dev/null  )
1214 then
1215         AC_MSG_CHECKING(for Net::SNMP perl module)
1216         AC_MSG_RESULT([found])
1217 else
1218         AC_MSG_WARN([Tried $PERL - install Net::SNMP perl module if you want to use the perl snmp plugins])
1219 fi
1221 AC_PATH_PROG(PATH_TO_QUAKESTAT,quakestat)
1222 AC_PATH_PROG(PATH_TO_QSTAT,qstat)
1223 AC_ARG_WITH(qstat_command,
1224             ACX_HELP_STRING([--with-qstat-command=PATH], 
1225                             [Path to qstat command]), PATH_TO_QSTAT=$withval)
1227 if test -x "$PATH_TO_QUAKESTAT"
1228 then
1229         ac_cv_path_to_qstat="$PATH_TO_QUAKESTAT"
1230         EXTRAS="$EXTRAS check_game"
1232 elif test -n "$PATH_TO_QSTAT"
1233 then
1234         ac_cv_path_to_qstat="$PATH_TO_QSTAT"
1235         EXTRAS="$EXTRAS check_game"
1236 else
1237         AC_MSG_WARN([Get qstat from http://www.activesw.com/people/steve/qstat.html in order to make check_game plugin])
1238 fi
1240 if test $ac_cv_path_to_qstat 
1241 then
1242         AC_DEFINE_UNQUOTED(PATH_TO_QSTAT,"$ac_cv_path_to_qstat",
1243                 [path to qstat/quakestat])
1244 fi
1246 AC_PATH_PROG(PATH_TO_FPING,fping)
1247 AC_ARG_WITH(fping_command,
1248             ACX_HELP_STRING([--with-fping-command=PATH],
1249                             [Path to fping command]), PATH_TO_FPING=$withval)
1250 if test -n "$PATH_TO_FPING"
1251 then
1252         AC_DEFINE_UNQUOTED(PATH_TO_FPING,"$PATH_TO_FPING",[path to fping])
1253         EXTRAS="$EXTRAS check_fping"
1254 else
1255         AC_MSG_WARN([Get fping from http://www.fping.com in order to make check_fping plugin])
1256 fi
1258 AC_PATH_PROG(PATH_TO_SSH,ssh)
1259 AC_ARG_WITH(ssh_command,
1260             ACX_HELP_STRING([--with-ssh-command=PATH],
1261                             [sets path for ssh]), PATH_TO_SSH=$withval)
1262 if test -n "$PATH_TO_SSH"
1263 then
1264         AC_DEFINE_UNQUOTED(SSH_COMMAND,"$PATH_TO_SSH",[path to ssh binary])
1265         EXTRAS="$EXTRAS check_by_ssh"
1266 else
1267         AC_MSG_WARN([Get ssh in order to make check_by_ssh plugin])
1268 fi
1271 AC_PATH_PROG(PATH_TO_MAILQ,mailq)
1272 AC_ARG_WITH(mailq_command,
1273             ACX_HELP_STRING([--with-mailq-command=PATH],
1274                             [sets path to mailq]), PATH_TO_MAILQ=$withval)
1275 if test -n "$PATH_TO_MAILQ"
1276 then
1277         AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_MAILQ",[path to mailq])
1278 else
1279         AC_MSG_WARN([Could not find mailq or eqivalent])
1280 fi
1282 AC_PATH_PROG(PATH_TO_QMAIL_QSTAT,qmail-qstat)
1283 if test -x "$PATH_TO_QMAIL_QSTAT"
1284 then
1285         AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_QMAIL_QSTAT",[path to qmail-qstat])
1286 else
1287         AC_MSG_WARN([Could not find qmail-qstat or eqivalent])
1288 fi
1290 dnl SWAP info required is amount allocated/available and amount free
1291 dnl The plugin works through all the swap devices and adds up the total swap
1292 dnl available.
1293 AC_PATH_PROG(PATH_TO_SWAP,swap)
1294 if (test -n "$PATH_TO_SWAP")
1295 then
1296 AC_MSG_CHECKING([for $PATH_TO_SWAP format])
1297 if [$PATH_TO_SWAP -l 2>&1 >/dev/null]
1298 then
1299         ac_cv_have_swap=yes
1300         ac_cv_swap_command="$PATH_TO_SWAP -l"
1301         if [$PATH_TO_SWAP -l 2>/dev/null | \
1302                 egrep -i "^lswap +path +pri +swaplo +blocks +free +maxswap" \
1303                 >/dev/null]
1304         then
1305                 ac_cv_swap_format=[" %*d %*s %*d,%*d %*d %*d %f %f"]
1306                 ac_cv_swap_conv=2048
1307                 AC_MSG_RESULT([using IRIX format swap])
1309         elif [$PATH_TO_SWAP -l 2>/dev/null | egrep -i "^path +dev +swaplo +blocks +free" >/dev/null]
1310         then
1311                 ac_cv_swap_format=["%*s %*[0-9,-] %*d %f %f"]
1312                 ac_cv_swap_conv=2048
1313                 AC_MSG_RESULT([using Unixware format swap])
1314         else
1315                 dnl if we don't know what format swap's output is
1316                 dnl we might as well pretend we didn't see it
1317                 ac_cv_have_swap=""
1318                 ac_cv_swap_command=""
1319         fi
1320 fi
1321 dnl end if for PATH_TO_SWAP
1322 fi
1324 AC_PATH_PROG(PATH_TO_SWAPINFO,swapinfo)
1325 if (test -n "$PATH_TO_SWAPINFO")
1326 then
1327 AC_MSG_CHECKING([for $PATH_TO_SWAPINFO format])
1328 if [$PATH_TO_SWAPINFO -k 2>&1 | egrep -i "^Device" >/dev/null]
1329 then
1330         ac_cv_have_swap=yes
1331         ac_cv_swap_command="$PATH_TO_SWAPINFO -k"
1333         if [$PATH_TO_SWAPINFO -k 2>/dev/null | egrep -i "^Device +1K-blocks +Used +Avail" >/dev/null]
1334         then
1335                 ac_cv_swap_format=["%*s %f %*d %f"]
1336                 ac_cv_swap_conv=1024
1337                 AC_MSG_RESULT([using FreeBSD format swapinfo])
1338         fi
1340 elif [$PATH_TO_SWAPINFO -dfM 2>/dev/null | egrep -i "^TYPE +AVAIL +USED +FREE" >/dev/null]
1341 then
1342         ac_cv_have_swap=yes
1343         ac_cv_swap_command="$PATH_TO_SWAPINFO -dfM"
1344         ac_cv_swap_format=["%*s %f %*d %f"]
1345         ac_cv_swap_conv=1024
1346         AC_MSG_RESULT([using HP-UX format swapinfo])
1347 fi
1348 dnl end if for PATH_TO_SWAPINFO
1349 fi
1351 AC_PATH_PROG(PATH_TO_LSPS,lsps)
1352 if (test -n "$PATH_TO_LSPS")
1353 then
1354 AC_MSG_CHECKING([for $PATH_TO_LSPS format])
1355 if [$PATH_TO_LSPS -a 2>/dev/null | egrep -i "^Page Space" > /dev/null]
1356 then
1357         ac_cv_have_swap=yes
1358         ac_cv_swap_command="$PATH_TO_LSPS -a"
1359         ac_cv_swap_format=["%*s %*s %*s %f%*s %f %*s"]
1360         ac_cv_swap_conv=1
1361         AC_MSG_RESULT([using AIX lsps])
1362 fi
1363 dnl end if for PATH_TO_SWAPINFO
1364 fi
1366 dnl
1367 dnl test for swapctl system call, both the 2-arg and 3-arg variants
1368 dnl fwict, the 2-arg is an SVR4 standard, whereas the 3-arg is shared
1369 dnl in the various BSD's
1370 dnl
1372 AC_CHECK_HEADERS([sys/stat.h sys/param.h])
1373 AC_CHECK_HEADERS([sys/swap.h], [], [], [
1374 #ifdef HAVE_SYS_PARAM_H
1375 #include <sys/param.h>
1376 #endif
1377 ])
1378 AC_CHECK_DECLS([swapctl],,,[
1379                #include <unistd.h>
1380                #include <sys/types.h>
1381                #include <sys/param.h>
1382                #include <sys/stat.h>
1383                #include <sys/swap.h>
1384                ])
1385 AC_CHECK_TYPES([swaptbl_t, swapent_t],,,[
1386                #include <sys/types.h>
1387                #include <sys/param.h>
1388                #include <sys/stat.h>
1389                #include <sys/swap.h>
1390                ])
1391 AC_CHECK_MEMBERS([struct swapent.se_nblks],,,[
1392                #include <unistd.h>
1393                #include <sys/types.h>
1394                #include <sys/param.h>
1395                #include <sys/stat.h>
1396                #include <sys/swap.h>
1397                ])
1399 if test "$ac_cv_have_decl_swapctl" = "yes"; 
1400 then
1401         EXTRAS="$EXTRAS check_swap"
1402         AC_MSG_CHECKING([for 2-arg (SVR4) swapctl])
1403         if test "$ac_cv_type_swaptbl_t" = "yes" -a \
1404                 "$ac_cv_type_swapent_t" = "yes"; 
1405         then
1406                 AC_MSG_RESULT([yes])
1407                 ac_cv_check_swap_swapctl_svr4="1";
1408                 AC_DEFINE([CHECK_SWAP_SWAPCTL_SVR4],1,
1409                           [Define if 2-argument SVR4 swapctl exists])
1410         else
1411                 AC_MSG_RESULT([no])
1412                 AC_MSG_CHECKING([for 3-arg (*BSD) swapctl])
1413                 if test "$ac_cv_member_struct_swapent_se_nblks" = "yes"; 
1414                 then
1415                         AC_MSG_RESULT([yes])
1416                         AC_DEFINE([CHECK_SWAP_SWAPCTL_BSD],1,
1417                                   [Define if 3-argument BSD swapctl exists])
1418                 else
1419                         AC_MSG_RESULT([no])
1420                 fi
1421         fi
1422         AC_MSG_CHECKING([for whether swapctl uses blocks or pages])
1423         if test "$ac_cv_check_swap_swapctl_svr4" = "1";
1424         then
1425                 dnl
1426                 dnl the SVR4 spec returns values in pages
1427                 dnl
1428                 AC_MSG_RESULT([page])
1429                 AC_CHECK_DECLS([sysconf])
1430                 AC_MSG_CHECKING([for system page size])
1431                 if test "$ac_cv_have_decl_sysconf" = "yes";
1432                 then
1433                         AC_MSG_RESULT([determined by sysconf(3)])
1434                         ac_cv_swap_conv="(1048576/sysconf(_SC_PAGESIZE))"
1435                 else
1436                         AC_MSG_WARN([don't know. guessing 4096k])
1437                         ac_cv_swap_conv=256
1438                 fi
1439         else
1440                 dnl
1441                 dnl the BSD spec returns values in blocks
1442                 dnl
1443                 AC_MSG_RESULT([blocks (assuming 512b)])
1444                 ac_cv_swap_conv=2048
1445         fi
1446         AC_DEFINE_UNQUOTED(SWAP_CONVERSION,$ac_cv_swap_conv,
1447                 [Conversion factor to MB])
1448 fi
1449 dnl
1450 dnl end tests for the swapctl system calls
1451 dnl
1454 if test "x$ac_cv_have_swap" != "x" 
1455 then
1456         AC_DEFINE(HAVE_SWAP,1,[Define if swap/swapinfo command is found])
1457         EXTRAS="$EXTRAS check_swap"
1458 fi
1459 if test "x$ac_cv_swap_command" != "x" 
1460 then
1461         AC_DEFINE_UNQUOTED(SWAP_COMMAND,"$ac_cv_swap_command",
1462                 [Path to swap/swapinfo binary, with any args])
1463         AC_DEFINE_UNQUOTED(SWAP_FORMAT,"$ac_cv_swap_format",
1464                 [Format string for parsing swap output])
1465         AC_DEFINE_UNQUOTED(SWAP_CONVERSION,$ac_cv_swap_conv,
1466                 [Conversion factor to MB])
1467 fi
1469 AC_ARG_WITH(proc-meminfo,
1470             ACX_HELP_STRING([--with-proc-meminfo=PATH],
1471                             [path to /proc/meminfo or equivalent]),
1472                             ac_cv_proc_meminfo=$withval)
1473 dnl dunno why this does not work below - use hack (kbd)
1474 dnl fine on linux, broken on solaris
1475 dnl if /bin/test -e "/proc/meminfo"
1476 AC_MSG_CHECKING([for /proc/meminfo])
1477 if test -n "$ac_cv_proc_meminfo"; then
1478         AC_MSG_RESULT([(command line) $ac_cv_proc_meminfo])
1479 elif [cat /proc/meminfo > /dev/null 2>&1]; then
1480         AC_MSG_RESULT([found /proc/meminfo])
1481         ac_cv_proc_meminfo="/proc/meminfo"
1482 else
1483         AC_MSG_RESULT([no])
1484 fi
1486 if test -n "$ac_cv_proc_meminfo"; then
1487         AC_DEFINE(HAVE_PROC_MEMINFO,1,[Define if we have /proc/meminfo])
1488         AC_DEFINE_UNQUOTED(PROC_MEMINFO,"$ac_cv_proc_meminfo",[path to /proc/meminfo if name changes])
1489         EXTRAS="$EXTRAS check_swap"
1490 fi
1492 AC_PATH_PROG(PATH_TO_DIG,dig)
1493 AC_ARG_WITH(dig_command,
1494             ACX_HELP_STRING([--with-dig-command=PATH],
1495                             [Path to dig command]), PATH_TO_DIG=$withval)
1496 if test -n "$PATH_TO_DIG"; then
1497         EXTRAS="$EXTRAS check_dig"
1498         AC_DEFINE_UNQUOTED(PATH_TO_DIG,"$PATH_TO_DIG",[Path to dig command, if present])
1499 fi
1501 AC_PATH_PROG(PATH_TO_APTGET,apt-get)
1502 AC_ARG_WITH(apt-get_command,
1503             ACX_HELP_STRING([--with-apt-get-command=PATH],
1504                             [Path to apt-get command]), 
1505                             with_apt_get_command=$withval,
1506                             with_apt_get_command=$PATH_TO_APTGET)
1507 AC_DEFINE_UNQUOTED(PATH_TO_APTGET,"$PATH_TO_APTGET",[Path to apt-get command, if present])
1508 if test -n "$PATH_TO_APTGET" ; then
1509         EXTRAS="$EXTRAS check_apt"
1510 fi
1513 if test -f plugins/check_nt.c ; then
1514   EXTRAS="$EXTRAS check_nt"
1515 elif test -f ../plugins/check_nt.c ; then
1516   EXTRAS="$EXTRAS check_nt"
1517 fi
1520 dnl used in check_dhcp
1521 AC_CHECK_HEADERS(sys/sockio.h)
1523 case $host in
1524         *bsd*)
1525                 AC_DEFINE(__bsd__,1,[bsd specific code in check_dhcp.c])
1526         ;;
1527         *linux*)
1528                 AC_DEFINE(__linux__,1,[linux specific code in check_dhcp.c])
1529         ;;
1530         *sun* | *solaris*)
1531                 AC_DEFINE(__sun__,1,[sun specific code in check_dhcp.c])
1532         ;;
1533         *hpux*)  
1534                 AC_DEFINE(__hpux__,1,[hpux specific code in check_dhcp.c])
1535         ;;
1536 esac
1538 AC_SUBST(EXTRAS)
1539 AC_SUBST(EXTRAS_ROOT)
1540 AC_SUBST(EXTRA_NETOBJS)
1541 AC_SUBST(DEPLIBS)
1543 AM_GNU_GETTEXT([external], [need-ngettext])
1544 AM_GNU_GETTEXT_VERSION(0.15)
1546 dnl Check for Redhat spopen problem
1547 dnl Wierd problem where ECHILD is returned from a wait call in error
1548 dnl Only appears to affect nslookup and dig calls. Only affects redhat around
1549 dnl 2.6.9-11 (okay in 2.6.9-5). Redhat investigating root cause
1550 dnl We patch plugins/popen.c
1551 dnl Need to add smp because uname different on those
1552 dnl Can force patch to be applied with --enable-redhat-pthread-workaround
1553 AC_ARG_ENABLE(redhat-pthread-workaround, 
1554         AC_HELP_STRING([--enable-redhat-pthread-workaround], 
1555                 [force Redhat patch to be applied (default: test system)]),
1556         [ac_cv_enable_redhat_pthread_workaround=$enableval],
1557         [ac_cv_enable_redhat_pthread_workaround=test])
1558 if test "$ac_cv_enable_redhat_pthread_workaround" = "test" ; then
1559         if echo $ac_cv_uname_r | egrep "\.EL(smp)?$" >/dev/null 2>&1 ; then
1560                 AC_MSG_NOTICE([See http://nagiosplugins.org/faq/compile/configure_appears_to_hang if this next part takes a long time])
1561                 AC_MSG_CHECKING(for redhat spopen problem)
1562                 ( cd config_test && make && make test ) > /dev/null 2>&1
1563                 if test $? -eq 0 ; then
1564                         AC_MSG_RESULT(okay)
1565                 else
1566                         AC_MSG_RESULT(error)
1567                         AC_DEFINE(REDHAT_SPOPEN_ERROR, 1, [Workaround on redhat in spopen])
1568                 fi
1569         fi
1570 elif test "$ac_cv_enable_redhat_pthread_workaround" = "yes" ; then
1571         AC_DEFINE(REDHAT_SPOPEN_ERROR, 1, [Forced workaround on redhat in spopen])
1572 fi
1574 dnl Perl modules
1575 AC_ARG_ENABLE(perl-modules,
1576         AC_HELP_STRING([--enable-perl-modules], 
1577                 [Enables installation of Nagios::Plugin and its dependencies (default: no)]),
1578         [enable_perl_modules=$enableval],
1579         [enable_perl_modules=no])
1580 if test "$enable_perl_modules" = "yes" ; then
1581   AC_SUBST(PERLMODS_DIR,perlmods)
1582 fi
1584 dnl External libraries - see ACKNOWLEDGEMENTS
1585 gl_INIT
1587 dnl Some helpful common compile errors checked here
1588 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
1589         AC_MSG_ERROR(No ar found for Solaris - is /usr/ccs/bin in PATH?)
1590 fi
1592 AC_ARG_ENABLE(libtap,
1593   AC_HELP_STRING([--enable-libtap], 
1594                 [Enables configuring of libtap in external/tap/. Run "make tap" to compile (default: no)]),
1595         [enable_libtap=$enableval],
1596         [enable_libtap=no])
1597 dnl Have to define TAP_DIR so that Makefile can pull it as an extra dist
1598 TAP_DIR=external/tap-1.01
1599 AC_SUBST(TAP_DIR)
1600 if test "$enable_libtap" = yes; then
1601         dnl Have to have AC_CONFIG_SUBDIRS as a literal
1602         AC_CONFIG_SUBDIRS([external/tap-1.01])
1603         EXTRA_TEST="test_utils test_disk test_tcp test_cmd test_base64"
1604         AC_SUBST(EXTRA_TEST)
1605 fi
1607 AC_OUTPUT(
1608   Makefile 
1609   lib/Makefile 
1610   plugins/Makefile 
1611   lib/tests/Makefile
1612   plugins-root/Makefile
1613   plugins-scripts/Makefile 
1614   plugins-scripts/subst 
1615   plugins-scripts/utils.pm 
1616   plugins-scripts/utils.sh 
1617   perlmods/Makefile
1618   command.cfg 
1619   test.pl 
1620   pkg/solaris/pkginfo 
1621   po/Makefile.in 
1625 dnl the ones below that are commented out need to be cleaned up 
1626 dnl in the configure code above to use with_foo instead of ac_cv_foo
1627 dnl if we want them to show up here.  it'd also make the code cleaner.
1628 dnl i'll get to that on another rainy day :) -sf
1629 ACX_FEATURE([with],[apt-get-command])
1630 dnl ACX_FEATURE([with],[dig-command])
1631 dnl ACX_FEATURE([with],[fping-command])
1632 dnl ACX_FEATURE([with],[mailq-command])
1633 dnl ACX_FEATURE([with],[nslookup-command])
1634 ACX_FEATURE([with],[ping6-command])
1635 ACX_FEATURE([with],[ping-command])
1636 dnl ACX_FEATURE([with],[qstat-command])
1637 dnl ACX_FEATURE([with],[rpcinfo-command])
1638 dnl ACX_FEATURE([with],[smbclient-command])
1639 dnl ACX_FEATURE([with],[snmpget-command])
1640 dnl ACX_FEATURE([with],[snmpgetnext-command])
1641 dnl ACX_FEATURE([with],[ssh-command])
1642 dnl ACX_FEATURE([with],[uptime-command])
1644 dnl ACX_FEATURE([with],[proc-meminfo])
1645 dnl ACX_FEATURE([with],[ps-command])
1646 dnl ACX_FEATURE([with],[ps-format])
1647 dnl ACX_FEATURE([with],[ps-cols])
1648 dnl ACX_FEATURE([with],[ps-varlist])
1650 ACX_FEATURE([with],[ipv6])
1651 ACX_FEATURE([with],[mysql])
1652 ACX_FEATURE([with],[openssl])
1653 ACX_FEATURE([with],[gnutls])
1654 ACX_FEATURE([enable],[extra-opts])
1655 ACX_FEATURE([with],[perl])
1656 ACX_FEATURE([enable],[perl-modules])
1657 ACX_FEATURE([with],[cgiurl])
1658 ACX_FEATURE([with],[trusted-path])