Added SOGo logs

master
andryyy 2017-05-13 22:58:29 +02:00
parent 980acb507e
commit 2291b4e121
5 changed files with 92 additions and 4 deletions

View File

@ -328,6 +328,21 @@ $tfa_data = get_tfa();
</div> </div>
</div> </div>
</div> </div>
<div class="panel panel-default">
<div class="panel-heading">SOGo
<div class="btn-group pull-right">
<a class="btn btn-xs btn-default dropdown-toggle" data-toggle="dropdown" href="#"><?=$lang['admin']['action'];?> <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="#" id="refresh_sogo_log"><?=$lang['admin']['refresh'];?></a></li>
</ul>
</div>
</div>
<div class="panel-body">
<div class="table-responsive">
<table class="table table-striped" id="sogo_log"></table>
</div>
</div>
</div>
</div> </div>
</div> </div>

View File

@ -5228,6 +5228,14 @@ function get_logs($container, $lines = 100) {
return $data_array; return $data_array;
} }
} }
if ($container == "sogo-mailcow") {
if ($data = $redis->lRange('SOGO_LOG', 1, $lines)) {
foreach ($data as $json_line) {
$data_array[] = json_decode($json_line, true);
}
return $data_array;
}
}
return false; return false;
} }
?> ?>

View File

@ -79,6 +79,10 @@ jQuery(function($){
e.preventDefault(); e.preventDefault();
draw_dovecot_logs(); draw_dovecot_logs();
}); });
$("#refresh_sogo_log").on('click', function(e) {
e.preventDefault();
draw_sogo_logs();
});
function draw_postfix_logs() { function draw_postfix_logs() {
ft_postfix_logs = FooTable.init('#postfix_log', { ft_postfix_logs = FooTable.init('#postfix_log', {
"columns": [ "columns": [
@ -126,6 +130,53 @@ jQuery(function($){
} }
}); });
} }
function draw_sogo_logs() {
ft_sogo_logs = FooTable.init('#sogo_log', {
"columns": [
{"name":"time","formatter":function unix_time_format(tm) { var date = new Date(tm ? tm * 1000 : 0); return date.toLocaleString();},"title":lang.time,"style":{"width":"170px"}},
{"name":"priority","title":lang.priority,"style":{"width":"80px"}},
{"name":"message","title":lang.message},
],
"rows": $.ajax({
dataType: 'json',
url: '/api/v1/get/logs/sogo/1000',
jsonp: false,
error: function () {
console.log('Cannot draw sogo log table');
},
success: function (data) {
$.each(data, function (i, item) {
var danger_class = ["emerg", "alert", "crit"];
var warning_class = ["warning"];
var info_class = ["notice", "info", "debug"];
if (jQuery.inArray(item.priority, danger_class) !== -1) {
item.priority = '<span class="label label-danger">' + item.priority + '</span>';
}
else if (jQuery.inArray(item.priority, warning_class) !== -1) {
item.priority = '<span class="label label-warning">' + item.priority + '</span>';
}
else if (jQuery.inArray(item.priority, info_class) !== -1) {
item.priority = '<span class="label label-info">' + item.priority + '</span>';
}
});
}
}),
"empty": lang.empty,
"paging": {
"enabled": true,
"limit": 5,
"size": pagination_size
},
"filtering": {
"enabled": true,
"position": "left",
"placeholder": lang.filter_table
},
"sorting": {
"enabled": true
}
});
}
function draw_dovecot_logs() { function draw_dovecot_logs() {
ft_postfix_logs = FooTable.init('#dovecot_log', { ft_postfix_logs = FooTable.init('#dovecot_log', {
"columns": [ "columns": [
@ -214,7 +265,6 @@ jQuery(function($){
} }
}); });
} }
function draw_fwd_hosts() { function draw_fwd_hosts() {
ft_domainadmins = FooTable.init('#forwardinghoststable', { ft_domainadmins = FooTable.init('#forwardinghoststable', {
"columns": [ "columns": [
@ -260,6 +310,7 @@ jQuery(function($){
draw_postfix_logs(); draw_postfix_logs();
draw_dovecot_logs(); draw_dovecot_logs();
draw_sogo_logs();
draw_domain_admins(); draw_domain_admins();
draw_fwd_hosts(); draw_fwd_hosts();
}); });

View File

@ -80,7 +80,6 @@ if (isset($_SESSION['mailcow_cc_role']) || isset($_SESSION['pending_mailcow_cc_u
echo '{}'; echo '{}';
} }
break; break;
case "postfix": case "postfix":
if (isset($extra) && !empty($extra)) { if (isset($extra) && !empty($extra)) {
$extra = intval($extra); $extra = intval($extra);
@ -96,6 +95,21 @@ if (isset($_SESSION['mailcow_cc_role']) || isset($_SESSION['pending_mailcow_cc_u
echo '{}'; echo '{}';
} }
break; break;
case "sogo":
if (isset($extra) && !empty($extra)) {
$extra = intval($extra);
$logs = get_logs('sogo-mailcow', $extra);
}
else {
$logs = get_logs('sogo-mailcow', -1);
}
if (isset($logs) && !empty($logs)) {
echo json_encode($logs, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
}
else {
echo '{}';
}
break;
} }
break; break;
case "mailbox": case "mailbox":

View File

@ -33,8 +33,8 @@ $lang['danger']['alias_empty'] = 'Alias-Adresse darf nicht leer sein';
$lang['danger']['goto_empty'] = 'Ziel-Adresse darf nicht leer sein'; $lang['danger']['goto_empty'] = 'Ziel-Adresse darf nicht leer sein';
$lang['danger']['policy_list_from_exists'] = 'Ein Eintrag mit diesem Wert existiert bereits'; $lang['danger']['policy_list_from_exists'] = 'Ein Eintrag mit diesem Wert existiert bereits';
$lang['danger']['policy_list_from_invalid'] = 'Eintrag hat ungültiges Format'; $lang['danger']['policy_list_from_invalid'] = 'Eintrag hat ungültiges Format';
$lang['danger']['alias_invalid'] = 'Alias-Adrese ist ungültig'; $lang['danger']['alias_invalid'] = 'Alias-Adresse ist ungültig';
$lang['danger']['goto_invalid'] = 'Ziel-Adrese ist ungültig'; $lang['danger']['goto_invalid'] = 'Ziel-Adresse ist ungültig';
$lang['danger']['last_key'] = 'Letzter Key kann nicht gelöscht werden'; $lang['danger']['last_key'] = 'Letzter Key kann nicht gelöscht werden';
$lang['danger']['alias_domain_invalid'] = 'Alias-Domain ist ungültig'; $lang['danger']['alias_domain_invalid'] = 'Alias-Domain ist ungültig';
$lang['danger']['target_domain_invalid'] = 'Ziel-Domain ist ungültig'; $lang['danger']['target_domain_invalid'] = 'Ziel-Domain ist ungültig';