+2007-07-05, Version 4.0.5
+ * Portability: More fixes for OpenBSD have been included.
+
2007-06-24, Version 4.0.4
* cpu plugin: Fixed the Solaris code.
* dns plugin: Fixed a build issue for OpenBSD.
dnl Process this file with autoconf to produce a configure script.
-AC_INIT(collectd, 4.0.4)
+AC_INIT(collectd, 4.0.5)
AC_CONFIG_SRCDIR(src/collectd.c)
AC_CONFIG_HEADERS(src/config.h)
AM_INIT_AUTOMAKE(dist-bzip2)
])
# For cpu modules
-AC_CHECK_HEADERS(sys/sysctl.h sys/dkstat.h mach/mach_init.h mach/host_priv.h mach/mach_error.h mach/mach_host.h mach/mach_port.h mach/mach_types.h mach/message.h mach/processor_set.h mach/processor.h mach/processor_info.h mach/task.h mach/thread_act.h mach/vm_region.h mach/vm_map.h mach/vm_prot.h mach/vm_statistics.h mach/kern_return.h)
+AC_CHECK_HEADERS(sys/dkstat.h mach/mach_init.h mach/host_priv.h mach/mach_error.h mach/mach_host.h mach/mach_port.h mach/mach_types.h mach/message.h mach/processor_set.h mach/processor.h mach/processor_info.h mach/task.h mach/thread_act.h mach/vm_region.h mach/vm_map.h mach/vm_prot.h mach/vm_statistics.h mach/kern_return.h)
+AC_CHECK_HEADERS(sys/sysctl.h, [], [],
+[
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#if HAVE_SYS_PARAM_H
+# include <sys/param.h>
+#endif
+])
# For hddtemp module
AC_CHECK_HEADERS(linux/major.h libgen.h)
#endif
])
+# For the swap module
+AC_CHECK_HEADERS(sys/swap.h, [], [],
+[
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#if HAVE_SYS_PARAM_H
+# include <sys/param.h>
+#endif
+])
+
# For load module
# For the processes plugin
-# For the swap module
# For users module
-AC_CHECK_HEADERS(sys/loadavg.h linux/config.h sys/swap.h utmp.h utmpx.h)
+AC_CHECK_HEADERS(sys/loadavg.h linux/config.h utmp.h utmpx.h)
# For interface plugin
AC_CHECK_HEADERS(ifaddrs.h)
#endif
])
-# For apache plugin
+# For quota module
+AC_CHECK_HEADERS(sys/ucred.h, [], [],
+[
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#if HAVE_SYS_PARAM_H
+# include <sys/param.h>
+#endif
+])
+
# For mount interface
+AC_CHECK_HEADERS(sys/mount.h, [], [],
+[
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#if HAVE_SYS_PARAM_H
+# include <sys/param.h>
+#endif
+])
+
+# For the email plugin
+AC_CHECK_HEADERS(linux/un.h, [], [],
+[
+#if HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#endif
+])
+
+AC_CHECK_HEADERS(curl/curl.h pwd.h grp.h sys/un.h ctype.h limits.h sys/quota.h xfs/xqm.h fs_info.h fshelp.h paths.h mntent.h mnttab.h sys/fstyp.h sys/fs_types.h sys/mntent.h sys/mnttab.h sys/statfs.h sys/statvfs.h sys/vfs.h sys/vfstab.h kvm.h)
+
# For the dns plugin
-AC_CHECK_HEADERS(curl/curl.h pwd.h grp.h sys/un.h sys/ucred.h ctype.h limits.h sys/quota.h xfs/xqm.h fs_info.h fshelp.h paths.h mntent.h mnttab.h sys/fstyp.h sys/fs_types.h sys/mntent.h sys/mnttab.h sys/mount.h sys/statfs.h sys/statvfs.h sys/vfs.h sys/vfstab.h kvm.h arpa/nameser.h arpa/nameser_compat.h)
+AC_CHECK_HEADERS(arpa/nameser.h)
+AC_CHECK_HEADERS(arpa/nameser_compat.h, [], [],
+[
+#if HAVE_ARPA_NAMESER_H
+# include <arpa/nameser.h>
+#endif
+])
AC_CHECK_HEADERS(net/if_arp.h, [], [],
[#if HAVE_SYS_SOCKET_H
AC_PROG_GCC_TRADITIONAL
AC_CHECK_FUNCS(gettimeofday select strdup strtol getaddrinfo getnameinfo strchr memcpy strstr strcmp strncmp strncpy strlen strncasecmp strcasecmp openlog closelog)
+AC_CHECK_FUNCS(getpwnam_r)
+AC_CHECK_FUNCS(getgrnam_r)
+
socket_needs_socket="no"
AC_CHECK_FUNCS(socket, [], AC_CHECK_LIB(socket, socket, [socket_needs_socket="yes"], AC_MSG_ERROR(cannot find socket)))
AM_CONDITIONAL(BUILD_WITH_LIBSOCKET, test "x$socket_needs_socket" = "xyes")
Exporter::export_ok_tags('all');
-bootstrap Collectd "4.0.4";
+bootstrap Collectd "4.0.5";
1;
=head1 DESCRIPTION
This small program is the glue between collectd and nagios. collectd collects
-various performance statistics which is provides via the C<unixsock plugin>,
+various performance statistics which it provides via the C<unixsock plugin>,
see L<collectd-unixsock(5)>. This program is called by Nagios, connects to the
UNIX socket and reads the values from collectd. It then returns B<OKAY>,
B<WARNING> or B<CRITICAL> depending on the values and the ranges provided by
#include "common.h"
#include "plugin.h"
+#if HAVE_PTHREAD_H
+# include <pthread.h>
+#endif
+
#ifdef HAVE_MATH_H
-# include <math.h>
+# include <math.h>
#endif
/* for ntohl and htonl */
extern kstat_ctl_t *kc;
#endif
+#if !HAVE_GETPWNAM_R
+static pthread_mutex_t getpwnam_r_lock = PTHREAD_MUTEX_INITIALIZER;
+#endif
+
void sstrncpy (char *d, const char *s, int len)
{
strncpy (d, s, len);
return (-1);
return (0);
} /* int parse_values */
+
+#if !HAVE_GETPWNAM_R
+int getpwnam_r (const char *name, struct passwd *pwbuf, char *buf,
+ size_t buflen, struct passwd **pwbufp)
+{
+ int status = 0;
+ struct passwd *pw;
+
+ memset (pwbuf, '\0', sizeof (struct passwd));
+
+ pthread_mutex_lock (&getpwnam_r_lock);
+
+ do
+ {
+ pw = getpwnam (name);
+ if (pw == NULL)
+ {
+ status = (errno != 0) ? errno : ENOENT;
+ break;
+ }
+
+#define GETPWNAM_COPY_MEMBER(member) \
+ if (pw->member != NULL) \
+ { \
+ int len = strlen (pw->member); \
+ if (len >= buflen) \
+ { \
+ status = ENOMEM; \
+ break; \
+ } \
+ sstrncpy (buf, pw->member, buflen); \
+ pwbuf->member = buf; \
+ buf += (len + 1); \
+ buflen -= (len + 1); \
+ }
+ GETPWNAM_COPY_MEMBER(pw_name);
+ GETPWNAM_COPY_MEMBER(pw_passwd);
+ GETPWNAM_COPY_MEMBER(pw_gecos);
+ GETPWNAM_COPY_MEMBER(pw_dir);
+ GETPWNAM_COPY_MEMBER(pw_shell);
+
+ pwbuf->pw_uid = pw->pw_uid;
+ pwbuf->pw_gid = pw->pw_gid;
+
+ if (pwbufp != NULL)
+ *pwbufp = pwbuf;
+ } while (0);
+
+ pthread_mutex_unlock (&getpwnam_r_lock);
+
+ return (status);
+} /* int getpwnam_r */
+#endif
#include "collectd.h"
#include "plugin.h"
+#if HAVE_PWD_H
+# include <pwd.h>
+#endif
+
#define sfree(ptr) \
if((ptr) != NULL) { \
free(ptr); \
char **ret_type, char **ret_type_instance);
int parse_values (char *buffer, value_list_t *vl, const data_set_t *ds);
+#if !HAVE_GETPWNAM_R
+int getpwnam_r (const char *name, struct passwd *pwbuf, char *buf,
+ size_t buflen, struct passwd **pwbufp);
+#endif
+
#endif /* COMMON_H */
int ai_return;
memset (&ai_hints, '\0', sizeof (ai_hints));
- ai_hints.ai_flags = AI_ADDRCONFIG;
+ ai_hints.ai_flags = 0;
+#ifdef AI_ADDRCONFIG
+ ai_hints.ai_flags |= AI_ADDRCONFIG;
+#endif
ai_hints.ai_family = PF_UNSPEC;
ai_hints.ai_socktype = SOCK_STREAM;
ai_hints.ai_protocol = IPPROTO_TCP;
int ai_return;
memset (&ai_hints, '\0', sizeof (ai_hints));
- ai_hints.ai_flags = AI_ADDRCONFIG;
+ ai_hints.ai_flags = 0;
+#ifdef AI_ADDRCONFIG
+ ai_hints.ai_flags |= AI_ADDRCONFIG;
+#endif
ai_hints.ai_family = PF_UNSPEC;
ai_hints.ai_socktype = SOCK_STREAM;
ai_hints.ai_protocol = IPPROTO_TCP;
port = NTPD_DEFAULT_PORT;
memset (&ai_hints, '\0', sizeof (ai_hints));
- ai_hints.ai_flags = AI_ADDRCONFIG;
+ ai_hints.ai_flags = 0;
+#ifdef AI_ADDRCONFIG
+ ai_hints.ai_flags |= AI_ADDRCONFIG;
+#endif
ai_hints.ai_family = PF_UNSPEC;
ai_hints.ai_socktype = SOCK_DGRAM;
ai_hints.ai_protocol = IPPROTO_UDP;
#if HAVE_ARPA_NAMESER_H
# include <arpa/nameser.h>
-#elif HAVE_ARPA_NAMESER_COMPAT_H
+#endif
+#if HAVE_ARPA_NAMESER_COMPAT_H
# include <arpa/nameser_compat.h>
#endif
{
static char buf[32];
switch (t) {
+#if (defined (__NAMESER)) && (__NAMESER >= 19991006)
case ns_t_a: return ("A");
case ns_t_ns: return ("NS");
case ns_t_md: return ("MD");
case ns_t_maila: return ("MAILA");
case ns_t_any: return ("ANY");
case ns_t_zxfr: return ("ZXFR");
+/* #endif __NAMESER >= 19991006 */
+#elif (defined (__BIND)) && (__BIND >= 19950621)
+ case T_A: return ("A"); /* 1 ... */
+ case T_NS: return ("NS");
+ case T_MD: return ("MD");
+ case T_MF: return ("MF");
+ case T_CNAME: return ("CNAME");
+ case T_SOA: return ("SOA");
+ case T_MB: return ("MB");
+ case T_MG: return ("MG");
+ case T_MR: return ("MR");
+ case T_NULL: return ("NULL");
+ case T_WKS: return ("WKS");
+ case T_PTR: return ("PTR");
+ case T_HINFO: return ("HINFO");
+ case T_MINFO: return ("MINFO");
+ case T_MX: return ("MX");
+ case T_TXT: return ("TXT");
+ case T_RP: return ("RP");
+ case T_AFSDB: return ("AFSDB");
+ case T_X25: return ("X25");
+ case T_ISDN: return ("ISDN");
+ case T_RT: return ("RT");
+ case T_NSAP: return ("NSAP");
+ case T_NSAP_PTR: return ("NSAP_PTR");
+ case T_SIG: return ("SIG");
+ case T_KEY: return ("KEY");
+ case T_PX: return ("PX");
+ case T_GPOS: return ("GPOS");
+ case T_AAAA: return ("AAAA");
+ case T_LOC: return ("LOC");
+ case T_NXT: return ("NXT");
+ case T_EID: return ("EID");
+ case T_NIMLOC: return ("NIMLOC");
+ case T_SRV: return ("SRV");
+ case T_ATMA: return ("ATMA");
+ case T_NAPTR: return ("NAPTR"); /* ... 35 */
+#if (__BIND >= 19960801)
+ case T_KX: return ("KX"); /* 36 ... */
+ case T_CERT: return ("CERT");
+ case T_A6: return ("A6");
+ case T_DNAME: return ("DNAME");
+ case T_SINK: return ("SINK");
+ case T_OPT: return ("OPT");
+ case T_APL: return ("APL");
+ case T_DS: return ("DS");
+ case T_SSHFP: return ("SSHFP");
+ case T_RRSIG: return ("RRSIG");
+ case T_NSEC: return ("NSEC");
+ case T_DNSKEY: return ("DNSKEY"); /* ... 48 */
+ case T_TKEY: return ("TKEY"); /* 249 */
+#endif /* __BIND >= 19960801 */
+ case T_TSIG: return ("TSIG"); /* 250 ... */
+ case T_IXFR: return ("IXFR");
+ case T_AXFR: return ("AXFR");
+ case T_MAILB: return ("MAILB");
+ case T_MAILA: return ("MAILA");
+ case T_ANY: return ("ANY"); /* ... 255 */
+#endif /* __BIND >= 19950621 */
default:
snprintf (buf, 32, "#%i", t);
buf[31] = '\0';
static char buf[32];
switch (rcode)
{
+#if (defined (__NAMESER)) && (__NAMESER >= 19991006)
case ns_r_noerror: return ("NOERROR");
case ns_r_formerr: return ("FORMERR");
case ns_r_servfail: return ("SERVFAIL");
case ns_r_badsig: return ("BADSIG");
case ns_r_badkey: return ("BADKEY");
case ns_r_badtime: return ("BADTIME");
+/* #endif __NAMESER >= 19991006 */
+#elif (defined (__BIND)) && (__BIND >= 19950621)
+ case NOERROR: return ("NOERROR");
+ case FORMERR: return ("FORMERR");
+ case SERVFAIL: return ("SERVFAIL");
+ case NXDOMAIN: return ("NXDOMAIN");
+ case NOTIMP: return ("NOTIMP");
+ case REFUSED: return ("REFUSED");
+#if defined (YXDOMAIN) && defined (NXRRSET)
+ case YXDOMAIN: return ("YXDOMAIN");
+ case YXRRSET: return ("YXRRSET");
+ case NXRRSET: return ("NXRRSET");
+ case NOTAUTH: return ("NOTAUTH");
+ case NOTZONE: return ("NOTZONE");
+#endif /* RFC2136 rcodes */
+#endif /* __BIND >= 19950621 */
default:
snprintf (buf, 32, "RCode%i", rcode);
buf[31] = '\0';