Code

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