dnl Process this file with autoconf to produce a configure script.
- AC_INIT(collectd, 3.11.0)
+ AC_INIT(collectd, 3.11.1)
AC_CONFIG_SRCDIR(src/collectd.c)
AC_CONFIG_HEADERS(src/config.h)
AM_INIT_AUTOMAKE(dist-bzip2)
AC_CHECK_HEADERS(sys/types.h)
AC_CHECK_HEADERS(sys/socket.h)
AC_CHECK_HEADERS(sys/select.h)
-AC_CHECK_HEADERS(sys/poll.h)
+AC_CHECK_HEADERS(poll.h)
AC_CHECK_HEADERS(netdb.h)
AC_CHECK_HEADERS(arpa/inet.h)
AC_CHECK_HEADERS(sys/resource.h)
# include <netinet/ip6.h>
#endif
])
++AC_CHECK_HEADERS(netinet/tcp.h, [], [],
++[#if HAVE_STDINT_H
++# include <stdint.h>
++#endif
++#if HAVE_SYS_TYPES_H
++# include <sys/types.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
++])
+ AC_CHECK_HEADERS(netinet/udp.h, [], [],
+ [#if HAVE_STDINT_H
+ # include <stdint.h>
+ #endif
+ #if HAVE_SYS_TYPES_H
+ # include <sys/types.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
+ ])
# For cpu modules
AC_CHECK_HEADERS(sys/sysctl.h sys/dkstat.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/tcp.h)
- AC_CHECK_HEADERS(netinet/udp.h)
+# For the multimeter plugin
+AC_CHECK_HEADERS(termios.h)
+AC_CHECK_HEADERS(sys/ioctl.h)
+
dnl Checking for libraries
AC_CHECK_LIB(m, ext)
#include <linux/netdevice.h>
])
+ AC_CHECK_MEMBERS([struct udphdr.uh_dport, struct udphdr.uh_sport], [], [],
+ [#if HAVE_STDINT_H
+ # include <stdint.h>
+ #endif
+ #if HAVE_SYS_TYPES_H
+ # include <sys/types.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
+ #if HAVE_NETINET_UDP_H
+ # include <netinet/udp.h>
+ #endif
+ ])
+ AC_CHECK_MEMBERS([struct udphdr.dest, struct udphdr.source], [], [],
+ [#if HAVE_STDINT_H
+ # include <stdint.h>
+ #endif
+ #if HAVE_SYS_TYPES_H
+ # include <sys/types.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
+ #if HAVE_NETINET_UDP_H
+ # include <netinet/udp.h>
+ #endif
+ ])
+
AC_MSG_CHECKING([for kernel type ($host_os)])
case $host_os in
*linux*)
if test "x$with_kstat" = "xyes"
then
- AC_CHECK_LIB(kstat, kstat_open,, [with_kstat="no (libkstat not found)"])
+ AC_CHECK_LIB(kstat, kstat_open, [with_kstat="yes"], [with_kstat="no (libkstat not found)"], [])
fi
if test "x$with_kstat" = "xyes"
then
- AC_CHECK_LIB(devinfo, di_init,, [with_devinfo="no (not found)"])
+ AC_CHECK_LIB(devinfo, di_init, [with_devinfo="yes"], [with_devinfo="no (not found)"], [])
AC_CHECK_HEADERS(kstat.h,, [with_kstat="no (kstat.h not found)"])
fi
if test "x$with_kstat" = "xyes"
AC_COLLECTD([cpu], [disable], [module], [cpu usage statistics])
AC_COLLECTD([cpufreq], [disable], [module], [system cpu frequency statistics])
AC_COLLECTD([disk], [disable], [module], [disk/partition statistics])
+AC_COLLECTD([csv], [disable], [module], [csv output plugin])
AC_COLLECTD([df], [disable], [module], [df statistics])
AC_COLLECTD([dns], [disable], [module], [dns statistics])
AC_COLLECTD([email], [disable], [module], [email statistics])
-AC_COLLECTD([quota], [enable], [module], [quota statistics (experimental)])
+AC_COLLECTD([entropy], [disable], [module], [entropy statistics])
AC_COLLECTD([hddtemp], [disable], [module], [hdd temperature statistics])
AC_COLLECTD([load], [disable], [module], [system load statistics])
AC_COLLECTD([mbmon], [disable], [module], [motherboard monitor statistics])
AC_COLLECTD([memory], [disable], [module], [memory statistics])
AC_COLLECTD([multimeter],[disable], [module], [multimeter statistics])
AC_COLLECTD([mysql], [disable], [module], [mysql statistics])
+AC_COLLECTD([network], [disable], [module], [network functionality])
AC_COLLECTD([nfs], [disable], [module], [nfs statistics])
AC_COLLECTD([ntpd], [disable], [module], [nfs statistics])
AC_COLLECTD([ping], [disable], [module], [ping statistics])
AC_COLLECTD([swap], [disable], [module], [swap statistics])
AC_COLLECTD([tape], [disable], [module], [tape statistics])
AC_COLLECTD([traffic], [disable], [module], [system traffic statistics])
+AC_COLLECTD([unixsock], [disable], [module], [UNIX socket plugin])
AC_COLLECTD([users], [disable], [module], [user count statistics])
AC_COLLECTD([vserver], [disable], [module], [vserver statistics])
AC_COLLECTD([wireless], [disable], [module], [wireless link statistics])
battery . . . . . . $enable_battery
cpu . . . . . . . . $enable_cpu
cpufreq . . . . . . $enable_cpufreq
+ csv . . . . . . . . $enable_csv
df . . . . . . . . $enable_df
disk . . . . . . . $enable_disk
dns . . . . . . . . $enable_dns
email . . . . . . . $enable_email
+ entropy . . . . . . $enable_entropy
hddtemp . . . . . . $enable_hddtemp
load . . . . . . . $enable_load
mbmon . . . . . . . $enable_mbmon
memory . . . . . . $enable_memory
multimeter . . . . $enable_multimeter
mysql . . . . . . . $enable_mysql
+ network . . . . . . $enable_network
nfs . . . . . . . . $enable_nfs
ntpd . . . . . . . $enable_ntpd
ping . . . . . . . $enable_ping
swap . . . . . . . $enable_swap
tape . . . . . . . $enable_tape
traffic . . . . . . $enable_traffic
+ unixsock . . . . . $enable_unixsock
users . . . . . . . $enable_users
vserver . . . . . . $enable_vserver
wireless . . . . . $enable_wireless
endif
sbin_PROGRAMS = collectd
+bin_PROGRAMS = collectd-nagios
collectd_SOURCES = collectd.c collectd.h \
utils_debug.c utils_debug.h \
utils_mount.c utils_mount.h \
+ utils_llist.c utils_llist.h \
utils_ignorelist.c utils_ignorelist.h \
common.c common.h \
- network.c network.h \
plugin.c plugin.h \
configfile.c configfile.h
collectd_CPPFLAGS = $(LTDLINCL)
+collectd_CPPFLAGS += -DPREFIX='"${prefix}"'
collectd_CPPFLAGS += -DCONFIGFILE='"${sysconfdir}/${PACKAGE_NAME}.conf"'
collectd_CPPFLAGS += -DPKGLOCALSTATEDIR='"${localstatedir}/lib/${PACKAGE_NAME}"'
if BUILD_FEATURE_DAEMON
# Link to these libraries..
collectd_LDFLAGS = -export-dynamic
-if BUILD_WITH_RRDTOOL
-collectd_LDFLAGS += -lm -lrrd
-endif
if BUILD_WITH_LIBRT
collectd_LDFLAGS += -lrt
endif
collectd_LDADD = $(LIBLTDL) libconfig/libconfig.la "-dlopen" self
collectd_DEPENDENCIES = $(LIBLTDL) libconfig/libconfig.la
+collectd_nagios_SOURCES = collectd-nagios.c
+
pkglib_LTLIBRARIES =
if BUILD_MODULE_APACHE
collectd_DEPENDENCIES += cpufreq.la
endif
+if BUILD_MODULE_CSV
+pkglib_LTLIBRARIES += csv.la
+csv_la_SOURCES = csv.c
+csv_la_LDFLAGS = -module -avoid-version
+collectd_LDADD += "-dlopen" csv.la
+collectd_DEPENDENCIES += csv.la
+endif
+
if BUILD_MODULE_DF
pkglib_LTLIBRARIES += df.la
df_la_SOURCES = df.c
if BUILD_MODULE_DNS
pkglib_LTLIBRARIES += dns.la
- dns_la_SOURCES = dns.c utils_dns.c utils_dns.h
+ dns_la_SOURCES = dns.c
+ if BUILD_WITH_LIBPCAP
+ if BUILD_WITH_LIBPTHREAD
+ dns_la_SOURCES += utils_dns.c utils_dns.h
+ endif
+ endif
dns_la_LDFLAGS = -module -avoid-version
if BUILD_WITH_LIBPCAP
dns_la_LDFLAGS += -lpcap
collectd_DEPENDENCIES += email.la
endif
+if BUILD_MODULE_ENTROPY
+pkglib_LTLIBRARIES += entropy.la
+entropy_la_SOURCES = entropy.c
+entropy_la_LDFLAGS = -module -avoid-version
+collectd_LDADD += "-dlopen" entropy.la
+collectd_DEPENDENCIES += entropy.la
+endif
+
#if BUILD_MODULE_QUOTA
#pkglib_LTLIBRARIES += quota.la
#quota_la_SOURCES = quota_plugin.c quota_plugin.h
collectd_DEPENDENCIES += mysql.la
endif
+if BUILD_MODULE_NETWORK
+pkglib_LTLIBRARIES += network.la
+network_la_SOURCES = network.c
+network_la_LDFLAGS = -module -avoid-version
+if BUILD_WITH_LIBSOCKET
+network_la_LDFLAGS += -lsocket
+endif
+if BUILD_WITH_LIBPTHREAD
+network_la_LDFLAGS += -lpthread
+endif
+collectd_LDADD += "-dlopen" network.la
+collectd_DEPENDENCIES += network.la
+endif
+
if BUILD_MODULE_NFS
pkglib_LTLIBRARIES += nfs.la
nfs_la_SOURCES = nfs.c
collectd_DEPENDENCIES += processes.la
endif
+if BUILD_WITH_RRDTOOL
+pkglib_LTLIBRARIES += rrdtool.la
+rrdtool_la_SOURCES = rrdtool.c
+rrdtool_la_LDFLAGS = -module -avoid-version -lrrd
+collectd_LDADD += "-dlopen" rrdtool.la
+collectd_DEPENDENCIES += rrdtool.la
+endif
+
if BUILD_MODULE_SENSORS
pkglib_LTLIBRARIES += sensors.la
sensors_la_SOURCES = sensors.c
endif
endif
+if BUILD_MODULE_UNIXSOCK
+pkglib_LTLIBRARIES += unixsock.la
+unixsock_la_SOURCES = unixsock.c
+unixsock_la_LDFLAGS = -module -avoid-version
+if BUILD_WITH_LIBPTHREAD
+unixsock_la_LDFLAGS += -lpthread
+endif
+collectd_LDADD += "-dlopen" unixsock.la
+collectd_DEPENDENCIES += unixsock.la
+endif
+
if BUILD_MODULE_USERS
pkglib_LTLIBRARIES += users.la
users_la_SOURCES = users.c
/**
* collectd - src/dns.c
- * Copyright (C) 2006 Florian octo Forster
+ * Copyright (C) 2006,2007 Florian octo Forster
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
+ * Free Software Foundation; only version 2 of the License is applicable.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
#include "plugin.h"
#include "configfile.h"
#include "utils_debug.h"
- #include "utils_dns.h"
-#define MODULE_NAME "dns"
-
#if HAVE_LIBPCAP && HAVE_LIBPTHREAD
+ # include "utils_dns.h"
# include <pthread.h>
# include <pcap.h>
-# include <sys/poll.h>
+# include <poll.h>
# define DNS_HAVE_READ 1
#else
# define DNS_HAVE_READ 0
/*
* 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 char *rcode_file = "dns/rcode-%s.rrd";
+static data_source_t octets_dsrc[2] =
+{
+ {"queries", DS_TYPE_COUNTER, 0, 125000000.0},
+ {"responses", DS_TYPE_COUNTER, 0, 125000000.0}
+};
-static char *traffic_ds_def[] =
+static data_set_t octets_ds =
{
- /* Limit to 1GBit/s */
- "DS:queries:COUNTER:"COLLECTD_HEARTBEAT":0:125000000",
- "DS:responses:COUNTER:"COLLECTD_HEARTBEAT":0:125000000",
- NULL
+ "dns_octets", 2, octets_dsrc
};
-static int traffic_ds_num = 2;
-static char *qtype_ds_def[] =
+static data_source_t counter_dsrc[1] =
{
- "DS:value:COUNTER:"COLLECTD_HEARTBEAT":0:65535",
- NULL
+ {"value", DS_TYPE_COUNTER, 0, 65535.0}
};
-static int qtype_ds_num = 1;
-static char *opcode_ds_def[] =
+static data_set_t qtype_ds =
{
- "DS:value:COUNTER:"COLLECTD_HEARTBEAT":0:65535",
- NULL
+ "dns_qtype", 1, counter_dsrc
};
-static int opcode_ds_num = 1;
-static char *rcode_ds_def[] =
+static data_set_t opcode_ds =
{
- "DS:value:COUNTER:"COLLECTD_HEARTBEAT":0:65535",
- NULL
+ "dns_opcode", 1, counter_dsrc
+};
+
+static data_set_t rcode_ds =
+{
+ "dns_rcode", 1, counter_dsrc
};
-static int rcode_ds_num = 1;
#if DNS_HAVE_READ
-static char *config_keys[] =
+static const char *config_keys[] =
{
"Interface",
"IgnoreSource",
#define PCAP_SNAPLEN 1460
static char *pcap_device = NULL;
-static unsigned int tr_queries;
-static unsigned int tr_responses;
+static counter_t tr_queries;
+static counter_t tr_responses;
static counter_list_t *qtype_list;
static counter_list_t *opcode_list;
static counter_list_t *rcode_list;
DBG ("return ()");
}
-static int dns_config (char *key, char *value)
+static int dns_config (const char *key, const char *value)
{
if (strcasecmp (key, "Interface") == 0)
{
return (NULL);
} /* static void dns_child_loop (void) */
-#endif /* DNS_HAVE_READ */
-static void dns_init (void)
+static int dns_init (void)
{
-#if DNS_HAVE_READ
/* clean up an old thread */
int status;
pthread_mutex_unlock (&traffic_mutex);
if (listen_thread_init != 0)
- return;
+ return (-1);
status = pthread_create (&listen_thread, NULL, dns_child_loop,
(void *) 0);
{
syslog (LOG_ERR, "dns plugin: pthread_create failed: %s",
strerror (status));
- return;
+ return (-1);
}
listen_thread_init = 1;
-#endif /* DNS_HAVE_READ */
-}
-
-static void traffic_write (char *host, char *inst, char *val)
-{
- rrd_update_file (host, traffic_file, val,
- traffic_ds_def, traffic_ds_num);
-}
-
-static void qtype_write (char *host, char *inst, char *val)
-{
- char file[512];
- int status;
-
- status = snprintf (file, 512, qtype_file, inst);
- if (status < 1)
- return;
- else if (status >= 512)
- return;
-
- rrd_update_file (host, file, val, qtype_ds_def, qtype_ds_num);
-}
-
-static void rcode_write (char *host, char *inst, char *val)
-{
- char file[512];
- int status;
-
- status = snprintf (file, 512, rcode_file, inst);
- if (status < 1)
- return;
- else if (status >= 512)
- return;
- rrd_update_file (host, file, val, rcode_ds_def, rcode_ds_num);
-}
-
-static void opcode_write (char *host, char *inst, char *val)
-{
- char file[512];
- int status;
-
- status = snprintf (file, 512, opcode_file, inst);
- if (status < 1)
- return;
- else if (status >= 512)
- return;
-
- 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];
- int status;
-
- status = snprintf (buffer, 64, "N:%u:%u", queries, replies);
- if ((status < 1) || (status >= 64))
- return;
-
- plugin_submit ("dns_traffic", "-", buffer);
-}
-
-static void qtype_submit (int qtype, unsigned int counter)
-{
- char inst[32];
- char buffer[32];
- int status;
-
- strncpy (inst, qtype_str (qtype), 32);
- inst[31] = '\0';
-
- status = snprintf (buffer, 32, "N:%u", counter);
- if ((status < 1) || (status >= 32))
- return;
-
- plugin_submit ("dns_qtype", inst, buffer);
-}
+ return (0);
+} /* int dns_init */
-static void rcode_submit (int rcode, unsigned int counter)
+static void submit_counter (const char *type, const char *type_instance,
+ counter_t value)
{
- char inst[32];
- char buffer[32];
- int status;
+ value_t values[1];
+ value_list_t vl = VALUE_LIST_INIT;
- strncpy (inst, rcode_str (rcode), 32);
- inst[31] = '\0';
+ values[0].counter = value;
- status = snprintf (buffer, 32, "N:%u", counter);
- if ((status < 1) || (status >= 32))
- return;
+ vl.values = values;
+ vl.values_len = 1;
+ vl.time = time (NULL);
+ strcpy (vl.host, hostname);
+ strcpy (vl.plugin, "dns");
+ strncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
- plugin_submit ("dns_rcode", inst, buffer);
-}
+ plugin_dispatch_values (type, &vl);
+} /* void submit_counter */
-static void opcode_submit (int opcode, unsigned int counter)
+static void submit_octets (counter_t queries, counter_t responses)
{
- char inst[32];
- char buffer[32];
- int status;
+ value_t values[2];
+ value_list_t vl = VALUE_LIST_INIT;
- strncpy (inst, opcode_str (opcode), 32);
- inst[31] = '\0';
+ values[0].counter = queries;
+ values[1].counter = responses;
- status = snprintf (buffer, 32, "N:%u", counter);
- if ((status < 1) || (status >= 32))
- return;
+ vl.values = values;
+ vl.values_len = 2;
+ vl.time = time (NULL);
+ strcpy (vl.host, hostname);
+ strcpy (vl.plugin, "dns");
- plugin_submit ("dns_opcode", inst, buffer);
-}
+ plugin_dispatch_values ("dns_octets", &vl);
+} /* void submit_counter */
-static void dns_read (void)
+static int dns_read (void)
{
unsigned int keys[T_MAX];
unsigned int values[T_MAX];
values[0] = tr_queries;
values[1] = tr_responses;
pthread_mutex_unlock (&traffic_mutex);
- traffic_submit (values[0], values[1]);
+ submit_octets (values[0], values[1]);
pthread_mutex_lock (&qtype_mutex);
for (ptr = qtype_list, len = 0;
for (i = 0; i < len; i++)
{
DBG ("qtype = %u; counter = %u;", keys[i], values[i]);
- qtype_submit (keys[i], values[i]);
+ submit_counter ("dns_qtype", qtype_str (keys[i]), values[i]);
}
pthread_mutex_lock (&opcode_mutex);
for (i = 0; i < len; i++)
{
DBG ("opcode = %u; counter = %u;", keys[i], values[i]);
- opcode_submit (keys[i], values[i]);
+ submit_counter ("dns_opcode", opcode_str (keys[i]), values[i]);
}
pthread_mutex_lock (&rcode_mutex);
for (i = 0; i < len; i++)
{
DBG ("rcode = %u; counter = %u;", keys[i], values[i]);
- rcode_submit (keys[i], values[i]);
+ submit_counter ("dns_rcode", rcode_str (keys[i]), values[i]);
}
-}
-#else /* if !DNS_HAVE_READ */
-# define dns_read NULL
+
+ return (0);
+} /* int dns_read */
#endif
void module_register (void)
{
- plugin_register (MODULE_NAME, dns_init, dns_read, NULL);
- plugin_register ("dns_traffic", NULL, NULL, traffic_write);
- plugin_register ("dns_qtype", NULL, NULL, qtype_write);
- plugin_register ("dns_rcode", NULL, NULL, rcode_write);
- plugin_register ("dns_opcode", NULL, NULL, opcode_write);
+ plugin_register_data_set (&octets_ds);
+ plugin_register_data_set (&qtype_ds);
+ plugin_register_data_set (&opcode_ds);
+ plugin_register_data_set (&rcode_ds);
+
#if DNS_HAVE_READ
- cf_register (MODULE_NAME, dns_config, config_keys, config_keys_num);
+ plugin_register_config ("dns", dns_config, config_keys, config_keys_num);
+ plugin_register_init ("dns", dns_init);
+ plugin_register_read ("dns", dns_read);
#endif
-}
-
-#undef MODULE_NAME
+} /* void module_register */
/**
* collectd - src/processes.c
* Copyright (C) 2005 Lyonel Vincent
- * Copyright (C) 2006 Florian Forster (Mach code)
+ * Copyright (C) 2006-2007 Florian Forster (Mach code)
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
#define BUFSIZE 256
-static char *processes_file = "processes.rrd";
-static char *processes_ds_def[] =
+static data_source_t state_dsrc[1] =
{
- "DS:running:GAUGE:"COLLECTD_HEARTBEAT":0:65535",
- "DS:sleeping:GAUGE:"COLLECTD_HEARTBEAT":0:65535",
- "DS:zombies:GAUGE:"COLLECTD_HEARTBEAT":0:65535",
- "DS:stopped:GAUGE:"COLLECTD_HEARTBEAT":0:65535",
- "DS:paging:GAUGE:"COLLECTD_HEARTBEAT":0:65535",
- "DS:blocked:GAUGE:"COLLECTD_HEARTBEAT":0:65535",
- NULL
+ {"value", DS_TYPE_GAUGE, 0.0, 65535.0}
};
-static int processes_ds_num = 6;
-static char *ps_rss_file = "processes/ps_rss-%s.rrd";
-static char *ps_rss_ds_def[] =
+static data_set_t state_ds =
+{
+ "ps_state", 1, state_dsrc
+};
+
+static data_source_t rss_dsrc[1] =
{
/* max = 2^63 - 1 */
- "DS:byte:GAUGE:"COLLECTD_HEARTBEAT":0:9223372036854775807",
- NULL
+ {"value", DS_TYPE_GAUGE, 0.0, 9223372036854775807.0}
};
-static int ps_rss_ds_num = 1;
-static char *ps_cputime_file = "processes/ps_cputime-%s.rrd";
-static char *ps_cputime_ds_def[] =
+static data_set_t rss_ds =
+{
+ "ps_rss", 1, rss_dsrc
+};
+
+static data_source_t time_dsrc[2] =
{
/* 1 second in user-mode per second ought to be enough.. */
- "DS:user:COUNTER:"COLLECTD_HEARTBEAT":0:1000000",
- "DS:syst:COUNTER:"COLLECTD_HEARTBEAT":0:1000000",
- NULL
+ {"user", DS_TYPE_COUNTER, 0.0, 1000000.0},
+ {"syst", DS_TYPE_COUNTER, 0.0, 1000000.0}
};
-static int ps_cputime_ds_num = 2;
-static char *ps_count_file = "processes/ps_count-%s.rrd";
-static char *ps_count_ds_def[] =
+static data_set_t time_ds =
{
- "DS:processes:GAUGE:"COLLECTD_HEARTBEAT":0:65535",
- "DS:threads:GAUGE:"COLLECTD_HEARTBEAT":0:65535",
- NULL
+ "ps_cputime", 2, time_dsrc
+};
+
+static data_source_t count_dsrc[2] =
+{
+ /* 1 second in user-mode per second ought to be enough.. */
+ {"processes", DS_TYPE_GAUGE, 0.0, 1000000.0},
+ {"threads", DS_TYPE_GAUGE, 0.0, 1000000.0}
};
-static int ps_count_ds_num = 2;
-static char *ps_pagefaults_file = "processes/ps_pagefaults-%s.rrd";
-static char *ps_pagefaults_ds_def[] =
+static data_set_t count_ds =
+{
+ "ps_count", 2, count_dsrc
+};
+
+static data_source_t pagefaults_dsrc[2] =
{
/* max = 2^63 - 1 */
- "DS:minflt:COUNTER:"COLLECTD_HEARTBEAT":0:9223372036854775807",
- "DS:majflt:COUNTER:"COLLECTD_HEARTBEAT":0:9223372036854775807",
- NULL
+ {"minflt", DS_TYPE_COUNTER, 0.0, 9223372036854775807.0},
+ {"majflt", DS_TYPE_COUNTER, 0.0, 9223372036854775807.0}
};
-static int ps_pagefaults_ds_num = 2;
-static char *config_keys[] =
+static data_set_t pagefaults_ds =
+{
+ "ps_pagefaults", 2, pagefaults_dsrc
+};
+
+#if PROCESSES_HAVE_READ
+ #if HAVE_THREAD_INFO | KERNEL_LINUX
+static const char *config_keys[] =
{
"Process",
NULL
};
static int config_keys_num = 1;
+ #endif
typedef struct procstat_entry_s
{
struct procstat_entry_s *instances;
} procstat_t;
+ #if HAVE_THREAD_INFO | KERNEL_LINUX
static procstat_t *list_head_g = NULL;
+ #endif
#if HAVE_THREAD_INFO
static mach_port_t port_host_self;
} /* while (pse != NULL) */
} /* for (ps = list_head_g; ps != NULL; ps = ps->next) */
}
- #endif /* HAVE_THREAD_INFO | KERNEL_LINUX */
-static int ps_config (char *key, char *value)
+static int ps_config (const char *key, const char *value)
{
if (strcasecmp (key, "Process") == 0)
{
return (0);
}
+ #endif /* HAVE_THREAD_INFO | KERNEL_LINUX */
-static void ps_init (void)
+static int ps_init (void)
{
#if HAVE_THREAD_INFO
kern_return_t status;
mach_error_string (status));
pset_list = NULL;
pset_list_len = 0;
- return;
+ return (-1);
}
/* #endif HAVE_THREAD_INFO */
pagesize_g, CONFIG_HZ);
#endif /* KERNEL_LINUX */
- return;
-}
-
-static void ps_write (char *host, char *inst, char *val)
-{
- rrd_update_file (host, processes_file, val,
- processes_ds_def, processes_ds_num);
-}
-
-static void ps_rss_write (char *host, char *inst, char *val)
-{
- char filename[256];
- int status;
-
- status = snprintf (filename, 256, ps_rss_file, inst);
- if ((status < 1) || (status >= 256))
- return;
-
- rrd_update_file (host, filename, val, ps_rss_ds_def, ps_rss_ds_num);
-}
-
-static void ps_cputime_write (char *host, char *inst, char *val)
-{
- char filename[256];
- int status;
-
- status = snprintf (filename, 256, ps_cputime_file, inst);
- if ((status < 1) || (status >= 256))
- return;
-
- DBG ("host = %s; filename = %s; val = %s;",
- host, filename, val);
- rrd_update_file (host, filename, val,
- ps_cputime_ds_def, ps_cputime_ds_num);
-}
-
-static void ps_count_write (char *host, char *inst, char *val)
-{
- char filename[256];
- int status;
-
- status = snprintf (filename, 256, ps_count_file, inst);
- if ((status < 1) || (status >= 256))
- return;
-
- DBG ("host = %s; filename = %s; val = %s;",
- host, filename, val);
- rrd_update_file (host, filename, val,
- ps_count_ds_def, ps_count_ds_num);
-}
-
-static void ps_pagefaults_write (char *host, char *inst, char *val)
-{
- char filename[256];
- int status;
-
- status = snprintf (filename, 256, ps_pagefaults_file, inst);
- if ((status < 1) || (status >= 256))
- return;
-
- DBG ("host = %s; filename = %s; val = %s;",
- host, filename, val);
- rrd_update_file (host, filename, val,
- ps_pagefaults_ds_def, ps_pagefaults_ds_num);
-}
+ return (0);
+} /* int ps_init */
-#if PROCESSES_HAVE_READ
-static void ps_submit (int running,
- int sleeping,
- int zombies,
- int stopped,
- int paging,
- int blocked)
+static void ps_submit_state (const char *state, double value)
{
- char buf[BUFSIZE];
+ value_t values[1];
+ value_list_t vl = VALUE_LIST_INIT;
- if (snprintf (buf, BUFSIZE, "%u:%i:%i:%i:%i:%i:%i",
- (unsigned int) curtime,
- running, sleeping, zombies, stopped, paging,
- blocked) >= BUFSIZE)
- return;
+ values[0].gauge = value;
- DBG ("running = %i; sleeping = %i; zombies = %i; stopped = %i; paging = %i; blocked = %i;",
- running, sleeping, zombies, stopped, paging, blocked);
+ vl.values = values;
+ vl.values_len = 1;
+ vl.time = time (NULL);
+ strcpy (vl.host, hostname);
+ strcpy (vl.plugin, "processes");
+ strcpy (vl.plugin_instance, "");
+ strncpy (vl.type_instance, state, sizeof (vl.type_instance));
- plugin_submit (MODULE_NAME, "-", buf);
+ plugin_dispatch_values ("ps_state", &vl);
}
static void ps_submit_proc_list (procstat_t *ps)
{
- char buffer[64];
-
- if (ps == NULL)
- return;
-
- snprintf (buffer, 64, "%u:%lu",
- (unsigned int) curtime,
- ps->vmem_rss);
- buffer[63] = '\0';
- plugin_submit ("ps_rss", ps->name, buffer);
-
- snprintf (buffer, 64, "%u:%u:%u",
- (unsigned int) curtime,
- /* Make the counter overflow */
- (unsigned int) (ps->cpu_user_counter & 0xFFFFFFFF),
- (unsigned int) (ps->cpu_system_counter & 0xFFFFFFFF));
- buffer[63] = '\0';
- plugin_submit ("ps_cputime", ps->name, buffer);
-
- snprintf (buffer, 64, "%u:%lu:%lu",
- (unsigned int) curtime,
- ps->num_proc, ps->num_lwp);
- buffer[63] = '\0';
- plugin_submit ("ps_count", ps->name, buffer);
-
- snprintf (buffer, 64, "%u:%lu:%lu",
- (unsigned int) curtime,
- ps->vmem_minflt_counter, ps->vmem_majflt_counter);
- buffer[63] = '\0';
- plugin_submit ("ps_pagefaults", ps->name, buffer);
+ value_t values[2];
+ value_list_t vl = VALUE_LIST_INIT;
+
+ vl.values = values;
+ vl.values_len = 2;
+ vl.time = time (NULL);
+ strcpy (vl.host, hostname);
+ strcpy (vl.plugin, "processes");
+ strncpy (vl.plugin_instance, ps->name, sizeof (vl.plugin_instance));
+
+ vl.values[0].gauge = ps->vmem_rss;
+ vl.values_len = 1;
+ plugin_dispatch_values ("ps_rss", &vl);
+
+ vl.values[0].counter = ps->cpu_user_counter;
+ vl.values[1].counter = ps->cpu_system_counter;
+ vl.values_len = 2;
+ plugin_dispatch_values ("ps_cputime", &vl);
+
+ vl.values[0].gauge = ps->num_proc;
+ vl.values[1].gauge = ps->num_lwp;
+ vl.values_len = 2;
+ plugin_dispatch_values ("ps_count", &vl);
+
+ vl.values[0].counter = ps->vmem_minflt_counter;
+ vl.values[1].counter = ps->vmem_majflt_counter;
+ vl.values_len = 2;
+ plugin_dispatch_values ("ps_pagefaults", &vl);
DBG ("name = %s; num_proc = %lu; num_lwp = %lu; vmem_rss = %lu; "
"vmem_minflt_counter = %lu; vmem_majflt_counter = %lu; "
"cpu_user_counter = %lu; cpu_system_counter = %lu;",
ps->name, ps->num_proc, ps->num_lwp, ps->vmem_rss,
- ps->vmem_minflt_counter, ps->vmem_majflt_counter, ps->cpu_user_counter,
- ps->cpu_system_counter);
-
-}
+ ps->vmem_minflt_counter, ps->vmem_majflt_counter,
+ ps->cpu_user_counter, ps->cpu_system_counter);
+} /* void ps_submit_proc_list */
#if KERNEL_LINUX
static int *ps_read_tasks (int pid)
}
#endif /* HAVE_THREAD_INFO */
-static void ps_read (void)
+static int ps_read (void)
{
#if HAVE_THREAD_INFO
kern_return_t status;
}
} /* for (pset_list) */
- ps_submit (running, sleeping, zombies, stopped, -1, blocked);
+ ps_submit_state ("running", running);
+ ps_submit_state ("sleeping", sleeping);
+ ps_submit_state ("zombies", zombies);
+ ps_submit_state ("stopped", stopped);
+ ps_submit_state ("blocked", blocked);
for (ps = list_head_g; ps != NULL; ps = ps->next)
ps_submit_proc_list (ps);
if ((proc = opendir ("/proc")) == NULL)
{
syslog (LOG_ERR, "Cannot open `/proc': %s", strerror (errno));
- return;
+ return (-1);
}
while ((ent = readdir (proc)) != NULL)
closedir (proc);
- ps_submit (running, sleeping, zombies, stopped, paging, blocked);
+ ps_submit_state ("running", running);
+ ps_submit_state ("sleeping", sleeping);
+ ps_submit_state ("zombies", zombies);
+ ps_submit_state ("stopped", stopped);
+ ps_submit_state ("paging", paging);
+ ps_submit_state ("blocked", blocked);
for (ps_ptr = list_head_g; ps_ptr != NULL; ps_ptr = ps_ptr->next)
ps_submit_proc_list (ps_ptr);
#endif /* KERNEL_LINUX */
-}
-#else
-# define ps_read NULL
+
+ return (0);
+} /* int ps_read */
#endif /* PROCESSES_HAVE_READ */
void module_register (void)
{
- plugin_register (MODULE_NAME, ps_init, ps_read, ps_write);
- plugin_register ("ps_rss", NULL, NULL, ps_rss_write);
- plugin_register ("ps_cputime", NULL, NULL, ps_cputime_write);
- plugin_register ("ps_count", NULL, NULL, ps_count_write);
- plugin_register ("ps_pagefaults", NULL, NULL, ps_pagefaults_write);
+ plugin_register_data_set (&state_ds);
+ plugin_register_data_set (&rss_ds);
+ plugin_register_data_set (&time_ds);
+ plugin_register_data_set (&count_ds );
+ plugin_register_data_set (&pagefaults_ds );
+
+#if PROCESSES_HAVE_READ
+ #if HAVE_THREAD_INFO | KERNEL_LINUX
- cf_register (MODULE_NAME, ps_config, config_keys, config_keys_num);
+ plugin_register_config ("processes", ps_config,
+ config_keys, config_keys_num);
+ #endif
+ plugin_register_init ("processes", ps_init);
+ plugin_register_read ("processes", ps_read);
+#endif /* PROCESSES_HAVE_READ */
}
-#undef BUFSIZE
-#undef MODULE_NAME