X-Git-Url: https://git.octo.it/?p=collectd.git;a=blobdiff_plain;f=src%2Fvirt.c;h=2f64b505ba4c42e40747a949c810fc96e8b08d3d;hp=a6f050d4952fae90ffde05575f5460b796ec3d9b;hb=c4439c9cb3e2348ad7013644731de27a55eca478;hpb=04d9e221d31f38d80acfff48c611b1fee5f830f4 diff --git a/src/virt.c b/src/virt.c index a6f050d4..2f64b505 100644 --- a/src/virt.c +++ b/src/virt.c @@ -22,10 +22,10 @@ #include "collectd.h" -#include "common.h" #include "plugin.h" +#include "utils/common/common.h" +#include "utils/ignorelist/ignorelist.h" #include "utils_complain.h" -#include "utils_ignorelist.h" #include /* for basename(3) */ #include @@ -735,7 +735,7 @@ static int get_block_stats(struct lv_block_stats *bstats, ERROR(PLUGIN_NAME " plugin: %s failed: %s", (s), err->message); \ } while (0) -char *metadata_get_hostname(virDomainPtr dom) { +static char *metadata_get_hostname(virDomainPtr dom) { const char *xpath_str = NULL; if (hm_xpath == NULL) xpath_str = "/instance/name/text()"; @@ -1718,21 +1718,26 @@ static int get_disk_err(virDomainPtr domain) { #endif /* HAVE_DISK_ERR */ static int get_block_device_stats(struct block_device *block_dev) { - virDomainBlockInfo binfo; - init_block_info(&binfo); - if (!block_dev) { ERROR(PLUGIN_NAME " plugin: get_block_stats NULL pointer"); return -1; } - /* Block info statistics can be only fetched from devices with 'source' - * defined */ - if (block_dev->has_source) { - if (virDomainGetBlockInfo(block_dev->dom, block_dev->path, &binfo, 0) < 0) { - ERROR(PLUGIN_NAME " plugin: virDomainGetBlockInfo failed for path: %s", - block_dev->path); - return -1; + virDomainBlockInfo binfo; + init_block_info(&binfo); + + /* Fetching block info stats only if needed*/ + if (extra_stats & (ex_stats_disk_allocation | ex_stats_disk_capacity | + ex_stats_disk_physical)) { + /* Block info statistics can be only fetched from devices with 'source' + * defined */ + if (block_dev->has_source) { + if (virDomainGetBlockInfo(block_dev->dom, block_dev->path, &binfo, 0) < + 0) { + ERROR(PLUGIN_NAME " plugin: virDomainGetBlockInfo failed for path: %s", + block_dev->path); + return -1; + } } }