summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0debfde)
raw | patch | inline | side by side (parent: 0debfde)
author | Francesco Romani <fromani@redhat.com> | |
Mon, 13 Feb 2017 08:08:02 +0000 (09:08 +0100) | ||
committer | Francesco Romani <fromani@redhat.com> | |
Mon, 13 Feb 2017 14:06:13 +0000 (15:06 +0100) |
We are adding more metrics to the virt plugin, but not everyone
may be interested in those.
This patch add one more option to the virt plugin to enable
or disable the new stats.
For backward compatibility, the default is disabled.
Signed-off-by: Francesco Romani <fromani@redhat.com>
may be interested in those.
This patch add one more option to the virt plugin to enable
or disable the new stats.
For backward compatibility, the default is disabled.
Signed-off-by: Francesco Romani <fromani@redhat.com>
src/collectd.conf.in | patch | blob | history | |
src/collectd.conf.pod | patch | blob | history | |
src/virt.c | patch | blob | history |
diff --git a/src/collectd.conf.in b/src/collectd.conf.in
index 1cc86af48889ae8119c8e1cc179082603a31a02f..982cba9f32eaac594252c52aab7c314d9930c277 100644 (file)
--- a/src/collectd.conf.in
+++ b/src/collectd.conf.in
# InterfaceFormat name
# PluginInstanceFormat name
# Instances 1
+# ExtraStats "disk"
#</Plugin>
#<Plugin vmem>
diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod
index 6931066e99a935a9274a557748a87fe83eacfbd8..57f2897d92e888546f497e86cdc5f318ca54794b 100644 (file)
--- a/src/collectd.conf.pod
+++ b/src/collectd.conf.pod
and the sensible setting is a multiple of the B<ReadThreads> value.
If you are not sure, just use the default setting.
+=item B<ExtraStats> B<string>
+
+Enable extra statistics. This allows the plugin to reported more detailed
+statistics about the behaviour of Virtual Machines. The argument is a
+space-separated list of selectors. Currently only B<disk> is supported.
+
=back
=head2 Plugin C<vmem>
diff --git a/src/virt.c b/src/virt.c
index acdc11fac88129f6a6a20e01fb23534d718131a3..06081097cb7e2116071ec3599d770d5a1eb39b59 100644 (file)
--- a/src/virt.c
+++ b/src/virt.c
"PluginInstanceFormat",
"Instances",
+ "ExtraStats",
NULL};
#define NR_CONFIG_KEYS ((sizeof config_keys / sizeof config_keys[0]) - 1)
/* InterfaceFormat. */
enum if_field { if_address, if_name, if_number };
+/* ExtraStats */
+#define EX_STATS_MAX_FIELDS 8
+#define EX_STATS_DISK "disk"
+enum ex_stats { ex_stats_none = 0, ex_stats_disk = 1 };
+static enum ex_stats extra_stats = ex_stats_none;
+
/* BlockDeviceFormatBasename */
_Bool blockdevice_format_basename = 0;
static enum bd_field blockdevice_format = target;
submit_derive2("disk_octets", (derive_t)binfo->bi.rd_bytes,
(derive_t)binfo->bi.wr_bytes, dom, type_instance);
- if ((binfo->rd_total_times != -1) && (binfo->wr_total_times != -1))
- submit_derive2("disk_time", (derive_t)binfo->rd_total_times,
- (derive_t)binfo->wr_total_times, dom, type_instance);
-
- if (binfo->fl_req != -1)
- submit(dom, "total_requests", flush_type_instance,
- &(value_t){.derive = (derive_t)binfo->fl_req}, 1);
- if (binfo->fl_total_times != -1) {
- derive_t value = binfo->fl_total_times / 1000; // ns -> ms
- submit(dom, "total_time_in_ms", flush_type_instance,
- &(value_t){.derive = value}, 1);
+ if (extra_stats & ex_stats_disk) {
+ if ((binfo->rd_total_times != -1) && (binfo->wr_total_times != -1))
+ submit_derive2("disk_time", (derive_t)binfo->rd_total_times,
+ (derive_t)binfo->wr_total_times, dom, type_instance);
+
+ if (binfo->fl_req != -1)
+ submit(dom, "total_requests", flush_type_instance,
+ &(value_t){.derive = (derive_t)binfo->fl_req}, 1);
+ if (binfo->fl_total_times != -1) {
+ derive_t value = binfo->fl_total_times / 1000; // ns -> ms
+ submit(dom, "total_time_in_ms", flush_type_instance,
+ &(value_t){.derive = value}, 1);
+ }
}
}
return 0;
}
+ if (strcasecmp(key, "ExtraStats") == 0) {
+ char *localvalue = sstrdup(value);
+ if (localvalue != NULL) {
+ char *exstats[EX_STATS_MAX_FIELDS];
+ int numexstats;
+
+ numexstats = strsplit(localvalue, exstats, STATIC_ARRAY_SIZE(exstats));
+ for (int i = 0; i < numexstats; i++) {
+ if (strcasecmp(exstats[i], EX_STATS_DISK) == 0) {
+ DEBUG(PLUGIN_NAME " plugin: enabling extra stats for '%s'",
+ EX_STATS_DISK);
+ extra_stats |= ex_stats_disk;
+ }
+ }
+ sfree(localvalue);
+ }
+ }
+
/* Unrecognised option. */
return -1;
}