Services & logs
Control services, follow logs, count error codes, check disk and load.
Service status
Shows state, start type and dependencies of a service.
- Service
-
postfixChange in the builder →
PowerShell (Windows)
Get-Service Built-in
Get-Service postfix | Format-List Name, Status, StartType, DependentServices sc.exe Built-in
sc.exe qc postfix
sc.exe queryex postfix Unix shell (bash)
systemctl Built-in
systemctl status postfix --no-pager
systemctl is-enabled postfix service Add-on tool
service postfix status Restart a service
Restarts a service and shows its state afterwards.
- Service
-
postfixChange in the builder →
PowerShell (Windows)
Restart-Service Built-in
Restart-Service postfix -Force
Get-Service postfix | Select-Object Name, Status sc.exe Built-in
sc.exe stop postfix
sc.exe start postfix Unix shell (bash)
systemctl Built-in
sudo systemctl restart postfix
systemctl status postfix --no-pager | head -10 service Add-on tool
sudo service postfix restart Interrupts running connections. On a mail server that means submissions are rejected for a few seconds and retried later.
Follow a log
Follows a log file or the service journal live while you reproduce a fault.
Postfix
- Service
-
postfixChange in the builder →
PowerShell (Windows)
Get-Content -Wait Built-in
Get-Content "/var/log/mail.log" -Tail 50 -Wait Get-WinEvent Built-in
Get-WinEvent -LogName Application -MaxEvents 50 | Where-Object { $_.ProviderName -like "*postfix*" } | Format-Table TimeCreated, Id, LevelDisplayName, Message -AutoSize Unix shell (bash)
journalctl Built-in
journalctl -u postfix -f -n 50 tail Built-in
tail -f -n 50 /var/log/mail.log Search a log
Searches a term or response code in a log file and shows the last matches.
- Search term
-
550Change in the builder →
PowerShell (Windows)
Select-String Built-in
Select-String -Path "/var/log/mail.log" -Pattern "550" | Select-Object -Last 40 Get-WinEvent Built-in
Get-WinEvent -FilterHashtable @{LogName="Application"; Level=2; StartTime=(Get-Date).AddHours(-24)} | Format-Table TimeCreated, ProviderName, Message -AutoSize Unix shell (bash)
grep Built-in
grep -i "550" /var/log/mail.log | tail -40 journalctl Add-on tool
journalctl --since "24 hours ago" | grep -i "550" | tail -40 Count SMTP error codes
Counts the 4xx and 5xx response codes in the mail log, sorted by frequency: shows immediately whether one destination or a pattern is at fault.
Mail-Log
PowerShell (Windows)
Select-String Built-in
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 Add-on tool
Get-MessageTrackingLog -EventId FAIL -Start (Get-Date).AddHours(-24) | Group-Object RecipientStatus -NoElement | Sort-Object Count -Descending Unix shell (bash)
grep / awk Built-in
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 Add-on tool
journalctl -u postfix --since today | grep -oE "status=(bounced|deferred|sent)" | sort | uniq -c Disk space
Shows free space and the largest directories: a full disk stops the queue and the logs.
PowerShell (Windows)
Get-PSDrive / Get-Volume Built-in
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 Built-in
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 Built-in
df -h
du -xh --max-depth=1 /var | sort -h | tail -15 ncdu Add-on tool
ncdu /var Load and processes
Shows the processes with the highest CPU load and their memory use.
PowerShell (Windows)
Get-Process Built-in
Get-Process | Sort-Object CPU -Descending | Select-Object -First 10 Name, Id, CPU, @{N="MB";E={[math]::Round($_.WorkingSet64/1MB)}} Get-Counter Built-in
Get-Counter "\Processor(_Total)\% Processor Time", "\Memory\Available MBytes" -SampleInterval 2 -MaxSamples 3 Unix shell (bash)
ps / top Built-in
ps aux --sort=-%cpu | head -11
top -b -n 1 | head -15 htop Add-on tool
htop -d 10