summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d1e5372)
raw | patch | inline | side by side (parent: d1e5372)
author | Chad Malfait <cmalfait@yahoo.com> | |
Sun, 7 Apr 2013 01:32:27 +0000 (19:32 -0600) | ||
committer | Chad Malfait <cmalfait@yahoo.com> | |
Sun, 7 Apr 2013 01:32:27 +0000 (19:32 -0600) |
messages. Also changed variable names to follow recommended standard
from the website.
from the website.
src/volume.c | patch | blob | history |
diff --git a/src/volume.c b/src/volume.c
index ab39dc907549cd97d77ef223cef992a3f809af86..3cb6d28cd963dead5e1a8dfdeba3335ac49c61da 100644 (file)
--- a/src/volume.c
+++ b/src/volume.c
* Chad Malfait <malfaitc at yahoo.com>
**/
+#include <lvm2app.h>
+
#include "collectd.h"
#include "common.h"
#include "plugin.h"
-#include <lvm2app.h>
-static void volume_submit(const char *vol_name, gauge_t size, gauge_t free)
+static void volume_submit(const char *vol_name, const char *type, const char type_instance, gauge_t value)
{
- value_t values[2];
+ value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- values[0].gauge = size;
- values[1].gauge = free;
+ values[0].gauge = value;
vl.values = values;
vl.values_len = STATIC_ARRAY_SIZE (values);
sstrncpy(vl.host, hostname_g, sizeof (vl.host));
- sstrncpy(vl.plugin, "volume", sizeof (vl.plugin));
- sstrncpy(vl.type, vol_name, sizeof (vl.type));
+ sstrncpy(vl.type, type, sizeof (vl.type));
+ sstrncpy(vl.type_instance, type_instacne, sizeof (vl.type_instance));
plugin_dispatch_values (&vl);
}
{
lvm_t lvm;
vg_t vg;
- struct dm_list *vgnames;
- struct lvm_str_list *strl;
+ int status = 0;
+ struct dm_list *vg_names;
+ struct lvm_str_list *name_list;
lvm = lvm_init(NULL);
if (!lvm) {
- fprintf(stderr, "lvm_init() failed\n");
+ status = lvm_errno(lvm);
+ ERROR("volume plugin: lvm_init failed: %s", lvm_errmsg(lvm));
}
- vgnames = lvm_list_vg_names(lvm);
- if (!vgnames) {
- fprintf(stderr, "lvm_list_vg_names() failed\n");
+ vg_names = lvm_list_vg_names(lvm);
+ if (!vg_names) {
+ status = lvm_errno(lvm);
+ ERROR("volume plugin lvm_list_vg_name failed %s", lvm_errmsg(lvm));
}
- dm_list_iterate_items(strl, vgnames) {
- vg = lvm_vg_open(lvm, strl->str, "r", 0);
- volume_submit(strl->str, lvm_vg_get_size(vg), lvm_vg_get_free_size(vg));
+ dm_list_iterate_items(name_list, vg_names) {
+ vg = lvm_vg_open(lvm, name_list->str, "r", 0);
+ volume_submit(name_list->str, "df_complex", "size", lvm_vg_get_size(vg));
+ volume_submit(name_list->str, "df_complex", "free", lvm_vg_get_free_size(vg));
+
lvm_vg_close(vg);
}