Module: check_mk
Branch: master
Commit: 8d284ab7a20060d3546e2e9565b50267694e5234
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=8d284ab7a20060…
Author: Marcel Arentz <ma(a)mathias-kettner.de>
Date: Fri Aug 4 17:37:55 2017 +0200
5012 lvm_lvs: New check vor LVM logical volume pools
In LVM you can configure thin provisioned logical volume pools. These can
be overprovisioned. This checkplugin measures the usage of these pools.
Change-Id: I50d509e5c9e606f9ba4fc733089e12c820a6feb8
---
.werks/5012 | 11 +++++
agents/plugins/lvm | 3 ++
checkman/lvm_lvs | 12 ++++++
checks/lvm_lvs | 82 ++++++++++++++++++++++++++++++++++++
web/plugins/wato/check_parameters.py | 33 +++++++++++++++
5 files changed, 141 insertions(+)
diff --git a/.werks/5012 b/.werks/5012
new file mode 100644
index 0000000..f5e07e2
--- /dev/null
+++ b/.werks/5012
@@ -0,0 +1,11 @@
+Title: lvm_lvs: New check vor LVM logical volume pools
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.5.0i1
+Date: 1501861028
+Class: feature
+
+In LVM you can configure thin provisioned logical volume pools. These can
+be overprovisioned. This checkplugin measures the usage of these pools.
diff --git a/agents/plugins/lvm b/agents/plugins/lvm
index 6f0b9de..00cd5fe 100755
--- a/agents/plugins/lvm
+++ b/agents/plugins/lvm
@@ -2,5 +2,8 @@
echo "<<<lvm_vgs>>>"
vgs --units b --nosuffix --noheadings --separator ' '
+echo "<<<lvm_lvs:sep(124)>>>"
+lvs --units b --nosuffix --noheadings --separator '|'
+
#echo "<<<lvm_pvs>>>"
#pvs --units b --nosuffix --noheadings --separator ' '
diff --git a/checkman/lvm_lvs b/checkman/lvm_lvs
new file mode 100644
index 0000000..d844767
--- /dev/null
+++ b/checkman/lvm_lvs
@@ -0,0 +1,12 @@
+title: LVM: Logical volumes
+agents: linux
+catalog: os/storage
+license: GPL
+distribution: check_mk
+description:
+
+ This check monitors the usage of LVM logical volumes.
+
+item:
+
+inventory:
diff --git a/checks/lvm_lvs b/checks/lvm_lvs
new file mode 100644
index 0000000..8bae5bd
--- /dev/null
+++ b/checks/lvm_lvs
@@ -0,0 +1,82 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2017 mk(a)mathias-kettner.de |
+# +------------------------------------------------------------------+
+#
+# This file is part of Check_MK.
+# The official homepage is at
http://mathias-kettner.de/check_mk.
+#
+# check_mk 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 in version 2. check_mk is distributed
+# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
+# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE. See the GNU General Public License for more de-
+# tails. You should have received a copy of the GNU General Public
+# License along with GNU Make; see the file COPYING. If not, write
+# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301 USA.
+
+
+# example output
+
+factory_settings["lvm_lvs_default_levels"] = {
+ "levels_data" : (80.0, 90.0),
+ "levels_meta" : (80.0, 90.0),
+}
+
+def parse_lvm_lvs(info):
+ parsed = {}
+ for line in info:
+ item = "%s/%s" % (line[1], line[4])
+ if not line[4] == "" and not item in parsed:
+ parsed[item] = []
+
+ for line in info:
+ item = "%s/%s" % (line[1], line[0])
+ if item in parsed:
+ parsed[item] = {"data" : line[6], "meta" : line[7]}
+
+ return parsed
+
+
+def inventory_lvm_lvs(parsed):
+ for key, values in parsed.iteritems():
+ yield ( key, {} )
+
+
+def check_lvm_lvs(item, params, parsed):
+ for key, values in parsed.iteritems():
+ if item == key:
+ for key, value in values.iteritems():
+ value = float(value)
+ warn, crit = params["levels_%s" % key]
+ if value >= crit:
+ state = 2
+ elif value >= warn:
+ state = 1
+ else:
+ state = 0
+
+ key = key[0].upper()+key[1:]
+ yield 0, "%s usage: %.2f %%" % (key, value)
+ if state:
+ yield state, "(warn/crit at %s/%s)" % (warn, crit)
+
+
+check_info['lvm_lvs'] = {
+ 'parse_function' : parse_lvm_lvs,
+ 'inventory_function' : inventory_lvm_lvs,
+ 'check_function' : check_lvm_lvs,
+ 'service_description' : 'LVM LV Pool %s',
+ 'has_perfdata' : True,
+ 'default_levels_variable' : 'lvm_lvs_default_levels',
+ 'group' : 'lvm_lvs_pools',
+}
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index 26d3e30..07c4133 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -4595,6 +4595,39 @@ register_check_parameters(
register_check_parameters(
subgroup_storage,
+ "lvm_lvs_pools",
+ _("Logical Volume Pools (LVM)"),
+ Dictionary(
+ elements = [
+ ( "levels_meta", Tuple(
+ title = _("Levels for Meta"),
+ default_value = (80.0, 90.0),
+ elements = [
+ Percentage(title = _("Warning at"), unit =
_("%")),
+ Percentage(title = _("Critical at"), unit =
_("%"))
+ ]
+ ),
+ ),
+ ( "levels_data", Tuple(
+ title = _("Levels for Data"),
+ default_value = (80.0, 90.0),
+ elements = [
+ Percentage(title = _("Warning at"), unit =
_("%")),
+ Percentage(title = _("Critical at"), unit =
_("%"))
+ ]
+ ),
+ ),
+ ]
+ ),
+ TextAscii(
+ title = _("Logical Volume Pool"),
+ allow_empty = True,
+ ),
+ match_type = "dict"
+)
+
+register_check_parameters(
+ subgroup_storage,
"filehandler",
_("Filehandler"),
Dictionary(