Module: check_mk
Branch: master
Commit: 5cf69a3267768273533112521413e2d735cee778
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=5cf69a32677682…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Sep 22 09:43:26 2016 +0200
3888 FIX df checks: Fixed invalid displayed WARN / CRIT lines in graphs when using
"bytes left" thresholds
---
.werks/3888 | 10 ++++++++++
ChangeLog | 1 +
checks/df.include | 34 +++++++++++++++-------------------
3 files changed, 26 insertions(+), 19 deletions(-)
diff --git a/.werks/3888 b/.werks/3888
new file mode 100644
index 0000000..d643c77
--- /dev/null
+++ b/.werks/3888
@@ -0,0 +1,10 @@
+Title: df checks: Fixed invalid displayed WARN / CRIT lines in graphs when using
"bytes left" thresholds
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.4.0i1
+Date: 1474530137
+
+
diff --git a/ChangeLog b/ChangeLog
index 8b98b42..d5986dc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -403,6 +403,7 @@
* 3810 FIX: windows agent: no longer truncates plugin output, no longer freezes when
plugin produces too much output...
* 3812 FIX: winperf_phydisk: reintroduced read and write queue length performance
data...
* 3813 FIX: check_mail: fixed missing base64 decoding on multipart mails
+ * 3888 FIX: df checks: Fixed invalid displayed WARN / CRIT lines in graphs when using
"bytes left" thresholds
Multisite:
* 3187 notification view: new filter for log command via regex
diff --git a/checks/df.include b/checks/df.include
index c9bfdee..4e73135 100644
--- a/checks/df.include
+++ b/checks/df.include
@@ -304,11 +304,6 @@ def df_check_filesystem_single(hostname, mountpoint, size_mb,
avail_mb, reserved
# bigger than 100 GB and lowers it for file systems smaller than 100 GB.
# Please run df_magic_factor.py to understand how it works.
- # TODO: In some future version use a fixed name as perf variable
- perf_var = mountpoint.replace(" ", "_")
- perfdata = [(perf_var, str(used_mb) + 'MB', warn_mb, crit_mb, 0, size_mb)]
- perfdata.append(('fs_size', str(size_mb) + 'MB'))
-
used_hr = get_bytes_human_readable(used_mb * 1024 * 1024)
size_hr = get_bytes_human_readable(size_mb * 1024 * 1024)
# If both numbers end with both MB or GB or TB, then drop the first one
@@ -320,21 +315,22 @@ def df_check_filesystem_single(hostname, mountpoint, size_mb,
avail_mb, reserved
infotext = "%s used (%s of %s)" % (
get_percent_human_readable(used_perc), used_hr, size_hr)
+ if warn_mb < 0.0:
+ # Negative levels, so user configured thresholds based on space left. Calculate
the
+ # upper thresholds based on the size of the filesystem
+ crit_mb = size_mb + crit_mb
+ warn_mb = size_mb + warn_mb
+
status = 0
- if warn_mb < 0:
- # Negative levels, so calculate MB left
- rest_mb = size_mb - used_mb
- crit_mb = crit_mb * -1
- warn_mb = warn_mb * -1
- if rest_mb <= crit_mb:
- status = 2
- elif rest_mb <= warn_mb:
- status = max(1, status)
- else:
- if used_mb >= crit_mb:
- status = 2
- elif used_mb >= warn_mb:
- status = max(1, status)
+ if used_mb >= crit_mb:
+ status = 2
+ elif used_mb >= warn_mb:
+ status = max(1, status)
+
+ # TODO: In some future version use a fixed name as perf variable
+ perf_var = mountpoint.replace(" ", "_")
+ perfdata = [(perf_var, str(used_mb) + 'MB', warn_mb, crit_mb, 0, size_mb)]
+ perfdata.append(('fs_size', str(size_mb) + 'MB'))
if type(params) == dict:
show_levels = params.get("show_levels")