Code

Changed plugin from volume to lvm
authorChad Malfait <cmalfait@yahoo.com>
Sat, 13 Apr 2013 19:34:38 +0000 (13:34 -0600)
committerFlorian Forster <octo@collectd.org>
Wed, 17 Apr 2013 05:45:15 +0000 (07:45 +0200)
Signed-off-by: Florian Forster <octo@collectd.org>
configure.in
src/Makefile.am
src/collectd.conf.in
src/lvm.c [new file with mode: 0644]
src/volume.c [deleted file]

index 0fb20c6c5ea8edf0485e20d07668c61eb64d448f..fb71e6f24ee943ded36ae4edc2bc431e45e6c371 100644 (file)
@@ -4682,6 +4682,7 @@ then
        plugin_interface="yes"
        plugin_irq="yes"
        plugin_load="yes"
+       plugin_lvm="yes"
        plugin_memory="yes"
        plugin_nfs="yes"
        plugin_numa="yes"
@@ -4693,7 +4694,6 @@ then
        plugin_thermal="yes"
        plugin_uptime="yes"
        plugin_vmem="yes"
-       plugin_volume="yes"
        plugin_vserver="yes"
        plugin_wireless="yes"
 
@@ -4979,6 +4979,7 @@ AC_PLUGIN([libvirt],     [$plugin_libvirt],    [Virtual machine statistics])
 AC_PLUGIN([load],        [$plugin_load],       [System load])
 AC_PLUGIN([logfile],     [yes],                [File logging plugin])
 AC_PLUGIN([lpar],        [$with_perfstat],     [AIX logical partitions statistics])
+AC_PLUGIN([lvm],         [$with_liblvm2app],   [LVM statistics])
 AC_PLUGIN([madwifi],     [$have_linux_wireless_h], [Madwifi wireless statistics])
 AC_PLUGIN([match_empty_counter], [yes],        [The empty counter match])
 AC_PLUGIN([match_hashed], [yes],               [The hashed match])
@@ -5047,7 +5048,6 @@ AC_PLUGIN([users],       [$plugin_users],      [User statistics])
 AC_PLUGIN([uuid],        [yes],                [UUID as hostname plugin])
 AC_PLUGIN([varnish],     [$with_libvarnish],   [Varnish cache statistics])
 AC_PLUGIN([vmem],        [$plugin_vmem],       [Virtual memory statistics])
-AC_PLUGIN([volume],      [$with_liblvm2app],   [Volume statistics])
 AC_PLUGIN([vserver],     [$plugin_vserver],    [Linux VServer statistics])
 AC_PLUGIN([wireless],    [$plugin_wireless],   [Wireless statistics])
 AC_PLUGIN([write_graphite], [yes],             [Graphite / Carbon output plugin])
@@ -5316,6 +5316,7 @@ Configuration:
     load  . . . . . . . . $enable_load
     logfile . . . . . . . $enable_logfile
     lpar... . . . . . . . $enable_lpar
+    lvm . . . . . . . . . $enable_lvm
     madwifi . . . . . . . $enable_madwifi
     match_empty_counter . $enable_match_empty_counter
     match_hashed  . . . . $enable_match_hashed
@@ -5383,7 +5384,6 @@ Configuration:
     uuid  . . . . . . . . $enable_uuid
     varnish . . . . . . . $enable_varnish
     vmem  . . . . . . . . $enable_vmem
-    volume  . . . . . . . $enable_volume
     vserver . . . . . . . $enable_vserver
     wireless  . . . . . . $enable_wireless
     write_graphite  . . . $enable_write_graphite
index 4ffb8b0119a55aa1429ec6d99415254c4f58ceb4..8dfdebedff03237bd3447283263bd5d6d322f659 100644 (file)
@@ -568,6 +568,15 @@ collectd_DEPENDENCIES += lpar.la
 lpar_la_LIBADD = -lperfstat
 endif
 
+if BUILD_PLUGIN_LVM
+pkglib_LTLIBRARIES += lvm.la
+lvm_la_SOURCES = lvm.c
+lvm_la_LDFLAGS = -module -avoid-version
+lvm_la_LIBADD = $(BUILD_WITH_LIBLVM2APP_LIBS)
+collectd_LDADD += "-dlopen" lvm.la
+collectd_DEPENDENCIES += lvm.la
+endif
+
 if BUILD_PLUGIN_MADWIFI
 pkglib_LTLIBRARIES += madwifi.la
 madwifi_la_SOURCES = madwifi.c madwifi.h
@@ -1290,15 +1299,6 @@ collectd_LDADD += "-dlopen" vmem.la
 collectd_DEPENDENCIES += vmem.la
 endif
 
-if BUILD_PLUGIN_VOLUME
-pkglib_LTLIBRARIES += volume.la
-volume_la_SOURCES = volume.c
-volume_la_LDFLAGS = -module -avoid-version
-volume_la_LIBADD = $(BUILD_WITH_LIBLVM2APP_LIBS)
-collectd_LDADD += "-dlopen" volume.la
-collectd_DEPENDENCIES += volume.la
-endif
-
 if BUILD_PLUGIN_VSERVER
 pkglib_LTLIBRARIES += vserver.la
 vserver_la_SOURCES = vserver.c
index ecc45c9ab9bd9320db6b68fa8a8fb9b63042566a..e95fae6a613799b6c72ac758e9502a3bcdc77955 100644 (file)
@@ -99,6 +99,7 @@
 #@BUILD_PLUGIN_LIBVIRT_TRUE@LoadPlugin libvirt
 @BUILD_PLUGIN_LOAD_TRUE@@BUILD_PLUGIN_LOAD_TRUE@LoadPlugin load
 #@BUILD_PLUGIN_LPAR_TRUE@LoadPlugin lpar
+#@BUILD_PLUGIN_LVM_TRUE@LoadPlugin lvm
 #@BUILD_PLUGIN_MADWIFI_TRUE@LoadPlugin madwifi
 #@BUILD_PLUGIN_MBMON_TRUE@LoadPlugin mbmon
 #@BUILD_PLUGIN_MD_TRUE@LoadPlugin md
 #@BUILD_PLUGIN_VARNISH_TRUE@LoadPlugin varnish
 #@BUILD_PLUGIN_VMEM_TRUE@LoadPlugin vmem
 #@BUILD_PLUGIN_VSERVER_TRUE@LoadPlugin vserver
-#@BUILD_PLUGIN_VOLUME_TRUE@LoadPlugin volume
 #@BUILD_PLUGIN_WIRELESS_TRUE@LoadPlugin wireless
 #@BUILD_PLUGIN_WRITE_GRAPHITE_TRUE@LoadPlugin write_graphite
 #@BUILD_PLUGIN_WRITE_HTTP_TRUE@LoadPlugin write_http
diff --git a/src/lvm.c b/src/lvm.c
new file mode 100644 (file)
index 0000000..6ef3a7b
--- /dev/null
+++ b/src/lvm.c
@@ -0,0 +1,103 @@
+/**
+ * collectd - src/lvm.c
+ * Copyright (C) 2013       Chad Malfait
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; only version 2 of the License is applicable.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ *
+ * Authors:
+ *   Chad Malfait <malfaitc at yahoo.com>
+ **/
+
+#include <lvm2app.h>
+
+#include "collectd.h"
+#include "common.h"
+#include "plugin.h"
+
+static void lvm_submit (char const *plugin_instance, char const *type_instance,
+        uint64_t ivalue)
+{
+    value_t v;
+    value_list_t vl = VALUE_LIST_INIT;
+
+    v.gauge = (gauge_t) ivalue;
+
+    vl.values = &v;
+    vl.values_len = 1;
+
+    sstrncpy(vl.host, hostname_g, sizeof (vl.host));
+    sstrncpy(vl.plugin, "lvm", sizeof (vl.plugin));
+    sstrncpy(vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance));
+    sstrncpy(vl.type, "df_complex", sizeof (vl.type));
+    sstrncpy(vl.type_instance, type_instance, sizeof (vl.type_instance));
+
+    plugin_dispatch_values (&vl);
+}
+
+static int vg_read(vg_t vg, char const *vg_name)
+{
+    struct dm_list *lvs;
+    struct lvm_lv_list *lvl;
+
+    lvm_submit (vg_name, "free", lvm_vg_get_free_size(vg));
+
+    lvs = lvm_vg_list_lvs(vg);
+    dm_list_iterate_items(lvl, lvs) {
+         lvm_submit(vg_name, lvm_lv_get_name(lvl->lv), lvm_lv_get_size(lvl->lv));
+    }
+
+    return (0);
+}
+
+static int lvm_read(void)
+{
+    lvm_t lvm;
+    struct dm_list *vg_names;
+    struct lvm_str_list *name_list;
+
+    lvm = lvm_init(NULL);
+    if (!lvm) {
+        ERROR("lvm plugin: lvm_init failed.");
+        return (-1);
+    }
+
+    vg_names = lvm_list_vg_names(lvm);
+    if (!vg_names) {
+        ERROR("lvm plugin lvm_list_vg_name failed %s", lvm_errmsg(lvm));
+        lvm_quit(lvm);
+        return (-1);
+    }
+
+    dm_list_iterate_items(name_list, vg_names) {
+        vg_t vg;
+
+        vg = lvm_vg_open(lvm, name_list->str, "r", 0);
+        if (!vg) {
+            ERROR ("lvm plugin: lvm_vg_open (%s) failed: %s",
+                    name_list->str, lvm_errmsg(lvm));
+            continue;
+        }
+
+        vg_read(vg, name_list->str);
+        lvm_vg_close(vg);
+    }
+
+    lvm_quit(lvm);
+    return (0);
+} /*lvm_read */
+
+void module_register(void)
+{
+    plugin_register_read("lvm", lvm_read);
+} /* void module_register */
diff --git a/src/volume.c b/src/volume.c
deleted file mode 100644 (file)
index 009f442..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-/**
- * collectd - src/volume.c
- * Copyright (C) 2013       Chad Malfait
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; only version 2 of the License is applicable.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
- *
- * Authors:
- *   Chad Malfait <malfaitc at yahoo.com>
- **/
-
-#include <lvm2app.h>
-
-#include "collectd.h"
-#include "common.h"
-#include "plugin.h"
-
-static void lvm_submit (char const *plugin_instance, char const *type_instance,
-        uint64_t ivalue)
-{
-    value_t v;
-    value_list_t vl = VALUE_LIST_INIT;
-
-    v.gauge = (gauge_t) ivalue;
-
-    vl.values = &v;
-    vl.values_len = 1;
-
-    sstrncpy(vl.host, hostname_g, sizeof (vl.host));
-    sstrncpy(vl.plugin, "lvm", sizeof (vl.plugin));
-    sstrncpy(vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance));
-    sstrncpy(vl.type, "df_complex", sizeof (vl.type));
-    sstrncpy(vl.type_instance, type_instance, sizeof (vl.type_instance));
-
-    plugin_dispatch_values (&vl);
-}
-
-static int vg_read(vg_t vg, char const *vg_name)
-{
-    struct dm_list *lvs;
-    struct lvm_lv_list *lvl;
-
-    lvm_submit (vg_name, "free", lvm_vg_get_free_size(vg));
-
-    lvs = lvm_vg_list_lvs(vg);
-    dm_list_iterate_items(lvl, lvs) {
-         lvm_submit(vg_name, lvm_lv_get_name(lvl->lv), lvm_lv_get_size(lvl->lv));
-    }
-
-    return (0);
-}
-
-static int lvm_read(void)
-{
-    lvm_t lvm;
-    struct dm_list *vg_names;
-    struct lvm_str_list *name_list;
-
-    lvm = lvm_init(NULL);
-    if (!lvm) {
-        ERROR("volume plugin: lvm_init failed.");
-        return (-1);
-    }
-
-    vg_names = lvm_list_vg_names(lvm);
-    if (!vg_names) {
-        ERROR("volume plugin lvm_list_vg_name failed %s", lvm_errmsg(lvm));
-        lvm_quit(lvm);
-        return (-1);
-    }
-
-    dm_list_iterate_items(name_list, vg_names) {
-        vg_t vg;
-
-        vg = lvm_vg_open(lvm, name_list->str, "r", 0);
-        if (!vg) {
-            ERROR ("volume plugin: lvm_vg_open (%s) failed: %s",
-                    name_list->str, lvm_errmsg(lvm));
-            continue;
-        }
-
-        vg_read(vg, name_list->str);
-        lvm_vg_close(vg);
-    }
-
-    lvm_quit(lvm);
-    return (0);
-} /*lvm_read */
-
-void module_register(void)
-{
-    plugin_register_read("volume", lvm_read);
-} /* void module_register */