From: Johan Wirén Date: Wed, 6 Feb 2013 22:37:00 +0000 (+0100) Subject: libvirt: Added support for memory allocation X-Git-Tag: collectd-5.3.0~28^2~3 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=055c714460257cd2b09f7d23aea4a300abe809ab;p=collectd.git libvirt: Added support for memory allocation --- diff --git a/README b/README index a8ec07b0..77ea6ff2 100644 --- a/README +++ b/README @@ -133,7 +133,7 @@ Features technique built into IBM's POWER processors. - libvirt - CPU, disk and network I/O statistics from virtual machines. + CPU, memory, disk and network I/O statistics from virtual machines. - madwifi Queries very detailed usage statistics from wireless LAN adapters and diff --git a/src/libvirt.c b/src/libvirt.c index c53a81d4..6b0cf9a4 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -178,6 +178,24 @@ init_value_list (value_list_t *vl, virDomainPtr dom) } /* void init_value_list */ static void +memory_submit (unsigned long memory, virDomainPtr dom, const char *type) +{ + value_t values[1]; + value_list_t vl = VALUE_LIST_INIT; + + init_value_list (&vl, dom); + + values[0].gauge = memory; + + vl.values = values; + vl.values_len = 1; + + sstrncpy (vl.type, type, sizeof (vl.type)); + + plugin_dispatch_values (&vl); +} + +static void cpu_submit (unsigned long long cpu_time, virDomainPtr dom, const char *type) { @@ -407,7 +425,7 @@ lv_read (void) interface_devices[i].path); #endif - /* Get CPU usage, VCPU usage for each domain. */ + /* Get CPU usage, memory, VCPU usage for each domain. */ for (i = 0; i < nr_domains; ++i) { virDomainInfo info; virVcpuInfoPtr vinfo = NULL; @@ -423,6 +441,7 @@ lv_read (void) } cpu_submit (info.cpuTime, domains[i], "virt_cpu_total"); + memory_submit (info.memory, domains[i], "memory"); vinfo = malloc (info.nrVirtCpu * sizeof (vinfo[0])); if (vinfo == NULL) {