From: Pavel Rochnyack Date: Thu, 23 May 2019 21:10:12 +0000 (+0700) Subject: virt plugin: Added ExtraStats selector 'vcpu' X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=a620282e87a3f5ac7c976d4f1f0ce4d87a14b3ff;p=collectd.git virt plugin: Added ExtraStats selector 'vcpu' This allows to disable virDomainGetVcpus calls when hypervisor/driver does not supports that function. Closes: #2615 --- diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod index 3395bed1..ed49195e 100644 --- a/src/collectd.conf.pod +++ b/src/collectd.conf.pod @@ -9531,6 +9531,8 @@ metrics they must be enabled for domain and supported by the platform. Requires libvirt API version I<1.3.3> or later. B: I metrics can't be collected if I plugin is enabled. +=item B: report domain virtual CPUs utilisation. + =item B: report pinning of domain VCPUs to host physical CPUs. =item B: report 'disk_physical' statistic for disk device. diff --git a/src/virt.c b/src/virt.c index 2a97df32..17420269 100644 --- a/src/virt.c +++ b/src/virt.c @@ -611,7 +611,8 @@ enum ex_stats { ex_stats_disk_allocation = 1 << 10, ex_stats_disk_capacity = 1 << 11, ex_stats_disk_physical = 1 << 12, - ex_stats_memory = 1 << 13 + ex_stats_memory = 1 << 13, + ex_stats_vcpu = 1 << 14 }; static unsigned int extra_stats = ex_stats_none; @@ -643,6 +644,7 @@ static const struct ex_stats_item ex_stats_table[] = { {"disk_capacity", ex_stats_disk_capacity}, {"disk_physical", ex_stats_disk_physical}, {"memory", ex_stats_memory}, + {"vcpu", ex_stats_vcpu}, {NULL, ex_stats_none}, }; @@ -1613,7 +1615,8 @@ static int get_vcpu_stats(virDomainPtr domain, unsigned short nr_virt_cpu) { } for (int i = 0; i < nr_virt_cpu; ++i) { - vcpu_submit(vinfo[i].cpuTime, domain, vinfo[i].number, "virt_vcpu"); + if (extra_stats & ex_stats_vcpu) + vcpu_submit(vinfo[i].cpuTime, domain, vinfo[i].number, "virt_vcpu"); if (extra_stats & ex_stats_vcpupin) vcpu_pin_submit(domain, max_cpus, i, cpumaps, cpu_map_len); } @@ -2020,7 +2023,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); + if (extra_stats & (ex_stats_vcpu | ex_stats_vcpupin)) + GET_STATS(get_vcpu_stats, "vcpu stats", domain->ptr, info.nrVirtCpu); if (extra_stats & ex_stats_memory) GET_STATS(get_memory_stats, "memory stats", domain->ptr);