From fc37cc221738adb2b0f511533f4271d9345a52b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20MOHIER?= Date: Sat, 21 Dec 2019 09:46:02 +0100 Subject: [PATCH] For #726, improve check_command rendering - still some... --- etc/modules/webui2.cfg | 1 + module/helper.py | 15 +++++++++++---- .../eltdetail/views/_eltdetail_information.tpl | 15 +++++++++++---- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/etc/modules/webui2.cfg b/etc/modules/webui2.cfg index 34fef03f..18cc6792 100644 --- a/etc/modules/webui2.cfg +++ b/etc/modules/webui2.cfg @@ -70,6 +70,7 @@ define module { # Database name where to fetch the logs/availability collections #database shinken + # User authentication for database access #username #password diff --git a/module/helper.py b/module/helper.py index 716ee6ee..370c6943 100644 --- a/module/helper.py +++ b/module/helper.py @@ -806,7 +806,7 @@ def get_timeperiod_html(self, timeperiod): return content - def get_check_command_html(self, item): + def get_check_command_html(self, item, command_line): if not item or not item.check_command: return '' @@ -814,10 +814,17 @@ def get_check_command_html(self, item): getattr(item.check_command, "command_name", "None")) checks_data = [item, item.host] if item.my_type == 'service' else [item] + mr = MacroResolver() if ALIGNAK: - expanded = MacroResolver().resolve_simple_macros_in_string(c_line, checks_data, [], []) + expanded = mr.resolve_simple_macros_in_string(command_line, + checks_data, [], []) + expanded2 = mr.resolve_simple_macros_in_string(c_line, checks_data, [], []) + + # expanded = mr.resolve_command(item.check_command, checks_data, [], []) else: - expanded = MacroResolver().resolve_simple_macros_in_string(c_line, checks_data) + expanded = mr.resolve_simple_macros_in_string(command_line, + checks_data) + expanded2 = mr.resolve_simple_macros_in_string(c_line, checks_data) html_content = 'Command line:' \ '
' \ @@ -833,7 +840,7 @@ def get_check_command_html(self, item): '
%s' % ("
  ".join(item.check_command.args) if item.check_command.args else "None") - return html_content, expanded + return html_content, expanded, expanded2 def get_contact_avatar(self, contact, size=24, with_name=True, with_link=True): name = contact diff --git a/module/plugins/eltdetail/views/_eltdetail_information.tpl b/module/plugins/eltdetail/views/_eltdetail_information.tpl index 6bb8a2ab..a8519606 100644 --- a/module/plugins/eltdetail/views/_eltdetail_information.tpl +++ b/module/plugins/eltdetail/views/_eltdetail_information.tpl @@ -144,15 +144,22 @@ Check command: %if elt.check_command: - %html_content, expanded = helper.get_check_command_html(elt) + %cmd = app.datamgr.get_command(elt.get_check_command()) + %html_content, expanded, expanded2 = helper.get_check_command_html(elt, cmd.command_line) + %from alignak.macroresolver import MacroResolver + %checks_data = [elt, elt.host] if elt.my_type == 'service' else [elt] + %mr = MacroResolver() + %#expanded = mr.resolve_command(elt.check_command, checks_data, [], []) - - + {{ getattr(elt.check_command, "command_name", "None") }} -
{{ expanded }} +
{{ expanded2 }} + {{ type(elt.check_command) }} + {{ cmd.__dict__ }} %else: No check command