X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Flibvirt.c;h=cfabaaa235d6efe81da7896e4c51185d6afa08a3;hb=282c39de93158c8fbdc9640d0a39963602f57f4c;hp=c53a81d4b5d1e4261667954b079d26e36a797e07;hpb=d6d42818a8794a756727a6bb56e3680c7eefd6f9;p=collectd.git diff --git a/src/libvirt.c b/src/libvirt.c index c53a81d4..cfabaaa2 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -178,6 +178,25 @@ init_value_list (value_list_t *vl, virDomainPtr dom) } /* void init_value_list */ static void +memory_submit (gauge_t memory, virDomainPtr dom) +{ + 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, "memory", sizeof (vl.type)); + sstrncpy (vl.type_instance, "total", sizeof (vl.type_instance)); + + plugin_dispatch_values (&vl); +} + +static void cpu_submit (unsigned long long cpu_time, virDomainPtr dom, const char *type) { @@ -407,7 +426,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 +442,7 @@ lv_read (void) } cpu_submit (info.cpuTime, domains[i], "virt_cpu_total"); + memory_submit ((gauge_t) info.memory * 1024, domains[i]); vinfo = malloc (info.nrVirtCpu * sizeof (vinfo[0])); if (vinfo == NULL) {