Module: check_mk
Branch: master
Commit: 0d5107c598a68a4824a9d7ebb560a0eedba88eb3
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=0d5107c598a68a…
Author: Konstantin Büttner <kb(a)mathias-kettner.de>
Date: Wed Nov 29 14:25:04 2017 +0100
5523 df: Make filesystem types ignored during discovery configurable via WATO
Previously, the only way to influence the filesystem types to be ignored was by
setting a config variable manually in a file, which would affect the behaviour
globally. Now, this can be configured by a rule, allowing to include eg. tmpfs
only for certain hosts.
Change-Id: Ibae2bcbbddf4328f9b99e7964eeb62b934a723b4
---
.werks/5523 | 14 ++++++++++++++
checks/df | 5 ++++-
tests/checks/test_df_check.py | 12 ++++++++++++
web/plugins/wato/check_parameters.py | 20 ++++++++++++++++++--
4 files changed, 48 insertions(+), 3 deletions(-)
diff --git a/.werks/5523 b/.werks/5523
new file mode 100644
index 0000000..946a504
--- /dev/null
+++ b/.werks/5523
@@ -0,0 +1,14 @@
+Title: df: Make filesystem types ignored during discovery configurable via WATO
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.5.0i2
+Date: 1511961740
+Class: feature
+
+Previously, the only way to influence the filesystem types to be ignored was by
+setting a config variable manually in a file, which would affect the behaviour
+globally. Now, this can be configured by a rule, allowing to include e.g. tmpfs
+only for certain hosts. Individual mountpoints can also be configured to be
+discovered regardless of filesystem type.
diff --git a/checks/df b/checks/df
index d780799..0f26539 100644
--- a/checks/df
+++ b/checks/df
@@ -195,6 +195,9 @@ def inventory_df(parsed):
inventory_options = host_extra_conf_merged(host_name(), inventory_df_rules)
include_volume_name = inventory_options.get("include_volume_name", False)
+ ignore_fs_types = inventory_options.get("ignore_fs_types",
inventory_df_exclude_fs)
+ never_ignore_mountpoints =
inventory_options.get("never_ignore_mountpoints", [])
+
(df_blocks, volume_info), _ = parsed
mplist = []
@@ -203,7 +206,7 @@ def inventory_df(parsed):
mountpoint = line[0]
if mountpoint in inventory_df_exclude_mountpoints:
continue # exclude this mount point (/tmp, /proc, whatever user wants)
- if volume_info[mountpoint]["fs_type"] in inventory_df_exclude_fs:
+ if volume_info[mountpoint]["fs_type"] in ignore_fs_types and mountpoint
not in never_ignore_mountpoints:
continue # ignore this filesystem type
mplist.append(mountpoint)
diff --git a/tests/checks/test_df_check.py b/tests/checks/test_df_check.py
index b2cf847..5bc8ccd 100644
--- a/tests/checks/test_df_check.py
+++ b/tests/checks/test_df_check.py
@@ -47,6 +47,7 @@ info_df_lnx_tmpfs = [[u'tmpfs',
u'8152744',
u'1%',
u'/opt/omd/sites/heute/tmp'],
+ [u'tmpfs', u'tmpfs', u'8152840', u'118732',
u'8034108', u'2%', u'/dev/shm'],
[u'[df_inodes_start]'],
[u'tmpfs',
u'tmpfs',
@@ -55,6 +56,7 @@ info_df_lnx_tmpfs = [[u'tmpfs',
u'2038157',
u'1%',
u'/opt/omd/sites/heute/tmp'],
+ [u'tmpfs', u'tmpfs', u'2038210', u'57',
u'2038153', u'1%', u'/dev/shm'],
[u'[df_inodes_end]']]
# NOTE: This gargantuan test info section is uncritically used data from an archived
agent output.
@@ -224,6 +226,16 @@ info_df_btrfs = \
(info_df_win, [(u'New_Volume E:/', {}), (u'New_Volume F:/', {}),
(u'C:\\ C:/', {})],
{
"include_volume_name" : True }), # Windows w/ volume name option
(info_df_lnx_tmpfs, [], {}),
# Ignoring tmpfs
+ (info_df_lnx_tmpfs, [], { "ignore_fs_types" : [ 'tmpfs',
'nfs', 'smbfs', 'cifs', 'iso9660' ] }), # Ignoring
tmpfs explicitly
+ (info_df_lnx_tmpfs, [(u'/opt/omd/sites/heute/tmp', {})],
+ { "ignore_fs_types" : [ 'tmpfs',
'nfs', 'smbfs', 'cifs', 'iso9660' ], # Ignoring
tmpfs explicitly, but
+ "never_ignore_mountpoints" : [
u'/opt/omd/sites/heute/tmp' ]}), # including one mountpoint explicitly
+ (info_df_lnx_tmpfs, [(u'/opt/omd/sites/heute/tmp', {}), (u'/dev/shm',
{})],
+ { "ignore_fs_types" : [ 'nfs',
'smbfs', 'cifs', 'iso9660' ] }), # Including tmpfs
+
+ (info_df_lnx_tmpfs, [(u'tmpfs /opt/omd/sites/heute/tmp', {}), (u'tmpfs
/dev/shm', {})],
+ { "ignore_fs_types" : [ 'nfs',
'smbfs', 'cifs', 'iso9660' ],
+ "include_volume_name" : True}),
# Including tmpfs and volume name
(info_df_btrfs, [(u'/sys/fs/cgroup', {}), (u'btrfs /dev/sda1', {})],
{}), # btrfs
(info_df_btrfs, [(u'/dev/sda1 /sys/fs/cgroup', {}), (u'/dev/sda1 btrfs
/dev/sda1', {})],
{
"include_volume_name" : True }), # btrfs w/ volume name option
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index bb6562d..22e04f8 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -1549,14 +1549,30 @@ register_rule(group + '/' + subgroup_inventory,
register_rule(group + '/' + subgroup_inventory,
varname = "inventory_df_rules",
- title = _("Include Volume name in Filesystem Checks"),
+ title = _("Discovery parameters for filesystem checks"),
valuespec = Dictionary(
elements = [
("include_volume_name", Checkbox(
title = _("Include Volume name in item")
)),
+ ("ignore_fs_types", ListChoice(
+ title = _("Filesystem types to ignore"),
+ choices = [
+ ("tmpfs", "tmpfs"),
+ ("nfs", "nfs"),
+ ("smbfs", "smbfs"),
+ ("cifs", "cifs"),
+ ("iso9660", "iso9660"),
+ ],
+ default_value = [ "tmpfs", "nfs", "smbfs",
"cifs", "iso9660" ]
+ )),
+ ("never_ignore_mountpoints", ListOf(
+ TextUnicode(),
+ title = _(u"Mountpoints to never ignore"),
+ help =_(u"Regardless of filesystem type, these mountpoints will
always be discovered."
+ u"Globbing or regular expressions are currently not
supported."),
+ )),
],
- optional_keys = []
),
match = "dict",
)