Module: check_mk
Branch: master
Commit: 34819035a76e123045f1d59d6e4b3e30433b18c6
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=34819035a76e12…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Sep 28 13:15:37 2016 +0200
3893 FIX Predictive levels: Improved handling of broken prediction files (empty files)
In previous versions it could happen that the predictive levels feature created empty
(zero byte sized) files below var/check_mk/prediction which made the predictive levels
not work anymore for the affected service. This situation is now being repaired
automatically.
---
.werks/3893 | 12 ++++++++++++
ChangeLog | 1 +
modules/prediction.py | 7 +++++++
web/htdocs/prediction.py | 22 ++++++++++++++--------
4 files changed, 34 insertions(+), 8 deletions(-)
diff --git a/.werks/3893 b/.werks/3893
new file mode 100644
index 0000000..57219f0
--- /dev/null
+++ b/.werks/3893
@@ -0,0 +1,12 @@
+Title: Predictive levels: Improved handling of broken prediction files (empty files)
+Level: 1
+Component: core
+Compatible: compat
+Version: 1.4.0i1
+Date: 1475061250
+Class: fix
+
+In previous versions it could happen that the predictive levels feature created empty
+(zero byte sized) files below var/check_mk/prediction which made the predictive levels
+not work anymore for the affected service. This situation is now being repaired
+automatically.
diff --git a/ChangeLog b/ChangeLog
index f9f68e0..b1ac70e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -31,6 +31,7 @@
* 3846 FIX: Nagios: define_contactgroups = False is handled correctly again
* 3852 FIX: Host related files are now deleted during host deletion...
* 3737 FIX: Fixed slow activation of changes due to loss of IP address cache...
+ * 3893 FIX: Predictive levels: Improved handling of broken prediction files (empty files)...
Checks & Agents:
* 3183 aruba_wlc_aps: new check which monitors the provisioned accesspoints of an Aruba Network WLAN Controller
diff --git a/modules/prediction.py b/modules/prediction.py
index 1a31b33..f1c3387 100644
--- a/modules/prediction.py
+++ b/modules/prediction.py
@@ -213,6 +213,13 @@ def get_predictive_levels(dsname, params, cf, levels_factor=1.0):
pred_file = "%s/%s" % (dir, timegroup)
info_file = pred_file + ".info"
+ # In previous versions it could happen that the files were created with 0 bytes of size
+ # which was never handled correctly so that the prediction could never be used again until
+ # manual removal of the files. Clean this up.
+ for file_path in [ pred_file, info_file ]:
+ if os.stat(file_path).st_size == 0:
+ os.unlink(file_path)
+
# Check, if we need to (re-)compute the prediction file. This is
# the case if:
# - no prediction has been done yet for this time group
diff --git a/web/htdocs/prediction.py b/web/htdocs/prediction.py
index fb6aa6c..f0e9914 100644
--- a/web/htdocs/prediction.py
+++ b/web/htdocs/prediction.py
@@ -67,14 +67,20 @@ def page_graph():
timegroups = []
now = time.time()
for f in os.listdir(dir):
- if f.endswith(".info"):
- tg_info = eval(file(dir + "/" + f).read())
- tg_info["name"] = f[:-5]
- timegroups.append(tg_info)
- if tg_info["name"] == tg_name or \
- (tg_name == None and now >= tg_info["range"][0] and now <= tg_info["range"][1]):
- timegroup = tg_info
- tg_name = tg_info["name"]
+ file_path = dir + "/" + f
+ if not f.endswith(".info"):
+ continue
+
+ if os.stat(file_path).st_size == 0:
+ continue
+
+ tg_info = eval(file(dir + "/" + f).read())
+ tg_info["name"] = f[:-5]
+ timegroups.append(tg_info)
+ if tg_info["name"] == tg_name or \
+ (tg_name == None and now >= tg_info["range"][0] and now <= tg_info["range"][1]):
+ timegroup = tg_info
+ tg_name = tg_info["name"]
timegroups.sort(cmp = lambda a,b: cmp(a["range"][0], b["range"][0]))
Module: check_mk
Branch: master
Commit: 75516b6ff1b4bd094e8548a044854be5c630b003
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=75516b6ff1b4bd…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Sep 28 12:01:49 2016 +0200
Fixed unused variables
---
web/htdocs/cron.py | 5 ++---
web/htdocs/pagetypes.py | 2 +-
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/web/htdocs/cron.py b/web/htdocs/cron.py
index 996a003..8771c9d 100644
--- a/web/htdocs/cron.py
+++ b/web/htdocs/cron.py
@@ -25,6 +25,7 @@
# Boston, MA 02110-1301 USA.
import time
+import traceback
from lib import *
import cmk.paths
@@ -53,7 +54,6 @@ def load_plugins(force):
# There is no output written to the user in regular cases. Exceptions
# are written to the web log.
def page_run_cron():
- now = time.time()
# Prevent cron jobs from being run too often, also we need
# locking in order to prevent overlapping runs
if os.path.exists(lock_file):
@@ -66,9 +66,8 @@ def page_run_cron():
for cron_job in multisite_cronjobs:
try:
cron_job()
- except Exception, e:
+ except Exception:
html.write("An exception occured. Take a look at the web.log.\n")
- import traceback
logger(LOG_ERR, "Exception in cron_job [%s]:\n%s" %
(cron_job.__name__, traceback.format_exc()))
diff --git a/web/htdocs/pagetypes.py b/web/htdocs/pagetypes.py
index 0b75acb..3178e29 100644
--- a/web/htdocs/pagetypes.py
+++ b/web/htdocs/pagetypes.py
@@ -154,7 +154,7 @@ class Base(object):
# with more than one topic
parameters = []
for topic, elements in sorted_topics:
- for order, key, vs in elements:
+ for _unused_order, key, vs in elements:
parameters.append((key, vs))
return parameters
Module: check_mk
Branch: master
Commit: 9888bfac60dff5172943ad8e744deff3bf0a84c1
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=9888bfac60dff5…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Sep 28 11:34:21 2016 +0200
Updated bug entries #2471
---
.bugs/2471 | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/.bugs/2471 b/.bugs/2471
new file mode 100644
index 0000000..67cb037
--- /dev/null
+++ b/.bugs/2471
@@ -0,0 +1,10 @@
+Title: Sidebar slow on new apache process because of werk loading
+Component: multisite
+State: open
+Date: 2016-09-28 11:33:19
+Targetversion: 1.2.8
+Class: bug
+
+When rendering the side bar for the first time in a new apache process, all werk files
+are loaded which seem to take a lot of time in some installations. This should be
+optimized.