Code

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