Module: check_mk
Branch: master
Commit: d1d8e8a35991bd52cfd566d5a40fd33739e5f3ee
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d1d8e8a35991bd…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Apr 15 09:35:16 2013 +0200
Fix levels on disk IO (was wrong by 10^12)
---
checks/diskstat.include | 2 +-
modules/check_mk_base.py | 15 +++++++++++----
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/checks/diskstat.include b/checks/diskstat.include
index 3ea731b..ac50687 100644
--- a/checks/diskstat.include
+++ b/checks/diskstat.include
@@ -121,7 +121,7 @@ def check_diskstat_line(this_time, item, params, line):
# check levels
state, text, extraperf = check_levels(bytes_per_sec, dsname, levels,
- unit = "MB/s", factor = 1.0 /
1048576, statemarkers=True)
+ unit = "MB/s", factor = 1048576,
statemarkers=True)
if text:
infos.append(text)
status = max(state, status)
diff --git a/modules/check_mk_base.py b/modules/check_mk_base.py
index 1585a8c..56c7de0 100755
--- a/modules/check_mk_base.py
+++ b/modules/check_mk_base.py
@@ -1293,6 +1293,13 @@ def nodes_of(hostname):
# Generic function for checking a value against levels. This also support
# predictive levels.
+# value: currently measured value
+# dsname: name of the datasource in the RRD that corresponds to this value
+# unit: unit to be displayed in the plugin output, e.g. "MB/s"
+# factor: the levels are multiplied with this factor before applying
+# them to the value. For example the disk-IO check uses B/s
+# as the unit for the value. But the levels are in MB/s. In that
+# case the factor is 1.0 / 1048576.
def check_levels(value, dsname, params, unit = "", factor = 1.0,
statemarkers=False):
if params == None or params == (None, None):
@@ -1325,18 +1332,18 @@ def check_levels(value, dsname, params, unit = "",
factor = 1.0, statemarkers=Fa
# Critical cases
if crit_upper != None and value >= crit_upper:
state = 2
- infotext += " (critical level at %.2f)" % crit_upper
+ infotext += " (critical level at %.2f%s)" % (crit_upper / factor,
unit)
elif crit_lower != None and value <= crit_lower:
state = 2
- infotext += " (too low: critical level at %.2f)" % crit_lower
+ infotext += " (too low: critical level at %.2f%s)" % (crit_lower /
factor, unit)
# Warning cases
elif warn_upper != None and value >= warn_upper:
state = 1
- infotext += " (warning level at %.2f)" % warn_upper
+ infotext += " (warning level at %.2f%s)" % (warn_upper / factor, unit)
elif warn_lower != None and value <= warn_lower:
state = 1
- infotext += " (too low: warning level at %.2f)" % warn_lower
+ infotext += " (too low: warning level at %.2f%s)" % (warn_lower /
factor, unit)
# OK
else: