network plugin: Avoid "status may be used uninitialized" warning.
[collectd.git] / src / libvirt.c
index f8be994..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,6 +441,12 @@ 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 * 1024, domains[i]);