virt plugin: only gather stats for running domains
[collectd.git] / src / libvirt.c
index 91fda7a..4ab8bd5 100644 (file)
@@ -306,6 +306,12 @@ lv_read (void)
             continue;
         }
 
+        if (info.state != VIR_DOMAIN_RUNNING)
+        {
+            /* only gather stats for running domains */
+            continue;
+        }
+
         cpu_submit (info.cpuTime, t, domains[i], "virt_cpu_total");
 
         vinfo = malloc (info.nrVirtCpu * sizeof (vinfo[0]));
@@ -665,8 +671,6 @@ init_value_list (value_list_t *vl, time_t t, virDomainPtr dom)
     int i, n;
     const char *name;
     char uuid[VIR_UUID_STRING_BUFLEN];
-    char  *host_ptr;
-    size_t host_len;
 
     vl->time = t;
     vl->interval = interval_g;
@@ -674,8 +678,6 @@ init_value_list (value_list_t *vl, time_t t, virDomainPtr dom)
     sstrncpy (vl->plugin, "libvirt", sizeof (vl->plugin));
 
     vl->host[0] = '\0';
-    host_ptr = vl->host;
-    host_len = sizeof (vl->host);
 
     /* Construct the hostname field according to HostnameFormat. */
     for (i = 0; i < HF_MAX_FIELDS; ++i) {