Skip to content

Commit

Permalink
Cleanup logs
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillaume Subiron committed Oct 17, 2017
1 parent e8ea199 commit c13db68
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion module/plugins/eltdetail/views/_eltdetail_history.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="tab-pane fade" id="history">
<div class="panel panel-default" style="border-top:none; border-radius:0;">
<div class="panel-body">
<div id="inner_history" data-base-url='/logs/inner/' data-host='{{ elt.host_name }}' data-service='{{ elt.service_description if elt_type == 'service' else '' }}'>
<div id="inner_history" data-host='{{ elt.host_name }}' data-service='{{ elt.service_description if elt_type == 'service' else '' }}'>
</div>

<div class="text-center" id="loading-spinner">
Expand Down
3 changes: 1 addition & 2 deletions module/plugins/logs/htdocs/js/history.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ function more_history() {
$(window).data('ajaxready', false);

$("#loading-spinner").fadeIn(400);
var url = $('#inner_history').data('base-url');
url = url + $('#inner_history').data('element');
var url = '/logs/inner';
url = url +'?limit=100&offset='+history_offset;
if ($('#inner_history').data('service') !== undefined) {
var url = url + '&service=' + $('#inner_history').data('service');
Expand Down
12 changes: 6 additions & 6 deletions module/plugins/logs/logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,8 @@ def set_logs_type_list():
app.bottle.redirect("/logs")
return

def get_host_history(name):
def get_history():
user = app.request.environ['USER']
name = urllib.unquote(name)

filters=dict()

Expand All @@ -152,10 +151,10 @@ def get_host_history(name):
else:
user.is_administrator() or app.redirect403()

if service is not None:
if service:
filters['service_description'] = service

if host is not None:
if host:
filters['host_name'] = host

logclass = app.request.GET.get('logclass', None)
Expand All @@ -173,6 +172,7 @@ def get_host_history(name):
return {'records': logs}


# :TODO:maethor:171017: This function should be merge in get_history
def get_global_history():
user = app.request.environ['USER']
user.is_administrator() or app.redirect403()
Expand All @@ -197,8 +197,8 @@ def get_global_history():
get_global_history: {
'name': 'History', 'route': '/logs', 'view': 'logs', 'static': True
},
get_host_history: {
'name': 'HistoryHost', 'route': '/logs/inner/<name:path>', 'view': 'history'
get_history: {
'name': 'HistoryHost', 'route': '/logs/inner', 'view': 'history'
},
form_hosts_list: {
'name': 'GetHostsList', 'route': '/logs/hosts_list', 'view': 'form_hosts_list'
Expand Down
6 changes: 5 additions & 1 deletion module/plugins/logs/views/history.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
%for log in logs:
<tr>
<td width="150px" style="vertical-align: middle;">{{time.strftime(date_format, time.localtime(log['time']))}}</td>
%# STATE CHANGE
%if log['logclass'] == 1 and log['state_type'] in ['SOFT', 'HARD']:
%state = log['message'].split(';')[2]
<td width="40px" class="text-center" style="vertical-align: middle;">
Expand All @@ -32,6 +33,7 @@
{{ log['service_description'] }}<br>
<samp class="text-muted">{{ log['plugin_output'] }}</samp>
</td>
%# FLAPPING/DOWNTIME
%elif log['logclass'] == 1:
<td width="40px" class="text-center" style="vertical-align: middle;">
<i class="fa fa-info-circle text-primary fa-2x" title="State change"></i>
Expand All @@ -50,8 +52,9 @@
{{ log['service_description'] }}<br>
<samp class="text-muted">{{ log['message'].split(';')[-1] }}</samp>
</td>
%# Not used for now
%# NOTIFICATION
%elif log['logclass'] == 3:
%# Not used for now
%if 'sms' in log['command_name']:
%icon = 'fa-mobile'
%elif 'mail' in log['command_name']:
Expand All @@ -71,6 +74,7 @@
</td>
<td>
User {{ log['contact_name'] }} notified with <code>{{ log['command_name'] }}</code><br>
{{ log['host_name'] }} / {{ log['service_description'] }} &nbsp;&nbsp;&nbsp;&nbsp;
<samp class="text-muted">{{ log['message'].split(';')[-1] }}</samp>
</td>
%else:
Expand Down

0 comments on commit c13db68

Please sign in to comment.