Fixes: First line was missing in logs. Adds support for Fail2ban container
parent
b8e9b3d879
commit
c75ce5124c
|
@ -22,6 +22,7 @@ $tfa_data = get_tfa();
|
||||||
<li role="presentation"><a href="#tab-postfix-logs" aria-controls="tab-postfix-logs" role="tab" data-toggle="tab">Postfix</a></li>
|
<li role="presentation"><a href="#tab-postfix-logs" aria-controls="tab-postfix-logs" role="tab" data-toggle="tab">Postfix</a></li>
|
||||||
<li role="presentation"><a href="#tab-dovecot-logs" aria-controls="tab-dovecot-logs" role="tab" data-toggle="tab">Dovecot</a></li>
|
<li role="presentation"><a href="#tab-dovecot-logs" aria-controls="tab-dovecot-logs" role="tab" data-toggle="tab">Dovecot</a></li>
|
||||||
<li role="presentation"><a href="#tab-sogo-logs" aria-controls="tab-sogo-logs" role="tab" data-toggle="tab">SOGo</a></li>
|
<li role="presentation"><a href="#tab-sogo-logs" aria-controls="tab-sogo-logs" role="tab" data-toggle="tab">SOGo</a></li>
|
||||||
|
<li role="presentation"><a href="#tab-fail2ban-logs" aria-controls="tab-fail2ban-logs" role="tab" data-toggle="tab">Fail2ban</a></li>
|
||||||
<li role="presentation"><a href="#tab-rspamd-history" aria-controls="tab-rspamd-history" role="tab" data-toggle="tab">Rspamd</a></li>
|
<li role="presentation"><a href="#tab-rspamd-history" aria-controls="tab-rspamd-history" role="tab" data-toggle="tab">Rspamd</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
@ -324,6 +325,24 @@ $tfa_data = get_tfa();
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div role="tabpanel" class="tab-pane" id="tab-fail2ban-logs">
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-heading">Fail2ban
|
||||||
|
<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_fail2ban_log"><?=$lang['admin']['refresh'];?></a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="panel-body">
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-striped table-condensed" id="fail2ban_log"></table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div role="tabpanel" class="tab-pane" id="tab-rspamd-history">
|
<div role="tabpanel" class="tab-pane" id="tab-rspamd-history">
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading">Rspamd history
|
<div class="panel-heading">Rspamd history
|
||||||
|
|
|
@ -1388,7 +1388,7 @@ function get_logs($container, $lines = 100) {
|
||||||
}
|
}
|
||||||
$lines = intval($lines);
|
$lines = intval($lines);
|
||||||
if ($container == "dovecot-mailcow") {
|
if ($container == "dovecot-mailcow") {
|
||||||
if ($data = $redis->lRange('DOVECOT_MAILLOG', 1, $lines)) {
|
if ($data = $redis->lRange('DOVECOT_MAILLOG', 0, $lines)) {
|
||||||
foreach ($data as $json_line) {
|
foreach ($data as $json_line) {
|
||||||
$data_array[] = json_decode($json_line, true);
|
$data_array[] = json_decode($json_line, true);
|
||||||
}
|
}
|
||||||
|
@ -1396,7 +1396,7 @@ function get_logs($container, $lines = 100) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($container == "postfix-mailcow") {
|
if ($container == "postfix-mailcow") {
|
||||||
if ($data = $redis->lRange('POSTFIX_MAILLOG', 1, $lines)) {
|
if ($data = $redis->lRange('POSTFIX_MAILLOG', 0, $lines)) {
|
||||||
foreach ($data as $json_line) {
|
foreach ($data as $json_line) {
|
||||||
$data_array[] = json_decode($json_line, true);
|
$data_array[] = json_decode($json_line, true);
|
||||||
}
|
}
|
||||||
|
@ -1404,7 +1404,15 @@ function get_logs($container, $lines = 100) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($container == "sogo-mailcow") {
|
if ($container == "sogo-mailcow") {
|
||||||
if ($data = $redis->lRange('SOGO_LOG', 1, $lines)) {
|
if ($data = $redis->lRange('SOGO_LOG', 0, $lines)) {
|
||||||
|
foreach ($data as $json_line) {
|
||||||
|
$data_array[] = json_decode($json_line, true);
|
||||||
|
}
|
||||||
|
return $data_array;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($container == "fail2ban-mailcow") {
|
||||||
|
if ($data = $redis->lRange('F2B_LOG', 0, $lines)) {
|
||||||
foreach ($data as $json_line) {
|
foreach ($data as $json_line) {
|
||||||
$data_array[] = json_decode($json_line, true);
|
$data_array[] = json_decode($json_line, true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,10 @@ jQuery(function($){
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
draw_sogo_logs();
|
draw_sogo_logs();
|
||||||
});
|
});
|
||||||
|
$("#refresh_fail2ban_log").on('click', function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
draw_fail2ban_logs();
|
||||||
|
});
|
||||||
$("#refresh_rspamd_history").on('click', function(e) {
|
$("#refresh_rspamd_history").on('click', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
draw_rspamd_history();
|
draw_rspamd_history();
|
||||||
|
@ -95,6 +99,41 @@ jQuery(function($){
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
function draw_fail2ban_logs() {
|
||||||
|
ft_fail2ban_logs = FooTable.init('#fail2ban_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":"message","title":lang.message},
|
||||||
|
],
|
||||||
|
"rows": $.ajax({
|
||||||
|
dataType: 'json',
|
||||||
|
url: '/api/v1/get/logs/fail2ban/1000',
|
||||||
|
jsonp: false,
|
||||||
|
error: function () {
|
||||||
|
console.log('Cannot draw fail2ban log table');
|
||||||
|
},
|
||||||
|
success: function (data) {
|
||||||
|
$.each(data, function (i, item) {
|
||||||
|
item.message = escapeHtml(item.message);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
"empty": lang.empty,
|
||||||
|
"paging": {
|
||||||
|
"enabled": true,
|
||||||
|
"limit": 5,
|
||||||
|
"size": log_pagination_size
|
||||||
|
},
|
||||||
|
"filtering": {
|
||||||
|
"enabled": true,
|
||||||
|
"position": "left",
|
||||||
|
"placeholder": lang.filter_table
|
||||||
|
},
|
||||||
|
"sorting": {
|
||||||
|
"enabled": true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
function draw_sogo_logs() {
|
function draw_sogo_logs() {
|
||||||
ft_sogo_logs = FooTable.init('#sogo_log', {
|
ft_sogo_logs = FooTable.init('#sogo_log', {
|
||||||
"columns": [
|
"columns": [
|
||||||
|
@ -454,6 +493,7 @@ jQuery(function($){
|
||||||
draw_postfix_logs();
|
draw_postfix_logs();
|
||||||
draw_dovecot_logs();
|
draw_dovecot_logs();
|
||||||
draw_sogo_logs();
|
draw_sogo_logs();
|
||||||
|
draw_fail2ban_logs();
|
||||||
draw_domain_admins();
|
draw_domain_admins();
|
||||||
draw_fwd_hosts();
|
draw_fwd_hosts();
|
||||||
draw_rspamd_history();
|
draw_rspamd_history();
|
||||||
|
|
|
@ -480,6 +480,21 @@ if (isset($_SESSION['mailcow_cc_role']) || isset($_SESSION['pending_mailcow_cc_u
|
||||||
echo '{}';
|
echo '{}';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case "fail2ban":
|
||||||
|
if (isset($extra) && !empty($extra)) {
|
||||||
|
$extra = intval($extra);
|
||||||
|
$logs = get_logs('fail2ban-mailcow', $extra);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$logs = get_logs('fail2ban-mailcow', -1);
|
||||||
|
}
|
||||||
|
if (isset($logs) && !empty($logs)) {
|
||||||
|
echo json_encode($logs, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
echo '{}';
|
||||||
|
}
|
||||||
|
break;
|
||||||
case "postfix":
|
case "postfix":
|
||||||
if (isset($extra) && !empty($extra)) {
|
if (isset($extra) && !empty($extra)) {
|
||||||
$extra = intval($extra);
|
$extra = intval($extra);
|
||||||
|
|
Loading…
Reference in New Issue