Module: check_mk
Branch: master
Commit: 8cf2e7b4a246e565e279196af7d7509571ff5ec5
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=8cf2e7b4a246e5…
Author: Moritz Kiemer <mo(a)mathias-kettner.de>
Date: Tue Jan 8 10:55:54 2019 +0100
cpu util check parameters: a step towards consistency
CMK-1297
Change-Id: I8c88a2dfc058667876a296e45de89cf5b54ef3e3
---
checks/bintec_cpu | 10 +--
checks/cisco_nexus_cpu | 2 +-
checks/cpu_util.include | 4 +-
checks/hr_cpu | 2 +-
cmk/gui/plugins/wato/check_parameters/unsorted.py | 77 +++++++++++------------
5 files changed, 48 insertions(+), 47 deletions(-)
diff --git a/checks/bintec_cpu b/checks/bintec_cpu
index b2a9b2c..6538c22 100644
--- a/checks/bintec_cpu
+++ b/checks/bintec_cpu
@@ -42,12 +42,12 @@ def check_bintec_cpu(_no_item, params, info):
streams = float(info[0][2])
util = user + system + streams
- for res in check_cpu_util(util, params):
- state, infotext, perfdata = res
- yield state, "total: %s" % infotext, perfdata
+ yield 0, "user: %.1f%%" % user
+ yield 0, "system: %.1f%%" % system
+ yield 0, "streams: %.1f%%" % streams, [("streams", streams)]
- yield 0, "user: %.1f%%, system: %.1f%%, streams: %.1f%%" % \
- (user, system, streams), [ ("streams", "%.3f" %
streams), ]
+ for res in check_cpu_util(util, params):
+ yield res
check_info['bintec_cpu'] = {
diff --git a/checks/cisco_nexus_cpu b/checks/cisco_nexus_cpu
index 966bd08..8db0175 100644
--- a/checks/cisco_nexus_cpu
+++ b/checks/cisco_nexus_cpu
@@ -27,7 +27,7 @@
# .1.3.6.1.4.1.9.9.305.1.1.1.0 1 --> CISCO-SYSTEM-EXT-MIB::cseSysCPUUtilization.0
factory_settings["cisco_nexus_cpu_default_levels"] = {
- 'levels': (80.0, 90.0),
+ 'util': (80.0, 90.0),
}
diff --git a/checks/cpu_util.include b/checks/cpu_util.include
index f9deecd..631caf4 100644
--- a/checks/cpu_util.include
+++ b/checks/cpu_util.include
@@ -67,7 +67,9 @@ def check_cpu_util(util, params, this_time=None, cores=None):
elif isinstance(params, tuple):
params = {"levels": params}
- levels = params.get("levels")
+ levels = params.get("util")
+ if levels is None: # legacy rules before 1.6
+ levels = params.get("levels")
# Averaging
if "average" in params:
diff --git a/checks/hr_cpu b/checks/hr_cpu
index f1d6604..0e6f723 100644
--- a/checks/hr_cpu
+++ b/checks/hr_cpu
@@ -28,7 +28,7 @@
# .1.3.6.1.2.1.25.3.3.1.2.769 1 --> HOST-RESOURCES-MIB::hrProcessorLoad.769
factory_settings["hr_cpu_default_levels"] = {
- "levels": (80.0, 90.0),
+ "util": (80.0, 90.0),
}
diff --git a/cmk/gui/plugins/wato/check_parameters/unsorted.py
b/cmk/gui/plugins/wato/check_parameters/unsorted.py
index e5c2153..36474c0 100644
--- a/cmk/gui/plugins/wato/check_parameters/unsorted.py
+++ b/cmk/gui/plugins/wato/check_parameters/unsorted.py
@@ -6063,6 +6063,18 @@ cpu_util_common_elements = [
],
help=_("Here you can set levels on the CPU utilization on single
cores"),
)),
+ ("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."),
+ )),
("core_util_time_total",
Tuple(
title=_("Levels over an extended time period on total CPU
utilization"),
@@ -6102,35 +6114,36 @@ cpu_util_common_elements = [
"as well as devices monitored through the host-resource
mib"))),
]
+
+def transform_legacy_cpu_utilization_os(params):
+ if "levels" in params:
+ params['util'] = params.pop('levels')
+ return params
+
+
register_check_parameters(
RulespecGroupCheckParametersOperatingSystem,
"cpu_utilization_os",
_("CPU utilization for simple devices"),
- Dictionary(
- help=_("This rule configures levels for the CPU utilization (not load) for
"
- "the operating systems Windows and VMWare ESX host systems, as well
as devices "
- "implementing the Host Resources MIB. The utilization "
- "ranges from 0 to 100 - regardless of the number of CPUs."),
- elements=[
- ("average",
- Integer(
- title=_("Averaging"),
- help=_("When this option is activated then the CPU utilization is
being "
- "averaged <b>before</b> the levels are being
applied."),
- unit=_("minutes"),
- minvalue=1,
- 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,
- )),
- ] + cpu_util_common_elements,
+ Transform(
+ Dictionary(
+ help=_("This rule configures levels for the CPU utilization (not load)
for "
+ "the operating systems Windows and VMWare ESX host systems, as
well as devices "
+ "implementing the Host Resources MIB. The utilization "
+ "ranges from 0 to 100 - regardless of the number of
CPUs."),
+ elements=[
+ ("average",
+ Integer(
+ title=_("Averaging"),
+ help=_("When this option is activated then the CPU utilization
is being "
+ "averaged <b>before</b> the levels are being
applied."),
+ unit=_("minutes"),
+ minvalue=1,
+ default_value=15,
+ label=_("Compute average over last "),
+ )),
+ ] + cpu_util_common_elements),
+ forth=transform_legacy_cpu_utilization_os,
),
None,
match_type="dict",
@@ -6150,20 +6163,6 @@ register_check_parameters(
_("CPU utilization on Linux/UNIX"),
Transform(
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)"),