[Web] Add rspamd-stats route to API
parent
003499200e
commit
f3c72832f2
|
@ -1673,6 +1673,20 @@ function get_logs($application, $lines = false) {
|
|||
curl_close($curl);
|
||||
return false;
|
||||
}
|
||||
if ($application == "rspamd-stats") {
|
||||
$curl = curl_init();
|
||||
curl_setopt($curl, CURLOPT_UNIX_SOCKET_PATH, '/var/lib/rspamd/rspamd.sock');
|
||||
curl_setopt($curl, CURLOPT_URL,"http://rspamd/stat");
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
||||
$stats = curl_exec($curl);
|
||||
if (!curl_errno($curl)) {
|
||||
$data_array = json_decode($stats, true);
|
||||
curl_close($curl);
|
||||
return $data_array;
|
||||
}
|
||||
curl_close($curl);
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function getGUID() {
|
||||
|
|
|
@ -707,6 +707,10 @@ if (isset($_SESSION['mailcow_cc_role']) || isset($_SESSION['pending_mailcow_cc_u
|
|||
}
|
||||
echo (isset($logs) && !empty($logs)) ? json_encode($logs, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT) : '{}';
|
||||
break;
|
||||
case "rspamd-stats":
|
||||
$logs = get_logs('rspamd-stats');
|
||||
echo (isset($logs) && !empty($logs)) ? json_encode($logs, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT) : '{}';
|
||||
break;
|
||||
// return no route found if no case is matched
|
||||
default:
|
||||
http_response_code(404);
|
||||
|
|
Loading…
Reference in New Issue