Module: check_mk
Branch: master
Commit: a11b8970e9f7b994857ff55cd637053f8518484e
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a11b8970e9f7b9…
Author: Marcel Arentz <ma(a)mathias-kettner.de>
Date: Fri Sep 16 14:23:36 2016 +0200
3839 filehandler: added new plugin for monitoring file handles in linux
This new plugin reads file handles provided by /proc/sys/fs/file-nr and
puts them in relation of each other.
Thresholds of this check can be configured. Defaults are on 80/90%.
---
.werks/3839 | 11 ++++++
ChangeLog | 1 +
agents/plugins/mk_filehandler | 33 +++++++++++++++++
checkman/filehandler | 16 +++++++++
checks/filehandler | 70 ++++++++++++++++++++++++++++++++++++
web/plugins/metrics/check_mk.py | 10 ++++++
web/plugins/wato/check_parameters.py | 20 +++++++++++
7 files changed, 161 insertions(+)
diff --git a/.werks/3839 b/.werks/3839
new file mode 100644
index 0000000..b5a6d24
--- /dev/null
+++ b/.werks/3839
@@ -0,0 +1,11 @@
+Title: filehandler: added new plugin for monitoring file handles in linux
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.4.0i1
+Date: 1474028116
+Class: feature
+
+This new plugin reads file handles provided by /proc/sys/fs/file-nr and
+puts them in relation of each other.
+Thresholds of this check can be configured. Defaults are on 80/90%.
diff --git a/ChangeLog b/ChangeLog
index 910e8e1..a36def0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -164,6 +164,7 @@
* 3803 netapp_api_connection: reports any errors happened during the collection of
data...
* 3859 check_mail_loop.vbs: New MRPE script to perform a mail loop check via Outlook
MAPI...
* 3838 hitachi_hus_dku & hitachi_hus_dkc: more detailed output even if everything
is in state OK...
+ * 3839 filehandler: added new plugin for monitoring file handles in linux...
* 3073 FIX: windows agent: relative paths to mrpe scripts are now treated as relative
to the agent installation directory...
* 3061 FIX: mk_jolokia: Fixed debugging of the agent plugin
* 3074 FIX: windows agent: fixed incorrect values for 32-bit performance counters
diff --git a/agents/plugins/mk_filehandler b/agents/plugins/mk_filehandler
new file mode 100755
index 0000000..64668e7
--- /dev/null
+++ b/agents/plugins/mk_filehandler
@@ -0,0 +1,33 @@
+#!/bin/bash
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2014 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.
+
+FILE=/proc/sys/fs/file-nr
+
+echo '<<<filehandler>>>'
+if [ -a $FILE ]; then
+ cat $FILE
+fi
+
diff --git a/checkman/filehandler b/checkman/filehandler
new file mode 100644
index 0000000..1f50c79
--- /dev/null
+++ b/checkman/filehandler
@@ -0,0 +1,16 @@
+title: Total and used filehandles on system
+agents: linux
+catalog: os/kernel
+license: GPL
+distribution: check_mk
+description:
+ This check measures the current used fileshandles and sets it
+ in relation to the maximum.
+
+ Upper default levels are set to 80, 90 %. These levels are configurable.
+
+perfdata:
+ The percentage of used filehandles.
+
+inventory:
+ One service is created.
diff --git a/checks/filehandler b/checks/filehandler
new file mode 100644
index 0000000..c3c2f1a
--- /dev/null
+++ b/checks/filehandler
@@ -0,0 +1,70 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2014 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.
+
+
+# Measures total allocated file handles.
+# The output displays
+# - the number of allocated file handles
+# - the number of allocatedly used file handles (with the 2.4 kernel); or
+# the number of allocatedly unused file handles (with the 2.6 kernel)
+# - the maximum files handles that can be allocated
+# (can also be found in /proc/sys/fs/file-max)
+# Example output of '/proc/sys/fs/file-nr':
+# <<<filehandler>>>
+# 9376 0 817805
+
+
+factory_settings['filehandler_default_levels'] = {
+ 'levels': (80.0, 90.0)
+}
+
+def inventory_filehandler(info):
+ return [ ( None, {} ) ]
+
+def check_filehandler(_no_item, params, info):
+ allocated, used_or_unused, maximum = info[0]
+ state = 0
+ perc = float(allocated) / float(maximum) * 100.0
+ infotext = '%.1f%% used (%s of %s file handles)' % (perc, allocated,
maximum)
+ warn, crit = params['levels']
+
+ if perc >= crit:
+ state = 2
+ elif perc >= warn:
+ state = 1
+ if state > 0:
+ infotext += ' (warn/crit at %.1f%%/%.1f%%)' % (warn, crit)
+
+ return state, infotext, [ ( 'filehandler_perc', perc, warn, crit ) ]
+
+check_info['filehandler'] = {
+ 'check_function' : check_filehandler,
+ 'inventory_function' : inventory_filehandler,
+ 'service_description' : 'Filehandler',
+ 'has_perfdata' : True,
+ 'default_levels_variable' : 'filehandler_default_levels',
+ 'group' : 'filehandler',
+}
diff --git a/web/plugins/metrics/check_mk.py b/web/plugins/metrics/check_mk.py
index 51739e4..ca69bf9 100644
--- a/web/plugins/metrics/check_mk.py
+++ b/web/plugins/metrics/check_mk.py
@@ -3630,6 +3630,11 @@ metric_info["dns_nxdomain"] = {
"color" : "34/a",
}
+metric_info["filehandler_perc"] = {
+ "title" : _("Used file handles"),
+ "unit" : "%",
+ "color" : "#4800ff",
+}
#.
# .--Checks--------------------------------------------------------------.
@@ -5572,6 +5577,11 @@ perfometer_info.append({
# all segments
})
+perfometer_info.append({
+ "type" : "linear",
+ "segments" : [ "filehandler_perc" ],
+ "total" : 100.0,
+})
#.
# .--Graphs--------------------------------------------------------------.
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index a4cd01f..d75cc39 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -2740,6 +2740,26 @@ register_check_parameters(
match_type = "dict",
)
+register_check_parameters(
+ subgroup_storage,
+ "filehandler",
+ _("Filehandler"),
+ Dictionary(
+ elements = [
+ ( "levels", Tuple(
+ title = _("Levels"),
+ default_value = (80.0, 90.0),
+ elements = [
+ Percentage(title = _("Warning at"), unit =
_("%")),
+ Percentage(title = _("Critical at"), unit =
_("%"))
+ ]
+ ),
+ ),
+ ]
+ ),
+ None,
+ match_type = "dict"
+)
#.
# .--Unsorted--(Don't create new stuff here!)----------------------------.