Module: check_mk
Branch: master
Commit: da9ca35d2a2d6b89ef05ac88928be399ff393431
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=da9ca35d2a2d6b…
Author: Óscar Nájera <on(a)mathias-kettner.de>
Date: Mon Nov 19 15:31:10 2018 +0100
6652 Predictive Levels for CPU utilization in Linux/Unix
Linux CPU utilization can now be monitored using predictive levels for the
thresholds to warning and critical states. This confiruration is directly
accessible in WATO.
CKM-1284
Change-Id: Ie6d4cfb55541e3a9ea7794d7e867806d8b080b4f
---
.werks/6652 | 12 +++
checks/kernel | 1 -
cmk/gui/plugins/wato/check_parameters.py | 112 ++++++++++-----------
.../cmk/gui/plugins/wato/test_check_parameters.py | 24 ++++-
4 files changed, 90 insertions(+), 59 deletions(-)
diff --git a/.werks/6652 b/.werks/6652
new file mode 100644
index 0000000..8933212
--- /dev/null
+++ b/.werks/6652
@@ -0,0 +1,12 @@
+Title: Predictive Levels for CPU utilization in Linux/Unix
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.6.0i1
+Date: 1543243736
+Class: feature
+
+Linux CPU utilization can now be monitored using predictive levels for the
+thresholds to warning and critical states. This confiruration is directly
+accessible in WATO.
diff --git a/checks/kernel b/checks/kernel
index 1edc2c0..06ffad7 100644
--- a/checks/kernel
+++ b/checks/kernel
@@ -85,7 +85,6 @@ check_info["kernel"] = {
'group': 'vm_counter',
}
-#.
# .--kernel.util--CPU Utilization----------------------------------------.
# | _ _ _ _ _ _ _ _ |
# | | | | | |_(_) (_)______ _| |_(_) ___ _ __ |
diff --git a/cmk/gui/plugins/wato/check_parameters.py
b/cmk/gui/plugins/wato/check_parameters.py
index c416dce..0044b7b 100644
--- a/cmk/gui/plugins/wato/check_parameters.py
+++ b/cmk/gui/plugins/wato/check_parameters.py
@@ -9358,18 +9358,16 @@ cpu_util_common_elements = [
"exceeding a utilization threshold over an extended period of
time."
"This is currently only supported on linux and windows agents
"
"as well as devices monitored through the host-resource
mib"))),
- (
- "core_util_graph",
- Checkbox(
- title=_("Graphs for individual cores"),
- label=_("Enable performance graph for utilization of individual
cores"),
- help=_("This adds another graph to the performance CPU utilization
"
- "details page, showing utilization of individual cores. "
- "Please note that this graph may be impractical on "
- "device with very many cores. "
- "This is currently only supported on linux and windows agents
"
- "as well as devices monitored through the host-resource
mib")),
- ),
+ ("core_util_graph",
+ Checkbox(
+ title=_("Graphs for individual cores"),
+ label=_("Enable performance graph for utilization of individual
cores"),
+ help=_("This adds another graph to the performance CPU utilization "
+ "details page, showing utilization of individual cores. "
+ "Please note that this graph may be impractical on "
+ "device with very many cores. "
+ "This is currently only supported on linux and windows agents
"
+ "as well as devices monitored through the host-resource
mib"))),
]
register_check_parameters(
@@ -9392,62 +9390,62 @@ register_check_parameters(
default_value=15,
label=_("Compute average over last "),
)),
- (
- "levels",
- Levels(
- title=_("Levels on total CPU utilization"),
- unit="%",
- default_levels=(85, 90),
- default_difference=(5, 8),
- default_value=None,
- ),
- ),
+ ("levels",
+ Levels(
+ title=_("Levels on total CPU utilization"),
+ unit="%",
+ default_levels=(85, 90),
+ default_difference=(5, 8),
+ default_value=None,
+ )),
] + cpu_util_common_elements,
),
None,
match_type="dict",
)
+
+def transform_cpu_iowait(params):
+ if isinstance(params, tuple):
+ return {"iowait": params}
+
+ return params
+
+
register_check_parameters(
subgroup_os,
"cpu_iowait",
_("CPU utilization on Linux/UNIX"),
Transform(
- Dictionary(
- elements=[
- (
- "iowait",
- Tuple(
- title=_("Levels on disk wait (IO wait)"),
- elements=[
- Percentage(title=_("Warning at a disk wait of"),
default_value=30.0),
- Percentage(title=_("Critical at a disk wait of"),
default_value=50.0)
- ],
- help=
- _("The CPU utilization sums up the percentages of CPU time
that is used "
- "for user processes, kernel routines (system), disk wait
(sometimes also "
- "called IO wait) or nothing (idle). "
- "Currently you can only set warning/critical levels to the
disk wait. This "
- "is the total percentage of time all CPUs have nothing
else to do then waiting "
- "for data coming from or going to disk. If you have a
significant disk wait "
- "the the bottleneck of your server is IO. Please note that
depending on the "
- "applications being run this might or might not be totally
normal.")),
- ),
- ("util",
- Tuple(
- title=_("Levels on total CPU utilization"),
- elements=[
- Percentage(title=_("Warning at a utilization of"),
default_value=90.0),
- Percentage(title=_("Critical at a utilization of"),
default_value=95.0)
- ],
- help=
- _("Here you can set levels on the total CPU utilization, i.e.
the sum of "
- "<i>system</i>, <i>user</i> and
<i>iowait</i>. The levels are always applied "
- "on the average utiliazation since the last check - which is
usually one minute."
- ),
- )),
- ] + cpu_util_common_elements,),
- forth=lambda old: not isinstance(old, dict) and {"iowait": old} or
old,
+ Dictionary(elements=[
+ ("util",
+ Levels(
+ title=_("Levels on total CPU utilization"),
+ unit="%",
+ default_levels=(90, 95),
+ default_difference=(5, 8),
+ default_value=None,
+ help=
+ _("The CPU utilization sums up the percentages of CPU time that is
used "
+ "for user processes, kernel routines (system), disk wait
(sometimes also "
+ "called IO wait) or nothing (idle). The levels are always applied
"
+ "on the average utiliazation since the last check - which is
usually one minute."
+ ),
+ )),
+ ("iowait",
+ Tuple(
+ title=_("Levels on disk wait (IO wait)"),
+ elements=[
+ Percentage(title=_("Warning at a disk wait of"),
default_value=30.0),
+ Percentage(title=_("Critical at a disk wait of"),
default_value=50.0)
+ ],
+ help=
+ _("The disk wait is the total percentage of time all CPUs have
nothing else to do but waiting "
+ "for data coming from or going to disk. If you have a significant
disk wait "
+ "the the bottleneck of your server is IO. Please note that
depending on the "
+ "applications being run this might or might not be totally
normal."))),
+ ] + cpu_util_common_elements),
+ forth=transform_cpu_iowait,
),
None,
"dict",
diff --git a/tests/unit/cmk/gui/plugins/wato/test_check_parameters.py
b/tests/unit/cmk/gui/plugins/wato/test_check_parameters.py
index afe72e3..e4f666c 100644
--- a/tests/unit/cmk/gui/plugins/wato/test_check_parameters.py
+++ b/tests/unit/cmk/gui/plugins/wato/test_check_parameters.py
@@ -1,6 +1,7 @@
import pytest
from cmk.gui.exceptions import MKUserError
-from cmk.gui.plugins.wato.check_parameters import forbid_re_delimiters_inside_groups
+from cmk.gui.plugins.wato.check_parameters import (forbid_re_delimiters_inside_groups,
+ transform_cpu_iowait)
@pytest.mark.parametrize('pattern', ["(test)$", 'foo\\b',
'^bar', '\\bfoo\\b', '(a)\\b'])
@@ -12,3 +13,24 @@ def test_validate_ps_allowed_regex(pattern):
def test_validate_ps_forbidden_regex(pattern):
with pytest.raises(MKUserError):
forbid_re_delimiters_inside_groups(pattern, '')
+
+
+(a)pytest.mark.parametrize('paramsrams, result', [
+ (
+ (10, 20),
+ {
+ 'iowait': (10, 20)
+ },
+ ),
+ ({}, {}),
+ (
+ {
+ 'util': (50, 60)
+ },
+ {
+ 'util': (50, 60)
+ },
+ ),
+])
+def test_transform_cpu_iowait(params, result):
+ assert transform_cpu_iowait(params) == result