Module: check_mk
Branch: master
Commit: ac5f2eac86053ad75e00679c94b98891fd068e26
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ac5f2eac86053a…
Author: Florian Kromer <fk(a)mathias-kettner.de>
Date: Wed Jan 9 18:44:47 2019 +0100
Icons in mkeventd.py refactored to new plugin registry structure
CMK-1514
Change-Id: I497aa998166242923a581f5fa4a0bf14c2aa948b
---
cmk/gui/plugins/views/icons/mkeventd.py | 130 +++++++++++++++++---------------
1 file changed, 69 insertions(+), 61 deletions(-)
diff --git a/cmk/gui/plugins/views/icons/mkeventd.py b/cmk/gui/plugins/views/icons/mkeventd.py
index 54f734c..0d47600 100644
--- a/cmk/gui/plugins/views/icons/mkeventd.py
+++ b/cmk/gui/plugins/views/icons/mkeventd.py
@@ -25,84 +25,92 @@
# Boston, MA 02110-1301 USA.
import cmk.gui.config as config
-from cmk.gui.i18n import _
from cmk.gui.globals import html
+from cmk.gui.i18n import _
+from cmk.gui.plugins.views.icons import Icon, icon_and_action_registry
+
+
+(a)icon_and_action_registry.register
+class MkeventdIcon(Icon):
+ @classmethod
+ def ident(cls):
+ return "mkeventd"
-from cmk.gui.plugins.views.icons import multisite_icons_and_actions
+ def default_toplevel(self):
+ return False
+ def default_sort_index(self):
+ return 30
-def paint_mkeventd(what, row, tags, custom_vars):
- if not config.mkeventd_enabled:
- return
+ def columns(self):
+ return ["check_command"]
- # show for services based on the mkevents active check
- command = row[what + '_check_command']
+ def host_columns(self):
+ return ["address", "name"]
- if what != 'service' or not command.startswith('check_mk_active-mkevents'):
- return
+ def render(self, what, row, tags, custom_vars):
+ if not config.mkeventd_enabled:
+ return
- if '!' not in command:
- return
+ # show for services based on the mkevents active check
+ command = row[what + '_check_command']
- host = None
- app = None
+ if what != 'service' or not command.startswith('check_mk_active-mkevents'):
+ return
- # Extract parameters from check_command:
- args = command.split('!')[1].split()
- if not args:
- return
+ if '!' not in command:
+ return
- # 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:]
+ host = None
+ app = None
- if len(args) >= 1:
- if args[0] == '$HOSTNAME$':
- host = row['host_name']
- elif args[0] == '$HOSTADDRESS$':
- host = row['host_address']
- else:
- host = args[0]
+ # Extract parameters from check_command:
+ args = command.split('!')[1].split()
+ if not args:
+ return
- # 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
+ # 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:]
- # 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
- url_prefix = ''
- if getattr(config, 'mkeventd_distributed', False):
- site = config.site(row["site"])
- url_prefix = site['url_prefix'] + 'check_mk/'
+ if len(args) >= 1:
+ if args[0] == '$HOSTNAME$':
+ host = row['host_name']
+ elif args[0] == '$HOSTADDRESS$':
+ host = row['host_address']
+ else:
+ host = args[0]
- url_vars = [
- ("view_name", "ec_events_of_monhost"),
- ("site", row["site"]),
- ("host", row["host_name"]),
- ]
+ # 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
- title = _('Events of Host %s') % (row["host_name"])
+ # 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
+ url_prefix = ''
+ if getattr(config, 'mkeventd_distributed', False):
+ site = config.site(row["site"])
+ url_prefix = site['url_prefix'] + 'check_mk/'
- if len(args) >= 2:
- app = args[1].strip('\'').replace("\\\\", "\\")
- title = _('Events of Application "%s" on Host %s') % (app, host)
- url_vars.append(("event_application", app))
+ url_vars = [
+ ("view_name", "ec_events_of_monhost"),
+ ("site", row["site"]),
+ ("host", row["host_name"]),
+ ]
- url = 'view.py?' + html.urlencode_vars(url_vars)
+ title = _('Events of Host %s') % (row["host_name"])
- return 'mkeventd', title, url_prefix + url
+ if len(args) >= 2:
+ app = args[1].strip('\'').replace("\\\\", "\\")
+ title = _('Events of Application "%s" on Host %s') % (app, host)
+ url_vars.append(("event_application", app))
+ url = 'view.py?' + html.urlencode_vars(url_vars)
-multisite_icons_and_actions["mkeventd"] = {
- "columns": ["check_command"],
- "host_columns": ["address", "name"],
- "paint": paint_mkeventd,
- "toplevel": False,
- "sort_index": 30,
-}
+ return 'mkeventd', title, url_prefix + url
Module: check_mk
Branch: master
Commit: 1282b7e6b91e79891d92fc2efc9fe7154b7d18d1
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=1282b7e6b91e79…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Jan 4 20:38:20 2019 +0100
Cleaned up internal site config handling
* Several different places cared about converting legacy config formats
and conversions. A lot of logic has been centralized which simplifies
the consuming code.
* Sockets are now handled in their CascadingDropdown data format
* Moved livestatus socketurl encoding to livestatus API calls
* Added tests for the old "socket" config format conversions
Change-Id: I3bf892eaf4a1e04ec9908a329898d9d4f25d93cb
---
cmk/gui/config.py | 95 ++++++++++++++----
cmk/gui/plugins/webapi/webapi.py | 6 +-
cmk/gui/sites.py | 37 ++++++-
cmk/gui/wato/pages/sites.py | 29 +-----
cmk/gui/watolib.py | 159 +++++++++++++++++--------------
tests/integration/cmk/gui/test_webapi.py | 38 ++++++--
tests/unit/cmk/gui/test_gui_config.py | 90 +++++++++++++++++
tests/unit/cmk/gui/test_sites.py | 23 +++++
8 files changed, 346 insertions(+), 131 deletions(-)
Diff: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commitdiff;h=1282b7e6b9…