X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fvirt.c;h=e95a31b49d23883ba725f4bbf03d6e89254773a9;hb=d3e97e2e0c710c1bbe0cac873bd1c5df004bc740;hp=68a8e6b98d91970f9d405e6efee3c14fe285c11e;hpb=99711bf92a44ad07f82b29792df3e4e2f9450ac6;p=collectd.git diff --git a/src/virt.c b/src/virt.c index 68a8e6b9..e95a31b4 100644 --- a/src/virt.c +++ b/src/virt.c @@ -414,7 +414,7 @@ static void memory_stats_submit(gauge_t value, virDomainPtr dom, "minor_fault", "unused", "available", "actual_balloon", "rss"}; - if ((tag_index < 0) || (tag_index >= STATIC_ARRAY_SIZE(tags))) { + if ((tag_index < 0) || (tag_index >= (int)STATIC_ARRAY_SIZE(tags))) { ERROR("virt plugin: Array index out of bounds: tag_index = %d", tag_index); return; } @@ -485,18 +485,18 @@ static void disk_submit(struct lv_block_info *binfo, virDomainPtr dom, } static unsigned int parse_ex_stats_flags(char **exstats, int numexstats) { - int extra_stats = ex_stats_none; + unsigned int ex_stats_flags = ex_stats_none; for (int i = 0; i < numexstats; i++) { for (int j = 0; ex_stats_table[j].name != NULL; j++) { if (strcasecmp(exstats[i], ex_stats_table[j].name) == 0) { DEBUG(PLUGIN_NAME " plugin: enabling extra stats for '%s'", ex_stats_table[j].name); - extra_stats |= ex_stats_table[j].flag; + ex_stats_flags |= ex_stats_table[j].flag; break; } } } - return extra_stats; + return ex_stats_flags; } static int lv_config(const char *key, const char *value) { @@ -824,11 +824,6 @@ static int lv_read(user_data_t *ud) { continue; } - if (info.di.state != VIR_DOMAIN_RUNNING) { - /* only gather stats for running domains */ - continue; - } - pcpu_submit(state->domains[i], &info); cpu_submit(info.di.cpuTime, state->domains[i], "virt_cpu_total"); memory_submit((gauge_t)info.di.memory * 1024, state->domains[i]); @@ -1129,6 +1124,8 @@ static int refresh_lists(struct lv_read_instance *inst) { xmlXPathContextPtr xpath_ctx = NULL; xmlXPathObjectPtr xpath_obj = NULL; char tag[PARTITION_TAG_MAX_LEN] = {'\0'}; + virDomainInfo info; + int status; dom = virDomainLookupByID(conn, domids[i]); if (dom == NULL) { @@ -1143,6 +1140,18 @@ static int refresh_lists(struct lv_read_instance *inst) { goto cont; } + status = virDomainGetInfo(dom, &info); + if (status != 0) { + ERROR(PLUGIN_NAME " plugin: virDomainGetInfo failed with status %i.", + status); + continue; + } + + if (info.state != VIR_DOMAIN_RUNNING) { + DEBUG(PLUGIN_NAME " plugin: skipping inactive domain %s", name); + continue; + } + if (il_domains && ignorelist_match(il_domains, name) != 0) goto cont;