Module: check_mk
Branch: master
Commit: 5fcd950400559d742703d9801002efa641c7036f
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=5fcd950400559d…
Author: Moritz Kiemer <mo(a)mathias-kettner.de>
Date: Thu Dec 20 08:35:40 2018 +0100
6949 ACME SBC Health (via SNMP)
This SNMP check reports the health status in percent and the redundancy state of
an ACME SBC device.
Change-Id: Ifbc2573820dfce036b93a3e2cc40644c6a2f7d8d
---
.werks/6949 | 11 +++
checkman/acme_sbc_snmp | 14 ++++
checks/acme_sbc_snmp | 92 ++++++++++++++++++++++
.../plugins/wato/check_parameters/acme_sbc_snmp.py | 55 +++++++++++++
.../checks/generictests/datasets/acme_sbc_snmp.py | 25 ++++++
tests/unit/cmk/gui/test_watolib.py | 2 +
6 files changed, 199 insertions(+)
diff --git a/.werks/6949 b/.werks/6949
new file mode 100644
index 0000000..79e1d27
--- /dev/null
+++ b/.werks/6949
@@ -0,0 +1,11 @@
+Title: ACME SBC Health (via SNMP)
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.6.0i1
+Date: 1545291224
+Class: feature
+
+This SNMP check reports the health status in percent and the redundancy state of
+an ACME SBC device.
diff --git a/checkman/acme_sbc_snmp b/checkman/acme_sbc_snmp
new file mode 100644
index 0000000..2efa09b
--- /dev/null
+++ b/checkman/acme_sbc_snmp
@@ -0,0 +1,14 @@
+title: ACME SBC: Health (via SNMP)
+agents: snmp
+catalog: hw/network/acme
+license: GPL
+distribution: check_mk
+description:
+ This is a simple check which checks the health status in percent and the redundancy state.
+ The percent value is reported by the devices and reflects the status of cluster
+ and hardware. If the status not is at 100 %, a {WARN} is raised. If a device is in outOfService
+ or unassigned state, a {CRIT} will be raised. If the device is in an initial or pending state, a
+ {WARN} will be raised.
+
+inventory:
+ One check will be created.
diff --git a/checks/acme_sbc_snmp b/checks/acme_sbc_snmp
new file mode 100644
index 0000000..d800b84
--- /dev/null
+++ b/checks/acme_sbc_snmp
@@ -0,0 +1,92 @@
+#!/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.
+
+# comNET GmbH, Fabian Binder
+
+# .1.3.6.1.4.1.9148.3.2.1.1.3 Health Score (apSysHealthScore)
+# .1.3.6.1.4.1.9148.3.2.1.1.4 Health Status Description (apSysRedundancy)
+
+factory_settings["acme_sbc_snmp_default_levels"] = {
+ "levels_lower": (99, 75),
+}
+
+
+def inventory_acme_sbc_snmp(info):
+ yield None, {}
+
+
+def check_acme_sbc_snmp(_no_item, params, info):
+ map_states = {
+ "0": (3, "unknown"),
+ "1": (1, "initial"),
+ "2": (0, "active"),
+ "3": (0, "standby"),
+ "4": (2, "out of service"),
+ "5": (2, "unassigned"),
+ "6": (1, "active (pending)"),
+ "7": (1, "standby (pending)"),
+ "8": (1, "out of service (pending)"),
+ "9": (1, "recovery"),
+ }
+
+ try:
+ score, state = info[0]
+ except (IndexError, ValueError):
+ return
+ health_state, health_state_readable = map_states.get(state, (3, "unknown"))
+ yield health_state, "Health state: %s" % (health_state_readable)
+
+ try:
+ score = int(score)
+ except ValueError:
+ yield 3, "Unknown score: %s" % score
+ return
+ warn, crit = params.get("levels_lower", (None, None))
+ levels_msg = " (warn/crit at or below %s%%/%s%%)" % (warn, crit)
+ score_msg = "Score: %s%%" % score
+ if crit is not None and score <= crit:
+ yield 2, score_msg + levels_msg
+ elif warn is not None and score <= warn:
+ yield 1, score_msg + levels_msg
+ else:
+ yield 0, score_msg
+
+
+check_info['acme_sbc_snmp'] = {
+ 'inventory_function': inventory_acme_sbc_snmp,
+ 'check_function': check_acme_sbc_snmp,
+ 'service_description': 'ACME SBC health',
+ 'snmp_info': (
+ '.1.3.6.1.4.1.9148.3.2.1.1',
+ [
+ "3", # APSYSMGMT-MIB::apSysHealthScore
+ "4", # APSYSMGMT-MIB::apSysRedundancy
+ ]),
+ 'snmp_scan_function': scan_acme,
+ 'includes': ['acme.include'],
+ 'group': 'acme_sbc_snmp',
+ 'default_levels_variable': 'acme_sbc_snmp_default_levels',
+}
diff --git a/cmk/gui/plugins/wato/check_parameters/acme_sbc_snmp.py b/cmk/gui/plugins/wato/check_parameters/acme_sbc_snmp.py
new file mode 100644
index 0000000..ec83909
--- /dev/null
+++ b/cmk/gui/plugins/wato/check_parameters/acme_sbc_snmp.py
@@ -0,0 +1,55 @@
+#!/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.
+
+from cmk.gui.i18n import _
+from cmk.gui.valuespec import (
+ Integer,
+ Dictionary,
+ Tuple,
+)
+from cmk.gui.plugins.wato import (
+ RulespecGroupCheckParametersApplications,
+ register_check_parameters,
+)
+
+register_check_parameters(
+ RulespecGroupCheckParametersApplications,
+ "acme_sbc_snmp",
+ _("ACME SBC health"),
+ Dictionary(
+ elements=[
+ ("levels_lower",
+ Tuple(
+ title=_("Levels on health status score in percent"),
+ elements=[
+ Integer(title=_("Warning below"), unit=_("percent"), default_value=99),
+ Integer(title=_("Critical below"), unit=_("percent"), default_value=75),
+ ])),
+ ],
+ required_keys=["levels_lower"]),
+ None,
+ match_type="dict",
+)
diff --git a/tests/unit/checks/generictests/datasets/acme_sbc_snmp.py b/tests/unit/checks/generictests/datasets/acme_sbc_snmp.py
new file mode 100644
index 0000000..ef1a7b8
--- /dev/null
+++ b/tests/unit/checks/generictests/datasets/acme_sbc_snmp.py
@@ -0,0 +1,25 @@
+
+
+checkname = 'acme_sbc_snmp'
+
+
+info = [
+ ['20', '2'],
+]
+
+
+discovery = {
+ '': [
+ (None, {}),
+ ],
+}
+
+
+checks = {
+ '': [
+ (None, {'levels_lower': (99, 75)}, [
+ (0, 'Health state: active', []),
+ (2, 'Score: 20% (warn/crit at or below 99%/75%)', []),
+ ]),
+ ],
+}
diff --git a/tests/unit/cmk/gui/test_watolib.py b/tests/unit/cmk/gui/test_watolib.py
index bec1ece..15d5aa5 100644
--- a/tests/unit/cmk/gui/test_watolib.py
+++ b/tests/unit/cmk/gui/test_watolib.py
@@ -582,6 +582,7 @@ def test_grouped_rulespecs():
'static_checks:skype_xmpp',
'static_checks:skype_edgeauth',
'static_checks:acme_certificates',
+ 'static_checks:acme_sbc_snmp',
'static_checks:skype',
'static_checks:skype_proxy',
'static_checks:skype_edge',
@@ -1088,6 +1089,7 @@ def test_grouped_rulespecs():
'checkgroup_parameters:skype_xmpp',
'checkgroup_parameters:skype_edgeauth',
'checkgroup_parameters:acme_certificates',
+ 'checkgroup_parameters:acme_sbc_snmp',
'checkgroup_parameters:skype',
'checkgroup_parameters:skype_proxy',
'checkgroup_parameters:skype_edge',
Module: check_mk
Branch: master
Commit: 1e614fa5d183d440117944d805e7311628bf205f
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=1e614fa5d183d4…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Dec 19 08:59:19 2018 +0100
7014 Add host name completion in different places
When entering host names in different places, like for example the parent attribute fields of a host
or the nodes fields of a cluster host, a dropdown is shown with the host names matching the already
inserted hostname parts. You may klick on the matching hostname to add it to the input field.
Change-Id: I2ec79aedf073543a5a18363d7536d9e73e10d03c
---
.werks/7014 | 12 ++++++++++
cmk/gui/plugins/wato/__init__.py | 1 +
cmk/gui/plugins/wato/builtin_attributes.py | 2 ++
cmk/gui/plugins/wato/utils/__init__.py | 1 +
cmk/gui/valuespec.py | 36 ++++++++++++------------------
cmk/gui/wato/pages/hosts.py | 4 ++--
cmk/gui/wato/pages/pattern_editor.py | 12 +++++++---
cmk/gui/wato/pages/rulesets.py | 4 ++--
cmk/gui/wato/pages/sites.py | 13 +++++++++--
cmk/gui/watolib.py | 24 ++++++++++++++++++++
10 files changed, 78 insertions(+), 31 deletions(-)
Diff: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commitdiff;h=1e614fa5d1…
Module: check_mk
Branch: master
Commit: d1c429a26ea1f275b7bf2e02650fda53b28f4f0b
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d1c429a26ea1f2…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Wed Dec 19 09:40:44 2018 +0100
Make parsing of ps section deterministic between runs.
Note: The hash value of None is based on the memory address of the
singleton, so it varies between runs. Consequently, the hash value of
tuples containing None varies between runs, too.
CMK-1465
Change-Id: Ia70fef31e23ff69c011205a995d949c9c93d0aec
---
checks/ps | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)
diff --git a/checks/ps b/checks/ps
index e9eb3cc..a0a09cb 100644
--- a/checks/ps
+++ b/checks/ps
@@ -173,7 +173,7 @@ def extract_wmic_info(info):
#
# Node,
if "Name" in row and "ProcessId" in row:
- wmic_info[(row["node"], row["Name"], row["ProcessId"])] = row
+ wmic_info.setdefault((row["node"], row["Name"]), []).append(row)
else:
ps_result.append(line) # plain list of process names
@@ -181,20 +181,14 @@ def extract_wmic_info(info):
def merge_wmic(ps_result, wmic_info, wmic_headers):
- def get_ps_info(node, name, processId=0):
- for key, value in wmic_info.items():
- if (not processId and key[0:2] == (node, name)) or key == (node, name, processId):
- # each info is only returned once!
- del wmic_info[key]
- return value
-
info = []
seen_pids = set([]) # Remove duplicate entries
cpu_cores = 1
for line in ps_result:
- psinfo = get_ps_info(line[0], line[1])
- # Get number of CPU cores from system idle process
- if psinfo:
+ psinfos = wmic_info.get((line[0], line[1]), [])
+ if psinfos:
+ psinfo = psinfos.pop() # each info is used only once!
+ # Get number of CPU cores from system idle process
if "ThreadCount" in wmic_headers and psinfo["Name"].lower() == "system idle process":
cpu_cores = int(psinfo["ThreadCount"])
pid = int(psinfo["ProcessId"])