Code

Added libtap tests for utils.c library functions. Removed redundant
[nagiosplug.git] / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2 AC_REVISION ($Revision$)
3 AC_PREREQ(2.58)
4 AC_INIT(nagios-plugins,1.4.2)
5 AC_CONFIG_SRCDIR(NPTest.pm)
6 AM_INIT_AUTOMAKE
7 AM_CONFIG_HEADER(config.h)
8 AC_CANONICAL_HOST
10 RELEASE=1
11 AC_SUBST(RELEASE)
13 AC_PREFIX_DEFAULT(/usr/local/nagios)
15 dnl Figure out how to invoke "install" and what install options to use.
16 AC_PROG_INSTALL
17 AC_SUBST(INSTALL)
19 dnl Must come very early on due to coreutils requirement
20 dnl Takes care of AC_GNU_SOURCE, AC_AIX and AC_MINIX
21 gl_USE_SYSTEM_EXTENSIONS
23 AC_PROG_CC
24 AC_PROG_CPP
25 AC_PROG_GCC_TRADITIONAL
26 AC_PROG_RANLIB
28 AC_PROG_MAKE_SET
29 AC_PROG_AWK
31 AC_FUNC_MALLOC
32 AC_FUNC_REALLOC
33 AC_FUNC_ERROR_AT_LINE
35 AC_CONFIG_LIBOBJ_DIR(lib)
36 AC_FUNC_GETLOADAVG([lib])
38 ifdef([AC_FUNC_STRTOD],[AC_FUNC_STRTOD],[AM_FUNC_STRTOD])
39 dnl AM_WITH_REGEX
41 PLUGIN_TEST=`echo $srcdir/plugins/t/*.t|sed -e 's,\.*/plugins/,,g'`
42 AC_SUBST(PLUGIN_TEST)dnl
44 SCRIPT_TEST=`echo $srcdir/plugins-scripts/t/*.t|sed -e 's,\.*/plugins-scripts/,,g'`
45 AC_SUBST(SCRIPT_TEST)dnl
47 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"
48 AC_SUBST(WARRANTY)
50 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"
51 AC_SUBST(SUPPORT)
53 dnl CGIURL has changed for Nagios with 1.0 beta
54 AC_ARG_WITH(cgiurl,
55         ACX_HELP_STRING([--with-cgiurl=DIR],
56                 [sets URL for cgi programs]),
57         with_cgiurl=$withval,
58         with_cgiurl=/nagios/cgi-bin)
59 CGIURL="$with_cgiurl"
60 AC_DEFINE_UNQUOTED(CGIURL,"$CGIURL",[URL of CGI programs])
62 AC_ARG_WITH(nagios_user,
63         ACX_HELP_STRING([--with-nagios-user=USER],
64                 [set user name to run nagios]),
65         with_nagios_user=$withval,
66         with_nagios_user=nagios)
67 AC_ARG_WITH(nagios_group,
68         ACX_HELP_STRING([--with-nagios-group=GROUP],
69                 [set group name to run nagios]),
70         with_nagios_group=$withval,
71         with_nagios_group=nagios)
72 AC_SUBST(with_nagios_user)
73 AC_SUBST(with_nagios_group)
74 INSTALL_OPTS="-o $with_nagios_user -g $with_nagios_group"
75 AC_SUBST(INSTALL_OPTS)
77 AC_ARG_WITH(libtap-object,
78         ACX_HELP_STRING([--with-libtap-object=path],
79                 [full path to tap.o]),
80         EXTRA_TEST=test_utils
81         EXTRA_TAPOBJ=$withval
82         AC_SUBST(EXTRA_TEST)
83         AC_SUBST(EXTRA_TAPOBJ)
84         )
86 AC_ARG_WITH(trusted_path,
87         ACX_HELP_STRING([--with-trusted-path=PATH],
88                 [sets trusted path for executables called by scripts (default=/bin:/sbin:/usr/bin:/usr/sbin)]),
89         with_trusted_path=$withval,
90         with_trusted_path=/bin:/sbin:/usr/bin:/usr/sbin)
91 AC_SUBST(with_trusted_path)
93 EXTRAS=
94 dnl PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/etc:/usr/local/bin:/usr/local/sbin:$PATH
96 LDFLAGS="$LDFLAGS -L."
98 ac_cv_uname_m=`uname -m`
99 ac_cv_uname_s=`uname -s`
100 ac_cv_uname_r=`uname -r`
101 ac_cv_uname_v=`uname -v`
103 PKG_ARCH=`uname -p`
104 REV_DATESTAMP=`date '+%Y.%m.%d.%H.%M'`
105 REV_TIMESTAMP=`date '+%Y%m%d%H%M%S'`
107 AC_SUBST(PKG_ARCH)
108 AC_SUBST(REV_DATESTAMP)
109 AC_SUBST(REV_TIMESTAMP)
111 dnl Checks for programs.
112 AC_PATH_PROG(PYTHON,python)
113 AC_PATH_PROG(SH,sh)
114 AC_PATH_PROG(PERL,perl)
115 AC_PATH_PROG(LIBGNUTLS_CONFIG,libgnutls-config)
116 AC_PATH_PROG(HOSTNAME,hostname)
117 AC_PATH_PROG(BASENAME,basename)
119 dnl allow them to override the path of perl
120 AC_ARG_WITH(perl,
121         ACX_HELP_STRING([--with-perl=PATH],
122                         [sets path to perl executable]),
123                         with_perl=$withval,with_perl=$PERL)
124 AC_SUBST(PERL, $with_perl)
126 dnl openssl/gnutls
127 AC_ARG_WITH(openssl,
128             AC_HELP_STRING([--with-openssl=DIR], 
129                            [path to openssl installation]),)
131 AC_ARG_WITH(gnutls,
132             ACX_HELP_STRING([--with-gnutls=PATH],
133                             [path to gnutls installation root]),)
135 dnl you can only have one or the other
136 if test ! "$with_openssl" = "" && test ! "$with_openssl" = "no"; then
137         with_gnutls="no"
138 fi
139 if test ! "$with_gnutls" = "" && test ! "$with_gnutls" = "no"; then
140         with_openssl="no"
141 fi
143 dnl list of possible dirs to try to autodetect openssl
144 dnl if $dir/include exists, we consider it found
145 dnl the order should allow locally installed versions to override distros' ones
146 OPENSSL_DIRS="/usr /usr/local /usr/slocal /usr/local/openssl /usr/local/ssl \
147               /opt /opt/openssl"
149 dnl
150 dnl Check for miscellaneous stuff
151 dnl 
153 case $host_vender-$host_os in
154 sun*)
155         AC_DEFINE(__EXTENSIONS__,1,[Sun's netdb.h needs this for getaddrinfo])
156         ;;
157 osf*)
158         AC_DEFINE(_OSF_SOURCE,1,[OSF needs this for getaddrinfo])
159         ;;
160 esac
162 dnl
163 dnl Checks for libraries.
164 dnl
166 AC_CHECK_LIB(dce,main,SOCKETLIBS="$SOCKETLIBS -ldce")
167 AC_CHECK_LIB(nsl,main,SOCKETLIBS="$SOCKETLIBS -lnsl")
168 AC_CHECK_LIB(socket,socket,SOCKETLIBS="$SOCKETLIBS -lsocket")
169 AC_CHECK_LIB(resolv,main,SOCKETLIBS="$SOCKETLIBS -lresolv")
170 AC_SUBST(SOCKETLIBS)
172 dnl
173 dnl check for math-related functions needing -lm
174 AC_CHECK_HEADERS(math.h)
175 AC_CHECK_LIB(m,floor,MATHLIBS="-lm")
176 AC_SUBST(MATHLIBS)
178 dnl Check for PostgreSQL libraries
179 _SAVEDLIBS="$LIBS"
180 _SAVEDCPPFLAGS="$CPPFLAGS"
181 AC_ARG_WITH(pgsql,
182         ACX_HELP_STRING([--with-pgsql=DIR],
183                 [sets path to pgsql installation]),
184         PGSQL=$withval,)
185 AC_CHECK_LIB(crypt,main)
186 if test "$ac_cv_lib_crypt_main" = "yes"; then
187   if test -n "$PGSQL"; then
188     LDFLAGS="$LDFLAGS -L$PGSQL/lib"
189     CPPFLAGS="$CPPFLAGS -I$PGSQL/include"
190   fi
191   AC_CHECK_LIB(pq,PQsetdbLogin,,,-lcrypt)
192   if test "$ac_cv_lib_pq_PQsetdbLogin" = "yes"; then
193     AC_CHECK_HEADERS(pgsql/libpq-fe.h)
194     AC_CHECK_HEADERS(postgresql/libpq-fe.h)
195     AC_CHECK_HEADERS(libpq-fe.h)
196     if [[ -n "$PGSQL" -a "$ac_cv_header_libpq_fe_h" = "yes" ]]; then
197       PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
198       PGINCLUDE="-I$PGSQL/include"
199     elif test  "$ac_cv_header_pgsql_libpq_fe_h" = "yes"; then
200       PGLIBS="-lpq -lcrypt"
201       PGINCLUDE="-I/usr/include/pgsql"
202     elif test  "$ac_cv_header_postgresql_libpq_fe_h" = "yes"; then
203       PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
204       PGINCLUDE="-I/usr/include/postgresql"
205     elif test  "$ac_cv_header_libpq_fe_h" = "yes"; then
206       PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
207       PGINCLUDE="-I$PGSQL/include"
208     fi
209     if test -z "$PGINCLUDE"; then
210       AC_MSG_WARN([Skipping PostgreSQL plugin (check_pgsql)])
211       AC_MSG_WARN([install PostgreSQL headers to compile this plugin (see REQUIREMENTS).])
212     else
213       AC_SUBST(PGLIBS)
214       AC_SUBST(PGINCLUDE)
215       EXTRAS="$EXTRAS check_pgsql"
216     fi
217   else
218     AC_MSG_WARN([Skipping PostgreSQL plugin (check_pgsql)])
219     AC_MSG_WARN([LIBS="$LIBS" CPPFLAGS="$CPPFLAGS"])
220     AC_MSG_WARN([install PostgreSQL libs to compile this plugin (see REQUIREMENTS).])
221   fi
222 else
223   AC_MSG_WARN([Skipping PostgreSQL plugin (check_pgsql)])
224   AC_MSG_WARN([install lib crypt and PostgreSQL libs to compile this plugin (see REQUIREMENTS).])
225 fi
226 LIBS="$_SAVEDLIBS"
227 CPPFLAGS="$_SAVEDCPPFLAGS"
229 dnl Check for radius libraries
230 _SAVEDLIBS="$LIBS"
231 AC_CHECK_LIB(radiusclient,rc_read_config)
232 if test "$ac_cv_lib_radiusclient_rc_read_config" = "yes"; then
233   EXTRAS="$EXTRAS check_radius"
234         RADIUSLIBS="-lradiusclient"
235   AC_SUBST(RADIUSLIBS)
236 else
237   AC_MSG_WARN([Skipping radius plugin])
238   AC_MSG_WARN([install radius libs to compile this plugin (see REQUIREMENTS).])
239 fi
240 LIBS="$_SAVEDLIBS"
242 dnl Check for LDAP libraries
243 _SAVEDLIBS="$LIBS"
244 AC_CHECK_LIB(ldap,main,,,-llber)
245 if test "$ac_cv_lib_ldap_main" = "yes"; then
246   LDAPLIBS="-lldap -llber"\
247   LDAPINCLUDE="-I/usr/include/ldap"
248   AC_SUBST(LDAPLIBS)
249   AC_SUBST(LDAPINCLUDE)
250   AC_CHECK_FUNCS(ldap_set_option)
251   EXTRAS="$EXTRAS check_ldap"
252         AC_CHECK_FUNCS(ldap_init ldap_set_option ldap_get_option ldap_start_tls_s)
253 else
254   AC_MSG_WARN([Skipping LDAP plugin])
255   AC_MSG_WARN([install LDAP libs to compile this plugin (see REQUIREMENTS).])
256 fi
257 LIBS="$_SAVEDLIBS"
260 dnl Check for mysql libraries
261 _SAVEDLIBS="$LIBS"
262 _SAVEDCPPFLAGS="$CPPFLAGS"
263 AC_ARG_WITH(mysql,
264         ACX_HELP_STRING([--with-mysql=DIR],
265                 [sets path to mysql installation (assumes lib/mysql and include subdirs]),
266         MYSQL=$withval,)
267 if test -n "$MYSQL"; then
268   MYSQLLIBDIR=$MYSQL/lib/mysql
269   CPPFLAGS="-I$MYSQL/include"
270   AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz" check_mysql_LDFLAGS="-L$MYSQLLIBDIR ",,-L$MYSQLLIBDIR -lz)
271   AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient")
272 elif test -f /usr/lib/libmysqlclient.so; then
273   AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz",,-lz)
274   AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient")
275 elif test -f /usr/lib/libmysqlclient.a; then
276   AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz",,-lz)
277   AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient")
278 elif test -f /usr/lib/mysql/libmysqlclient.so; then
279   AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz" check_mysql_LDFLAGS="-L/usr/lib/mysql",,-L/usr/lib/mysql -lz)
280   AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient" check_mysql_LDFLAGS="-L/usr/lib/mysql",,-L/usr/lib/mysql)
281 elif test -f /usr/lib/mysql/libmysqlclient.a; then
282   AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz" check_mysql_LDFLAGS="-L/usr/lib/mysql",,-L/usr/lib/mysql -lz)
283   AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient" check_mysql_LDFLAGS="-L/usr/lib/mysql",,-L/usr/lib/mysql)
284 fi
285 if test "$ac_cv_lib_mysqlclient_mysql_init" = "yes" -o "$ac_cv_lib_mysqlclient_mysql_close" = "yes"; then
286   AC_CHECK_HEADERS(mysql/mysql.h mysql/errmsg.h, MYSQLINCLUDE="-I$MYSQL/include" )
287   if test "$ac_cv_header_mysql_mysql_h" = "yes" -a "$ac_cv_header_mysql_errmsg_h" = "yes"; then
288     EXTRAS="$EXTRAS check_mysql"
289     AC_SUBST(MYSQLINCLUDE)
290     AC_SUBST(MYSQLLIBS)
291     AC_SUBST(check_mysql_LDFLAGS)
292   else
293     AC_MSG_WARN([Skipping mysql plugin])
294     AC_MSG_WARN([install mysql client headers to compile this plugin (see REQUIREMENTS).])
295   fi
296 else
297   AC_MSG_WARN([Skipping mysql plugin])
298   AC_MSG_WARN([install mysql client libs to compile this plugin (see REQUIREMENTS).])
299 fi
300 CPPFLAGS="$_SAVEDCPPFLAGS $MYSQLINCLUDE"
301 LIBS="$_SAVEDLIBS"
303 AC_CHECK_HEADERS(unistd.h)
305 dnl Check for AF_INET6 support - unistd.h required for Darwin
306 AC_CACHE_CHECK([for IPv6 support], with_ipv6, [
307         AC_TRY_COMPILE([#ifdef HAVE_UNISTD_H
308                         #include <unistd.h>
309                         #endif
310                         #include <netinet/in.h>
311                         #include <sys/socket.h>],
312                         [struct sockaddr_in6 sin6;
313                         void *p;
315                         sin6.sin6_family = AF_INET6;
316                         sin6.sin6_port = 587;
317                         p = &sin6.sin6_addr;],
318                         [with_ipv6=yes], 
319                         [with_ipv6=no])
320         ])
322 if test x"$with_ipv6" != xno ; then
323         AC_DEFINE(USE_IPV6,1,[Enable IPv6 support])
324 fi
326 dnl #########################################################################
327 dnl Check if Posix getaddrinfo() is available.  It is also possible to use
328 dnl the version from the lwres library distributed with BIND.
329 dnl #########################################################################
330 AC_ARG_ENABLE([emulate-getaddrinfo],
331               ACX_HELP_STRING([--enable-emulate-getaddrinfo],
332                              [enable getaddrinfo emulation (default=no)]),
333               ,
334               enable_emulate_getaddrinfo=no)
336 AC_ARG_WITH(lwres,
337             ACX_HELP_STRING([--with-lwres=DIR],
338                            [use lwres library for getaddrinfo (default=no)]),
339             ,
340             with_lwres=no)
342 dnl ## enable force to test getaddrinfo.c
343 if test x$enable_emulate_getaddrinfo = xforce ; then
344         enable_emulate_getaddrinfo=yes
345         have_getaddrinfo=no
346 else
348 have_getaddrinfo=no
349 if test x$with_lwres != xno ; then
350         if test "$with_lwres" != yes ; then
351                    CPPFLAGS="-I${with_lwres}/include $CPPFLAGS"
352                    LDFLAGS="-L${with_lwres}/lib $LDFLAGS"
353         fi
354         AC_CHECK_HEADERS(lwres/netdb.h, ,
355                         [AC_MSG_ERROR([cannot find <lwres/netdb.h>])])
356         AC_CHECK_LIB(lwres, lwres_getaddrinfo, ,
357                      [AC_MSG_ERROR([cannot find the lwres library])],
358                      -lnsl -lpthread)
359         have_getaddrinfo=yes
360 fi
362 if test x$have_getaddrinfo != xyes ; then
363         AC_SEARCH_LIBS(getaddrinfo, socket resolv bind nsl c_r cr, have_getaddrinfo=yes)
364 fi
366 dnl # Special nonsense for systems that actually have getaddrinfo but
367 dnl # redefine the name to something else, e.g. OSF
368 if test x$have_getaddrinfo != xyes ; then
369         AC_MSG_CHECKING(if getaddrinfo is redefined in netdb.h)
370         AC_TRY_LINK([
371 #               include <netdb.h>
372         ], [
373                 struct addrinfo hints, *res;
374                 int err;
376                 err = getaddrinfo ("host", "service", &hints, &res);
377         ], [
378                 have_getaddrinfo=yes
379                 AC_MSG_RESULT(yes)
380         ], [AC_MSG_RESULT(no)])
381 fi
383 fi
385 if test x$have_getaddrinfo != xno ; then
386         if test x$enable_emulate_getaddrinfo != xno ; then
387                 AC_MSG_ERROR([getaddrinfo found but emulate-getaddrinfo was enabled])
388         fi
389         AC_DEFINE(HAVE_GETADDRINFO, 1,
390                   [Does system provide RFC 2553/Posix getaddrinfo?])
391 else
392         if test x$enable_emulate_getaddrinfo != xyes ; then
393 dnl                AC_MSG_ERROR([getaddrinfo not found: try --with-lwres or --enable-emulate-getaddrinfo])
394                enable_emulate_getaddrinfo=yes
395                AC_MSG_WARN([enabling getaddrinfo emulation])
396         fi
397         EXTRA_NETOBJS="$EXTRA_NETOBJS getaddrinfo.o"
398 fi
400 if test x"$enable_emulate_getaddrinfo" != xno ; then
401     have_resolver=no
403   dnl  Try for getipnodebyname
404     AC_SEARCH_LIBS(getipnodebyname, resolv bind nsl c_r cr, have_resolver=yes)
405     if test x"$have_resolver" != xno ; then
406          AC_DEFINE(HAVE_GETIPNODEBYNAME, 1,
407                    [Set when getipnodebyname is available])
408     fi
410   dnl  Try for gethostbyname_r
411     if test x"$have_resolver" = xno ; then
412         AC_SEARCH_LIBS(gethostbyname_r, resolv bind nsl c_r cr,
413                        [have_resolver=yes
414                         ACX_WHICH_GETHOSTBYNAME_R])
415     fi
417   dnl  Try for gethostbyname
418     if test x"$have_resolver" = xno ; then
419         if test x"$enable_pthreads" != xno ; then
420             AC_MSG_WARN([using threads but cannot find gethostbyname_r or getipnodebyname])
421         fi
422         AC_SEARCH_LIBS(gethostbyname, resolv bind nsl, ,
423                        [AC_MSG_ERROR([cannot find gethostbyname])])
424     fi
425     EXTRA_NETOBJS="$EXTRA_NETOBJS gethostbyname.o"
427 fi
429 dnl Checks for Kerberos. Must come before openssl checks for Redhat EL 3
430 AC_CHECK_HEADERS(krb5.h,FOUNDINCLUDE=yes,FOUNDINCLUDE=no)
431 if test "$FOUNDINCLUDE" = "no"; then
432   _SAVEDCPPFLAGS="$CPPFLAGS"
433   CPPFLAGS="$_SAVEDCPPFLAGS -I/usr/kerberos/include"
434   unset ac_cv_header_krb5_h
435   AC_CHECK_HEADERS(krb5.h,
436                    KRB5INCLUDE="-I/usr/kerberos/include"
437                    FOUNDINCLUDE=yes,
438                    FOUNDINCLUDE=no)
439 fi
440 AC_SUBST(KRBINCLUDE)
441 if test "$FOUNDINCLUDE" = "no"; then
442   CPPFLAGS="$_SAVEDCPPFLAGS"
443 fi
446 dnl openssl detection/configuration
447 if ! test "$with_openssl" = "no"; then
448         dnl Check for OpenSSL location if it wasn't already specified
449         if ! test -d "$with_openssl"; then
450                 for d in $OPENSSL_DIRS; do
451                         if test -x ${d}/bin/openssl || test -x ${d}/sbin/openssl ; then
452                                 with_openssl=$d
453                         fi
454                 done
455         fi
457         _SAVEDCPPFLAGS="$CPPFLAGS"
458         _SAVEDLDFLAGS="$LDFLAGS"
459         dnl Check for OpenSSL header files
460         unset FOUNDINCLUDE
461         CPPFLAGS="$CPPFLAGS -I$OPENSSL/include"
462         LDFLAGS="$LDFLAGS -R$OPENSSL/lib"
464         dnl check for openssl in $dir/include/openssl
465         AC_CHECK_HEADERS(openssl/ssl.h openssl/x509.h openssl/rsa.h openssl/pem.h openssl/crypto.h openssl/err.h,
466                          SSLINCLUDE="-I$OPENSSL/include"
467                          FOUNDINCLUDE=yes,
468                          FOUNDINCLUDE=no)
469         dnl else check to see if $dir/include has it
470         if test "$FOUNDINCLUDE" = "no"; then
471                 AC_CHECK_HEADERS(ssl.h x509.h rsa.h pem.h crypto.h err.h,
472                                  SSLINCLUDE="-I$OPENSSL/include"
473                                  FOUNDINCLUDE=yes,
474                                  FOUNDINCLUDE=no)
475         fi
476         AC_SUBST(SSLINCLUDE)
477         dnl if we didn't find it, reset CPPFLAGS
478         if test "$FOUNDINCLUDE" = "no"; then
479                 CPPFLAGS="$_SAVEDCPPFLAGS"
480                 LDFLAGS="$_SAVEDLDFLAGS"
481         fi
483         dnl Check for crypto lib
484         _SAVEDLIBS="$LIBS"
485         LIBS="-L${with_openssl}/lib"
486         AC_CHECK_LIB(crypto,CRYPTO_lock)
487         if test "$ac_cv_lib_crypto_CRYPTO_lock" = "yes"; then
488                 dnl Check for SSL lib
489                 AC_CHECK_LIB(ssl,main, SSLLIBS="-lssl -lcrypto",,-lcrypto)
490         fi
491         LIBS="$_SAVEDLIBS"
493         dnl test headers and libs to decide whether check_http should use SSL
494         if test "$ac_cv_lib_crypto_CRYPTO_lock" = "yes"; then
495                 if test "$ac_cv_lib_ssl_main" = "yes"; then
496                         if test "$FOUNDINCLUDE" = "yes"; then
497                                 FOUNDOPENSSL="yes"
498                         fi
499                 fi
500         fi
501 fi
504 dnl check for gnutls if openssl isn't found (or is disabled)
505 if test ! "$FOUNDOPENSSL" = "yes" && test ! "$with_gnutls" = "no"; then
506         if test ! "$with_gnutls" = ""; then
507                 CPPFLAGS="$CPPFLAGS -I${with_gnutls}/include"
508         elif test ! "$LIBGNUTLS_CONFIG" = ""; then
509                 CPPFLAGS="$CPPFLAGS -I`$LIBGNUTLS_CONFIG --prefix`"
510         fi
511         AC_CHECK_HEADERS([gnutls/openssl.h],FOUNDGNUTLS="yes",)
512         if test "$FOUNDGNUTLS" = "yes"; then
513                 AC_CHECK_LIB(gnutls-openssl,main,SSLLIBS="-lgnutls-openssl")
514         fi
515 fi
516 dnl end check for gnutls
518 if test "$FOUNDOPENSSL" = "yes" || test "$FOUNDGNUTLS" = "yes"; then
519         check_tcp_ssl="check_simap check_spop check_jabber check_nntps check_ssmtp"
520         AC_SUBST(check_tcp_ssl)
521         AC_SUBST(SSLLIBS)
522         AC_DEFINE(HAVE_SSL,1,[Define if SSL libraries are found])
523         if test "$FOUNDOPENSSL" = "yes"; then
524                 AC_DEFINE(USE_OPENSSL,1,[Define if using OpenSSL libraries])
525                 with_openssl="yes"
526                 with_gnutls="no"
527         else
528                 AC_DEFINE(USE_GNUTLS,1,[Define if using gnutls libraries])
529                 with_gnutls="yes"
530                 with_openssl="no"
531         fi
532 else
533         dnl else deliberately disabled or no ssl support available
534         AC_MSG_WARN([OpenSSL or GnuTLS libs could not be found or were disabled])
535         with_openssl="no"
536         with_gnutls="no"
537 fi
539 dnl
540 dnl Checks for header files.
541 dnl
543 AC_HEADER_STDC
544 AC_HEADER_TIME
545 AC_HEADER_SYS_WAIT
546 AC_CHECK_HEADERS(signal.h strings.h string.h syslog.h uio.h errno.h regex.h sys/types.h sys/time.h sys/socket.h sys/loadavg.h sys/un.h)
547 AC_CHECK_HEADERS(features.h stdarg.h sys/unistd.h ctype.h stdlib.h)
549 dnl Checks for typedefs, structures, and compiler characteristics.
550 AC_C_CONST
551 AC_STRUCT_TM
552 AC_TYPE_PID_T
553 AC_TYPE_SIZE_T
554 AC_TYPE_SIGNAL
556 AC_CACHE_CHECK([for va_copy],ac_cv_HAVE_VA_COPY,[
557 AC_TRY_LINK([#include <stdarg.h>
558 va_list ap1,ap2;], [va_copy(ap1,ap2);],
559 ac_cv_HAVE_VA_COPY=yes,
560 ac_cv_HAVE_VA_COPY=no)])
561 if test x"$ac_cv_HAVE_VA_COPY" = x"yes"; then
562     AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available])
563 else    
564     AC_CACHE_CHECK([for __va_copy],ac_cv_HAVE___VA_COPY,[
565     AC_TRY_LINK([#include <stdarg.h>
566     va_list ap1,ap2;], [__va_copy(ap1,ap2);],
567     ac_cv_HAVE___VA_COPY=yes,
568     ac_cv_HAVE___VA_COPY=no)])
569     if test x"$ac_cv_HAVE___VA_COPY" = x"yes"; then
570         AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available])
571     fi
572 fi
574 AC_CHECK_FUNCS(vsnprintf snprintf asprintf vasprintf)
575 AC_CACHE_CHECK([for C99 vsnprintf],ac_cv_HAVE_C99_VSNPRINTF,[
576 AC_TRY_RUN([
577 #include <sys/types.h>
578 #include <stdarg.h>
579 void foo(const char *format, ...) { 
580        va_list ap;
581        int len;
582        char buf[5];
584        va_start(ap, format);
585        len = vsnprintf(buf, 0, format, ap);
586        va_end(ap);
587        if (len != 5) exit(1);
589        va_start(ap, format);
590        len = vsnprintf(0, 0, format, ap);
591        va_end(ap);
592        if (len != 5) exit(1);
594        if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
596        exit(0);
598 main() { foo("hello"); }
599 ],
600 ac_cv_HAVE_C99_VSNPRINTF=yes,ac_cv_HAVE_C99_VSNPRINTF=no,ac_cv_HAVE_C99_VSNPRINTF=cross)])
601 if test x"$ac_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
602     AC_DEFINE(HAVE_C99_VSNPRINTF,1,[Define if system has C99 compatible vsnprintf])
603 fi
605 AC_TRY_COMPILE([#include <sys/time.h>],
606                [struct timeval *tv;
607                 struct timezone *tz;],
608                AC_DEFINE(HAVE_STRUCT_TIMEVAL,1,[Define if we have a timeval structure])
609                AC_TRY_COMPILE([#include <sys/time.h>],
610                               [struct timeval *tv;
611                                struct timezone *tz;
612                                gettimeofday(tv, tz);],
613                               AC_DEFINE(HAVE_GETTIMEOFDAY,1,[Define if gettimeofday is found]),
614                               AC_DEFINE(NEED_GETTIMEOFDAY,1,[Define if gettimeofday is needed])))
616 dnl Checks for library functions.
617 AC_CHECK_FUNCS(memmove select socket strdup strstr strtod strtol strtoul floor)
619 AC_MSG_CHECKING(return type of socket size)
620 AC_TRY_COMPILE([#include <stdlib.h>
621                 #include <sys/types.h>
622                 #include <sys/socket.h>],
623                [int a = send(1, (const void *) buffer, (size_t *) 0, (int *) 0);],
624                ac_cv_socket_size_type=["size_t"]
625                 AC_MSG_RESULT(size_t),
626                ac_cv_socket_size_type=["int"]
627                 AC_MSG_RESULT(int))
629 AC_DEFINE_UNQUOTED(SOCKET_SIZE_TYPE, $ac_cv_socket_size_type ,
630         [Define type of socket size])
632 AC_ARG_WITH(proc-loadavg,
633             ACX_HELP_STRING([--with-proc-loadavg=PATH],
634                             [path to /proc/loadavg or equivalent]),
635             ac_cv_proc_loadavg=$withval)
636 AC_MSG_CHECKING([for /proc/loadavg])
637 if test -n "$ac_cv_proc_loadavg"; then
638   AC_MSG_RESULT([(command line) $ac_cv_proc_loadavg])
639 elif test -f "/proc/loadavg"; then
640   AC_MSG_RESULT([found /proc/loadavg])
641   ac_cv_proc_loadavg="/proc/loadavg"
642 else
643   AC_MSG_RESULT([no])
644 fi
646 if test -n "$ac_cv_proc_loadavg"; then
647   AC_DEFINE(HAVE_PROC_LOADAVG,1,[Define if /proc/loadavg or similar exists])
648   AC_DEFINE_UNQUOTED(PROC_LOADAVG,"/proc/loadavg",[Location of /proc/loadavg])
649 fi
651 dnl #### Process table test
653 AC_PATH_PROG(PATH_TO_PS,ps)
655 AC_MSG_CHECKING(for ps syntax)
656 AC_ARG_WITH(ps_command,
657             ACX_HELP_STRING([--with-ps-command=PATH], 
658                             [Verbatim command to execute for ps]),
659             PS_COMMAND=$withval)
660 AC_ARG_WITH(ps_format,
661             ACX_HELP_STRING([--with-ps-format=FORMAT],
662                             [Format string for scanning ps output]),
663             PS_FORMAT=$withval)
664 AC_ARG_WITH(ps_cols,
665             ACX_HELP_STRING([--with-ps-cols=NUM], 
666                             [Number of columns in ps command]),
667             PS_COLS=$withval)
668 AC_ARG_WITH(ps_varlist,
669             ACX_HELP_STRING([--with-ps-varlist=LIST],
670                             [Variable list for sscanf of 'ps' output]),
671             PS_VARLIST=$withval)
673 AM_CONDITIONAL(WANT_PST3, false)
675 if test -n "$PS_COMMAND" && test -n "$PS_FORMAT" && test -n "$PS_COLS" && test -n "$PS_VARLIST"; then 
676         ac_cv_ps_command="$PS_COMMAND"
677         ac_cv_ps_format="$PS_FORMAT"
678         ac_cv_ps_varlist="$PS_VARLIST"
679         ac_cv_ps_cols="$PS_COLS"
680         AC_MSG_RESULT([(command-line) $ac_cv_ps_command])
682 dnl Now using the pst3/kmem hack for solaris systems to avoid truncation
683 elif test "$ac_cv_uname_s" = "SunOS"; then
684         #
685         # this is a very, very ugly hack, to hardcode the location for plugins
686         #
687         if test "$libexecdir" = '${exec_prefix}/libexec'; then
688                 if test "$exec_prefix" = "NONE"; then
689                         if test "$prefix" = "NONE"; then
690                                 pst3="$ac_default_prefix/libexec/pst3"
691                         else
692                                 pst3="$prefix/libexec/pst3"
693                         fi
694                 else
695                         pst3="$exec_prefix/libexec/pst3"
696                 fi
697         else
698                 pst3="$libexecdir/pst3"
699         fi
700         ac_cv_ps_command="$pst3"
701         ac_cv_ps_format="%s %d %d %d %d %f %s %n"
702         ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
703         ac_cv_ps_cols=8
704         AC_MSG_RESULT([using nagios-plugins internal ps for solaris])
705         AM_CONDITIONAL(WANT_PST3, true)
707 dnl Some gnu/linux systems (debian for one) don't like -axwo and need axwo.
708 dnl so test for this first...
709 elif ps axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
710         egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null
711 then
712         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
713         ac_cv_ps_command="$PATH_TO_PS axwo 'stat uid pid ppid vsz rss pcpu comm args'"
714         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
715         ac_cv_ps_cols=9
716         AC_MSG_RESULT([$ac_cv_ps_command])
718 dnl For OpenBSD 3.2 & 3.3. Must come before ps -weo
719 dnl Should also work for FreeBSD 5.2.1 and 5.3
720 dnl  STAT UCOMM              VSZ   RSS USER      PPID COMMAND
721 elif ps -axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
722         egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null
723 then
724         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
725         ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid pid ppid vsz rss pcpu comm args'"
726         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
727         ac_cv_ps_cols=9
728         AC_MSG_RESULT([$ac_cv_ps_command])
730 dnl Some *BSDs have different format for ps. This is mainly to catch FreeBSD 4. 
731 dnl Limitation: Only first 16 chars returned for ucomm field
732 dnl Must come before ps -weo
733 elif ps -axwo 'stat uid pid ppid vsz rss pcpu ucomm command' 2>/dev/null | \
734         egrep -i ["^ *STAT +UID +PID +PPID +VSZ +RSS +%CPU +UCOMM +COMMAND"] > /dev/null
735 then
736         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
737         ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid pid ppid vsz rss pcpu ucomm command'"
738         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
739         ac_cv_ps_cols=9
740         AC_MSG_RESULT([$ac_cv_ps_command])
742 dnl  STAT UCOMM              VSZ   RSS USER       UID  PPID COMMAND
743 elif ps -weo 'stat comm vsz rss user uid pid ppid etime args' 2>/dev/null | \
744         egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[ID]+ +P[PID]+ +[ELAPSD]+ +[RGSCOMDNA]+"] >/dev/null
745 then
746         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procetime,procprog,&pos]"
747         ac_cv_ps_command="$PATH_TO_PS -weo 'stat uid pid ppid vsz rss pcpu etime comm args'"
748         ac_cv_ps_format="%s %d %d %d %d %d %f %s %s %n"
749         ac_cv_ps_cols=10
750         AC_MSG_RESULT([$ac_cv_ps_command])
752 dnl FreeBSD
753 elif ps waxco 'state command vsz rss uid user pid ppid' 2>/dev/null | \
754         egrep -i ["^STAT +COMMAND +VSZ +RSS +UID +USER +PID +PPID"] >/dev/null
755 then
756         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
757         ac_cv_ps_command="$PATH_TO_PS waxco 'state uid pid ppid vsz rss pcpu command command'"
758         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
759         ac_cv_ps_cols=9
760         AC_MSG_RESULT([$ac_cv_ps_command])
762 dnl BSD-like mode in RH 6.1
763 elif ps waxno 'state comm vsz rss uid user pid ppid args' 2>/dev/null | \
764         egrep -i ["^S +COMMAND +VSZ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
765 then
766         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
767         ac_cv_ps_command="$PATH_TO_PS waxno 'state uid pid ppid vsz rss pcpu comm args'"
768         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
769         ac_cv_ps_cols=9
770         AC_MSG_RESULT([$ac_cv_ps_command])
772 dnl SunOS 4.1.3:
773 dnl  F  UID  PID  PPID  CP  PRI  NI  SZ  RSS  WCHAN  STAT  TT  TIME  COMMAND
774 dnl Need the head -1 otherwise test will work because arguments are found
775 elif ps -laxnwww 2>/dev/null | head -1 | \
776         egrep -i ["^ *F(LAGS)? +UID +PID +PPID +CP +PRI +NI +(SZ)|(VSZ)|(SIZE) +RSS +WCHAN +STAT? +TTY? +TIME +COMMAND"] >/dev/null
777 then
778         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]"
779         ac_cv_ps_command="$PATH_TO_PS -laxnwww"
780         ac_cv_ps_format="%*s %d %d %d %*s %*s %*s %d %d %*s %s %*s %*s %n%s"
781         ac_cv_ps_cols=9
782         AC_MSG_RESULT([$ac_cv_ps_command])
784 dnl Debian Linux / procps v1.2.9:
785 dnl  FLAGS   UID   PID  PPID PRI  NI   SIZE   RSS WCHAN       STA TTY TIME COMMAND
786 dnl    100     0     1     0   0   0    776    76  c0131c8c   S  ffff  0:11 init [2]
787 dnl
788 elif ps laxnwww 2>/dev/null | \
789         egrep -i ["^ *F(LAGS)? +UID +PID +PPID +PRI +NI +(VSZ)|(SIZE) +RSS +WCHAN +STAT? TTY +TIME +COMMAND"] >/dev/null
790 then
791         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,procstat,&procvsz,&procrss,&pos,procprog]"
792         ac_cv_ps_command="$PATH_TO_PS laxnwww"
793         ac_cv_ps_format="%*s %d %d %d %*s %*s %d %d %*s %s %*s %*s %n%s"
794         ac_cv_ps_cols=9
795         AC_MSG_RESULT([$ac_cv_ps_command])
797 dnl OpenBSD (needs to come early because -exo appears to work, but does not give all procs)
798 elif ps -axo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
799         egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[PID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null
800 then
801         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
802         ac_cv_ps_command="$PATH_TO_PS -axo 'stat uid pid ppid vsz rss pcpu comm args'"
803         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
804         ac_cv_ps_cols=9
805         AC_MSG_RESULT([$ac_cv_ps_command])
807 dnl Tru64 - needs %*[ +<>] in PS_FORMAT. 
808 dnl Has /usr/bin/ps and /sbin/ps - force sbin version
809 dnl Can't use vsize and rssize because comes back with text (eg, 1.5M instead 
810 dnl of 1500). Will need big changes to check_procs to support
811 elif /sbin/ps -eo 'stat uid pid ppid pcpu etime comm args' 2>/dev/null | \
812         egrep -i ["^ *S +[UID]+ +[PID]+ +[PID]+ +[%CPU]+ +[ELAPSD]+ +[COMMAND]+ +[COMMAND]+"] > /dev/null
813 then
814         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procpcpu,procetime,procprog,&pos]"
815         ac_cv_ps_command="/sbin/ps -eo 'stat uid pid ppid pcpu etime comm args'"
816         ac_cv_ps_format=["%s%*[ +<>] %d %d %d %f %s %s %n"]
817         ac_cv_ps_cols=8
818         AC_MSG_RESULT([$ac_cv_ps_command])
820 elif ps -eo 's comm vsz rss user uid pid ppid args' 2>/dev/null | \
821         egrep -i ["^S[TAUES]* +C[OMDNA]+ +[VSIZE]+ +U[SER]+ +U[ID]+ +P[PID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null
822 then
823         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
824         ac_cv_ps_command="$PATH_TO_PS -eo 's uid pid ppid vsz rss pcpu comm args'"
825         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
826         ac_cv_ps_cols=9
827         AC_MSG_RESULT([$ac_cv_ps_command])
829 dnl AIX 4.3.3 and 5.1 do not have an rss field
830 elif ps -eo 'stat uid pid ppid vsz pcpu comm args' 2>/dev/null | \
831         egrep -i ["^ *S[TAUES]* +UID +PID +PPID +VSZ +%CPU +COMMAND +COMMAND"] >/dev/null
832 then
833         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procpcpu,procprog,&pos]"
834         ac_cv_ps_command="$PATH_TO_PS -eo 'stat uid pid ppid vsz pcpu comm args'"
835         ac_cv_ps_format="%s %d %d %d %d %f %s %n"
836         ac_cv_ps_cols=8
837         AC_MSG_RESULT([$ac_cv_ps_command - with no RSS])
839 dnl Solaris 2.6
840 elif ps -Ao 's comm vsz rss uid user pid ppid args' 2>/dev/null | \
841         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
842 then
843         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
844         ac_cv_ps_command="$PATH_TO_PS -Ao 's uid pid ppid vsz rss pcpu comm args'"
845         # There must be no space between the %s and %n due to a wierd problem in sscanf where
846         # it will return %n as longer than the line length
847         ac_cv_ps_format="%s %d %d %d %d %d %f %s%n"
848         ac_cv_ps_cols=9
849         AC_MSG_RESULT([$ac_cv_ps_command])
851 elif ps -Ao 'status comm vsz rss uid user pid ppid args' 2>/dev/null | \
852         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
853 then
854         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
855         ac_cv_ps_command="$PATH_TO_PS -Ao 'status uid pid ppid vsz rss pcpu comm args'"
856         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
857         ac_cv_ps_cols=9
858         AC_MSG_RESULT([$ac_cv_ps_command])
860 elif ps -Ao 'state comm vsz rss uid user pid ppid args' 2>/dev/null | \
861         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
862 then
863         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
864         ac_cv_ps_command="$PATH_TO_PS -Ao 'state uid pid ppid vsz rss pcpu comm args'"
865         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
866         ac_cv_ps_cols=9
867         AC_MSG_RESULT([$ac_cv_ps_command])
869 dnl wonder who takes state instead of stat
870 elif ps -ao 'state command vsz rss user pid ppid args' 2>/dev/null | \
871         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
872 then
873         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
874         ac_cv_ps_command="$PATH_TO_PS -ao 'state uid pid ppid vsz rss pcpu command args'"
875         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
876         ac_cv_ps_cols=8
877         AC_MSG_RESULT([$ac_cv_ps_command])
879 dnl IRIX 53
880 elif ps -el 2>/dev/null | \
881         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
882 then
883         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&pos,procprog]"
884         ac_cv_ps_command="$PATH_TO_PS -el (IRIX 53)"
885         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %d %d %*s %*s %*s %n%s"
886         ac_cv_ps_cols=8
887         AC_MSG_RESULT([$ac_cv_ps_command])
889 dnl IRIX 63
890 elif ps -el 2>/dev/null | \
891         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +ADDR +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
892 then
893         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
894         ac_cv_ps_command="$PATH_TO_PS -el (IRIX 63)"
895         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
896         ac_cv_ps_cols=6
897         AC_MSG_RESULT([$ac_cv_ps_command])
899 dnl AIX 4.1:
900 dnl     F S      UID   PID  PPID   C PRI NI ADDR  SZ  RSS   WCHAN    TTY  TIME CMD
901 dnl    303 A        0     0     0 120  16 -- 1c07  20   24              -  0:45 swapper
902 elif ps -el 2>/dev/null | \
903         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +ADDR +SZ +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
904 then
905         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
906         ac_cv_ps_command="$PATH_TO_PS -el (AIX 4.1 and HP-UX)"
907         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
908         ac_cv_ps_cols=6
909         AC_MSG_RESULT([$ac_cv_ps_command])
911 dnl AIX?
912 elif ps glaxen 2>/dev/null | \
913         egrep -i ["^ *F +UID +PID +PPID +PRI +NI +VSZ +RSS +WCHAN +STAT +TTY +TIME +COMMAND"] >/dev/null
914 then
915         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]"
916         ac_cv_ps_command="$PATH_TO_PS glaxen"
917         ac_cv_ps_format="%*s %d %d %d %*s %*s %d %d %*s %s %*s %*s %n%s"
918         ac_cv_ps_cols=8
919         AC_MSG_RESULT([$ac_cv_ps_command])
921 dnl MacOSX / Darwin
922 dnl TODO: MacOSX has commands with spaces which will cause problems to PS_FORMAT
923 dnl Some truncation will happen in UCOMM column
924 dnl STAT      VSZ    RSS   UID  PPID %CPU UCOMM            COMMAND
925 dnl Ss      52756  22496   501     1   6.9 Window Manager   /System/Library/CoreServices/WindowServer -daemon
926 elif ps wwaxo 'state vsz rss uid pid ppid pcpu ucomm command' 2>/dev/null | \
927         egrep -i ["^STAT +VSZ +RSS +UID +PPID +%CPU +UCOMM +COMMAND"] >/dev/null
928 then
929         ac_cv_ps_command="$PATH_TO_PS wwaxo 'state vsz rss uid pid ppid pcpu ucomm command'"
930         ac_cv_ps_varlist="[procstat,&procvsz,&procrss,&procuid,&procpid,&procppid,&procpcpu,procprog,&pos]"
931         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
932         ac_cv_ps_cols=8
933         AC_MSG_RESULT([$ac_cv_ps_command])
935 dnl UnixWare 
936 elif ps -Al 2>/dev/null | \
937         egrep -i ["^ *F +S +UID +PID +PPID +CLS +PRI +NI +C +ADDR +SZ +WCHAN +TTY +TIME +COMD"] >/dev/null
938 then
939         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
940         ac_cv_ps_command="$PATH_TO_PS -Al"
941         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
942         ac_cv_ps_cols=8
943         AC_MSG_RESULT([$ac_cv_ps_command])
945 else
946         AC_MSG_WARN([unable to find usable ps syntax - check_procs and check_nagios will not be compiled])
947 fi
949 if test -n "$ac_cv_ps_varlist" ; then
950         AC_DEFINE_UNQUOTED(PS_VARLIST,$ac_cv_ps_varlist,
951                 [Variable list for sscanf of 'ps' output])
952         AC_DEFINE_UNQUOTED(PS_COMMAND,"$ac_cv_ps_command",
953                 [Verbatim command to execute for ps in check_procs])
954         AC_DEFINE_UNQUOTED(PS_FORMAT,"$ac_cv_ps_format",
955                 [Format string for scanning ps output in check_procs])
956         AC_DEFINE_UNQUOTED(PS_COLS,$ac_cv_ps_cols,
957                 [Number of columns in ps command])
958         EXTRAS="$EXTRAS check_procs check_nagios"
959         if echo "$ac_cv_ps_varlist" | grep -q "procetime"; then
960                 AC_DEFINE(PS_USES_PROCETIME,"yes",
961                           [Whether the ps utility uses the "procetime" field])
962         fi
963 fi
965 AC_PATH_PROG(PATH_TO_PING,ping)
966 AC_PATH_PROG(PATH_TO_PING6,ping6)
968 AC_ARG_WITH(ping_command,
969         ACX_HELP_STRING([--with-ping-command=SYNTAX],
970                 [sets syntax for ICMP ping]),
971         with_ping_command=$withval,)
973 AC_MSG_CHECKING(for ICMP ping syntax)
974 ac_cv_ping_packets_first=no
975 ac_cv_ping_has_timeout=no
976 if test -n "$with_ping_command"
977 then
978         AC_MSG_RESULT([(command-line) $with_ping_command])
979         if test -n "$ac_cv_ping_packets_first"
980         then
981                 ac_cv_ping_packets_first=yes
982                 ac_cv_ping_has_timeout=yes
983         fi
985 elif [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
986         $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
987         egrep -i "^round-trip|^rtt" >/dev/null
988 then
989         with_ping_command="$PATH_TO_PING -n -U -c %d %s"
990         ac_cv_ping_packets_first=yes
991         AC_MSG_RESULT([$with_ping_command])
993 elif $PATH_TO_PING -n -U -w 10 -c 1 127.0.0.1 2>/dev/null | \
994         egrep -i "^round-trip|^rtt" >/dev/null
995 then
996         with_ping_command="$PATH_TO_PING -n -U -w %d -c %d %s"
997         ac_cv_ping_packets_first=yes
998   ac_cv_ping_has_timeout=yes
999         AC_MSG_RESULT([$with_ping_command])
1001 elif $PATH_TO_PING -n -U -c 1 127.0.0.1 2>/dev/null | \
1002         egrep -i "^round-trip|^rtt" >/dev/null
1003 then
1004         with_ping_command="$PATH_TO_PING -n -U -c %d %s"
1005         ac_cv_ping_packets_first=yes
1006         AC_MSG_RESULT([$with_ping_command])
1008 elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \
1009         egrep -i "^round-trip|^rtt" >/dev/null
1010 then
1011         with_ping_command="$PATH_TO_PING -n -c %d %s"
1012         ac_cv_ping_packets_first=yes
1013         AC_MSG_RESULT([$with_ping_command])
1015 elif $PATH_TO_PING -n 127.0.0.1 -c 1 2>/dev/null | \
1016         egrep -i "^round-trip|^rtt" >/dev/null
1017 then
1018         with_ping_command="$PATH_TO_PING -n %s -c %d"
1019         AC_MSG_RESULT([$with_ping_command])
1021 elif $PATH_TO_PING 127.0.0.1 -n 1 2>/dev/null | \
1022         egrep -i "^round-trip|^rtt" >/dev/null
1023 then
1024         with_ping_command="$PATH_TO_PING %s -n %d"
1025         AC_MSG_RESULT([$with_ping_command])
1027 elif $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
1028         egrep -i "^round-trip|^rtt" >/dev/null
1029 then
1030         with_ping_command="$PATH_TO_PING -n -s %s 56 %d"
1031         AC_MSG_RESULT([$with_ping_command])
1033 elif $PATH_TO_PING -n -h 127.0.0.1 -s 56 -c 1 2>/dev/null | \
1034         egrep -i "^round-trip|^rtt" >/dev/null
1035 then
1036         with_ping_command="$PATH_TO_PING -n -h %s -s 56 -c %d"
1037         AC_MSG_RESULT([$with_ping_command])
1039 elif $PATH_TO_PING -n -s 56 -c 1 127.0.0.1 2>/dev/null | \
1040         egrep -i "^round-trip|^rtt" >/dev/null
1041 then
1042         with_ping_command="$PATH_TO_PING -n -s 56 -c %d %s"
1043         ac_cv_ping_packets_first=yes
1044         AC_MSG_RESULT([$with_ping_command])
1046 elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \
1047         egrep -i "^round-trip|^rtt" >/dev/null
1048 then
1049         with_ping_command="$PATH_TO_PING -n -c %d %s"
1050         ac_cv_ping_packets_first=yes
1051         AC_MSG_RESULT([$with_ping_command])
1053 else
1054         AC_MSG_WARN([unable to find usable ping syntax])
1055 fi
1057 AC_DEFINE_UNQUOTED(PING_COMMAND,"$with_ping_command",
1058         [path and args for ICMP ping command])
1060 if test "x$ac_cv_ping_packets_first" != "xno"
1061 then
1062         AC_DEFINE(PING_PACKETS_FIRST,1,
1063                 [Define if packet count must precede host])
1064 fi
1066 if test "x$ac_cv_ping_has_timeout" != "xno"
1067 then
1068         AC_DEFINE(PING_HAS_TIMEOUT,1,
1069                 [Define if ping has its own timeout option that should be set])
1070 fi
1072 AC_ARG_WITH(ping6_command,
1073         ACX_HELP_STRING([--with-ping6-command=SYNTAX],
1074                 [sets syntax for ICMPv6 ping]),
1075         with_ping6_command=$withval,)
1077 if test x"$with_ipv6" != xno ; then
1078 AC_MSG_CHECKING(for ICMPv6 ping syntax)
1079 ac_cv_ping6_packets_first=no
1080 if test -n "$with_ping6_command"
1081 then
1082         AC_MSG_RESULT([(command-line) $with_ping6_command])
1083         if test -n "$ac_cv_ping6_packets_first"
1084         then
1085                 ac_cv_ping6_packets_first=yes
1086         fi
1088 elif test "x$PATH_TO_PING6" != "x"; then
1089         if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
1090                 $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \
1091                 egrep -i "^round-trip|^rtt" >/dev/null
1092         then
1093                 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s"
1094                 ac_cv_ping6_packets_first=yes
1095                 AC_MSG_RESULT([$with_ping6_command])
1097         elif $PATH_TO_PING6 -n -U -w 10 -c 1 ::1 2>/dev/null | \
1098                 egrep -i "^round-trip|^rtt" >/dev/null
1099         then
1100                 with_ping6_command="$PATH_TO_PING6 -n -U -w %d -c %d %s"
1101                 ac_cv_ping6_packets_first=yes
1102                 ac_cv_ping_has_timeout=yes
1103                 AC_MSG_RESULT([$with_ping6_command])
1105         elif $PATH_TO_PING6 -n -U -c 1 ::1 2>/dev/null | \
1106                 egrep -i "^round-trip|^rtt" >/dev/null
1107         then
1108                 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s"
1109                 ac_cv_ping6_packets_first=yes
1110                 AC_MSG_RESULT([$with_ping6_command])
1112         elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \
1113                 egrep -i "^round-trip|^rtt" >/dev/null
1114         then
1115                 with_ping6_command="$PATH_TO_PING6 -n -c %d %s"
1116                 ac_cv_ping6_packets_first=yes
1117                 AC_MSG_RESULT([$with_ping6_command])
1119         elif $PATH_TO_PING6 -n ::1 -c 1 2>/dev/null | \
1120                 egrep -i "^round-trip|^rtt" >/dev/null
1121         then
1122                 with_ping6_command="$PATH_TO_PING6 -n %s -c %d"
1123                 AC_MSG_RESULT([$with_ping6_command])
1125         elif $PATH_TO_PING6 ::1 -n 1 2>/dev/null | \
1126                 egrep -i "^round-trip|^rtt" >/dev/null
1127         then
1128                 with_ping6_command="$PATH_TO_PING6 %s -n %d"
1129                 AC_MSG_RESULT([$with_ping6_command])
1131         elif $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \
1132                 egrep -i "^round-trip|^rtt" >/dev/null
1133         then
1134                 with_ping6_command="$PATH_TO_PING6 -n -s %s 56 %d"
1135                 AC_MSG_RESULT([$with_ping6_command])
1137         elif $PATH_TO_PING6 -n -h ::1 -s 56 -c 1 2>/dev/null | \
1138                 egrep -i "^round-trip|^rtt" >/dev/null
1139         then
1140                 with_ping6_command="$PATH_TO_PING6 -n -h %s -s 56 -c %d"
1141                 AC_MSG_RESULT([$with_ping6_command])
1143         elif $PATH_TO_PING6 -n -s 56 -c 1 ::1 2>/dev/null | \
1144                 egrep -i "^round-trip|^rtt" >/dev/null
1145         then
1146                 with_ping6_command="$PATH_TO_PING6 -n -s 56 -c %d %s"
1147                 ac_cv_ping6_packets_first=yes
1148                 AC_MSG_RESULT([$with_ping_command])
1150         elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \
1151                 egrep -i "^round-trip|^rtt" >/dev/null
1152         then
1153                 with_ping6_command="$PATH_TO_PING6 -n -c %d %s"
1154                 ac_cv_ping6_packets_first=yes
1155                 AC_MSG_RESULT([$with_ping6_command])
1157         fi
1159 elif test "x$PATH_TO_PING" != "x"; then
1160         if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
1161                 $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \
1162                 egrep -i "^round-trip|^rtt" >/dev/null
1163         then
1164                 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s"
1165                 ac_cv_ping6_packets_first=yes
1166                 AC_MSG_RESULT([$with_ping6_command])
1168         elif $PATH_TO_PING -A inet6 -n -U -c 1 ::1 2>/dev/null | \
1169                 egrep -i "^round-trip|^rtt" >/dev/null
1170         then
1171                 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s"
1172                 ac_cv_ping6_packets_first=yes
1173                 AC_MSG_RESULT([$with_ping6_command])
1175         elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \
1176                 egrep -i "^round-trip|^rtt" >/dev/null
1177         then
1178                 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s"
1179                 ac_cv_ping6_packets_first=yes
1180                 AC_MSG_RESULT([$with_ping6_command])
1182         elif $PATH_TO_PING -A inet6 -n ::1 -c 1 2>/dev/null | \
1183                 egrep -i "^round-trip|^rtt" >/dev/null
1184         then
1185                 with_ping6_command="$PATH_TO_PING -A inet6 -n %s -c %d"
1186                 AC_MSG_RESULT([$with_ping6_command])
1188         elif $PATH_TO_PING -A inet6 ::1 -n 1 2>/dev/null | \
1189                 egrep -i "^round-trip|^rtt" >/dev/null
1190         then
1191                 with_ping6_command="$PATH_TO_PING -A inet6 %s -n %d"
1192                 AC_MSG_RESULT([$with_ping6_command])
1194         elif $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \
1195                 egrep -i "^round-trip|^rtt" >/dev/null
1196         then
1197                 with_ping6_command="$PATH_TO_PING -A inet6 -n -s %s 56 %d"
1198                 AC_MSG_RESULT([$with_ping6_command])
1200         elif $PATH_TO_PING -A inet6 -n -h ::1 -s 56 -c 1 2>/dev/null | \
1201                 egrep -i "^round-trip|^rtt" >/dev/null
1202         then
1203                 with_ping6_command="$PATH_TO_PING -A inet6 -n -h %s -s 56 -c %d"
1204                 AC_MSG_RESULT([$with_ping6_command])
1206         elif $PATH_TO_PING -A inet6 -n -s 56 -c 1 ::1 2>/dev/null | \
1207                 egrep -i "^round-trip|^rtt" >/dev/null
1208         then
1209                 with_ping6_command="$PATH_TO_PING -A inet6 -n -s 56 -c %d %s"
1210                 ac_cv_ping6_packets_first=yes
1211                 AC_MSG_RESULT([$with_ping_command])
1213         elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \
1214                 egrep -i "^round-trip|^rtt" >/dev/null
1215         then
1216                 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s"
1217                 ac_cv_ping6_packets_first=yes
1218                 AC_MSG_RESULT([$with_ping6_command])
1220         fi
1222 fi
1224 if test "x$with_ping6_command" != "x"; then
1225         AC_DEFINE_UNQUOTED(PING6_COMMAND,"$with_ping6_command",
1226                 [path and args for ICMPv6 ping command])
1227 else
1228         AC_MSG_RESULT([none])
1229 fi
1231 if test "x$ac_cv_ping6_packets_first" != "xno"; then
1232         AC_DEFINE(PING6_PACKETS_FIRST,1,
1233                 [Define if packet count must precede host])
1234 fi
1235 fi
1238 AC_MSG_CHECKING(for nslookup syntax)
1239 AC_ARG_WITH(nslookup_command,
1240             ACX_HELP_STRING([--with-nslookup-command=PATH],
1241                             [sets path to nslookup executable]),
1242             ac_cv_nslookup_command=$withval)
1243 if test -n "$ac_cv_nslookup_command"; then
1244         AC_MSG_RESULT([(command line) $ac_cv_nslookup_command])
1245 else
1246         AC_PATH_PROG(PATH_TO_NSLOOKUP,nslookup)
1247         if test -n "$PATH_TO_NSLOOKUP"
1248         then
1249                 if $PATH_TO_NSLOOKUP -sil 127.0.0.1 2>&1 | grep ["Invalid option: sil"] >/dev/null
1250                 then
1251                         ac_cv_nslookup_command="$PATH_TO_NSLOOKUP"
1252                         AC_MSG_RESULT([$ac_cv_nslookup_command])
1254                 else
1255                         ac_cv_nslookup_command="$PATH_TO_NSLOOKUP -sil"
1256                         AC_MSG_RESULT([$ac_cv_nslookup_command])
1258                 fi
1259         else
1260                 AC_MSG_WARN([nslookup command not found])
1261         fi
1262 fi
1264 if test -n "$ac_cv_nslookup_command"; then
1265         EXTRAS="$EXTRAS check_dns"
1266         AC_DEFINE_UNQUOTED(NSLOOKUP_COMMAND,"$ac_cv_nslookup_command", [path and args for nslookup])
1267 fi
1269 AC_PATH_PROG(PATH_TO_HOST,host)
1270 if test -n "$ac_cv_path_PATH_TO_HOST"
1271 then
1272         EXTRAS="$EXTRAS check_dns"
1273 fi
1275 AC_PATH_PROG(PATH_TO_UPTIME,uptime)
1276 AC_ARG_WITH(uptime_command,
1277             ACX_HELP_STRING([--with-uptime-command=PATH],
1278                             [sets path to uptime]), PATH_TO_UPTIME=$withval)
1279 AC_DEFINE_UNQUOTED(PATH_TO_UPTIME,"$PATH_TO_UPTIME",[path to uptime binary])
1281 AC_PATH_PROG(PATH_TO_RPCINFO,rpcinfo)
1282 AC_ARG_WITH(rpcinfo_command,
1283             ACX_HELP_STRING([--with-rpcinfo-command=PATH],
1284                             [sets path to rpcinfo]), PATH_TO_RPCINFO=$withval)
1285 AC_DEFINE_UNQUOTED(PATH_TO_RPCINFO,"$PATH_TO_RPCINFO",[path to rpcinfo binary])
1287 AC_PATH_PROG(PATH_TO_NTPDATE,ntpdate)
1288 AC_ARG_WITH(ntpdate_command,
1289             ACX_HELP_STRING([--with-ntpdate-command=PATH],
1290                             [sets path to ntpdate]), PATH_TO_NTPDATE=$withval)
1291 AC_PATH_PROGS(PATH_TO_NTPDC,ntpdc xntpdc)
1292 AC_PATH_PROGS(PATH_TO_NTPQ,ntpq)
1293 if (test -n "$PATH_TO_NTPDATE" || test -n "$PATH_TO_NTPQ")
1294 then
1295         AC_DEFINE_UNQUOTED(PATH_TO_NTPQ,"$PATH_TO_NTPQ",[path to ntpq binary])
1296         AC_DEFINE_UNQUOTED(PATH_TO_NTPDATE,"$PATH_TO_NTPDATE",[path to ntpdate binary])
1297 else
1298         AC_MSG_WARN([Install NTP programs (http://www.ntp.org) if you want to monitor time synchronization])
1299 fi
1301 AC_PATH_PROG(PATH_TO_LMSTAT,lmstat)
1302 if test -x "$PATH_TO_LMSTAT"
1303 then
1304         AC_DEFINE_UNQUOTED(PATH_TO_LMSTAT,"$PATH_TO_LMSTAT",[path to lmstat])
1305 else
1306         AC_MSG_WARN([Get lmstat from Globetrotter Software to monitor flexlm licenses])
1307 fi
1309 AC_PATH_PROG(PATH_TO_SMBCLIENT,smbclient)
1310 AC_ARG_WITH(smbclient_command,
1311             ACX_HELP_STRING([--with-smbclient-command=PATH],
1312                             [sets path to smbclient]), 
1313             PATH_TO_SMBCLIENT=$withval)
1314 if test -n "$PATH_TO_SMBCLIENT"
1315 then
1316         AC_DEFINE_UNQUOTED(PATH_TO_SMBCLIENT,"$PATH_TO_SMBCLIENT",[path to smbclient binary])
1317 else
1318         AC_MSG_WARN([Get smbclient from Samba.org to monitor SMB shares])
1319 fi
1322 AC_PATH_PROG(PATH_TO_WHO,who)
1324 if [$PATH_TO_WHO -q 2>/dev/null | egrep -i "^# users=[0-9]+$" >/dev/null]
1325 then
1326         ac_cv_path_to_who="$PATH_TO_WHO -q"
1327 else
1328         ac_cv_path_to_who="$PATH_TO_WHO"
1329 fi
1331 AC_DEFINE_UNQUOTED(WHO_COMMAND,"$ac_cv_path_to_who",
1332         [path and arguments for invoking 'who'])
1334 AC_PATH_PROG(PATH_TO_SNMPGET,snmpget)
1335 AC_ARG_WITH(snmpget_command,
1336             ACX_HELP_STRING([--with-snmpget-command=PATH],
1337                             [Path to snmpget command]),
1338             PATH_TO_SNMPGET=$withval)
1339 if test -n "$PATH_TO_SNMPGET"
1340 then
1341         AC_DEFINE_UNQUOTED(PATH_TO_SNMPGET,"$PATH_TO_SNMPGET",[path to snmpget binary])
1342         EXTRAS="$EXTRAS check_hpjd check_snmp"
1343 else
1344         AC_MSG_WARN([Get snmpget from http://net-snmp.sourceforge.net to make check_hpjd and check_snmp plugins])
1345 fi
1347 AC_PATH_PROG(PATH_TO_SNMPGETNEXT,snmpgetnext)
1348 AC_ARG_WITH(snmpgetnext_command,
1349             ACX_HELP_STRING([--with-snmpgetnext-command=PATH],
1350                             [Path to snmpgetnext command]),
1351             PATH_TO_SNMPGETNEXT=$withval)
1352 if test -n "$PATH_TO_SNMPGETNEXT"
1353 then
1354         AC_DEFINE_UNQUOTED(PATH_TO_SNMPGETNEXT,"$PATH_TO_SNMPGETNEXT",[path to snmpgetnext binary])
1355 fi
1357 if ( $PERL -M"Net::SNMP 3.6" -e 'exit' 2>/dev/null  )
1358 then
1359         AC_MSG_CHECKING(for Net::SNMP perl module)
1360         AC_MSG_RESULT([found])
1361 else
1362         AC_MSG_WARN([Tried $PERL - install Net::SNMP perl module if you want to use the perl snmp plugins])
1363 fi
1365 AC_PATH_PROG(PATH_TO_QUAKESTAT,quakestat)
1366 AC_PATH_PROG(PATH_TO_QSTAT,qstat)
1367 AC_ARG_WITH(qstat_command,
1368             ACX_HELP_STRING([--with-qstat-command=PATH], 
1369                             [Path to qstat command]), PATH_TO_QSTAT=$withval)
1371 if test -x "$PATH_TO_QUAKESTAT"
1372 then
1373         ac_cv_path_to_qstat="$PATH_TO_QUAKESTAT"
1374         EXTRAS="$EXTRAS check_game"
1376 elif test -n "$PATH_TO_QSTAT"
1377 then
1378         ac_cv_path_to_qstat="$PATH_TO_QSTAT"
1379         EXTRAS="$EXTRAS check_game"
1380 else
1381         AC_MSG_WARN([Get qstat from http://www.activesw.com/people/steve/qstat.html in order to make check_game plugin])
1382 fi
1384 if test $ac_cv_path_to_qstat 
1385 then
1386         AC_DEFINE_UNQUOTED(PATH_TO_QSTAT,"$ac_cv_path_to_qstat",
1387                 [path to qstat/quakestat])
1388 fi
1390 AC_PATH_PROG(PATH_TO_FPING,fping)
1391 AC_ARG_WITH(fping_command,
1392             ACX_HELP_STRING([--with-fping-command=PATH],
1393                             [Path to fping command]), PATH_TO_FPING=$withval)
1394 if test -n "$PATH_TO_FPING"
1395 then
1396         AC_DEFINE_UNQUOTED(PATH_TO_FPING,"$PATH_TO_FPING",[path to fping])
1397         EXTRAS="$EXTRAS check_fping"
1398 else
1399         AC_MSG_WARN([Get fping from http://www.fping.com in order to make check_fping plugin])
1400 fi
1402 AC_PATH_PROG(PATH_TO_SSH,ssh)
1403 AC_ARG_WITH(ssh_command,
1404             ACX_HELP_STRING([--with-ssh-command=PATH],
1405                             [sets path for ssh]), PATH_TO_SSH=$withval)
1406 if test -n "$PATH_TO_SSH"
1407 then
1408         AC_DEFINE_UNQUOTED(SSH_COMMAND,"$PATH_TO_SSH",[path to ssh binary])
1409         EXTRAS="$EXTRAS check_by_ssh"
1410 else
1411         AC_MSG_WARN([Get ssh in order to make check_by_ssh plugin])
1412 fi
1415 AC_PATH_PROG(PATH_TO_MAILQ,mailq)
1416 AC_ARG_WITH(mailq_command,
1417             ACX_HELP_STRING([--with-mailq-command=PATH],
1418                             [sets path to mailq]), PATH_TO_MAILQ=$withval)
1419 if test -n "$PATH_TO_MAILQ"
1420 then
1421         AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_MAILQ",[path to mailq])
1422 else
1423         AC_MSG_WARN([Could not find mailq or eqivalent])
1424 fi
1426 AC_PATH_PROG(PATH_TO_QMAIL_QSTAT,qmail-qstat)
1427 if test -x "$PATH_TO_QMAIL_QSTAT"
1428 then
1429         AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_QMAIL_QSTAT",[path to qmail-qstat])
1430 else
1431         AC_MSG_WARN([Could not find qmail-qstat or eqivalent])
1432 fi
1434 dnl SWAP info required is amount allocated/available and amount free
1435 dnl The plugin works through all the swap devices and adds up the total swap
1436 dnl available.
1437 AC_PATH_PROG(PATH_TO_SWAP,swap)
1438 if (test -n "$PATH_TO_SWAP")
1439 then
1440 AC_MSG_CHECKING([for $PATH_TO_SWAP format])
1441 if [$PATH_TO_SWAP -l 2>&1 >/dev/null]
1442 then
1443         ac_cv_have_swap=yes
1444         ac_cv_swap_command="$PATH_TO_SWAP -l"
1445         if [$PATH_TO_SWAP -l 2>/dev/null | \
1446                 egrep -i "^lswap +path +pri +swaplo +blocks +free +maxswap" \
1447                 >/dev/null]
1448         then
1449                 ac_cv_swap_format=[" %*d %*s %*d,%*d %*d %*d %f %f"]
1450                 ac_cv_swap_conv=2048
1451                 AC_MSG_RESULT([using IRIX format swap])
1453         elif [$PATH_TO_SWAP -l 2>/dev/null | egrep -i "^path +dev +swaplo +blocks +free" >/dev/null]
1454         then
1455                 ac_cv_swap_format=["%*s %*[0-9,-] %*d %f %f"]
1456                 ac_cv_swap_conv=2048
1457                 AC_MSG_RESULT([using Unixware format swap])
1458         else
1459                 dnl if we don't know what format swap's output is
1460                 dnl we might as well pretend we didn't see it
1461                 ac_cv_have_swap=""
1462                 ac_cv_swap_command=""
1463         fi
1464 fi
1465 dnl end if for PATH_TO_SWAP
1466 fi
1468 AC_PATH_PROG(PATH_TO_SWAPINFO,swapinfo)
1469 if (test -n "$PATH_TO_SWAPINFO")
1470 then
1471 AC_MSG_CHECKING([for $PATH_TO_SWAPINFO format])
1472 if [$PATH_TO_SWAPINFO -k 2>&1 | egrep -i "^Device" >/dev/null]
1473 then
1474         ac_cv_have_swap=yes
1475         ac_cv_swap_command="$PATH_TO_SWAPINFO -k"
1477         if [$PATH_TO_SWAPINFO -k 2>/dev/null | egrep -i "^Device +1K-blocks +Used +Avail" >/dev/null]
1478         then
1479                 ac_cv_swap_format=["%*s %f %*d %f"]
1480                 ac_cv_swap_conv=1024
1481                 AC_MSG_RESULT([using FreeBSD format swapinfo])
1482         fi
1484 elif [$PATH_TO_SWAPINFO -dfM 2>/dev/null | egrep -i "^TYPE +AVAIL +USED +FREE" >/dev/null]
1485 then
1486         ac_cv_have_swap=yes
1487         ac_cv_swap_command="$PATH_TO_SWAPINFO -dfM",
1488         ac_cv_swap_format=["%*s %f %*d %f"]
1489         ac_cv_swap_conv=1024
1490         AC_MSG_RESULT([using HP-UX format swapinfo])
1491 fi
1492 dnl end if for PATH_TO_SWAPINFO
1493 fi
1495 AC_PATH_PROG(PATH_TO_LSPS,lsps)
1496 if (test -n "$PATH_TO_LSPS")
1497 then
1498 AC_MSG_CHECKING([for $PATH_TO_LSPS format])
1499 if [$PATH_TO_LSPS -a 2>/dev/null | egrep -i "^Page Space" > /dev/null]
1500 then
1501         ac_cv_have_swap=yes
1502         ac_cv_swap_command="$PATH_TO_LSPS -a"
1503         ac_cv_swap_format=["%*s %*s %*s %f%*s %f %*s"]
1504         ac_cv_swap_conv=1
1505         AC_MSG_RESULT([using AIX lsps])
1506 fi
1507 dnl end if for PATH_TO_SWAPINFO
1508 fi
1510 dnl
1511 dnl test for swapctl system call, both the 2-arg and 3-arg variants
1512 dnl fwict, the 2-arg is an SVR4 standard, whereas the 3-arg is shared
1513 dnl in the various BSD's
1514 dnl
1516 AC_CHECK_HEADERS([sys/stat.h sys/param.h])
1517 AC_CHECK_HEADERS([sys/swap.h], [], [], [
1518 #ifdef HAVE_SYS_PARAM_H
1519 #include <sys/param.h>
1520 #endif
1521 ])
1522 AC_CHECK_DECLS([swapctl],,,[
1523                #include <unistd.h>
1524                #include <sys/types.h>
1525                #include <sys/param.h>
1526                #include <sys/stat.h>
1527                #include <sys/swap.h>
1528                ])
1529 AC_CHECK_TYPES([swaptbl_t, swapent_t],,,[
1530                #include <sys/types.h>
1531                #include <sys/param.h>
1532                #include <sys/stat.h>
1533                #include <sys/swap.h>
1534                ])
1535 AC_CHECK_MEMBERS([struct swapent.se_nblks],,,[
1536                #include <unistd.h>
1537                #include <sys/types.h>
1538                #include <sys/param.h>
1539                #include <sys/stat.h>
1540                #include <sys/swap.h>
1541                ])
1543 if test "$ac_cv_have_decl_swapctl" = "yes"; 
1544 then
1545         EXTRAS="$EXTRAS check_swap"
1546         AC_MSG_CHECKING([for 2-arg (SVR4) swapctl])
1547         if test "$ac_cv_type_swaptbl_t" = "yes" -a \
1548                 "$ac_cv_type_swapent_t" = "yes"; 
1549         then
1550                 AC_MSG_RESULT([yes])
1551                 ac_cv_check_swap_swapctl_svr4="1";
1552                 AC_DEFINE([CHECK_SWAP_SWAPCTL_SVR4],1,
1553                           [Define if 2-argument SVR4 swapctl exists])
1554         else
1555                 AC_MSG_RESULT([no])
1556                 AC_MSG_CHECKING([for 3-arg (*BSD) swapctl])
1557                 if test "$ac_cv_member_struct_swapent_se_nblks" = "yes"; 
1558                 then
1559                         AC_MSG_RESULT([yes])
1560                         AC_DEFINE([CHECK_SWAP_SWAPCTL_BSD],1,
1561                                   [Define if 3-argument BSD swapctl exists])
1562                 else
1563                         AC_MSG_RESULT([no])
1564                 fi
1565         fi
1566         AC_MSG_CHECKING([for whether swapctl uses blocks or pages])
1567         if test "$ac_cv_check_swap_swapctl_svr4" = "1";
1568         then
1569                 dnl
1570                 dnl the SVR4 spec returns values in pages
1571                 dnl
1572                 AC_MSG_RESULT([page])
1573                 AC_CHECK_DECLS([sysconf])
1574                 AC_MSG_CHECKING([for system page size])
1575                 if test "$ac_cv_have_decl_sysconf" = "yes";
1576                 then
1577                         AC_MSG_RESULT([determined by sysconf(3)])
1578                         ac_cv_swap_conv="(1048576/sysconf(_SC_PAGESIZE))"
1579                 else
1580                         AC_MSG_WARN([don't know. guessing 4096k])
1581                         ac_cv_swap_conv=256
1582                 fi
1583         else
1584                 dnl
1585                 dnl the BSD spec returns values in blocks
1586                 dnl
1587                 AC_MSG_RESULT([blocks (assuming 512b)])
1588                 ac_cv_swap_conv=2048
1589         fi
1590         AC_DEFINE_UNQUOTED(SWAP_CONVERSION,$ac_cv_swap_conv,
1591                 [Conversion factor to MB])
1592 fi
1593 dnl
1594 dnl end tests for the swapctl system calls
1595 dnl
1598 if test "x$ac_cv_have_swap" != "x" 
1599 then
1600         AC_DEFINE(HAVE_SWAP,1,[Define if swap/swapinfo command is found])
1601         EXTRAS="$EXTRAS check_swap"
1602 fi
1603 if test "x$ac_cv_swap_command" != "x" 
1604 then
1605         AC_DEFINE_UNQUOTED(SWAP_COMMAND,"$ac_cv_swap_command",
1606                 [Path to swap/swapinfo binary, with any args])
1607         AC_DEFINE_UNQUOTED(SWAP_FORMAT,"$ac_cv_swap_format",
1608                 [Format string for parsing swap output])
1609         AC_DEFINE_UNQUOTED(SWAP_CONVERSION,$ac_cv_swap_conv,
1610                 [Conversion factor to MB])
1611 fi
1613 AC_ARG_WITH(proc-meminfo,
1614             ACX_HELP_STRING([--with-proc-meminfo=PATH],
1615                             [path to /proc/meminfo or equivalent]),
1616                             ac_cv_proc_meminfo=$withval)
1617 dnl dunno why this does not work below - use hack (kbd)
1618 dnl fine on linux, broken on solaris
1619 dnl if /bin/test -e "/proc/meminfo"
1620 AC_MSG_CHECKING([for /proc/meminfo])
1621 if test -n "$ac_cv_proc_meminfo"; then
1622         AC_MSG_RESULT([(command line) $ac_cv_proc_meminfo])
1623 elif [cat /proc/meminfo > /dev/null 2>&1]; then
1624         AC_MSG_RESULT([found /proc/meminfo])
1625         ac_cv_proc_meminfo="/proc/meminfo"
1626 else
1627         AC_MSG_RESULT([no])
1628 fi
1630 if test -n "$ac_cv_proc_meminfo"; then
1631         AC_DEFINE(HAVE_PROC_MEMINFO,1,[Define if we have /proc/meminfo])
1632         AC_DEFINE_UNQUOTED(PROC_MEMINFO,"$ac_cv_proc_meminfo",[path to /proc/meminfo if name changes])
1633         EXTRAS="$EXTRAS check_swap"
1634 fi
1636 AC_PATH_PROG(PATH_TO_DIG,dig)
1637 AC_ARG_WITH(dig_command,
1638             ACX_HELP_STRING([--with-dig-command=PATH],
1639                             [Path to dig command]), PATH_TO_DIG=$withval)
1640 if test -n "$PATH_TO_DIG"; then
1641         EXTRAS="$EXTRAS check_dig"
1642         AC_DEFINE_UNQUOTED(PATH_TO_DIG,"$PATH_TO_DIG",[Path to dig command, if present])
1643 fi
1645 if test -f plugins/check_nt.c ; then
1646   EXTRAS="$EXTRAS check_nt"
1647 elif test -f ../plugins/check_nt.c ; then
1648   EXTRAS="$EXTRAS check_nt"
1649 fi
1651 AC_MSG_CHECKING(for va_list)
1652 AC_TRY_COMPILE([#ifdef __STDC__
1653                 #include <stdio.h>
1654                 #include <stdlib.h>
1655                 #include <stdarg.h>
1656                 #else
1657                 #include <sys/types.h>
1658                 #include <stdio.h>
1659                 #include <varargs.h>
1660                 #endif],
1661                 [va_list args;],
1662                 [AC_MSG_RESULT(yes)],
1663                 [NEED_VA_LIST=-DNEED_VA_LIST AC_SUBST(NEED_VA_LIST) AC_MSG_RESULT(no)])
1665 case $host in
1666         *bsd*)
1667                 AC_DEFINE(__bsd__,1,[bsd specific code in check_dhcp.c])
1668         ;;
1669         *linux*)
1670                 AC_DEFINE(__linux__,1,[sun specific code in check_dhcp.c])
1671         ;;
1672         *sun* | solaris*)
1673                 AC_DEFINE(__sun__,1,[sun specific code in check_dhcp.c])
1674         ;;
1675         *hpux*)  
1676                 AC_DEFINE(__hpux__,1,[hpux specific code in check_dhcp.c])
1677         ;;
1678 esac
1680 AC_SUBST(EXTRAS)
1681 AC_SUBST(EXTRA_NETOBJS)
1682 AC_SUBST(DEPLIBS)
1684 AM_GNU_GETTEXT([no-libtool], [need-ngettext])
1685 AM_GNU_GETTEXT_VERSION(0.11.5)
1687 dnl Check for Redhat spopen problem
1688 dnl Wierd problem where ECHILD is returned from a wait call in error
1689 dnl Only appears to affect nslookup and dig calls. Only affects redhat around
1690 dnl 2.6.9-11 (okay in 2.6.9-5). Redhat investigating root cause
1691 dnl We patch plugins/popen.c
1692 dnl Need to add smp because uname different on those
1693 dnl Can force patch to be applied with --enable-redhat-pthread-workaround
1694 AC_ARG_ENABLE(redhat-pthread-workaround, 
1695         AC_HELP_STRING([--enable-redhat-pthread-workaround], 
1696                 [force Redhat patch to be applied (default: test system)]),
1697         [ac_cv_enable_redhat_pthread_workaround=$enableval],
1698         [ac_cv_enable_redhat_pthread_workaround=test])
1699 if test "$ac_cv_enable_redhat_pthread_workaround" = "test" ; then
1700         if echo $ac_cv_uname_r | egrep "\.EL(smp)?$" >/dev/null 2>&1 ; then
1701                 AC_MSG_CHECKING(for redhat spopen problem)
1702                 ( cd config_test && make && make test ) > /dev/null 2>&1
1703                 if test $? -eq 0 ; then
1704                         AC_MSG_RESULT(okay)
1705                 else
1706                         AC_MSG_RESULT(error)
1707                         AC_DEFINE(REDHAT_SPOPEN_ERROR, 1, [Workaround on redhat in spopen])
1708                 fi
1709         fi
1710 elif test "$ac_cv_enable_redhat_pthread_workaround" = "yes" ; then
1711         AC_DEFINE(REDHAT_SPOPEN_ERROR, 1, [Forced workaround on redhat in spopen])
1712 fi
1714 dnl External libraries - see ACKNOWLEDGEMENTS
1715 np_COREUTILS
1716 np_CURL
1718 AC_OUTPUT(
1719   Makefile 
1720   lib/Makefile 
1721   m4/Makefile 
1722   plugins/Makefile 
1723   plugins/tests/Makefile
1724   plugins-root/Makefile
1725   plugins-scripts/Makefile 
1726   plugins-scripts/subst 
1727   plugins-scripts/utils.pm 
1728   plugins-scripts/utils.sh 
1729   command.cfg 
1730   test.pl 
1731   pkg/solaris/pkginfo 
1732   intl/Makefile
1733   po/Makefile.in 
1737 dnl the ones below that are commented out need to be cleaned up 
1738 dnl in the configure code above to use with_foo instead of ac_cv_foo
1739 dnl if we want them to show up here.  it'd also make the code cleaner.
1740 dnl i'll get to that on another rainy day :) -sf
1741 dnl ACX_FEATURE([with],[dig-command])
1742 dnl ACX_FEATURE([with],[fping-command])
1743 dnl ACX_FEATURE([with],[mailq-command])
1744 dnl ACX_FEATURE([with],[nslookup-command])
1745 dnl ACX_FEATURE([with],[ntpdate-command])
1746 ACX_FEATURE([with],[ping6-command])
1747 ACX_FEATURE([with],[ping-command])
1748 dnl ACX_FEATURE([with],[qstat-command])
1749 dnl ACX_FEATURE([with],[rpcinfo-command])
1750 dnl ACX_FEATURE([with],[smbclient-command])
1751 dnl ACX_FEATURE([with],[snmpget-command])
1752 dnl ACX_FEATURE([with],[snmpgetnext-command])
1753 dnl ACX_FEATURE([with],[ssh-command])
1754 dnl ACX_FEATURE([with],[uptime-command])
1756 dnl ACX_FEATURE([with],[proc-loadavg])
1757 dnl ACX_FEATURE([with],[proc-meminfo])
1758 dnl ACX_FEATURE([with],[ps-command])
1759 dnl ACX_FEATURE([with],[ps-format])
1760 dnl ACX_FEATURE([with],[ps-cols])
1761 dnl ACX_FEATURE([with],[ps-varlist])
1763 ACX_FEATURE([with],[lwres])
1764 ACX_FEATURE([with],[ipv6])
1765 ACX_FEATURE([with],[openssl])
1766 ACX_FEATURE([with],[gnutls])
1767 ACX_FEATURE([enable],[emulate-getaddrinfo])
1768 ACX_FEATURE([with],[perl])
1769 ACX_FEATURE([with],[cgiurl])
1770 ACX_FEATURE([with],[nagios-user])
1771 ACX_FEATURE([with],[nagios-group])
1772 ACX_FEATURE([with],[trusted-path])