Fix: Mailbox Stats über Dovecot mit config/mailpool.php

main v1.0.54
boban 2025-10-26 18:19:02 +01:00
parent e997d5374d
commit a943b42fec
3 changed files with 33 additions and 34 deletions

View File

@ -15,23 +15,34 @@ class SpamAvCollectCommand extends Command
{ {
$this->info('Collecting Spam/AV metrics…'); $this->info('Collecting Spam/AV metrics…');
$collect = function (): array { // Rspamd counters (kein Root nötig)
$out = trim(@shell_exec('rspamc counters 2>/dev/null') ?? ''); $out = trim(@shell_exec('rspamc counters 2>/dev/null') ?? '');
$ham = preg_match('/\bham\s*:\s*(\d+)/i', $out, $m1) ? (int)$m1[1] : 0; $ham = preg_match('/\bham\s*:\s*(\d+)/i', $out, $m1) ? (int)$m1[1] : 0;
$spam = preg_match('/\bspam\s*:\s*(\d+)/i', $out, $m2) ? (int)$m2[1] : 0; $spam = preg_match('/\bspam\s*:\s*(\d+)/i', $out, $m2) ? (int)$m2[1] : 0;
$reject = preg_match('/\breject\s*:\s*(\d+)/i', $out, $m3) ? (int)$m3[1] : 0; $reject = preg_match('/\breject\s*:\s*(\d+)/i', $out, $m3) ? (int)$m3[1] : 0;
$rspamdVer = trim(@shell_exec('rspamadm version 2>/dev/null') ?? '') ?: ''; // ClamAV Version + Signatur-Datum robust ohne Datei-Zugriff
$clamVer = trim(@shell_exec('clamd --version 2>/dev/null || clamscan --version 2>/dev/null') ?? '') ?: ''; $clamLine = trim((string) @shell_exec('clamd --version 2>/dev/null || clamscan --version 2>/dev/null'));
$clamVer = $clamLine !== '' ? $clamLine : '';
// Aus clamd/clamscan-Output das Datum am Ende herausziehen (Format: ".../Sun Oct 26 09:42:43 2025")
$sigUpdated = null; $sigUpdated = null;
$log = @shell_exec('grep -i "Database updated" /var/log/clamav/freshclam.log | tail -n1 2>/dev/null'); if ($clamLine && preg_match('#/([^/]+\d{4})$#', $clamLine, $m)) {
if ($log) { $sigUpdated = trim($log); } // $m[1] ist z.B. "Sun Oct 26 09:42:43 2025"
$sigUpdated = $m[1];
}
return compact('ham','spam','reject','rspamdVer','clamVer','sigUpdated') + ['ts' => time()]; $data = [
}; 'ts' => time(),
'ham' => $ham,
'spam' => $spam,
'reject' => $reject,
'rspamdVer' => trim((string) @shell_exec('rspamadm version 2>/dev/null')) ?: '',
'clamVer' => $clamVer,
'sigUpdated' => $sigUpdated,
];
$data = $collect(); // Persistieren (DB→Redis) + kurzer UI-Cache
Setting::set('spamav.metrics', $data); Setting::set('spamav.metrics', $data);
Cache::put('dash.spamav', $data, 60); Cache::put('dash.spamav', $data, 60);

View File

@ -70,29 +70,18 @@ class SpamAvCard extends Component
$reject = preg_match('/\breject\s*:\s*(\d+)/i', $out, $m3) ? (int)$m3[1] : 0; $reject = preg_match('/\breject\s*:\s*(\d+)/i', $out, $m3) ? (int)$m3[1] : 0;
// Versionen // Versionen
// $rspamdVer = trim(@shell_exec('rspamadm version 2>/dev/null') ?? '') ?: ''; $clamLine = trim((string) @shell_exec('clamd --version 2>/dev/null || clamscan --version 2>/dev/null'));
// $clamVer = trim(@shell_exec('clamd --version 2>/dev/null || clamscan --version 2>/dev/null') ?? '') ?: ''; $clamVer = $clamLine !== '' ? $clamLine : '';
//
// // Letztes Signatur-Update aus freshclam.log
// $sigUpdated = null;
// $log = @shell_exec('grep -i "Database updated" /var/log/clamav/freshclam.log | tail -n1 2>/dev/null');
// if ($log) {
// $sigUpdated = trim($log);
// }
$clamLine = trim(shell_exec('clamd --version 2>/dev/null || clamscan --version 2>/dev/null') ?? '');
$clamVer = $clamLine ?: '';
$sigUpdated = null; $sigUpdated = null;
if ($clamLine && preg_match('#/([^/]+ [0-9]{2} [0-9:]{8} [0-9]{4})$#', $clamLine, $m)) { if ($clamLine && preg_match('#/([^/]+\d{4})$#', $clamLine, $m)) {
// Beispiel-Match: "Sun Oct 26 09:42:43 2025"
$sigUpdated = $m[1]; $sigUpdated = $m[1];
} }
// Fallback: Versuch über journalctl (falls adm-Rechte vorhanden) //// Fallback: Versuch über journalctl (falls adm-Rechte vorhanden)
if (!$sigUpdated) { // if (!$sigUpdated) {
$jl = trim(shell_exec('journalctl -u freshclam -n 50 --no-pager 2>/dev/null | grep -i "Database updated" | tail -n1') ?? ''); // $jl = trim(shell_exec('journalctl -u freshclam -n 50 --no-pager 2>/dev/null | grep -i "Database updated" | tail -n1') ?? '');
if ($jl) $sigUpdated = $jl; // if ($jl) $sigUpdated = $jl;
} // }
return [ return [

View File

@ -110,7 +110,6 @@ class UpdateCard extends Component
@shell_exec('nohup php /var/www/mailwolt/artisan mailwolt:restart-services >/dev/null 2>&1 &'); @shell_exec('nohup php /var/www/mailwolt/artisan mailwolt:restart-services >/dev/null 2>&1 &');
@shell_exec('nohup php /var/www/mailwolt/artisan settings:sync >/dev/null 2>&1 &'); @shell_exec('nohup php /var/www/mailwolt/artisan settings:sync >/dev/null 2>&1 &');
@shell_exec('nohup php /var/www/mailwolt/artisan spamav:collect >/dev/null 2>&1 &'); @shell_exec('nohup php /var/www/mailwolt/artisan spamav:collect >/dev/null 2>&1 &');
$this->postActionsDone = true; $this->postActionsDone = true;
$ver = $this->displayCurrent ?? 'aktuelle Version'; $ver = $this->displayCurrent ?? 'aktuelle Version';