Module: check_mk
Branch: master
Commit: 1dd5a1e70717c4fcd1a67efd3cac1866a2df77ed
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=1dd5a1e70717c4…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Nov 30 16:07:09 2012 +0100
FIX: fix event icon in case of using TCP access to EC
---
ChangeLog | 1 +
mkeventd/web/plugins/icons/mkeventd.py | 21 +++++++++++++--------
2 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 4a46188..1bcdf66 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -41,6 +41,7 @@
Event Console:
* FIX: fix exception in rules that use facility local7
+ * FIX: fix event icon in case of using TCP access to EC
* Replication slave can now copy rules from master into local configuration
via a new button in WATO.
* Speedup access to event history by earlier filtering and prefiltering with grep
diff --git a/mkeventd/web/plugins/icons/mkeventd.py b/mkeventd/web/plugins/icons/mkeventd.py
index fff175f..9487d6b 100644
--- a/mkeventd/web/plugins/icons/mkeventd.py
+++ b/mkeventd/web/plugins/icons/mkeventd.py
@@ -45,18 +45,18 @@ def paint_mkeventd(what, row, tags, custom_vars):
app = None
# Extract parameters from check_command:
- args = command.split('!')[1].split(' ', 1)
+ args = command.split('!')[1].split()
if not args:
return
- if len(args) >= 1:
- # Handle -a and -H options. Sorry for the hack. We currently
- # have no better idea
- if args[0] == '-H':
- args = args[2:] # skip two arguments
- if args[0] == '-a':
- args = args[1:]
+ # Handle -a and -H options. Sorry for the hack. We currently
+ # have no better idea
+ if len(args) >= 2 and args[0] == '-H':
+ args = args[2:] # skip two arguments
+ if len(args) >= 1 and args[0] == '-a':
+ args = args[1:]
+ if len(args) >= 1:
if args[0] == '$HOSTNAME$':
host = row['host_name']
elif args[0] == '$HOSTADDRESS$':
@@ -64,6 +64,11 @@ def paint_mkeventd(what, row, tags, custom_vars):
else:
host = args[0]
+ # If we have no host then the command line from the check_command seems
+ # to be garbled. Better show nothing in this case.
+ if not host:
+ return
+
# It is possible to have a central event console, this is the default case.
# Another possible architecture is to have an event console in each site in
# a distributed environment. For the later case the base url need to be
Module: check_mk
Branch: master
Commit: 06a979af3b27683fcad801375dd1f370a536cc3f
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=06a979af3b2768…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Nov 30 10:05:10 2012 +0100
EC slave can copy rules from master via button
---
ChangeLog | 2 ++
mkeventd/web/plugins/wato/mkeventd.py | 28 +++++++++++++++++++++++++++-
2 files changed, 29 insertions(+), 1 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 968b550..16e6faa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -40,6 +40,8 @@
Event Console:
* FIX: fix exception in rules that use facility local7
+ * Replication slave can now copy rules from master into local configuration
+ via a new button in WATO.
1.2.1i3:
Core:
diff --git a/mkeventd/web/plugins/wato/mkeventd.py b/mkeventd/web/plugins/wato/mkeventd.py
index b083d1a..58c0401 100644
--- a/mkeventd/web/plugins/wato/mkeventd.py
+++ b/mkeventd/web/plugins/wato/mkeventd.py
@@ -771,6 +771,20 @@ def mode_mkeventd_rules(phase):
else:
return
+ elif html.has_var("_copy_rules"):
+ c = wato_confirm(_("Confirm copying rules"),
+ _("Do you really want to copy all event rules from the master and "
+ "replace your local configuration with them?"))
+ if c:
+ copy_rules_from_master()
+ log_mkeventd("copy-rules-from-master", _("Copied the event rules from the master "
+ "into the local configuration"))
+ return None, _("Copied rules from master")
+ elif c == False:
+ return ""
+ else:
+ return
+
if html.check_transaction():
if html.has_var("_move"):
@@ -785,10 +799,14 @@ def mode_mkeventd_rules(phase):
rep_mode = mkeventd.replication_mode()
if rep_mode in [ "sync", "takeover" ]:
+ copy_url = make_action_link([("mode", "mkeventd_rules"), ("_copy_rules", "1")])
html.show_warning(_("WARNING: This Event Console is currently running as a replication "
"slave. The rules edited here will not be used. Instead a copy of the rules of the "
"master are being used in the case of a takeover. The same holds for the event "
- "actions in the global settings."))
+ "actions in the global settings.<br><br>If you want you can copy the ruleset of "
+ "the master into your local slave configuration: ") + \
+ '<a class=button href="%s">' % copy_url +
+ _("Copy Rules From Master") + '</a>')
if len(rules) == 0:
html.write(_("You have not created any rules yet."))
@@ -917,6 +935,14 @@ def mode_mkeventd_rules(phase):
html.write('</table>')
+def copy_rules_from_master():
+ answer = mkeventd.query("REPLICATE 0")
+ if "rules" not in answer:
+ raise MKGeneralException(_("Cannot get rules from local event daemon."))
+ rules = answer["rules"]
+ save_mkeventd_rules(rules)
+
+
def mode_mkeventd_edit_rule(phase):
rules = load_mkeventd_rules()
# Links from status view refer to rule via the rule id