Module: check_mk
Branch: master
Commit: 963bb8e60ee45e5aa8441be5f94c4549f088df50
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=963bb8e60ee45e…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Tue Apr 19 08:53:52 2016 +0200
3400 FIX local: do not crash in P mode if performance data contains a unit of measurement
---
.werks/3400 | 10 ++++++++++
ChangeLog | 1 +
checks/local | 12 +++++++++++-
3 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/.werks/3400 b/.werks/3400
new file mode 100644
index 0000000..0a02009
--- /dev/null
+++ b/.werks/3400
@@ -0,0 +1,10 @@
+Title: local: do not crash in P mode if performance data contains a unit of measurement
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.9i1
+Date: 1461048810
+
+
diff --git a/ChangeLog b/ChangeLog
index 2f50127..1f92a08 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -157,6 +157,7 @@
* 3409 FIX: apt: fixed 'UNKNOWN - Item not found in agent output' error if
there are no pending updates
* 3399 FIX: statgrab_mem, hr_mem: Fix display of total installed memory in graph
* 3384 FIX: eltek_battery: Fixed broken check due to wrong spelled include file
+ * 3400 FIX: local: do not crash in P mode if performance data contains a unit of
measurement
Multisite:
* 3187 notification view: new filter for log command via regex
diff --git a/checks/local b/checks/local
index 0785aaf..58bf27e 100644
--- a/checks/local
+++ b/checks/local
@@ -40,6 +40,16 @@
def local_compute_state(perfdata):
texts = []
+ # 16MB -> 16.0
+ def float_ignore_uom(value):
+ while value:
+ if value[-1] not in "012345678.-":
+ value = value[:-1]
+ else:
+ return float(value)
+ return 0.0
+
+
def outof_levels(value, levels):
if levels == None:
return
@@ -59,7 +69,7 @@ def local_compute_state(perfdata):
if len(entry) < 3:
continue # No levels attached
varname = entry[0]
- value = float(entry[1])
+ value = float_ignore_uom(entry[1])
warn = entry[2]
if len(entry) >= 4:
crit = entry[3]