Module: check_mk
Branch: master
Commit: 14885098b77fbaf416e4e9d706f18493f3644ded
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=14885098b77fba…
Author: Moritz Kiemer <mo(a)mathias-kettner.de>
Date: Wed Jan 9 15:04:19 2019 +0100
6953 lparstat_aix.cpu: Add levels for utilization
You can now set levels for the CPU utilization as well as for IO-wait.
Also available: Averaging and levels for time periods where CPU
utilization is above the CPU entitlement.
CMK-1297
Change-Id: I5ebe6ae882f61ca7d7300fb941e642aee494a36a
---
.werks/6953 | 12 ++++++++
checks/lparstat_aix | 26 ++++-------------
.../datasets/lparstat_aix_1_regression.py | 9 +++---
.../datasets/lparstat_aix_2_regression.py | 9 +++---
.../datasets/lparstat_aix_regression.py | 33 +++++++++++++---------
5 files changed, 45 insertions(+), 44 deletions(-)
diff --git a/.werks/6953 b/.werks/6953
new file mode 100644
index 0000000..832b80d
--- /dev/null
+++ b/.werks/6953
@@ -0,0 +1,12 @@
+Title: lparstat_aix.cpu: Add levels for utilization
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.6.0i1
+Date: 1547044973
+Class: feature
+
+You can now set levels for the CPU utilization as well as for IO-wait.
+Also available: Averaging and levels for time periods where CPU
+utilization is above the CPU entitlement.
diff --git a/checks/lparstat_aix b/checks/lparstat_aix
index 972f004..668e888 100644
--- a/checks/lparstat_aix
+++ b/checks/lparstat_aix
@@ -100,26 +100,12 @@ def check_lparstat_aix_cpu(_no_item, params, parsed):
# and legacy None defaults before 1.6
params = transform_cpu_iowait(params)
- perfdata = [("user", user), ("system", system),
("wait", wait)]
+ yield check_levels(user, "user", None, "%")
+ yield check_levels(system, "system", None, "%")
+ yield check_levels(wait, "wait", params.get('iowait'),
"%")
- infotext = "user: %2.1f%%, system: %2.1f%%, wait: %2.1f%%" % (user, system,
wait)
-
- result = 0
-
- if isinstance(params.get('util'), tuple):
- warn, crit = params['util']
- if util >= crit:
- result = max(result, 2)
- elif util >= warn:
- result = max(result, 1)
- if 'iowait' in params:
- warn, crit = params['iowait']
- if wait >= crit:
- result = max(result, 2)
- elif wait >= warn:
- result = max(result, 1)
-
- yield result, infotext, perfdata
+ for util_result in check_cpu_util(util, params, perf_max=None):
+ yield util_result
check_info['lparstat_aix.cpu_util'] = {
@@ -128,5 +114,5 @@ check_info['lparstat_aix.cpu_util'] = {
"service_description": "CPU utilization",
"has_perfdata": True,
"group": "cpu_iowait",
- 'includes': ['transforms.include'],
+ "includes": ["transforms.include",
"cpu_util.include"],
}
diff --git a/tests/unit/checks/generictests/datasets/lparstat_aix_1_regression.py
b/tests/unit/checks/generictests/datasets/lparstat_aix_1_regression.py
index 81e1c80..f883db4 100644
--- a/tests/unit/checks/generictests/datasets/lparstat_aix_1_regression.py
+++ b/tests/unit/checks/generictests/datasets/lparstat_aix_1_regression.py
@@ -32,11 +32,10 @@ checks = {
],
'cpu_util': [
(None, None, [
- (0, 'user: 0.2%, system: 0.4%, wait: 0.0%', [
- ('user', 0.2, None, None, None, None),
- ('system', 0.4, None, None, None, None),
- ('wait', 0.0, None, None, None, None),
- ]),
+ (0, 'user: 0.20%', [('user', 0.2)]),
+ (0, 'system: 0.40%', [('system', 0.4)]),
+ (0, 'wait: 0.00%', [('wait', 0.0)]),
+ (0, 'total cpu: 0.60%', [('util', 0.6000000000000001, None,
None, 0, None)]),
]),
],
}
diff --git a/tests/unit/checks/generictests/datasets/lparstat_aix_2_regression.py
b/tests/unit/checks/generictests/datasets/lparstat_aix_2_regression.py
index d667b35..0a2dbe7 100644
--- a/tests/unit/checks/generictests/datasets/lparstat_aix_2_regression.py
+++ b/tests/unit/checks/generictests/datasets/lparstat_aix_2_regression.py
@@ -65,11 +65,10 @@ checks = {
],
'cpu_util': [
(None, None, [
- (0, 'user: 0.2%, system: 0.4%, wait: 0.0%', [
- ('user', 0.2, None, None, None, None),
- ('system', 0.4, None, None, None, None),
- ('wait', 0.0, None, None, None, None),
- ]),
+ (0, 'user: 0.20%', [('user', 0.2)]),
+ (0, 'system: 0.40%', [('system', 0.4)]),
+ (0, 'wait: 0.00%', [('wait', 0.0)]),
+ (0, 'total cpu: 0.60%', [('util', 0.6000000000000001, None,
None, 0, None)]),
]),
],
}
diff --git a/tests/unit/checks/generictests/datasets/lparstat_aix_regression.py
b/tests/unit/checks/generictests/datasets/lparstat_aix_regression.py
index 8695c96..490b993 100644
--- a/tests/unit/checks/generictests/datasets/lparstat_aix_regression.py
+++ b/tests/unit/checks/generictests/datasets/lparstat_aix_regression.py
@@ -17,7 +17,7 @@ discovery = {
checks = {
'': [
(None, None, [
- (0, 'Physc: 0.02',[('physc', 0.02, None, None, None,
None)]),
+ (0, 'Physc: 0.02', [('physc', 0.02, None, None, None,
None)]),
(0, 'Entc: 9.3%', [('entc', 9.3, None, None, None, None)]),
(0, 'Lbusy: 0.1', [('lbusy', 0.1, None, None, None, None)]),
(0, 'App: 519.0', [('app', 519.0, None, None, None, None)]),
@@ -27,18 +27,23 @@ checks = {
]),
],
'cpu_util': [
- (None, None, [(0, 'user: 0.2%, system: 1.2%, wait: 0.2%',
- [('user', 0.2, None, None, None, None),
- ('system', 1.2, None, None, None, None),
- ('wait', 0.2, None, None, None, None)])]),
- (None, (0.1, 0.3), [(1, 'user: 0.2%, system: 1.2%, wait: 0.2%',
- [('user', 0.2, None, None, None, None),
- ('system', 1.2, None, None, None, None),
- ('wait', 0.2, None, None, None, None)])]),
- (None, {
- 'util': (0.5, 1.3)
- }, [(2, 'user: 0.2%, system: 1.2%, wait: 0.2%', [('user', 0.2,
None, None, None, None),
- ('system', 1.2, None,
None, None, None),
- ('wait', 0.2, None,
None, None, None)])]),
+ (None, None, [
+ (0, 'user: 0.20%', [('user', 0.2)]),
+ (0, 'system: 1.20%', [('system', 1.2)]),
+ (0, 'wait: 0.20%', [('wait', 0.2)]),
+ (0, 'total cpu: 1.60%', [('util', 1.5999999999999999, None,
None, 0, None)]),
+ ]),
+ (None, (0.1, 0.3), [
+ (0, 'user: 0.20%', [('user', 0.2)]),
+ (0, 'system: 1.20%', [('system', 1.2)]),
+ (1, 'wait: 0.20% (warn/crit at 0.10%/0.30%)', [('wait', 0.2,
0.1, 0.3)]),
+ (0, 'total cpu: 1.60%', [('util', 1.5999999999999999, None,
None, 0, None)]),
+ ]),
+ (None, {'util': (0.5, 1.3)}, [
+ (0, 'user: 0.20%', [('user', 0.2)]),
+ (0, 'system: 1.20%', [('system', 1.2)]),
+ (0, 'wait: 0.20%', [('wait', 0.2)]),
+ (2, 'total cpu: 1.60% (warn/crit at 0.50%/1.30%)', [('util',
1.5999999999999999, 0.5, 1.3, 0, None)]),
+ ]),
]
}