libvirt: Added support for memory allocation
authorJohan Wirén <johan.wiren.se@gmail.com>
Wed, 6 Feb 2013 22:37:00 +0000 (23:37 +0100)
committerJohan Wirén <johan.wiren.se@gmail.com>
Thu, 21 Feb 2013 18:07:43 +0000 (19:07 +0100)
README
src/libvirt.c

diff --git a/README b/README
index a8ec07b..77ea6ff 100644 (file)
--- 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
index c53a81d..6b0cf9a 100644 (file)
@@ -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) {