#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 <libgen.h> /* for basename(3) */
#include <libvirt/libvirt.h>
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()";
#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;
+ }
}
}