Module: check_mk
Branch: master
Commit: 110cd6b42743bc5470cb32f8fa2baf5ab6c40367
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=110cd6b42743bc…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Nov 25 10:32:32 2014 +0100
#1532 FIX mk_sap: Cleaning up old state information from sap.state file
The mk_sap agent plugin writes a state file which contains information
for each SAP alert log file which is monitored. Old log files are now
cleaned up from this file, when they are not monitored anymore.
---
.werks/1532 | 11 +++++++++++
ChangeLog | 1 +
agents/plugins/mk_sap | 46 +++++++++++++++++++++++++++++++++++++---------
3 files changed, 49 insertions(+), 9 deletions(-)
diff --git a/.werks/1532 b/.werks/1532
new file mode 100644
index 0000000..bf6feb4
--- /dev/null
+++ b/.werks/1532
@@ -0,0 +1,11 @@
+Title: mk_sap: Cleaning up old state information from sap.state file
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.5i7
+Date: 1416907854
+Class: fix
+
+The mk_sap agent plugin writes a state file which contains information
+for each SAP alert log file which is monitored. Old log files are now
+cleaned up from this file, when they are not monitored anymore.
diff --git a/ChangeLog b/ChangeLog
index a5092a2..bc3f9df 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -38,6 +38,7 @@
* 1503 FIX: Fixed monitoring of multiple SAP instances with one mk_sap plugin...
* 1515 FIX: cisco_secure: fix service description, fix OK state in case of no violation
* 1449 FIX: nginx_status: agent plugin no longer honours "http(s)_proxy" env variables of root user
+ * 1532 FIX: mk_sap: Cleaning up old state information from sap.state file...
Multisite:
* 1508 Allow input of plugin output and perfdata when faking check results...
diff --git a/agents/plugins/mk_sap b/agents/plugins/mk_sap
index 8f867df..747f9ae 100755
--- a/agents/plugins/mk_sap
+++ b/agents/plugins/mk_sap
@@ -109,6 +109,7 @@ SKIP_MTCLASSES = [
]
STATE_FILE = '/etc/check_mk/sap.state'
+state_file_changed = False
# #############################################################################
@@ -139,7 +140,6 @@ monitor_paths = [
# 'SAP CCMS Monitor Templates/Dialog Overview/*',
]
monitor_types = []
-# henri
config_file = os.getenv('MK_CONFDIR', '/etc/check_mk') + '/sap.cfg'
cfg = {}
@@ -156,6 +156,10 @@ try:
except IOError:
states = {}
+# index of all logfiles which have been found in a run. This is used to
+# remove logfiles which are not available anymore from the states dict.
+logfiles = []
+
# #############################################################################
#
@@ -322,6 +326,8 @@ def alert_details(cfg, alert):
return state, msg
def process_alerts(cfg, logs, ms_name, mon_name, node, alerts):
+ global state_file_changed
+
sid = node["MTSYSID"].strip() or 'Other'
context = node["MTMCNAME"].strip() or 'Other'
path = node["PATH"]
@@ -330,6 +336,8 @@ def process_alerts(cfg, logs, ms_name, mon_name, node, alerts):
hostname = sid
logfile = context + "/" + path
+ logfiles.append((hostname, logfile))
+
logs.setdefault(sid, {})
logs[hostname][logfile] = []
newest_log_dt = None
@@ -350,7 +358,7 @@ def process_alerts(cfg, logs, ms_name, mon_name, node, alerts):
if newest_log_dt:
# Write newest log age to cache to prevent double processing of logs
states[(hostname, logfile)] = newest_log_dt
- file(STATE_FILE, 'w').write(repr(states))
+ state_file_changed = True
return logs
@@ -452,12 +460,32 @@ def check(cfg):
# It is possible to configure multiple SAP instances to monitor. Loop them all, but
# do not terminate when one connection failed
-for entry in cfg:
- try:
- check(entry)
- except sapnwrfc.RFCCommunicationError, e:
- sys.stderr.write('ERROR: Unable to connect (%s)\n' % e)
- except:
- sys.stderr.write('ERROR: Unhandled exception (%s)\n' % e)
+processed_all = True
+try:
+ for entry in cfg:
+ try:
+ check(entry)
+ except sapnwrfc.RFCCommunicationError, e:
+ sys.stderr.write('ERROR: Unable to connect (%s)\n' % e)
+ processed_all = False
+ except Exception, e:
+ sys.stderr.write('ERROR: Unhandled exception (%s)\n' % e)
+ processed_all = False
+
+ # Now check whether or not an old logfile needs to be removed. This can only
+ # be done this way, when all hosts have been reached. Otherwise the cleanup
+ # is skipped.
+ if processed_all:
+ for key in states.keys():
+ if key not in logfiles:
+ state_file_changed = True
+ del states[key]
+
+ # Only write the state file once per run. And only when it has been changed
+ if state_file_changed:
+ file(STATE_FILE, 'w').write(repr(states))
+
+except Exception, e:
+ sys.stderr.write('ERROR: Unhandled exception (%s)\n' % e)
sys.exit(0)
Module: check_mk
Branch: master
Commit: 1cf1c6ae1d62c5a9ae227f405916399805e7e8d1
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=1cf1c6ae1d62c5…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Nov 25 10:14:43 2014 +0100
Updated bug entries #2206
---
.bugs/2206 | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/.bugs/2206 b/.bugs/2206
new file mode 100644
index 0000000..318df69
--- /dev/null
+++ b/.bugs/2206
@@ -0,0 +1,22 @@
+Title: Rework "crashed checks" mechanism
+Component: core
+State: open
+Date: 2014-11-25 10:11:51
+Targetversion: 1.2.5i1
+Class: todo
+
+The optional crashed checks log should be replaced by a new mechanism
+where each exception is written to a dedicated folder hierarchy like
+HOST/SERVICE, where only the last exception is stored per service.
+It is written as text file where all needed information like
+
+a) the raw agent output
+b) the raw SNMP data
+c) the traceback
+
+are written to.
+
+This file can be downloaded from the Web-GUI by clicking on an icon
+which is shown when there is some file for a service available.
+
+The files are removed using the diskspace cleanup mechanism regularly.
Module: check_mk
Branch: master
Commit: 51209db66fd5529e420f3f78a2716f6bb4b89112
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=51209db66fd552…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Nov 24 15:13:46 2014 +0100
Updated bug entries #2205
---
.bugs/2205 | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/.bugs/2205 b/.bugs/2205
new file mode 100644
index 0000000..d9ac414
--- /dev/null
+++ b/.bugs/2205
@@ -0,0 +1,10 @@
+Title: Path in debug_log is wrong in distributed WATO setups
+Component: wato
+State: open
+Date: 2014-11-24 15:07:07
+Targetversion: 1.2.5i1
+Class: bug
+
+The shown path always shows the path on the centeral site. It should either
+show the path to the correct site, or better, just a spacer which indicates
+that the site id needs to be put into the path.
Module: check_mk
Branch: master
Commit: 0256bdc7711ecca4d5bccbb95ce0bdffa3dcae01
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=0256bdc7711ecc…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Sun Nov 23 14:57:39 2014 +0100
Fix a few comments
---
web/htdocs/valuespec.py | 2 +-
web/htdocs/wato.py | 1 -
web/plugins/views/inventory.py | 2 +-
3 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/web/htdocs/valuespec.py b/web/htdocs/valuespec.py
index 5b62e2d..e090a59 100644
--- a/web/htdocs/valuespec.py
+++ b/web/htdocs/valuespec.py
@@ -1301,7 +1301,7 @@ class CascadingDropdown(ValueSpec):
options.append((str(nr), title))
# Determine the default value for the select, so the
# the dropdown pre-selects the line corresponding with value.
- # Note: the html.select with automatically show the modified
+ # Note: the html.select() with automatically show the modified
# selection, if the HTML variable varprefix_sel aleady
# exists.
if value == val or (
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index fa121bf..5305e9d 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -10968,7 +10968,6 @@ def ajax_activation():
log_commit_pending() # flush logfile with pending actions
log_audit(None, "activate-config", _("Configuration activated, monitoring server restarted"))
- # html.message
html.write('OK: ')
html.write('<div class=act_success><img src="images/icon_apply.png" /> %s</div>' %
_("Configuration successfully activated."))
diff --git a/web/plugins/views/inventory.py b/web/plugins/views/inventory.py
index bacfd1d..96c02c1 100644
--- a/web/plugins/views/inventory.py
+++ b/web/plugins/views/inventory.py
@@ -243,7 +243,7 @@ def render_inv_dicttable(hostname, invpath, node):
extratitles.sort()
titles += extratitles
- # We cannot use table here, since html.plug does not work recursively
+ # We cannot use table here, since html.plug() does not work recursively
html.write('<table class=data>')
html.write('<tr>')
for title, key in titles: