summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9505171)
raw | patch | inline | side by side (parent: 9505171)
author | Tiago Carvalho <tfrcarvalho@gmail.com> | |
Sun, 28 Apr 2013 20:36:48 +0000 (21:36 +0100) | ||
committer | Tiago Carvalho <tfrcarvalho@gmail.com> | |
Sun, 28 Apr 2013 20:36:48 +0000 (21:36 +0100) |
Included all the metrics about the actual memory used by VMs (as
returned by libvirt.virDomainMemoryStats)
returned by libvirt.virDomainMemoryStats)
src/libvirt.c | patch | blob | history |
diff --git a/src/libvirt.c b/src/libvirt.c
index cfabaaa235d6efe81da7896e4c51185d6afa08a3..849cfe2264d3e739ebb420b9072601616fbdb11c 100644 (file)
--- a/src/libvirt.c
+++ b/src/libvirt.c
plugin_dispatch_values (&vl);
}
+static void
+memory_stats_submit (gauge_t memory, virDomainPtr dom, int tag_index)
+{
+ static const char *tags[] = { "swap_in", "swap_out", "major_fault", "minor_fault",
+ "unused", "available", "actual_balloon", "rss"};
+
+ value_t values[1];
+ value_list_t vl = VALUE_LIST_INIT;
+
+ init_value_list (&vl, dom);
+
+ values[0].gauge = memory;
+
+ vl.values = values;
+ vl.values_len = 1;
+
+ sstrncpy (vl.type, "memory", sizeof (vl.type));
+ sstrncpy (vl.type_instance, tags[tag_index], sizeof (vl.type_instance));
+
+ plugin_dispatch_values (&vl);
+}
+
static void
cpu_submit (unsigned long long cpu_time,
virDomainPtr dom, const char *type)
for (i = 0; i < nr_domains; ++i) {
virDomainInfo info;
virVcpuInfoPtr vinfo = NULL;
+ virDomainMemoryStatPtr minfo = NULL;
int status;
int j;
vcpu_submit (vinfo[j].cpuTime,
domains[i], vinfo[j].number, "virt_vcpu");
+
+ minfo = malloc (VIR_DOMAIN_MEMORY_STAT_NR * sizeof (virDomainMemoryStatStruct));
+ if (minfo == NULL) {
+ ERROR ("libvirt plugin: malloc failed.");
+ continue;
+ }
+
+ status = virDomainMemoryStats (domains[i], minfo, VIR_DOMAIN_MEMORY_STAT_NR, 0);
+
+ if (status < 0) {
+ ERROR ("libvirt plugin: virDomainMemoryStats failed with status %i.",
+ status);
+ continue;
+ }
+
+ for (j = 0; j < status; j++) {
+ memory_stats_submit ((gauge_t) minfo[j].val, domains[i], minfo[j].tag);
+ }
+
+ sfree (minfo);
sfree (vinfo);
}
+
/* Get block device stats for each domain. */
for (i = 0; i < nr_block_devices; ++i) {
struct _virDomainBlockStats stats;