From 3db6326f553512b1d58a9dd284d4243211320f43 Mon Sep 17 00:00:00 2001 From: Pavel Rochnyack Date: Wed, 5 Dec 2018 14:29:31 +0700 Subject: [PATCH] virt plugin: New options: ReportBlockDevices and ReportNetworkInterfaces This allows to disable unneeded reports if stats are gathered by another plugin. --- src/collectd.conf.pod | 10 ++++++++++ src/virt.c | 19 +++++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod index 09ad826b..1251d245 100644 --- a/src/collectd.conf.pod +++ b/src/collectd.conf.pod @@ -9356,6 +9356,16 @@ When B is used in B or B, this describes where the hostname is located in the libvirt metadata. The default is I. +=item B B|B + +Enabled by default. Allows to disable stats reporting of block devices for +whole plugin. + +=item B B|B + +Enabled by default. Allows to disable stats reporting of network interfaces for +whole plugin. + =item B B Report additional extra statistics. The default is no extra statistics, preserving diff --git a/src/virt.c b/src/virt.c index 56e44fbd..876fe30a 100644 --- a/src/virt.c +++ b/src/virt.c @@ -143,6 +143,9 @@ static const char *config_keys[] = {"Connection", /* PersistentNotification is false by default */ static bool persistent_notification = false; +static bool report_block_devices = true; +static bool report_network_interfaces = true; + /* Thread used for handling libvirt notifications events */ static virt_notif_thread_t notif_thread; @@ -1368,6 +1371,16 @@ static int lv_config(const char *key, const char *value) { return 0; } + if (strcasecmp(key, "ReportBlockDevices") == 0) { + report_block_devices = IS_TRUE(value); + return 0; + } + + if (strcasecmp(key, "ReportNetworkInterfaces") == 0) { + report_network_interfaces = IS_TRUE(value); + return 0; + } + /* Unrecognised option. */ return -1; } @@ -2624,10 +2637,12 @@ static int refresh_lists(struct lv_read_instance *inst) { goto cont; /* Block devices. */ - lv_add_block_devices(state, dom, domname, xpath_ctx); + if (report_block_devices) + lv_add_block_devices(state, dom, domname, xpath_ctx); /* Network interfaces. */ - lv_add_network_interfaces(state, dom, domname, xpath_ctx); + if (report_network_interfaces) + lv_add_network_interfaces(state, dom, domname, xpath_ctx); cont: if (xpath_ctx) -- 2.11.0