Add Json log parser for Dovecot and Postfix containers

This commit is contained in:
andryyy
2017-05-06 23:52:40 +02:00
parent d614aaf617
commit 8c8bfc0108
4 changed files with 109 additions and 49 deletions

View File

@@ -5181,4 +5181,30 @@ function delete_forwarding_host($postarray) {
'msg' => sprintf($lang['success']['forwarding_host_removed'], htmlspecialchars($host))
);
}
function get_logs($container, $lines = 100) {
global $lang;
global $redis;
if ($_SESSION['mailcow_cc_role'] != "admin") {
$_SESSION['return'] = array(
'type' => 'danger',
'msg' => sprintf($lang['danger']['access_denied'])
);
return false;
}
$lines = intval($lines);
if ($container == "dovecot-mailcow") {
if ($data = $redis->lRange('DOVECOT_MAILLOG', 1, $lines)) {
foreach ($data as $json_line) {
$data_array[] = json_decode($json_line, true);
}
return $data_array;
}
}
if ($container == "postfix-mailcow") {
if ($data = $redis->lRange('POSTFIX_MAILLOG', 1, $lines)) {
return $data;
}
}
return false;
}
?>