Dienste & Logs
Dienste steuern, Logs verfolgen, Fehlercodes zählen, Platz und Last prüfen.
Dienst-Status
Zeigt Zustand, Starttyp und Abhängigkeiten eines Dienstes.
PowerShell (Windows)
Get-Service Bordmittel
Get-Service postfix | Format-List Name, Status, StartType, DependentServices sc.exe Bordmittel
sc.exe qc postfix
sc.exe queryex postfix Unix-Shell (bash)
systemctl Bordmittel
systemctl status postfix --no-pager
systemctl is-enabled postfix service Zusatztool
service postfix status Dienst neu starten
Startet einen Dienst neu und zeigt danach den Zustand.
PowerShell (Windows)
Restart-Service Bordmittel
Restart-Service postfix -Force
Get-Service postfix | Select-Object Name, Status sc.exe Bordmittel
sc.exe stop postfix
sc.exe start postfix Unix-Shell (bash)
systemctl Bordmittel
sudo systemctl restart postfix
systemctl status postfix --no-pager | head -10 service Zusatztool
sudo service postfix restart Unterbricht laufende Verbindungen. Auf einem Mailserver heisst das: Einlieferungen werden für einige Sekunden abgewiesen und später wiederholt.
Log mitlaufen lassen
Verfolgt eine Logdatei oder das Dienst-Journal live, während ein Fehler nachgestellt wird.
Postfix
PowerShell (Windows)
Get-Content -Wait Bordmittel
Get-Content "/var/log/mail.log" -Tail 50 -Wait Get-WinEvent Bordmittel
Get-WinEvent -LogName Application -MaxEvents 50 | Where-Object { $_.ProviderName -like "*postfix*" } | Format-Table TimeCreated, Id, LevelDisplayName, Message -AutoSize Unix-Shell (bash)
journalctl Bordmittel
journalctl -u postfix -f -n 50 tail Bordmittel
tail -f -n 50 /var/log/mail.log Log durchsuchen
Sucht einen Begriff oder Antwortcode in einer Logdatei und zeigt die letzten Treffer.
- Suchbegriff
-
550Im Generator ändern →
PowerShell (Windows)
Select-String Bordmittel
Select-String -Path "/var/log/mail.log" -Pattern "550" | Select-Object -Last 40 Get-WinEvent Bordmittel
Get-WinEvent -FilterHashtable @{LogName="Application"; Level=2; StartTime=(Get-Date).AddHours(-24)} | Format-Table TimeCreated, ProviderName, Message -AutoSize Unix-Shell (bash)
grep Bordmittel
grep -i "550" /var/log/mail.log | tail -40 journalctl Zusatztool
journalctl --since "24 hours ago" | grep -i "550" | tail -40 SMTP-Fehlercodes zählen
Zählt die 4xx- und 5xx-Antwortcodes im Mail-Log und sortiert nach Häufigkeit: zeigt sofort, ob ein einzelnes Ziel oder ein Muster stört.
Mail-Log
PowerShell (Windows)
Select-String Bordmittel
Select-String -Path "/var/log/mail.log" -Pattern "\b(4\d\d|5\d\d)\b" |
Group-Object { ($_.Line -split "\s+" | Select-String "^[45]\d\d$").Matches.Value } -NoElement |
Sort-Object Count -Descending | Select-Object -First 15 Get-MessageTrackingLog Zusatztool
Get-MessageTrackingLog -EventId FAIL -Start (Get-Date).AddHours(-24) | Group-Object RecipientStatus -NoElement | Sort-Object Count -Descending Unix-Shell (bash)
grep / awk Bordmittel
grep -oE "\b[45][0-9][0-9] [0-9]\.[0-9]\.[0-9]" /var/log/mail.log | sort | uniq -c | sort -rn | head -15 journalctl Zusatztool
journalctl -u postfix --since today | grep -oE "status=(bounced|deferred|sent)" | sort | uniq -c Plattenplatz
Zeigt freien Platz und die grössten Verzeichnisse: eine volle Platte legt Warteschlange und Logs still.
PowerShell (Windows)
Get-PSDrive / Get-Volume Bordmittel
Get-Volume | Where-Object DriveLetter | Format-Table DriveLetter, FileSystemLabel, @{N="Frei(GB)";E={[math]::Round($_.SizeRemaining/1GB,1)}}, @{N="Gesamt(GB)";E={[math]::Round($_.Size/1GB,1)}} Get-ChildItem Bordmittel
Get-ChildItem C:\ -Recurse -File -ErrorAction SilentlyContinue | Sort-Object Length -Descending | Select-Object -First 10 FullName, @{N="MB";E={[math]::Round($_.Length/1MB,1)}} Unix-Shell (bash)
df / du Bordmittel
df -h
du -xh --max-depth=1 /var | sort -h | tail -15 ncdu Zusatztool
ncdu /var Last und Prozesse
Zeigt die Prozesse mit der höchsten CPU-Last und den Speicherverbrauch.
PowerShell (Windows)
Get-Process Bordmittel
Get-Process | Sort-Object CPU -Descending | Select-Object -First 10 Name, Id, CPU, @{N="MB";E={[math]::Round($_.WorkingSet64/1MB)}} Get-Counter Bordmittel
Get-Counter "\Processor(_Total)\% Processor Time", "\Memory\Available MBytes" -SampleInterval 2 -MaxSamples 3 Unix-Shell (bash)
ps / top Bordmittel
ps aux --sort=-%cpu | head -11
top -b -n 1 | head -15 htop Zusatztool
htop -d 10