Module: check_mk
Branch: master
Commit: e2358103ae2335793bd0dd2e0c35fe928f6c5f7e
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e2358103ae2335…
Author: Tom Baerwinkel <tb(a)mathias-kettner.de>
Date: Tue Mar 19 17:12:01 2019 +0100
7066 FIX k8s_stats.network: prefer lnx_if check if present
When the check_mk_agent was used together with the Kubernetes
special agent duplicate interfaces were discovered. Now the
lnx_if check from the check_mk_agent is preferred over the
k8s_stats.network check from the special agent.
Change-Id: Ic91376da1594d8861dd7cd9d6731775d62cb7e29
---
.werks/7066 | 14 ++++++++++++++
checks/k8s_stats | 39 +++++++++++++++++++++++++++++----------
2 files changed, 43 insertions(+), 10 deletions(-)
diff --git a/.werks/7066 b/.werks/7066
new file mode 100644
index 0000000..83056f2
--- /dev/null
+++ b/.werks/7066
@@ -0,0 +1,14 @@
+Title: k8s_stats.network: prefer lnx_if check if present
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.6.0i1
+Date: 1553011735
+
+When the check_mk_agent was used together with the Kubernetes
+special agent duplicate interfaces were discovered. Now the
+lnx_if check from the check_mk_agent is preferred over the
+k8s_stats.network check from the special agent.
diff --git a/checks/k8s_stats b/checks/k8s_stats
index 2ee6b4e..0e58d36 100644
--- a/checks/k8s_stats
+++ b/checks/k8s_stats
@@ -25,18 +25,32 @@
# Boston, MA 02110-1301 USA.
-@discover
-def discover_k8s_stats_network(key, value):
- if key == 'network':
- return set([interface.get('name') for interface in
value['interfaces']])
+def discover_k8s_stats_network(parsed):
+ # don't use the k8s check if the check_mk_agent delivers interface data
+ parsed, lnx_info = parsed
+ if lnx_info:
+ return
+ for key, value in parsed.iteritems():
+ if key != 'network':
+ continue
-@discover
-def discover_k8s_stats_fs(key, value):
+ for interface in value['interface']:
+ yield interface.get('name'), {}
+
+
+def discover_k8s_stats_fs(parsed):
+ parsed, _ = parsed
ignore_fs = ['tmpfs', 'rootfs']
- if key == 'filesystem':
+
+ for key, value in parsed.iteritems():
+ if key != 'filesystem':
+ continue
+
devices = [disk.get('device') for disk in value]
- return set([x for x in devices if x not in ignore_fs])
+ for device in devices:
+ if device not in ignore_fs:
+ yield device, {}
def k8s_network_err_pac(device, params, now):
@@ -65,7 +79,9 @@ def k8s_network_err_pac(device, params, now):
yield status, infotext, perf_data
-def check_k8s_stats_network(item, params, metrics):
+def check_k8s_stats_network(item, params, parsed):
+ metrics, _ = parsed
+
device = sum([
collections.Counter(device)
for device in metrics['network']['interfaces']
@@ -98,7 +114,9 @@ def check_k8s_stats_network(item, params, metrics):
yield check_levels(rate, dsname, params.get('discards'),
unit='1/s', infoname=name)
-def check_k8s_stats_fs(item, params, metrics):
+def check_k8s_stats_fs(item, params, parsed):
+ metrics, _ = parsed
+
disk = sum([
collections.Counter(device)
for device in metrics['filesystem']
@@ -118,6 +136,7 @@ def check_k8s_stats_fs(item, params, metrics):
check_info['k8s_stats'] = {
'parse_function': parse_k8s,
+ 'extra_sections': ['lnx_if'],
}
check_info['k8s_stats.network'] = {