Module: check_mk
Branch: master
Commit: 5f9c0cf787c6d5287d5538a94bc12534c52dfc20
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=5f9c0cf787c6d5…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Oct 25 14:42:27 2012 +0200
New icon linking to event views for the event services
---
ChangeLog | 1 +
mkeventd/web/plugins/icons/mkeventd.py | 84 ++++++++++++++++++++++++++++++++
2 files changed, 85 insertions(+), 0 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index e4da1dc..c635862 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -11,6 +11,7 @@
* New feature of hiding certain actions from the commands in the status GUI
* FIX: rule simulator ("Try out") now handles cancelling rules correctly
* New global option for enabling log entries for rule hits (debugging)
+ * New icon linking to event views for the event services
Multisite:
* Enable automation login with _username= and _secret=, while
diff --git a/mkeventd/web/plugins/icons/mkeventd.py
b/mkeventd/web/plugins/icons/mkeventd.py
new file mode 100644
index 0000000..b87a5cc
--- /dev/null
+++ b/mkeventd/web/plugins/icons/mkeventd.py
@@ -0,0 +1,84 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2012 mk(a)mathias-kettner.de |
+# +------------------------------------------------------------------+
+#
+# This file is part of Check_MK.
+# The official homepage is at
http://mathias-kettner.de/check_mk.
+#
+# check_mk is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation in version 2. check_mk is distributed
+# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
+# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE. See the GNU General Public License for more de-
+# ails. You should have received a copy of the GNU General Public
+# License along with GNU Make; see the file COPYING. If not, write
+# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301 USA.
+
+import mkeventd
+
+try:
+ mkeventd_enabled = config.mkeventd_enabled
+except:
+ mkeventd_enabled = False
+
+def paint_mkeventd(what, row, tags, custom_vars):
+ # show for services based on the mkevents active check
+ command = row[what + '_check_command']
+
+ if what != 'service' or not
command.startswith('check_mk_active-mkevents'):
+ return
+
+ if '!' not in command:
+ return
+
+ host = None
+ app = None
+
+ # Extract parameters from check_command:
+ args = command.split('!')[1].split(' ', 1)
+ if not args:
+ return
+
+ if len(args) >= 1:
+ if args[0] == '$HOSTNAME$':
+ host = row['host_name']
+ elif args[0] == '$HOSTADDRESS$':
+ host = row['host_address']
+ else:
+ host = args[0]
+
+ # 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
+ # constructed here
+ site = html.site_status[row['site']]["site"]
+ url_prefix = ''
+ if getattr(config, 'mkeventd_distributed', False):
+ url_prefix = site['url_prefix'] + 'check_mk/'
+
+ title = _('Events of Host %s') % (host)
+ url = 'view.py?view_name=ec_events_of_host&event_host=' + host
+
+ if len(args) >= 2:
+ app = args[1].strip('\'')
+ title = _('Events of Application "%s" on Host %s') % (app,
host)
+ url += '&event_application=' + app
+
+ return '<a href="%s"><img class=icon title="%s"
src="images/icon_mkeventd.png" /></a>' % \
+ (url_prefix + url, title)
+
+if mkeventd_enabled:
+ multisite_icons.append({
+ 'host_columns': [ 'address' ],
+ 'paint': paint_mkeventd,
+ })