Merge pull request #3309 from rubenk/remove-lvm-plugin
authorRuben Kerkhof <ruben@rubenkerkhof.com>
Wed, 23 Oct 2019 11:26:51 +0000 (13:26 +0200)
committerGitHub <noreply@github.com>
Wed, 23 Oct 2019 11:26:51 +0000 (13:26 +0200)
Remove LVM plugin

.travis.yml
Makefile.am
README
configure.ac
contrib/redhat/collectd.spec
src/collectd.conf.in
src/lvm.c [deleted file]

index 6cf60fa..f715343 100644 (file)
@@ -63,7 +63,6 @@ addons:
     - liblua50-dev
     - liblua5.1-0-dev
     - liblua5.2-dev
-    - liblvm2-dev
     - libmemcached-dev
     - libmicrohttpd-dev
     - libmnl-dev
index bdb95a1..7795fd3 100644 (file)
@@ -1222,14 +1222,6 @@ lua_la_LDFLAGS = $(PLUGIN_LDFLAGS)
 lua_la_LIBADD = $(BUILD_WITH_LIBLUA_LIBS)
 endif
 
-if BUILD_PLUGIN_LVM
-pkglib_LTLIBRARIES += lvm.la
-lvm_la_SOURCES = src/lvm.c
-lvm_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBLVM2APP_CPPFLAGS)
-lvm_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBLVM2APP_LDFLAGS)
-lvm_la_LIBADD = $(BUILD_WITH_LIBLVM2APP_LIBS)
-endif
-
 if BUILD_PLUGIN_MADWIFI
 pkglib_LTLIBRARIES += madwifi.la
 madwifi_la_SOURCES = \
diff --git a/README b/README
index f77efd2..c8be7d3 100644 (file)
--- a/README
+++ b/README
@@ -207,10 +207,6 @@ Features
       collectd without the need to start a heavy interpreter every interval.
       See collectd-lua(5) for details.
 
-    - lvm
-      Size of “Logical Volumes” (LV) and “Volume Groups” (VG) of Linux'
-      “Logical Volume Manager” (LVM).
-
     - madwifi
       Queries very detailed usage statistics from wireless LAN adapters and
       interfaces that use the Atheros chipset and the MadWifi driver.
@@ -845,10 +841,6 @@ Prerequisites
     Used by the `lua' plugin. Currently, Lua 5.1 and later are supported.
     <https://www.lua.org/>
 
-  * liblvm2 (optional)
-    Used by the `lvm' plugin.
-    <ftp://sources.redhat.com/pub/lvm2/>
-
   * libmemcached (optional)
     Used by the `memcachec' plugin to connect to a memcache daemon.
     <http://tangent.org/552/libmemcached.html>
index abca971..34386d0 100644 (file)
@@ -3169,67 +3169,6 @@ AC_SUBST(BUILD_WITH_LIBLUA_CFLAGS)
 AC_SUBST(BUILD_WITH_LIBLUA_LIBS)
 # }}}
 
-# --with-liblvm2app {{{
-AC_ARG_WITH([liblvm2app],
-  [AS_HELP_STRING([--with-liblvm2app@<:@=PREFIX@:>@], [Path to liblvm2app.])],
-  [
-    if test "x$withval" = "xno"; then
-      with_liblvm2app="no"
-    else
-      with_liblvm2app="yes"
-      if test "x$withval" != "xyes"; then
-        with_liblvm2app_cppflags="-I$withval/include"
-        with_liblvm2app_ldflags="-L$withval/lib"
-      fi
-    fi
-  ],
-  [
-    if test "x$ac_system" = "xLinux"; then
-      with_liblvm2app="yes"
-    else
-      with_liblvm2app="no (Linux only library)"
-    fi
-  ]
-)
-
-if test "x$with_liblvm2app" = "xyes"; then
-  SAVE_CPPFLAGS="$CPPFLAGS"
-  CPPFLAGS="$CPPFLAGS $with_liblvm2app_cppflags"
-
-  AC_CHECK_HEADERS([lvm2app.h],
-    [with_liblvm2app="yes"],
-    [with_liblvm2app="no (lvm2app.h not found)"]
-  )
-
-  CPPFLAGS="$SAVE_CPPFLAGS"
-fi
-
-if test "x$with_liblvm2app" = "xyes"; then
-  SAVE_CPPFLAGS="$CPPFLAGS"
-  SAVE_LDFLAGS="$LDFLAGS"
-  CPPFLAGS="$CPPFLAGS $with_liblvm2app_cppflags"
-  LDFLAGS="$LDFLAGS $with_liblvm2app_ldflags"
-
-  AC_CHECK_LIB([lvm2app], [lvm_lv_get_property],
-    [with_liblvm2app="yes"],
-    [with_liblvm2app="no (Symbol 'lvm_lv_get_property' not found)"]
-  )
-
-  CPPFLAGS="$SAVE_CPPFLAGS"
-  LDFLAGS="$SAVE_LDFLAGS"
-fi
-
-if test "x$with_liblvm2app" = "xyes"; then
-  BUILD_WITH_LIBLVM2APP_CPPFLAGS="$with_liblvm2app_cppflags"
-  BUILD_WITH_LIBLVM2APP_LDFLAGS="$with_liblvm2app_ldflags"
-  BUILD_WITH_LIBLVM2APP_LIBS="-llvm2app"
-fi
-
-AC_SUBST([BUILD_WITH_LIBLVM2APP_CPPFLAGS])
-AC_SUBST([BUILD_WITH_LIBLVM2APP_LDFLAGS])
-AC_SUBST([BUILD_WITH_LIBLVM2APP_LIBS])
-# }}}
-
 # --with-libmemcached {{{
 AC_ARG_WITH([libmemcached],
   [AS_HELP_STRING([--with-libmemcached@<:@=PREFIX@:>@], [Path to libmemcached.])],
@@ -6458,7 +6397,6 @@ if test "x$ac_system" = "xLinux"; then
   plugin_ipc="yes"
   plugin_irq="yes"
   plugin_load="yes"
-  plugin_lvm="yes"
   plugin_mcelog="yes"
   plugin_memory="yes"
   plugin_nfs="yes"
@@ -6851,7 +6789,6 @@ AC_PLUGIN([log_logstash],        [$plugin_log_logstash],      [Logstash json_eve
 AC_PLUGIN([logfile],             [yes],                       [File logging plugin])
 AC_PLUGIN([lpar],                [$with_perfstat],            [AIX logical partitions statistics])
 AC_PLUGIN([lua],                 [$with_liblua],              [Lua plugin])
-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])
@@ -7170,7 +7107,6 @@ AC_MSG_RESULT([    libkstat  . . . . . . $with_kstat])
 AC_MSG_RESULT([    libkvm  . . . . . . . $with_libkvm])
 AC_MSG_RESULT([    libldap . . . . . . . $with_libldap])
 AC_MSG_RESULT([    liblua  . . . . . . . $with_liblua])
-AC_MSG_RESULT([    liblvm2app  . . . . . $with_liblvm2app])
 AC_MSG_RESULT([    libmemcached  . . . . $with_libmemcached])
 AC_MSG_RESULT([    libmicrohttpd . . . . $with_libmicrohttpd])
 AC_MSG_RESULT([    libmnl  . . . . . . . $with_libmnl])
@@ -7284,7 +7220,6 @@ AC_MSG_RESULT([    logfile . . . . . . . $enable_logfile])
 AC_MSG_RESULT([    log_logstash  . . . . $enable_log_logstash])
 AC_MSG_RESULT([    lpar  . . . . . . . . $enable_lpar])
 AC_MSG_RESULT([    lua . . . . . . . . . $enable_lua])
-AC_MSG_RESULT([    lvm . . . . . . . . . $enable_lvm])
 AC_MSG_RESULT([    madwifi . . . . . . . $enable_madwifi])
 AC_MSG_RESULT([    match_empty_counter . $enable_match_empty_counter])
 AC_MSG_RESULT([    match_hashed  . . . . $enable_match_hashed])
index 55f1022..864ef1b 100644 (file)
@@ -90,7 +90,6 @@
 %define with_log_logstash 0%{!?_without_log_logstash:1}
 %define with_logfile 0%{!?_without_logfile:1}
 %define with_lua 0%{!?_without_lua:1}
-%define with_lvm 0%{!?_without_lvm:1}
 %define with_madwifi 0%{!?_without_madwifi:1}
 %define with_mbmon 0%{!?_without_mbmon:1}
 %define with_mcelog 0%{!?_without_mcelog:1}
 %define with_gmond 0
 %define with_iptables 0
 %define with_ipvs 0
-%define with_lvm 0
 %define with_modbus 0
 %define with_netlink 0
 %define with_redis 0
 
 Summary:       Statistics collection and monitoring daemon
 Name:          collectd
-Version:       5.9.0
-Release:       1%{?dist}
+Version:       5.9.2
+Release:       2%{?dist}
 URL:           https://collectd.org
 Source:                https://collectd.org/files/%{name}-%{version}.tar.bz2
 License:       GPLv2
@@ -590,17 +588,6 @@ The Lua plugin embeds a Lua interpreter into collectd and exposes the
 application programming interface (API) to Lua scripts.
 %endif
 
-%if %{with_lvm}
-%package lvm
-Summary:       LVM plugin for collectd
-Group:         System Environment/Daemons
-Requires:      %{name}%{?_isa} = %{version}-%{release}
-BuildRequires: lvm2-devel
-%description lvm
-This plugin collects size of “Logical Volumes” (LV) and “Volume Groups” (VG)
-of Linux' “Logical Volume Manager” (LVM).
-%endif
-
 %if %{with_mcelog}
 %package mcelog
 Summary:       Mcelog plugin for collectd
@@ -1442,12 +1429,6 @@ Collectd utilities
 %define _with_lua --disable-lua
 %endif
 
-%if %{with_lvm}
-%define _with_lvm --enable-lvm
-%else
-%define _with_lvm --disable-lvm
-%endif
-
 %if %{with_madwifi}
 %define _with_madwifi --enable-madwifi
 %else
@@ -2089,7 +2070,6 @@ Collectd utilities
        %{?_with_logfile} \
        %{?_with_lpar} \
        %{?_with_lua} \
-       %{?_with_lvm} \
        %{?_with_madwifi} \
        %{?_with_mbmon} \
        %{?_with_mcelog} \
@@ -2710,11 +2690,6 @@ fi
 %{_libdir}/%{name}/lua.so
 %endif
 
-%if %{with_lvm}
-%files lvm
-%{_libdir}/%{name}/lvm.so
-%endif
-
 %if %{with_memcachec}
 %files memcachec
 %{_libdir}/%{name}/memcachec.so
@@ -2929,6 +2904,9 @@ fi
 %doc contrib/
 
 %changelog
+* Mon Oct 14 2019 Ruben Kerkhof <ruben@rubenkerkhof.com> - 5.9.2-2
+- Remove lvm plugin, liblvmapp has been deprecated upstream
+
 * Fri Jun 14 2019 Fabien Wernli <rpmbuild@faxmodem.org> - 5.9.0-1
 - add code for write_stackdriver (disabled for now)
 - add code for gpu_nvidia (disabled for now)
index a194b47..dcad150 100644 (file)
 @BUILD_PLUGIN_LOAD_TRUE@@BUILD_PLUGIN_LOAD_TRUE@LoadPlugin load
 #@BUILD_PLUGIN_LPAR_TRUE@LoadPlugin lpar
 #@BUILD_PLUGIN_LUA_TRUE@LoadPlugin lua
-#@BUILD_PLUGIN_LVM_TRUE@LoadPlugin lvm
 #@BUILD_PLUGIN_MADWIFI_TRUE@LoadPlugin madwifi
 #@BUILD_PLUGIN_MBMON_TRUE@LoadPlugin mbmon
 #@BUILD_PLUGIN_MCELOG_TRUE@LoadPlugin mcelog
diff --git a/src/lvm.c b/src/lvm.c
deleted file mode 100644 (file)
index 3077c93..0000000
--- a/src/lvm.c
+++ /dev/null
@@ -1,211 +0,0 @@
-/**
- * collectd - src/lvm.c
- * Copyright (C) 2013       Chad Malfait
- * Copyright (C) 2014       Carnegie Mellon University
- *
- * 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>
- *   Benjamin Gilbert <bgilbert at backtick.net>
- **/
-
-#include "collectd.h"
-
-#include "plugin.h"
-#include "utils/common/common.h"
-
-#include <lvm2app.h>
-
-#ifdef HAVE_SYS_CAPABILITY_H
-#include <sys/capability.h>
-#endif /* HAVE_SYS_CAPABILITY_H */
-
-#define NO_VALUE UINT64_MAX
-#define PERCENT_SCALE_FACTOR 1e-8
-
-static uint64_t get_lv_property_int(lv_t lv, char const *property) {
-  lvm_property_value_t v;
-
-  v = lvm_lv_get_property(lv, property);
-  if (!v.is_valid || !v.is_integer)
-    return NO_VALUE;
-  /* May be NO_VALUE if @property does not apply to this LV */
-  return v.value.integer;
-}
-
-static char const *get_lv_property_string(lv_t lv, char const *property) {
-  lvm_property_value_t v;
-
-  v = lvm_lv_get_property(lv, property);
-  if (!v.is_valid || !v.is_string)
-    return NULL;
-  return v.value.string;
-}
-
-static void lvm_submit(char const *plugin_instance, char const *type_instance,
-                       uint64_t ivalue) {
-  value_list_t vl = VALUE_LIST_INIT;
-
-  vl.values = &(value_t){.gauge = (gauge_t)ivalue};
-  vl.values_len = 1;
-
-  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 void report_lv_utilization(lv_t lv, char const *vg_name,
-                                  char const *lv_name, uint64_t lv_size,
-                                  char const *used_percent_property) {
-  uint64_t used_percent_unscaled;
-  uint64_t used_bytes;
-  char plugin_instance[DATA_MAX_NAME_LEN];
-
-  used_percent_unscaled = get_lv_property_int(lv, used_percent_property);
-  if (used_percent_unscaled == NO_VALUE)
-    return;
-  used_bytes = lv_size * (used_percent_unscaled * PERCENT_SCALE_FACTOR);
-
-  ssnprintf(plugin_instance, sizeof(plugin_instance), "%s-%s", vg_name,
-            lv_name);
-  lvm_submit(plugin_instance, "used", used_bytes);
-  lvm_submit(plugin_instance, "free", lv_size - used_bytes);
-}
-
-static void report_thin_pool_utilization(lv_t lv, char const *vg_name,
-                                         uint64_t lv_size) {
-  char const *data_lv;
-  char const *metadata_lv;
-  uint64_t metadata_size;
-
-  data_lv = get_lv_property_string(lv, "data_lv");
-  metadata_lv = get_lv_property_string(lv, "metadata_lv");
-  metadata_size = get_lv_property_int(lv, "lv_metadata_size");
-  if (data_lv == NULL || metadata_lv == NULL || metadata_size == NO_VALUE)
-    return;
-
-  report_lv_utilization(lv, vg_name, data_lv, lv_size, "data_percent");
-  report_lv_utilization(lv, vg_name, metadata_lv, metadata_size,
-                        "metadata_percent");
-}
-
-static void vg_read(vg_t vg, char const *vg_name) {
-  struct dm_list *lvs;
-  struct lvm_lv_list *lvl;
-  char const *name;
-  char const *attrs;
-  uint64_t size;
-
-  lvm_submit(vg_name, "free", lvm_vg_get_free_size(vg));
-
-  lvs = lvm_vg_list_lvs(vg);
-  if (!lvs) {
-    /* no VGs are defined, which is not an error per se */
-    return;
-  }
-
-  dm_list_iterate_items(lvl, lvs) {
-    name = lvm_lv_get_name(lvl->lv);
-    attrs = get_lv_property_string(lvl->lv, "lv_attr");
-    size = lvm_lv_get_size(lvl->lv);
-    if (name == NULL || attrs == NULL || size == NO_VALUE)
-      continue;
-
-    /* Condition on volume type.  We want the reported sizes in the
-       volume group to sum to the size of the volume group, so we ignore
-       virtual volumes.  */
-    switch (attrs[0]) {
-    case 's':
-    case 'S':
-      /* Snapshot.  Also report used/free space. */
-      report_lv_utilization(lvl->lv, vg_name, name, size, "data_percent");
-      break;
-    case 't':
-      /* Thin pool virtual volume.  We report the underlying data
-         and metadata volumes, not this one.  Report used/free
-         space, then ignore. */
-      report_thin_pool_utilization(lvl->lv, vg_name, size);
-      continue;
-    case 'v':
-      /* Virtual volume.  Ignore. */
-      continue;
-    case 'V':
-      /* Thin volume or thin snapshot.  Ignore. */
-      continue;
-    }
-    lvm_submit(vg_name, name, size);
-  }
-}
-
-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 */
-
-static int c_lvm_init(void) {
-#if defined(HAVE_SYS_CAPABILITY_H) && defined(CAP_SYS_ADMIN)
-  if (check_capability(CAP_SYS_ADMIN) != 0) {
-    if (getuid() == 0)
-      WARNING("lvm plugin: Running collectd as root, but the "
-              "CAP_SYS_ADMIN capability is missing. The plugin's read "
-              "function will probably fail. Is your init system dropping "
-              "capabilities?");
-    else
-      WARNING("lvm plugin: collectd doesn't have the CAP_SYS_ADMIN "
-              "capability. If you don't want to run collectd as root, try "
-              "running \"setcap cap_sys_admin=ep\" on the collectd binary.");
-  }
-#endif
-  return 0;
-}
-
-void module_register(void) {
-  plugin_register_init("lvm", c_lvm_init);
-  plugin_register_read("lvm", lvm_read);
-} /* void module_register */