Module: check_mk
Branch: master
Commit: 4f8b24e4f84c4c07f0c89160d6f42dde5865431d
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=4f8b24e4f84c4c…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Nov 29 15:58:03 2013 +0100
Introduce optional lower limit for predicted levels
When configuring predictive levels while using relative levels or those
based on the standard deviation then time periods with a very low
reference (e.g. a CPU load below 1) would result in very narrow levels
and lead to frequent false alarms.
Now you can set a lower limit for the levels, for example such that they
would never go below 5 and 10 for warn and crit - regardless of the
current predicted value.
---
.werks/11 | 15 +++++++++++++++
ChangeLog | 1 +
modules/prediction.py | 22 ++++++++++++++++------
web/htdocs/prediction.py | 14 +++++++++-----
web/htdocs/wato.py | 7 ++++---
5 files changed, 45 insertions(+), 14 deletions(-)
diff --git a/.werks/11 b/.werks/11
new file mode 100644
index 0000000..5c5cc7f
--- /dev/null
+++ b/.werks/11
@@ -0,0 +1,15 @@
+Title: Introduce optional lower limit for predicted levels
+Level: 1
+Component: core
+Version: 1.2.3i7
+Date: 1385736954
+Class: feature
+
+When configuring predictive levels while using relative levels or those
+based on the standard deviation then time periods with a very low
+reference (e.g. a CPU load below 1) would result in very narrow levels
+and lead to frequent false alarms.
+
+Now you can set a lower limit for the levels, for example such that they
+would never go below 5 and 10 for warn and crit - regardless of the
+current predicted value.
diff --git a/ChangeLog b/ChangeLog
index ab595e6..7f0fba9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,6 @@
1.2.3i7:
Core & Setup:
+ * 0011 Introduce optional lower limit for predicted levels...
* 0217 FIX: More verbose error output for SNMP errors on the command line...
* 0288 FIX: Error messages of datasource programs (e.g. VSphere Agent) are now
visible within WATO...
* 0010 FIX: Fix computation of hour-of-the-day and day-of-month prediction...
diff --git a/modules/prediction.py b/modules/prediction.py
index db1041f..b67facb 100644
--- a/modules/prediction.py
+++ b/modules/prediction.py
@@ -122,25 +122,35 @@ def group_by_wday(t):
def group_by_day(t):
return "everyday", (t - time.timezone) % 86400
+def group_by_day_of_month(t):
+ broken = time.localtime(t)
+ mday = broken[2]
+ return str(mday), (t - time.timezone) % 86400
+
def group_by_everyhour(t):
return "everyhour", (t - time.timezone) % 3600
prediction_periods = {
"wday" : {
- "slice" : 86400,
+ "slice" : 86400, # 7 slices
"groupby" : group_by_wday,
"valid" : 7,
},
"day" : {
- "slice" : 86400,
+ "slice" : 86400, # 31 slices
+ "groupby" : group_by_day_of_month,
+ "valid" : 28,
+ },
+ "hour" : {
+ "slice" : 86400, # 1 slice
"groupby" : group_by_day,
"valid" : 1,
},
- "hour" : {
- "slice" : 3600,
+ "minute" : {
+ "slice" : 3600, # 1 slice
"groupby" : group_by_everyhour,
- "valid" : 1,
- }
+ "valid" : 24,
+ },
}
diff --git a/web/htdocs/prediction.py b/web/htdocs/prediction.py
index b7d1d9d..0f1d35e 100644
--- a/web/htdocs/prediction.py
+++ b/web/htdocs/prediction.py
@@ -233,15 +233,19 @@ def compute_levels(params, ref_value, stdev):
if p in params:
how, (warn, crit) = params[p]
if how == "absolute":
- levels.append((ref_value + (sig * warn), ref_value + (sig * crit)))
+ this_levels = (ref_value + (sig * warn), ref_value + (sig * crit))
elif how == "relative":
- levels.append((ref_value + sig * (ref_value * warn / 100),
- ref_value + sig * (ref_value * crit / 100)))
+ this_levels = (ref_value + sig * (ref_value * warn / 100),
+ ref_value + sig * (ref_value * crit / 100))
else: # how == "stdev":
- levels.append((ref_value + sig * (stdev * warn),
- ref_value + sig * (stdev * crit)))
+ this_levels = (ref_value + sig * (stdev * warn),
+ ref_value + sig * (stdev * crit))
+ if what == "upper" and "levels_upper_min" in params:
+ limit_warn, limit_crit = params["levels_upper_min"]
+ this_levels = (max(limit_warn, this_levels[0]), max(limit_crit,
this_levels[1]))
+ levels.append(this_levels)
else:
levels.append((None, None))
return levels
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index eb2fc5c..8a2b923 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -12168,9 +12168,10 @@ def PredictiveLevels(**args):
DropdownChoice(
title = _("Base prediction on"),
choices = [
- ( "wday", _("Day of the week (1-7, 1 is
Monday)") ),
- ( "day", _("Day of the month (1-31)") ),
- ( "hour", _("Hour of the day (0-23)") ),
+ ( "wday", _("Day of the week (1-7, 1 is
Monday)") ),
+ ( "day", _("Day of the month (1-31)") ),
+ ( "hour", _("Hour of the day (0-23)") ),
+ ( "minute", _("Minute of the hour (0-59)")
),
]
)),
( "horizon",