From fe5167843e22b7b1ca4c7e5ba0e1d0df387b0094 Mon Sep 17 00:00:00 2001 From: Pavel Rochnyack Date: Fri, 24 May 2019 02:37:53 +0700 Subject: [PATCH] virt plugin: Added ExtraStats selector 'memory' This allows to disable virDomainMemoryStats calls when hypervisor/drivers does not supports that function or it does not provide additional details. --- src/collectd.conf.pod | 3 +++ src/virt.c | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod index 71931c2b..3395bed1 100644 --- a/src/collectd.conf.pod +++ b/src/collectd.conf.pod @@ -9520,6 +9520,9 @@ Requires libvirt API version I<1.2.9> or later. a domain. Only one type of job statistics can be collected at the same time. Requires libvirt API version I<1.2.9> or later. +=item B: report statistics about memory usage details, provided +by libvirt virDomainMemoryStats() function. + =item B: report the physical user/system cpu time consumed by the hypervisor, per-vm. Requires libvirt API version I<0.9.11> or later. diff --git a/src/virt.c b/src/virt.c index 9cfdb052..2a97df32 100644 --- a/src/virt.c +++ b/src/virt.c @@ -610,7 +610,8 @@ enum ex_stats { #endif ex_stats_disk_allocation = 1 << 10, ex_stats_disk_capacity = 1 << 11, - ex_stats_disk_physical = 1 << 12 + ex_stats_disk_physical = 1 << 12, + ex_stats_memory = 1 << 13 }; static unsigned int extra_stats = ex_stats_none; @@ -641,6 +642,7 @@ static const struct ex_stats_item ex_stats_table[] = { {"disk_allocation", ex_stats_disk_allocation}, {"disk_capacity", ex_stats_disk_capacity}, {"disk_physical", ex_stats_disk_physical}, + {"memory", ex_stats_memory}, {NULL, ex_stats_none}, }; @@ -2019,7 +2021,8 @@ static int get_domain_metrics(domain_t *domain) { memory_submit(domain->ptr, (gauge_t)info.memory * 1024); GET_STATS(get_vcpu_stats, "vcpu stats", domain->ptr, info.nrVirtCpu); - GET_STATS(get_memory_stats, "memory stats", domain->ptr); + if (extra_stats & ex_stats_memory) + GET_STATS(get_memory_stats, "memory stats", domain->ptr); #ifdef HAVE_PERF_STATS if (extra_stats & ex_stats_perf) -- 2.11.0