Module: check_mk
Branch: master
Commit: f704ee89f13a18eafe79ab24fec4a887b3f976a3
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f704ee89f13a18…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Wed Aug 24 22:28:58 2011 +0200
Update internal comments
---
.bugs/128 | 2 +-
checks/df.include | 17 +++++++++++------
modules/check_mk_base.py | 9 +++++++--
3 files changed, 19 insertions(+), 9 deletions(-)
diff --git a/.bugs/128 b/.bugs/128
index e09c2f6..9ee272f 100644
--- a/.bugs/128
+++ b/.bugs/128
@@ -1,4 +1,4 @@
-Title: df trends: Peak values after changing the levels_range param
+Title: df trends: Peak values after changing the trend_range
Component: checks
Benefit: 1
State: open
diff --git a/checks/df.include b/checks/df.include
index c338d02..b795019 100644
--- a/checks/df.include
+++ b/checks/df.include
@@ -161,17 +161,22 @@ def df_check_filesystem(hostname, mountpoint, size_mb, avail_mb,
params):
range = levels["trend_range"] # in hours
range_sec = range * 3600.0
this_time = time.time()
- # rate in MB/s, allow negative
- timdif, rate = get_counter("df.%s.delta" % mountpoint, this_time,
used_mb, True)
+
+ # first compute current rate in MB/s by computing delta since last check
+ timedif, rate = get_counter("df.%s.delta" % mountpoint, this_time,
used_mb, True)
if levels.get("trend_perfdata"):
perfdata.append(("growth", rate * range_sec))
- # average trend, initialize with zero
- timedif, rate_avg = get_average("df.%s.trend" % mountpoint,
this_time, rate, range_sec / 60.0, True)
- # rate_avg is groth in MB/sec
+ # average trend, initialize with zero, rate_avg is in MB/s
+ timedif, rate_avg = get_average("df.%s.trend" % mountpoint,
+ this_time, rate, range_sec / 60.0, True)
+
+ # rate_avg is growth in MB/s, trend is in MB per trend range hours
trend = rate_avg * range_sec
sign = trend > 0 and "+" or ""
- infotext += ", trend: %s%s / %g hours" % (sign,
get_bytes_human_readable(trend * MB), range)
+ infotext += ", trend: %s%s / %g hours" % \
+ (sign, get_bytes_human_readable(trend * MB), range)
+
# levels for performance data
warn_perf, crit_perf = None, None
diff --git a/modules/check_mk_base.py b/modules/check_mk_base.py
index 44ce064..8f71d42 100755
--- a/modules/check_mk_base.py
+++ b/modules/check_mk_base.py
@@ -605,14 +605,19 @@ def get_counter(countername, this_time, this_val,
allow_negative=False):
return timedif, per_sec
+# Compute average by gliding exponential algorithm
+# itemname: unique id for storing this average until the next check
+# this_time: timestamp of new value
+# backlog: averaging horizon in minutes
+# initialize_zero: assume average of 0.0 when now previous average is stored
def get_average(itemname, this_time, this_val, backlog, initialize_zero = True):
- # first call: take current value as average
+ # first call: take current value as average or assume 0.0
if not itemname in g_counters:
if initialize_zero:
this_val = 0
g_counters[itemname] = (this_time, this_val)
- return 1.0, this_val
+ return 1.0, this_val # avoid time diff of 0.0 -> avoid division by zero
# Get previous value and time difference
last_time, last_val = g_counters.get(itemname)