then
AC_DEFINE(_POSIX_PTHREAD_SEMANTICS, 1, [Define to enforce POSIX thread semantics under Solaris.])
AC_DEFINE(_REENTRANT, 1, [Define to enable reentrancy interfaces.])
+
+ AC_MSG_CHECKING([whether compiler builds 64bit binaries])
+ AC_PREPROC_IFELSE([AC_LANG_PROGRAM([
+ #ifndef _LP64
+ # error "Compiler not in 64bit mode."
+ #endif
+ ])],
+ [AC_MSG_RESULT([yes])],
+ [
+ AC_MSG_RESULT([no])
+ AC_MSG_NOTICE([Solaris detected. Please consider building a 64-bit binary.])
+ ])
fi
+
if test "x$ac_system" = "xAIX"
then
AC_DEFINE(_THREAD_SAFE_ERRNO, 1, [Define to use the thread-safe version of errno under AIX.])
#endif
])
+AC_CHECK_TYPES([struct ip6_ext], [], [],
+[#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_IP6_H
+# include <netinet/ip6.h>
+#endif
+])
+
# For cpu modules
AC_CHECK_HEADERS(sys/dkstat.h)
if test "x$ac_system" = "xDarwin"
#endif
])
-if test "x$have_sys_swap_h$ac_system" = "xnoSolaris"
-then
- hint_64=""
- if test "x$GCC" = "xyes"
- then
- hint_64="CFLAGS='-m64'"
- else
- hint_64="CFLAGS='-xarch=v9'"
- fi
- AC_MSG_NOTICE([Solaris detected and sys/swap.h not usable. Try building a 64-bit binary ($hint_64 ./configure).])
-fi
-
# For load module
# For the processes plugin
# For users module
License: GPLv2
Group: System Environment/Daemons
BuildRoot: %{_tmppath}/%{name}-%{version}-root
-BuildRequires: libgcrypt-devel, kernel-headers, libtool-ltdl-devel, libcap-devel
+BuildRequires: libgcrypt-devel, kernel-headers, libtool-ltdl-devel, libcap-devel, flex, bison
Vendor: collectd development team <collectd@verplant.org>
%if 0%{?el7:1}
%define _with_zookeeper --disable-zookeeper
%endif
+export YACC=bison
+export YFLAGS=-y
+
%configure CFLAGS="%{optflags} -DLT_LAZY_OR_NOW=\"RTLD_LAZY|RTLD_GLOBAL\"" \
--disable-static \
--without-included-ltdl \
"Hostname defaults to the local hostname if omitted (e.g., uptime/uptime).\n"
"No error is returned if the specified identifier does not exist.\n"
- "\n"PACKAGE" "VERSION", http://collectd.org/\n"
+ "\n"PACKAGE_NAME" "PACKAGE_VERSION", http://collectd.org/\n"
"by Florian octo Forster <octo@collectd.org>\n"
"for contributions see `AUTHORS'\n"
, name);
"\nFor <collectd options> see collectd.conf(5).\n"
- "\n"PACKAGE" "VERSION", http://collectd.org/\n"
+ "\n"PACKAGE_NAME" "PACKAGE_VERSION", http://collectd.org/\n"
"by Florian octo Forster <octo@collectd.org>\n"
"for contributions see `AUTHORS'\n", name);
exit (0);
AM_CPPFLAGS += -DPLUGINDIR='"${pkglibdir}"'
AM_CPPFLAGS += -DPKGDATADIR='"${pkgdatadir}"'
+# Link to these libraries..
+COMMON_LIBS =
+if BUILD_WITH_LIBRT
+COMMON_LIBS += -lrt
+endif
+if BUILD_WITH_LIBPOSIX4
+COMMON_LIBS += -lposix4
+endif
+if BUILD_WITH_LIBSOCKET
+COMMON_LIBS += -lsocket
+endif
+if BUILD_WITH_LIBRESOLV
+COMMON_LIBS += -lresolv
+endif
+if BUILD_WITH_LIBPTHREAD
+COMMON_LIBS += -lpthread
+endif
+if BUILD_WITH_LIBKSTAT
+COMMON_LIBS += -lkstat
+endif
+if BUILD_WITH_LIBDEVINFO
+COMMON_LIBS += -ldevinfo
+endif
+
AUTOMAKE_OPTIONS = subdir-objects
sbin_PROGRAMS = collectd
collectd_CPPFLAGS = $(AM_CPPFLAGS) $(LTDLINCL)
collectd_CFLAGS = $(AM_CFLAGS)
collectd_LDFLAGS = -export-dynamic
-collectd_LDADD = libavltree.la libcommon.la libheap.la -lm
+collectd_LDADD = libavltree.la libcommon.la libheap.la -lm $(COMMON_LIBS)
collectd_DEPENDENCIES =
-# Link to these libraries..
-if BUILD_WITH_LIBRT
-collectd_LDADD += -lrt
-endif
-if BUILD_WITH_LIBPOSIX4
-collectd_LDADD += -lposix4
-endif
-if BUILD_WITH_LIBSOCKET
-collectd_LDADD += -lsocket
-endif
-if BUILD_WITH_LIBRESOLV
-collectd_LDADD += -lresolv
-endif
-if BUILD_WITH_LIBPTHREAD
-collectd_LDADD += -lpthread
-endif
-if BUILD_WITH_LIBKSTAT
-collectd_LDADD += -lkstat
-endif
-if BUILD_WITH_LIBDEVINFO
-collectd_LDADD += -ldevinfo
-endif
-if BUILD_AIX
-collectd_LDFLAGS += -Wl,-bexpall,-brtllib
-endif
-
# The daemon needs to call sg_init, so we need to link it against libstatgrab,
# too. -octo
if BUILD_WITH_LIBSTATGRAB
TESTS = test_common test_utils_avltree test_utils_heap
test_common_SOURCES = common_test.c ../testing.h
-test_common_LDADD = libcommon.la libplugin_mock.la
+test_common_LDADD = libcommon.la libplugin_mock.la $(COMMON_LIBS)
test_utils_avltree_SOURCES = utils_avltree_test.c ../testing.h
-test_utils_avltree_LDADD = libavltree.la
+test_utils_avltree_LDADD = libavltree.la $(COMMON_LIBS)
test_utils_heap_SOURCES = utils_heap_test.c ../testing.h
-test_utils_heap_LDADD = libheap.la
+test_utils_heap_LDADD = libheap.la $(COMMON_LIBS)
*/
static void exit_usage (int status)
{
- printf ("Usage: "PACKAGE" [OPTIONS]\n\n"
+ printf ("Usage: "PACKAGE_NAME" [OPTIONS]\n\n"
"Available options:\n"
" General:\n"
" PID file "PIDFILE"\n"
" Plugin directory "PLUGINDIR"\n"
" Data directory "PKGLOCALSTATEDIR"\n"
- "\n"PACKAGE" "VERSION", http://collectd.org/\n"
+ "\n"PACKAGE_NAME" "PACKAGE_VERSION", http://collectd.org/\n"
"by Florian octo Forster <octo@collectd.org>\n"
"for contributions see `AUTHORS'\n");
exit (status);
if (IS_TRUE (global_option_get ("AutoLoadPlugin")))
{
+ plugin_ctx_t ctx;
+ plugin_ctx_t old_ctx;
int status;
+ /* default to the global interval set before loading this plugin */
+ memset (&ctx, 0, sizeof (ctx));
+ ctx.interval = cf_get_default_interval ();
+
+ old_ctx = plugin_set_ctx (ctx);
status = plugin_load (name, /* flags = */ 0);
+ /* reset to the "global" context */
+ plugin_set_ctx (old_ctx);
+
if (status != 0)
{
ERROR ("Automatically loading plugin \"%s\" failed "
continue;
}
+ memset (&pse, 0, sizeof (pse));
pse.id = pid;
pse.age = 0;
}
} /* if (process has argument list) */
+ memset (&pse, 0, sizeof (pse));
pse.id = procs[i].p_pid;
pse.age = 0;
pse.io_syscr = -1;
pse.io_syscw = -1;
+ pse.cswitch_vol = -1;
+ pse.cswitch_invol = -1;
+
ps_list_add (procs[i].p_comm, have_cmdline ? cmdline : NULL, &pse);
} /* if ((proc_ptr == NULL) || (proc_ptr->p_pid != procs[i].p_pid)) */
continue;
}
+ memset (&pse, 0, sizeof (pse));
pse.id = pid;
pse.age = 0;
pse.io_syscr = ps.io_syscr;
pse.io_syscw = ps.io_syscw;
+ pse.cswitch_vol = -1;
+ pse.cswitch_invol = -1;
+
switch (state)
{
case 'R': running++; break;
/* Query status with libatasmart */
smart_handle_disk (devpath);
+ udev_device_unref (dev);
}
udev_enumerate_unref (enumerate);
return (0);
} /* }}} int statsd_metric_add */
+static void statsd_metric_free (statsd_metric_t *metric) /* {{{ */
+{
+ if (metric == NULL)
+ return;
+
+ if (metric->latency != NULL)
+ {
+ latency_counter_destroy (metric->latency);
+ metric->latency = NULL;
+ }
+
+ if (metric->set != NULL)
+ {
+ void *key;
+ void *value;
+
+ while (c_avl_pick (metric->set, &key, &value) == 0)
+ {
+ sfree (key);
+ assert (value == NULL);
+ }
+
+ c_avl_destroy (metric->set);
+ metric->set = NULL;
+ }
+
+ sfree (metric);
+} /* }}} void statsd_metric_free */
+
static int statsd_parse_value (char const *str, value_t *ret_value) /* {{{ */
{
char *endptr = NULL;
else if (metric->type == STATSD_TIMER)
{
size_t i;
+ _Bool have_events = (metric->updates_num > 0);
- if (metric->updates_num == 0)
- return (0);
-
+ /* Make sure all timer metrics share the *same* timestamp. */
vl.time = cdtime ();
ssnprintf (vl.type_instance, sizeof (vl.type_instance),
"%s-average", name);
- values[0].gauge = CDTIME_T_TO_DOUBLE (
- latency_counter_get_average (metric->latency));
+ values[0].gauge = have_events
+ ? CDTIME_T_TO_DOUBLE (latency_counter_get_average (metric->latency))
+ : NAN;
plugin_dispatch_values (&vl);
if (conf_timer_lower) {
ssnprintf (vl.type_instance, sizeof (vl.type_instance),
"%s-lower", name);
- values[0].gauge = CDTIME_T_TO_DOUBLE (
- latency_counter_get_min (metric->latency));
+ values[0].gauge = have_events
+ ? CDTIME_T_TO_DOUBLE (latency_counter_get_min (metric->latency))
+ : NAN;
plugin_dispatch_values (&vl);
}
if (conf_timer_upper) {
ssnprintf (vl.type_instance, sizeof (vl.type_instance),
"%s-upper", name);
- values[0].gauge = CDTIME_T_TO_DOUBLE (
- latency_counter_get_max (metric->latency));
+ values[0].gauge = have_events
+ ? CDTIME_T_TO_DOUBLE (latency_counter_get_max (metric->latency))
+ : NAN;
plugin_dispatch_values (&vl);
}
if (conf_timer_sum) {
ssnprintf (vl.type_instance, sizeof (vl.type_instance),
"%s-sum", name);
- values[0].gauge = CDTIME_T_TO_DOUBLE (
- latency_counter_get_sum (metric->latency));
+ values[0].gauge = have_events
+ ? CDTIME_T_TO_DOUBLE (latency_counter_get_sum (metric->latency))
+ : NAN;
plugin_dispatch_values (&vl);
}
{
ssnprintf (vl.type_instance, sizeof (vl.type_instance),
"%s-percentile-%.0f", name, conf_timer_percentile[i]);
- values[0].gauge = CDTIME_T_TO_DOUBLE (
- latency_counter_get_percentile (
- metric->latency, conf_timer_percentile[i]));
+ values[0].gauge = have_events
+ ? CDTIME_T_TO_DOUBLE (latency_counter_get_percentile (metric->latency, conf_timer_percentile[i]))
+ : NAN;
plugin_dispatch_values (&vl);
}
}
sfree (name);
- sfree (metric);
+ statsd_metric_free (metric);
}
pthread_mutex_unlock (&metrics_lock);
if (total < used)
continue;
- swap_submit_usage (path, used, total - used, NULL, NAN);
+ swap_submit_usage (path, used * 1024.0, (total - used) * 1024.0,
+ NULL, NAN);
}
fclose (fh);
if (swap_used < 0.0)
return (EINVAL);
- swap_submit_usage (NULL, swap_used, swap_free,
- isnan (swap_cached) ? NULL : "cached", swap_cached);
+ swap_submit_usage (NULL, swap_used * 1024.0, swap_free * 1024.0,
+ isnan (swap_cached) ? NULL : "cached",
+ isnan (swap_cached) ? NAN : swap_cached * 1024.0);
return (0);
} /* }}} int swap_read_combined */
return (-1);
}
+ memset(&ud, '\0', sizeof(ud));
+
for (i = 0; i < tail_match_list_num; i++)
{
ud.data = (void *)tail_match_list[i];
if (md->data_source_type == -1)
return (EINVAL);
- if ((md->value_from >= fields_num) || (id->time_from >= fields_num))
+ if (md->value_from >= fields_num)
+ return (EINVAL);
+
+ if (id->time_from >= 0 && (id->time_from >= fields_num))
return (EINVAL);
t = 0;
sfree(id);
}
-static int tcsv_config_add_instance_collect(instance_definition_t *id, oconfig_item_t *ci){
+static int tcsv_config_add_instance_collect(instance_definition_t *id, oconfig_item_t *ci) {
metric_definition_t *metric;
+ metric_definition_t **metric_list;
+ size_t metric_list_size;
int i;
- if (ci->values_num < 1){
+ if (ci->values_num < 1) {
WARNING("tail_csv plugin: The `Collect' config option needs at least one argument.");
return (-1);
}
- /* Verify string arguments */
- for (i = 0; i < ci->values_num; ++i)
- if (ci->values[i].type != OCONFIG_TYPE_STRING){
+ metric_list_size = id->metric_list_len + (size_t) ci->values_num;
+ metric_list = realloc (id->metric_list, sizeof (*id->metric_list) * metric_list_size);
+ if (metric_list == NULL)
+ return (-1);
+ id->metric_list = metric_list;
+
+ for (i = 0; i < ci->values_num; i++) {
+ char *metric_name;
+
+ if (ci->values[i].type != OCONFIG_TYPE_STRING) {
WARNING("tail_csv plugin: All arguments to `Collect' must be strings.");
- return (-1);
+ continue;
}
+ metric_name = ci->values[i].value.string;
- id->metric_list = (metric_definition_t **)malloc(sizeof(metric_definition_t *) * ci->values_num);
- if (id->metric_list == NULL)
- return (-1);
-
- for (i = 0; i < ci->values_num; ++i){
for (metric = metric_head; metric != NULL; metric = metric->next)
- if (strcasecmp(ci->values[i].value.string, metric->name) == 0)
+ if (strcasecmp(metric_name, metric->name) == 0)
break;
- if (metric == NULL){
- WARNING("tail_csv plugin: `Collect' argument not found `%s'.", ci->values[i].value.string);
- return (-1);
+ if (metric == NULL) {
+ WARNING ("tail_csv plugin: `Collect' argument not found `%s'.", metric_name);
+ continue;
}
- id->metric_list[i] = metric;
+ id->metric_list[id->metric_list_len] = metric;
id->metric_list_len++;
}
/* If this entry was created while reading the files (ant not when handling
* the configuration) remove it now. */
if ((pe->flags & (PORT_COLLECT_LOCAL
- | PORT_COLLECT_REMOTE
- | PORT_IS_LISTENING)) == 0)
+ | PORT_COLLECT_REMOTE
+ | PORT_IS_LISTENING)) == 0)
{
port_entry_t *next = pe->next;
DEBUG ("tcpconns plugin: Removing temporary entry "
- "for listening port %"PRIu16, pe->port);
+ "for listening port %"PRIu16, pe->port);
if (prev == NULL)
- port_list_head = next;
+ port_list_head = next;
else
- prev->next = next;
+ prev->next = next;
sfree (pe);
pe = next;
memset (pe->count_remote, '\0', sizeof (pe->count_remote));
pe->flags &= ~PORT_IS_LISTENING;
+ prev = pe;
pe = pe->next;
}
} /* void conn_reset_port_entry */
#elif HAVE_UTMP_H
# include <utmp.h>
/* #endif HAVE_UTMP_H */
-
-#else
-# error "No applicable input method."
#endif
static void users_submit (gauge_t value)
# error "`struct udphdr' is unusable."
#endif
+#if HAVE_NETINET_IP6_H && HAVE_STRUCT_IP6_EXT
+# define HAVE_IPV6 1
+#endif
+
#include "utils_dns.h"
/*
return 1;
}
-#if HAVE_NETINET_IP6_H
+#if HAVE_IPV6
static int
handle_ipv6 (struct ip6_hdr *ipv6, int len)
{
return (1); /* Success */
} /* int handle_ipv6 */
-/* #endif HAVE_NETINET_IP6_H */
+/* #endif HAVE_IPV6 */
-#else /* if !HAVE_NETINET_IP6_H */
+#else /* if !HAVE_IPV6 */
static int
handle_ipv6 (__attribute__((unused)) void *pkg,
__attribute__((unused)) int len)
{
return (0);
}
-#endif /* !HAVE_NETINET_IP6_H */
+#endif /* !HAVE_IPV6 */
static int
handle_ip(const struct ip *ip, int len)
if (strncmp ("nr_", key, strlen ("nr_")) == 0)
{
char *inst = key + strlen ("nr_");
- value_t value = { .gauge = gauge };
- submit_one (NULL, "vmpage_number", inst, value);
+ if (strcmp(inst, "dirtied") == 0 || strcmp(inst, "written") == 0)
+ {
+ value_t value = { .derive = counter };
+ submit_one (NULL, "vmpage_action", inst, value);
+ }
+ else
+ {
+ value_t value = { .gauge = gauge };
+ submit_one (NULL, "vmpage_number", inst, value);
+ }
}
/*