summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 46ba00e)
raw | patch | inline | side by side (parent: 46ba00e)
author | Florian Forster <octo@collectd.org> | |
Sat, 17 Mar 2012 10:18:57 +0000 (11:18 +0100) | ||
committer | Florian Forster <octo@collectd.org> | |
Sat, 17 Mar 2012 10:18:57 +0000 (11:18 +0100) |
src/collectd.conf.in | patch | blob | history | |
src/collectd.conf.pod | patch | blob | history | |
src/ethstat.c | patch | blob | history |
diff --git a/src/collectd.conf.in b/src/collectd.conf.in
index befb7abae403abd7d7acfde74de1fa7bdb847912..f3ef6759b1fc7ee6573e7b621076954be7fbc503 100644 (file)
--- a/src/collectd.conf.in
+++ b/src/collectd.conf.in
# Interface "eth0"
# Map "rx_csum_offload_errors" "if_rx_errors" "checksum_offload"
# Map "multicast" "if_multicast"
+# MappedOnly false
#</Plugin>
#<Plugin exec>
diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod
index bd14d0e6fa8d2e805578edfc5ae0704c8528c02c..f89af084062a533a4dab052627bd3123c84a20bd 100644 (file)
--- a/src/collectd.conf.pod
+++ b/src/collectd.conf.pod
@@ -1300,6 +1300,11 @@ instance> set to I<Name>, the name of the metric as reported by the driver. If
an appropriate B<Map> option exists, the given I<Type> and, optionally,
I<TypeInstance> will be used.
+=item B<MappedOnly> B<true>|B<false>
+
+When set to B<true>, only metrics that can be mapped to to a I<type> will be
+collected, all other metrics will be ignored. Defaults to B<false>.
+
=back
=head2 Plugin C<exec>
diff --git a/src/ethstat.c b/src/ethstat.c
index 7507bd97851cbbb12ee256a1e067fa1196b9343b..bc02477176016307e095f9b7550e2fe0145f78e3 100644 (file)
--- a/src/ethstat.c
+++ b/src/ethstat.c
/**
* collectd - src/ethstat.c
* Copyright (C) 2011 Cyril Feraudet
+ * Copyright (C) 2012 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
*
* Authors:
* Cyril Feraudet <cyril at feraudet.com>
+ * Florian "octo" Forster <octo@collectd.org>
**/
#include "collectd.h"
#include "plugin.h"
#include "configfile.h"
#include "utils_avltree.h"
+#include "utils_complain.h"
#if HAVE_SYS_IOCTL_H
# include <sys/ioctl.h>
static c_avl_tree_t *value_map = NULL;
+static _Bool collect_mapped_only = 0;
+
static int ethstat_add_interface (const oconfig_item_t *ci) /* {{{ */
{
char **tmp;
ethstat_add_interface (child);
else if (strcasecmp ("Map", child->key) == 0)
ethstat_add_map (child);
+ else if (strcasecmp ("MappedOnly", child->key) == 0)
+ (void) cf_util_get_boolean (child, &collect_mapped_only);
else
WARNING ("ethstat plugin: The config option \"%s\" is unknown.",
child->key);
static void ethstat_submit_value (const char *device,
const char *type_instance, derive_t value)
{
+ static c_complain_t complain_no_map = C_COMPLAIN_INIT_STATIC;
+
value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
value_map_t *map = NULL;
if (value_map != NULL)
c_avl_get (value_map, type_instance, (void *) &map);
+ /* If the "MappedOnly" option is specified, ignore unmapped values. */
+ if (collect_mapped_only && (map == NULL))
+ {
+ if (value_map == NULL)
+ c_complain (LOG_WARNING, &complain_no_map,
+ "ethstat plugin: The \"MappedOnly\" option has been set to true, "
+ "but no mapping has been configured. All values will be ignored!");
+ return;
+ }
+
values[0].derive = value;
vl.values = values;
vl.values_len = 1;