src/utils_db_query.c: Fix use-after-free.
[collectd.git] / src / libvirt.c
index 10ca37f..87b71e6 100644 (file)
@@ -191,6 +191,7 @@ memory_submit (gauge_t memory, virDomainPtr dom)
     vl.values_len = 1;
 
     sstrncpy (vl.type, "memory", sizeof (vl.type));
+    sstrncpy (vl.type_instance, "total", sizeof (vl.type_instance));
 
     plugin_dispatch_values (&vl);
 }
@@ -440,8 +441,14 @@ lv_read (void)
             continue;
         }
 
+        if (info.state != VIR_DOMAIN_RUNNING)
+        {
+            /* only gather stats for running domains */
+            continue;
+        }
+
         cpu_submit (info.cpuTime, domains[i], "virt_cpu_total");
-        memory_submit ((gauge_t) info.memory, domains[i]);
+        memory_submit ((gauge_t) info.memory * 1024, domains[i]);
 
         vinfo = malloc (info.nrVirtCpu * sizeof (vinfo[0]));
         if (vinfo == NULL) {