From a18a9abda421484791f8eaac270794903f1438be Mon Sep 17 00:00:00 2001 From: Pavel Rochnyack Date: Sun, 12 May 2019 15:53:08 +0700 Subject: [PATCH] virt plugin: Do not report 'domain_state' metric when not enabled by ExtraStats PR #2701 adds 'domain_state' metric and ExtraStats's option `domain_state` selector behaviour was changed: now it enables metric, not notification. Removed inconsistency between documentation and implementation. Not all `get_domain_state` calls was covered by selector check. As result, metric was always sent for inactive domains. That is fixed now. --- src/collectd.conf.pod | 4 +--- src/virt.c | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod index fb0751a7..800c0d22 100644 --- a/src/collectd.conf.pod +++ b/src/collectd.conf.pod @@ -9466,9 +9466,7 @@ I<0.9.5> or later. =item B: report disk errors if any occured. Requires libvirt API version I<0.9.10> or later. -=item B: report domain state and reason in human-readable format as -a notification. If libvirt API version I<0.9.2> or later is available, domain -reason will be included in notification. +=item B: report domain state and reason as 'domain_state' metric. =item B: report file system information as a notification. Requires libvirt API version I<1.2.11> or later. Can be collected only if I diff --git a/src/virt.c b/src/virt.c index 58bacab7..1267dbcb 100644 --- a/src/virt.c +++ b/src/virt.c @@ -2297,7 +2297,7 @@ static int lv_read(user_data_t *ud) { if (dom->active) status = get_domain_metrics(dom); #ifdef HAVE_DOM_REASON - else + else if (extra_stats & ex_stats_domain_state) status = submit_domain_state(dom->ptr); #endif -- 2.11.0