Module: check_mk
Branch: master
Commit: e17de5d2087d9b5df0dfd4e5d5dad075dc562106
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e17de5d2087d9b…
Author: Moritz Kiemer <mo(a)mathias-kettner.de>
Date: Thu Jan 10 07:12:56 2019 +0100
6954 lparstat_aix: Add CPU entitlement info and graph
The CPU utilization service now shows the CPU entitlement
alongside the current total utilization.
CMK-1297
Change-Id: I99a8106aebdaa55b9536e090d586c6a386d64474
---
.werks/6954 | 11 ++++++++++
checks/lparstat_aix | 24 +++++++++++++++++++++-
cmk/gui/plugins/metrics/check_mk.py | 19 ++++++++++++++++-
.../datasets/lparstat_aix_1_regression.py | 5 ++++-
.../datasets/lparstat_aix_2_regression.py | 3 +++
.../datasets/lparstat_aix_regression.py | 9 ++++++++
6 files changed, 68 insertions(+), 3 deletions(-)
diff --git a/.werks/6954 b/.werks/6954
new file mode 100644
index 0000000..28444dd
--- /dev/null
+++ b/.werks/6954
@@ -0,0 +1,11 @@
+Title: lparstat_aix: Add CPU entitlement info and graph
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.6.0i1
+Date: 1547124006
+Class: feature
+
+The CPU utilization service now shows the CPU entitlement
+alongside the current total utilization.
diff --git a/checks/lparstat_aix b/checks/lparstat_aix
index 668e888..76980e9 100644
--- a/checks/lparstat_aix
+++ b/checks/lparstat_aix
@@ -37,7 +37,10 @@ def parse_lparstat_aix(info):
if len(info) < 4:
return {'update_required': True}
- parsed = {}
+ # get system config:
+ kv_pairs = (word for word in info[0] if '=' in word)
+ parsed = {'system_config': dict(kv.split('=', 1) for kv in
kv_pairs)}
+
for index, key in enumerate(info[1]):
name = key.lstrip('%')
uom = '%' if '%' in key else ''
@@ -107,6 +110,25 @@ def check_lparstat_aix_cpu(_no_item, params, parsed):
for util_result in check_cpu_util(util, params, perf_max=None):
yield util_result
+ config = parsed.get('system_config', {})
+ partition_type = config.get('type', '').lower()
+ try:
+ kwargs = {
+ 'shared': {
+ 'infoname': "100% corresponding to entitled processing
capacity",
+ 'unit': "CPUs"
+ },
+ 'dedicated': {
+ 'infoname': "100% corresponding to",
+ 'unit': "physical processors"
+ },
+ }[partition_type]
+ cpu_entitlement = float(config['ent'])
+ except (KeyError, ValueError):
+ return
+ yield check_levels(cpu_entitlement, 'cpu_entitlement', None, **kwargs)
+ yield 0, "", [('cpu_entitlement_util', util / 100. *
cpu_entitlement)]
+
check_info['lparstat_aix.cpu_util'] = {
"check_function": check_lparstat_aix_cpu,
diff --git a/cmk/gui/plugins/metrics/check_mk.py b/cmk/gui/plugins/metrics/check_mk.py
index d6910e6..86fe5ec 100644
--- a/cmk/gui/plugins/metrics/check_mk.py
+++ b/cmk/gui/plugins/metrics/check_mk.py
@@ -1536,6 +1536,18 @@ metric_info["util15"] = {
"color": "#9a52bf",
}
+metric_info["cpu_entitlement"] = {
+ "title": _("Entitlement"),
+ "unit": "",
+ "color": "#66FF66",
+}
+
+metric_info["cpu_entitlement_util"] = {
+ "title": _("Utilization"),
+ "unit": "",
+ "color": "#FF5555",
+}
+
MAX_CORES = 128
for i in range(MAX_CORES):
@@ -8345,7 +8357,7 @@ graph_info["util_average_1"] = {
"range": ("util:min", "util:max"),
}
-graph_info["cpu_average_2"] = {
+graph_info["util_average_2"] = {
"title": _("CPU utilization"),
"metrics": [("util1", "area"), ("util15",
"line")],
"scalars": [
@@ -8444,6 +8456,11 @@ graph_info["cpu_utilization_8"] = {
"range": (0, 100),
}
+graph_info["cpu_entitlement"] = {
+ "title": _("CPU entitlement"),
+ "metrics": [("cpu_entitlement", "area"),
("cpu_entitlement_util", "line")],
+}
+
graph_info["per_core_utilization"] = {
"title": _("Per Core utilization"),
"metrics": [("cpu_core_util_%d" % num, "line") for num
in range(MAX_CORES)],
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 f883db4..8702ee8 100644
--- a/tests/unit/checks/generictests/datasets/lparstat_aix_1_regression.py
+++ b/tests/unit/checks/generictests/datasets/lparstat_aix_1_regression.py
@@ -4,7 +4,7 @@ checkname = 'lparstat_aix'
info = [
- ['System Config line is currently not used'],
+ ['System', 'Config', 'type=Dedicated', 'ent=7.0',
'what=ever'],
[u'%user', u'%sys', u'%wait', u'%idle',
u'physc', u'%entc', u'lbusy',
u'vcsw', u'phint', u'%nsp', u'%utcyc'],
[u'#', u'-----', u'-----', u'------',
u'------', u'-----', u'-----',
@@ -36,6 +36,9 @@ checks = {
(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)]),
+ (0, '100% corresponding to: 7.00 physical processors', [
+ ('cpu_entitlement', 7.0)]),
+ (0, "", [('cpu_entitlement_util', 0.04200000000000001)]),
]),
],
}
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 0a2dbe7..23c26ff 100644
--- a/tests/unit/checks/generictests/datasets/lparstat_aix_2_regression.py
+++ b/tests/unit/checks/generictests/datasets/lparstat_aix_2_regression.py
@@ -69,6 +69,9 @@ checks = {
(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)]),
+ (0, '100% corresponding to entitled processing capacity: 1.00 CPUs',
[
+ ('cpu_entitlement', 1.0)]),
+ (0, "", [('cpu_entitlement_util', 0.006000000000000001)]),
]),
],
}
diff --git a/tests/unit/checks/generictests/datasets/lparstat_aix_regression.py
b/tests/unit/checks/generictests/datasets/lparstat_aix_regression.py
index 490b993..1dc1efe 100644
--- a/tests/unit/checks/generictests/datasets/lparstat_aix_regression.py
+++ b/tests/unit/checks/generictests/datasets/lparstat_aix_regression.py
@@ -32,18 +32,27 @@ checks = {
(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)]),
+ (0, '100% corresponding to entitled processing capacity: 1.00 CPUs',
[
+ ('cpu_entitlement', 1.0)]),
+ (0, "", [('cpu_entitlement_util', 0.016)]),
]),
(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)]),
+ (0, '100% corresponding to entitled processing capacity: 1.00 CPUs',
[
+ ('cpu_entitlement', 1.0)]),
+ (0, "", [('cpu_entitlement_util', 0.016)]),
]),
(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)]),
+ (0, '100% corresponding to entitled processing capacity: 1.00 CPUs',
[
+ ('cpu_entitlement', 1.0)]),
+ (0, "", [('cpu_entitlement_util', 0.016)]),
]),
]
}