mirror of
https://github.com/mailcow/mailcow-dockerized.git
synced 2025-01-26 05:27:29 +02:00
[Web] Add Rspamd stats export to API
This commit is contained in:
parent
4579124120
commit
3911ba0910
@ -634,10 +634,21 @@ if (isset($_SESSION['mailcow_cc_role']) || isset($_SESSION['pending_mailcow_cc_u
|
|||||||
switch ($category) {
|
switch ($category) {
|
||||||
case "rspamd":
|
case "rspamd":
|
||||||
switch ($object) {
|
switch ($object) {
|
||||||
case "stat":
|
case "actions":
|
||||||
$data = file_get_contents('http://rspamd-mailcow:11334/stat');
|
$curl = curl_init();
|
||||||
if (!empty($data)) {
|
curl_setopt($curl, CURLOPT_UNIX_SOCKET_PATH, '/rspamd-sock/rspamd.sock');
|
||||||
echo $data;
|
curl_setopt($curl, CURLOPT_URL,"http://rspamd/stat");
|
||||||
|
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
||||||
|
$data = curl_exec($curl);
|
||||||
|
if ($data) {
|
||||||
|
$return = array();
|
||||||
|
$stats_array = json_decode($data, true)['actions'];
|
||||||
|
$stats_array['soft reject'] = $stats_array['soft reject'] + $stats_array['greylist'];
|
||||||
|
unset($stats_array['greylist']);
|
||||||
|
foreach ($stats_array as $action => $count) {
|
||||||
|
$return[] = array($action, $count);
|
||||||
|
}
|
||||||
|
echo json_encode($return, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
|
||||||
}
|
}
|
||||||
elseif (!isset($data) || empty($data)) {
|
elseif (!isset($data) || empty($data)) {
|
||||||
echo '{}';
|
echo '{}';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user