AC_CHECK_HEADERS(regex.h)
# For the dns plugin
+AC_CHECK_HEADERS(arpa/nameser.h arpa/nameser_compat.h)
AC_CHECK_HEADERS(arpa/nameser.h)
-AC_CHECK_HEADERS(pthread.h)
+
+AC_CHECK_HEADERS(net/if_arp.h)
AC_CHECK_HEADERS(net/if_ppp.h)
+AC_CHECK_HEADERS(netinet/if_ether.h)
+AC_CHECK_HEADERS(netinet/udp.h)
dnl Checking for libraries
AC_CHECK_LIB(m, ext)
[Wether or not to use rrdtool library])
AM_CONDITIONAL(BUILD_WITH_RRDTOOL, test "x$with_rrdtool" = "xyes")
-with_pthread="yes"
-AC_ARG_WITH(pthread, [AS_HELP_STRING([--with-pthread=@<:@=PREFIX@:>@], [Path to pthread (experimental).])],
-[ if test "x$withval" != "xno" && test "x$withval" != "xyes"
+AC_ARG_WITH(libpthread, [AS_HELP_STRING([--with-libpthread=@<:@=PREFIX@:>@], [Path to libpthread.])],
+[ if test "x$withval" != "xno" -a "x$withval" != "xyes"
then
LDFLAGS="$LDFLAGS -L$withval/lib"
CPPFLAGS="$CPPFLAGS -I$withval/include"
- with_pthread="yes"
+ with_libpthread="yes"
+ else
+ if test "x$withval" = "xno"
+ then
+ with_libpthread="no (disabled)"
+ fi
fi
-], [with_pthread="no"])
-if test "x$with_pthread" = "xyes"
+], [with_libpthread="no"])
+if test "x$with_libpthread" = "xyes"
then
- AC_CHECK_LIB(pthread, pthread_create, [with_pthread="yes"], [with_pthread="no (libpthread not found)"], [])
+ AC_CHECK_LIB(pthread, pthread_create, [with_libpthread="yes"], [with_libpthread="no (libpthread not found)"], [])
fi
-if test "x$with_pthread" = "xyes"
+if test "x$with_libpthread" = "xyes"
then
- AC_CHECK_HEADERS(pthread.h,, [with_pthread="no (pthread.h not found)"])
+ AC_CHECK_HEADERS(pthread.h,, [with_libpthread="no (pthread.h not found)"])
fi
-if test "x$with_pthread" = "xyes"
+if test "x$with_libpthread" = "xyes"
then
collect_pthread=1
else
fi
AC_DEFINE_UNQUOTED(HAVE_LIBPTHREAD, [$collect_pthread],
[Wether or not to use pthread (POSIX threads) library])
-AM_CONDITIONAL(BUILD_WITH_LIBPTHREAD, test "x$with_pthread" = "xyes")
+AM_CONDITIONAL(BUILD_WITH_LIBPTHREAD, test "x$with_libpthread" = "xyes")
if test "$ac_system" = "Solaris"
then
libkstat . . . . . $with_kstat
libmysql . . . . . $with_libmysql
libpcap . . . . . . $with_libpcap
+ libpthread . . . . $with_libpthread
Features:
debug . . . . . . . $enable_debug
#include "plugin.h"
#include "configfile.h"
#include "utils_debug.h"
-
-#if HAVE_PTHREAD_H
-# include <pthread.h>
-#endif
-
-#if HAVE_SYS_POLL_H
-# include <sys/poll.h>
-#endif
+#include "utils_dns.h"
#define MODULE_NAME "dns"
-#if HAVE_LIBPCAP
-# define NAMED_HAVE_CONFIG 1
-#else
-# define NAMED_HAVE_CONFIG 0
-#endif
-
-#if HAVE_LIBPCAP && HAVE_PTHREAD_H
-# include "utils_dns.h"
-# define NAMED_HAVE_READ 1
+#if HAVE_LIBPCAP && HAVE_LIBPTHREAD
+# include <pthread.h>
+# include <pcap.h>
+# include <sys/poll.h>
+# define DNS_HAVE_READ 1
#else
-# define NAMED_HAVE_READ 0
+# define DNS_HAVE_READ 0
#endif
+/*
+ * Private data types
+ */
+#if DNS_HAVE_READ
struct counter_list_s
{
unsigned int key;
struct counter_list_s *next;
};
typedef struct counter_list_s counter_list_t;
+#endif
+/*
+ * Private variables
+ */
static char *traffic_file = "dns/dns_traffic.rrd";
static char *qtype_file = "dns/qtype-%s.rrd";
static char *opcode_file = "dns/opcode-%s.rrd";
};
static int rcode_ds_num = 1;
-/* FIXME: Wouldn't other defines be better? -octo */
-#if NAMED_HAVE_CONFIG
-#if HAVE_LIBPCAP
+#if DNS_HAVE_READ
static char *config_keys[] =
{
"Interface",
NULL
};
static int config_keys_num = 2;
-#endif /* HAVE_LIBPCAP */
-#endif /* NAMED_HAVE_CONFIG */
-#if HAVE_LIBPCAP
#define PCAP_SNAPLEN 1460
static char *pcap_device = NULL;
static counter_list_t *qtype_list;
static counter_list_t *opcode_list;
static counter_list_t *rcode_list;
-#endif
-#if HAVE_PTHREAD_H
static pthread_t listen_thread;
static int listen_thread_init = 0;
/* The `traffic' mutex if for `tr_queries' and `tr_responses' */
static pthread_mutex_t qtype_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t opcode_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t rcode_mutex = PTHREAD_MUTEX_INITIALIZER;
-#endif
+#endif /* DNS_HAVE_READ */
+/*
+ * Private functions
+ */
+#if DNS_HAVE_READ
static counter_list_t *counter_list_search (counter_list_t **list, unsigned int key)
{
counter_list_t *entry;
DBG ("return ()");
}
-#if NAMED_HAVE_CONFIG
static int dns_config (char *key, char *value)
{
-#if HAVE_LIBPCAP
if (strcasecmp (key, "Interface") == 0)
{
if (pcap_device != NULL)
}
return (0);
-#endif /* HAVE_LIBPCAP */
}
-#endif /* NAMED_HAVE_CONFIG */
static void dns_child_callback (const rfc1035_header_t *dns)
{
return (NULL);
} /* static void dns_child_loop (void) */
+#endif /* DNS_HAVE_READ */
static void dns_init (void)
{
-#if HAVE_LIBPCAP
-#if HAVE_PTHREAD_H
+#if DNS_HAVE_READ
/* clean up an old thread */
int status;
}
listen_thread_init = 1;
-#endif
-#endif
+#endif /* DNS_HAVE_READ */
}
static void traffic_write (char *host, char *inst, char *val)
rrd_update_file (host, file, val, opcode_ds_def, opcode_ds_num);
}
+#if DNS_HAVE_READ
static void traffic_submit (unsigned int queries, unsigned int replies)
{
char buffer[64];
plugin_submit ("dns_opcode", inst, buffer);
}
-#if NAMED_HAVE_READ
static void dns_read (void)
{
unsigned int keys[T_MAX];
rcode_submit (keys[i], values[i]);
}
}
-#else /* if !NAMED_HAVE_READ */
+#else /* if !DNS_HAVE_READ */
# define dns_read NULL
#endif
plugin_register ("dns_qtype", NULL, NULL, qtype_write);
plugin_register ("dns_rcode", NULL, NULL, rcode_write);
plugin_register ("dns_opcode", NULL, NULL, opcode_write);
+#if DNS_HAVE_READ
cf_register (MODULE_NAME, dns_config, config_keys, config_keys_num);
+#endif
}
#undef MODULE_NAME
* Florian octo Forster <octo at verplant.org>
*/
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/stat.h>
-
-#include <netinet/in.h>
-
-#include <pcap.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <time.h>
-#include <ctype.h>
-#include <curses.h>
-#include <assert.h>
-#include <arpa/inet.h>
-#include <arpa/nameser.h>
-#ifdef __APPLE__
-#include <arpa/nameser_compat.h>
-#endif
-
-#include <sys/socket.h>
-#include <net/if_arp.h>
-#include <net/if.h>
-#include <netinet/if_ether.h>
-
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
-#include <netinet/ip6.h>
-#include <netinet/udp.h>
-
-#include <netdb.h>
+#include "collectd.h"
+
+#if HAVE_NETINET_IN_H
+# include <netinet/in.h>
+#endif
+#if HAVE_PCAP_H
+# include <pcap.h>
+#endif
+#if HAVE_ARPA_INET_H
+# include <arpa/inet.h>
+#endif
+
+#if HAVE_ARPA_NAMESER_H
+# include <arpa/nameser.h>
+#elif HAVE_ARPA_NAMESER_COMPAT_H
+# include <arpa/nameser_compat.h>
+#endif
+
+#if HAVE_NET_IF_ARP_H
+# include <net/if_arp.h>
+#endif
+#if HAVE_NET_IF_H
+# include <net/if.h>
+#endif
+#if HAVE_NETINET_IF_ETHER_H
+# include <netinet/if_ether.h>
+#endif
+#if HAVE_NET_IF_PPP_H
+# include <net/if_ppp.h>
+#endif
+
+#if HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#endif
+#if HAVE_NETDB_H
+# include <netdb.h>
+#endif
+
+#if HAVE_NETINET_IN_SYSTM_H
+# include <netinet/in_systm.h>
+#endif
+#if HAVE_NETINET_IN_H
+# include <netinet/in.h>
+#endif
+#if HAVE_NETINET_IP_H
+# include <netinet/ip.h>
+#endif
+#ifdef HAVE_NETINET_IP_VAR_H
+# include <netinet/ip_var.h>
+#endif
+#if HAVE_NETINET_IP6_H
+# include <netinet/ip6.h>
+#endif
+#if HAVE_NETINET_UDP_H
+# include <netinet/udp.h>
+#endif
#define PCAP_SNAPLEN 1460
#ifndef ETHER_HDR_LEN
# define ETHERTYPE_IPV6 0x86DD
#endif
-#include <net/if_ppp.h>
#ifndef PPP_ADDRESS_VAL
# define PPP_ADDRESS_VAL 0xff /* The address byte value */
#endif
int opcode_counts[OP_MAX];
int qclass_counts[C_MAX];
+#if HAVE_PCAP_H
static pcap_t *pcap_obj = NULL;
+#endif
static ip_list_t *IgnoreList = NULL;
}
} /* void in6_addr_from_buffer */
+#if HAVE_PCAP_H
void dnstop_set_pcap_obj (pcap_t *po)
{
pcap_obj = po;
}
+#endif
void dnstop_set_callback (void (*cb) (const rfc1035_header_t *))
{
}
/* public function */
+#if HAVE_PCAP_H
void handle_pcap(u_char *udata, const struct pcap_pkthdr *hdr, const u_char *pkt)
{
int status;
query_count_total++;
last_ts = hdr->ts;
}
+#endif
const char *qtype_str(int t)
{
* Florian octo Forster <octo at verplant.org>
*/
+#include "config.h"
+
#include <arpa/nameser.h>
-#include <pcap.h>
+
+#if HAVE_PCAP_H
+# include <pcap.h>
+#endif
#define T_MAX 65536
#define OP_MAX 16
extern int opcode_counts[OP_MAX];
extern int qclass_counts[C_MAX];
+#if HAVE_PCAP_H
void dnstop_set_pcap_obj (pcap_t *po);
+#endif
void dnstop_set_callback (void (*cb) (const rfc1035_header_t *));
void ignore_list_add_name (const char *name);
+#if HAVE_PCAP_H
void handle_pcap (u_char * udata, const struct pcap_pkthdr *hdr, const u_char * pkt);
+#endif
const char *qtype_str(int t);
const char *opcode_str(int o);