Logwatch: Unterschied zwischen den Versionen

Aus Xinux Wiki
Zur Navigation springen Zur Suche springen
Zeile 26: Zeile 26:
 
Datei '''/etc/rspamd/local.d/logging.inc''' erstellen oder ergänzen:
 
Datei '''/etc/rspamd/local.d/logging.inc''' erstellen oder ergänzen:
  
type = "file";
+
type = "file";
filename = "/var/log/rspamd/rspamd.log";
+
filename = "/var/log/rspamd/rspamd.log";
level = "info";
+
level = "info";
  
 
Rspamd danach neu starten:
 
Rspamd danach neu starten:

Version vom 28. März 2025, 06:36 Uhr

```

Logwatch unter Debian 12 mit Postfix, Dovecot, Rspamd, ClamAV und Apache

Logwatch wertet standardmäßig klassische Logdateien unter /var/log aus. Debian 12 (Bookworm) verwendet jedoch journald, welches keine Text-Logs erzeugt.

Damit Logwatch alle gewünschten Dienste auswerten kann, ist es nötig, rsyslog zusätzlich zu installieren.

rsyslog installieren

rsyslog schreibt wieder klassische Logdateien.

  • apt install rsyslog

Nach der Installation werden automatisch die üblichen Logs wie /var/log/syslog und /var/log/mail.log erzeugt.

Logdateien prüfen

Prüfen, ob folgende Logdateien existieren und beschrieben werden:

  • ls -l /var/log/mail.log /var/log/syslog /var/log/rspamd/rspamd.log /var/log/clamav/clamav.log /var/log/apache2/access.log /var/log/apache2/error.log

Falls rspamd und clamav keine Logs in /var/log erstellen, Konfiguration anpassen:

Rspamd-Logging aktivieren (falls nicht aktiv)

Datei /etc/rspamd/local.d/logging.inc erstellen oder ergänzen:

type = "file";
filename = "/var/log/rspamd/rspamd.log";
level = "info";

Rspamd danach neu starten:

  • systemctl restart rspamd

ClamAV-Logging aktivieren (falls nicht aktiv)

Datei /etc/clamav/clamd.conf ergänzen/anpassen:

LogFile /var/log/clamav/clamav.log LogTime yes

ClamAV neu starten:

  • systemctl restart clamav-daemon

Logwatch konfigurieren

Logwatch benötigt für Rspamd und ClamAV zusätzliche Konfigurationsdateien. Postfix, Dovecot und Apache funktionieren automatisch.

Rspamd in Logwatch integrieren

Konfigurationsdatei /etc/logwatch/conf/services/rspamd.conf erstellen:

Title = "Rspamd" LogFile = /var/log/rspamd/rspamd.log

Skript /etc/logwatch/scripts/services/rspamd erstellen und ausführbar machen:

#!/bin/bash
grep -E "(reject|spam|greylist|action)" | sort | uniq -c | sort -nr

Ausführbar setzen:

  • chmod +x /etc/logwatch/scripts/services/rspamd

ClamAV in Logwatch integrieren

Konfigurationsdatei /etc/logwatch/conf/services/clamav.conf erstellen:

Title = "ClamAV" LogFile = /var/log/clamav/clamav.log

Skript /etc/logwatch/scripts/services/clamav erstellen und ausführbar machen:

#!/bin/bash
grep -E "(FOUND|Infected)" | sort | uniq -c | sort -nr

Ausführbar setzen:

  • chmod +x /etc/logwatch/scripts/services/clamav

Apache in Logwatch prüfen

Apache wird automatisch von Logwatch ausgewertet, sofern Standardpfade verwendet werden:

  • /var/log/apache2/access.log
  • /var/log/apache2/error.log

Keine Anpassungen nötig.

Logwatch testen

Ausgabe von Logwatch sofort auf der Konsole testen:

  • logwatch --output stdout --detail High

Der Bericht enthält nun:

  • Postfix (Mail-Versand, Empfang, Fehler)
  • Dovecot (Logins, Authentifizierungsfehler)
  • Rspamd (Spam- und Greylisting-Berichte)
  • ClamAV (Virenmeldungen, Updates)
  • Apache (Zugriffe, Fehler, Warnungen)

Hinweis zur aktuellen Situation (2025)

Logwatch besitzt bis heute keine native Unterstützung für journald, was es in Umgebungen mit reinem Journald-Logging weniger zeitgemäß macht.

Zeitgemäße Alternativen für Journald wären:

  • Nutzung von journalctl direkt
  • Grafische Verwaltung über Cockpit
  • Monitoring-Stacks (Grafana mit Loki oder ELK-Stack)

Logwatch ist weiterhin nutzbar, wenn klassisches Logging (rsyslog) parallel aktiviert wird, wie oben beschrieben. ```