X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fvirt.c;h=c9355c4a1cd961417ce8611befb2c1454c488bfe;hb=55ef2778ade050e2924eeb027c98feea103f1585;hp=6118c0fdabddc541214294e9390f7d7112516e49;hpb=04b620afa8ff7c9f6565e57174fe5b9b9d462d61;p=collectd.git diff --git a/src/virt.c b/src/virt.c index 6118c0fd..c9355c4a 100644 --- a/src/virt.c +++ b/src/virt.c @@ -327,8 +327,8 @@ lv_init (void) { if (virInitialize () != 0) return -1; - - return 0; + else + return 0; } static int @@ -417,8 +417,8 @@ lv_config (const char *key, const char *value) else if (strcasecmp (fields[i], "uuid") == 0) hostname_format[i] = hf_uuid; else { - sfree (value_copy); ERROR (PLUGIN_NAME " plugin: unknown HostnameFormat field: %s", fields[i]); + sfree (value_copy); return -1; } } @@ -454,8 +454,8 @@ lv_config (const char *key, const char *value) else if (strcasecmp (fields[i], "uuid") == 0) plugin_instance_format[i] = plginst_uuid; else { + ERROR (PLUGIN_NAME " plugin: unknown PluginInstanceFormat field: %s", fields[i]); sfree (value_copy); - ERROR (PLUGIN_NAME " plugin: unknown HostnameFormat field: %s", fields[i]); return -1; } } @@ -547,6 +547,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]); @@ -588,7 +594,7 @@ lv_read (void) } for (j = 0; j < status; j++) { - memory_stats_submit ((gauge_t) minfo[j].val, domains[i], minfo[j].tag); + memory_stats_submit ((gauge_t) minfo[j].val * 1024, domains[i], minfo[j].tag); } sfree (minfo); @@ -920,6 +926,9 @@ add_interface_device (virDomainPtr dom, const char *path, const char *address, u int new_size = sizeof (interface_devices[0]) * (nr_interface_devices+1); char *path_copy, *address_copy, number_string[15]; + if ((path == NULL) || (address == NULL)) + return EINVAL; + path_copy = strdup (path); if (!path_copy) return -1; @@ -955,6 +964,9 @@ ignore_device_match (ignorelist_t *il, const char *domname, const char *devpath) char *name; int n, r; + if ((domname == NULL) || (devpath == NULL)) + return 0; + n = sizeof (char) * (strlen (domname) + strlen (devpath) + 2); name = malloc (n); if (name == NULL) {