Skip to content

Commit

Permalink
For shinken-monitoring#726, improve check_command rendering - still s…
Browse files Browse the repository at this point in the history
…ome...
  • Loading branch information
mohierf committed Dec 21, 2019
1 parent ddf162a commit fc37cc2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
1 change: 1 addition & 0 deletions etc/modules/webui2.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ define module {

# Database name where to fetch the logs/availability collections
#database shinken

# User authentication for database access
#username
#password
Expand Down
15 changes: 11 additions & 4 deletions module/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -806,18 +806,25 @@ 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 ''

c_line = getattr(item.check_command, "command_line",
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 = '<u>Command line:</u>' \
'<br>' \
Expand All @@ -833,7 +840,7 @@ def get_check_command_html(self, item):
'<br>%s' % ("<br>&nbsp;&nbsp;".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
Expand Down
15 changes: 11 additions & 4 deletions module/plugins/eltdetail/views/_eltdetail_information.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,22 @@
<tr>
<td><strong>Check command:</strong></td>
%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, [], [])

<td name="check_command" class="popover-dismiss" data-html="true" data-toggle="popover" data-placement="bottom"
<td name="check_command" class="popover-dismiss" data-html="true" data-toggle="popover" data-placement="top"
data-title='<code>{{ getattr(elt.check_command, "command_name", "None") }}</code>'
data-content='{{ html_content }}'>
<a href="/commands#{{elt.get_check_command()}}">
<a href="/commands#{{ elt.get_check_command() }}">
{{ getattr(elt.check_command, "command_name", "None") }}
</a>
<br><code>{{ expanded }}</code>
<br><code>{{ expanded2 }}</code>
{{ type(elt.check_command) }}
{{ cmd.__dict__ }}
</td>
%else:
<strong>No check command</strong>
Expand Down

0 comments on commit fc37cc2

Please sign in to comment.