Skip to content

Commit

Permalink
For shinken-monitoring#726, improve check_command rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
mohierf committed Dec 19, 2019
1 parent b49b16c commit ddf162a
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 8 deletions.
29 changes: 29 additions & 0 deletions module/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,35 @@ def get_timeperiod_html(self, timeperiod):

return content

def get_check_command_html(self, item):
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]
if ALIGNAK:
expanded = MacroResolver().resolve_simple_macros_in_string(c_line, checks_data, [], [])
else:
expanded = MacroResolver().resolve_simple_macros_in_string(c_line, checks_data)

html_content = '<u>Command line:</u>' \
'<br>' \
'<div style="max-width: 320px; overflow-wrap: break-word;">%s</div>' \
% c_line
html_content += '<br>' \
'<u>Command line with macro expansion:</u>' \
'<br>' \
'<div style="max-width: 320px; overflow-wrap: break-word;">%s</div>' \
% expanded
html_content += '<br>' \
'Arguments:' \
'<br>%s' % ("<br>&nbsp;&nbsp;".join(item.check_command.args)
if item.check_command.args else "None")

return html_content, expanded

def get_contact_avatar(self, contact, size=24, with_name=True, with_link=True):
name = contact
title = name
Expand Down
21 changes: 13 additions & 8 deletions module/plugins/eltdetail/views/_eltdetail_information.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,20 @@
%end
<tr>
<td><strong>Check command:</strong></td>
<td>
%if elt.check_command:
<a href="/commands#{{elt.get_check_command()}}">{{elt.get_check_command()}}</a>
%else:
<strong>No check command</strong>
%end
</td>
<td>
%if elt.check_command:
%html_content, expanded = helper.get_check_command_html(elt)

<td name="check_command" class="popover-dismiss" data-html="true" data-toggle="popover" data-placement="bottom"
data-title='<code>{{ getattr(elt.check_command, "command_name", "None") }}</code>'
data-content='{{ html_content }}'>
<a href="/commands#{{elt.get_check_command()}}">
{{ getattr(elt.check_command, "command_name", "None") }}
</a>
<br><code>{{ expanded }}</code>
</td>
%else:
<strong>No check command</strong>
%end
</tr>
%enabled = app.datamgr.get_configuration_parameter('execute_host_checks' if elt_type == 'host' else 'execute_service_checks')
<tr>
Expand Down
4 changes: 4 additions & 0 deletions module/views/header_element.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,10 @@
%if app.logs_module.is_available():
<li> <a href="{{ app.get_url('History') }}"> <i class="fas fa-fw fa-th-list sidebar-icon"></i>
&nbsp;Logs </a> </li>
%if alignak:
<li> <a href="{{ app.get_url('AlignakStats') }}"> <i class="fas fa-fw fa-bell sidebar-icon"></i>
&nbsp;Alignak alerts </a> </li>
%end
<li> <a href="{{ app.get_url('GlobalStats') }}"> <i class="fas fa-fw fa-bell sidebar-icon"></i>
&nbsp;Alerts </a> </li>
%end
Expand Down

0 comments on commit ddf162a

Please sign in to comment.