Logwatch: Unterschied zwischen den Versionen

Aus Xinux Wiki
Zur Navigation springen Zur Suche springen
 
(5 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 1: Zeile 1:
= Logwatch mit Debian 12 und journald =
+
```
 +
= Logwatch unter Debian 12 mit Postfix, Dovecot, Rspamd, ClamAV und Apache =
  
Logwatch unterstützt standardmäßig kein direktes Auslesen der Logs aus '''journald''', sondern erwartet klassische Log-Dateien. Unter Debian 12 wird '''journald''' verwendet, weshalb Logwatch hier ohne Anpassungen keine brauchbaren Berichte erstellt.
+
Logwatch wertet standardmäßig klassische Logdateien unter '''/var/log''' aus. Debian 12 (Bookworm) verwendet jedoch '''journald''', welches keine Text-Logs erzeugt.
  
= Voraussetzung =
+
Damit Logwatch alle gewünschten Dienste auswerten kann, ist es nötig, '''rsyslog''' zusätzlich zu installieren.
  
Um Logwatch mit Debian 12 verwenden zu können, muss '''rsyslog''' installiert werden. '''rsyslog''' erzeugt klassische Log-Dateien unter '''/var/log''', welche von Logwatch ausgewertet werden.
+
= rsyslog installieren =
  
== rsyslog installieren ==
+
'''rsyslog''' schreibt wieder klassische Logdateien.
  
 
* apt install rsyslog
 
* apt install rsyslog
  
'''rsyslog''' startet automatisch nach der Installation und schreibt ab sofort klassische Log-Dateien wie '''/var/log/mail.log''', '''/var/log/syslog''', usw.
+
Nach der Installation werden automatisch die üblichen Logs wie '''/var/log/syslog''' und '''/var/log/mail.log''' erzeugt.
  
= Testen der Log-Dateien =
+
= Logdateien prüfen =
  
Prüfen, ob klassische Log-Dateien angelegt wurden:
+
Prüfen, ob folgende Logdateien existieren und beschrieben werden:
  
* ls -l /var/log/mail.log /var/log/syslog
+
* 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 =
 
= Logwatch testen =
  
Logwatch manuell ausführen, um zu prüfen, ob Logs erkannt werden:
+
Ausgabe von Logwatch sofort auf der Konsole testen:
  
 
* logwatch --output stdout --detail High
 
* logwatch --output stdout --detail High
  
Die Ausgabe enthält nun Postfix, Dovecot, Rspamd und ClamAV, falls diese Dienste aktiv sind.
+
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:
  
= Hinweis zur nativen journald-Unterstützung =
+
* Nutzung von '''journalctl''' direkt
 +
* Grafische Verwaltung über '''Cockpit'''
 +
* Monitoring-Stacks (Grafana mit Loki oder ELK-Stack)
  
Logwatch besitzt aktuell (Stand 2025) keine native journald-Unterstützung und ist somit nicht mehr als State-of-the-Art anzusehen. Alternativen wären direkte Nutzung von '''journalctl''', grafische Lösungen wie '''Cockpit''', oder moderne Monitoring-Tools wie '''Grafana/Loki''' oder der '''ELK-Stack'''.
+
Logwatch ist weiterhin nutzbar, wenn klassisches Logging (rsyslog) parallel aktiviert wird, wie oben beschrieben.
 +
```

Aktuelle Version vom 28. März 2025, 06:37 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. ```