Code

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