[Web] Fix Rspamd plot
parent
07c1a0bcd3
commit
82209196f5
|
@ -343,18 +343,13 @@ jQuery(function($){
|
|||
var ft_paging = ft.use(FooTable.Paging)
|
||||
return ft_paging.totalRows;
|
||||
})
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
function plot_rspamd() {
|
||||
$.ajax({
|
||||
url: '/api/v1/get/rspamd/actions',
|
||||
success: function(data){
|
||||
var total = 0;
|
||||
$(data).map(function(){total += this[1];})
|
||||
rspamd_labels = $.makeArray($(data).map(function(){return "<h5>" + this[0] + " (" + this[1] + ") " + Math.round(this[1]/total * 100) + "%</h5>";}));
|
||||
rspamd_donut = $.jqplot('rspamd_donut', [data],
|
||||
rspamd_donut_plot = $.jqplot('rspamd_donut', [data],
|
||||
{
|
||||
seriesDefaults: {
|
||||
renderer: jQuery.jqplot.DonutRenderer,
|
||||
|
@ -383,6 +378,9 @@ jQuery(function($){
|
|||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
function process_table_data(data, table) {
|
||||
if (table == 'rspamd_history') {
|
||||
$.each(data, function (i, item) {
|
||||
|
@ -538,8 +536,8 @@ jQuery(function($){
|
|||
var timer;
|
||||
clearTimeout(timer);
|
||||
timer = setTimeout(function () {
|
||||
if (typeof rspamd_donut !== 'undefined') {
|
||||
rspamd_donut.replot({});
|
||||
if (typeof rspamd_donut_plot !== 'undefined') {
|
||||
rspamd_donut_plot.replot({});
|
||||
}
|
||||
}, 500);
|
||||
});
|
||||
|
|
|
@ -158,6 +158,26 @@ if (isset($_SESSION['mailcow_cc_role']) || isset($_SESSION['pending_mailcow_cc_u
|
|||
switch ($category) {
|
||||
case "rspamd":
|
||||
switch ($object) {
|
||||
case "actions":
|
||||
$curl = curl_init();
|
||||
curl_setopt($curl, CURLOPT_UNIX_SOCKET_PATH, '/rspamd-sock/rspamd.sock');
|
||||
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)) {
|
||||
echo '{}';
|
||||
}
|
||||
break;
|
||||
case "stat":
|
||||
$data = file_get_contents('http://rspamd-mailcow:11334/stat');
|
||||
process_get_return($data);
|
||||
|
|
Loading…
Reference in New Issue