Services et journaux
Piloter les services, suivre les journaux, compter les codes d'erreur, vérifier l'espace disque et la charge.
État d'un service
Affiche l'état, le type de démarrage et les dépendances d'un service.
PowerShell (Windows)
Get-Service Natif
Get-Service postfix | Format-List Name, Status, StartType, DependentServices sc.exe Natif
sc.exe qc postfix
sc.exe queryex postfix Shell Unix (bash)
systemctl Natif
systemctl status postfix --no-pager
systemctl is-enabled postfix service Outil complémentaire
service postfix status Redémarrer un service
Redémarre un service et affiche ensuite son état.
PowerShell (Windows)
Restart-Service Natif
Restart-Service postfix -Force
Get-Service postfix | Select-Object Name, Status sc.exe Natif
sc.exe stop postfix
sc.exe start postfix Shell Unix (bash)
systemctl Natif
sudo systemctl restart postfix
systemctl status postfix --no-pager | head -10 service Outil complémentaire
sudo service postfix restart Interrompt les connexions en cours. Sur un serveur de messagerie, les envois sont refusés pendant quelques secondes et retentés plus tard.
Suivre un journal
Suit en direct un fichier journal ou le journal du service pendant que vous reproduisez une erreur.
Postfix
- Fichier journal
-
/var/log/mail.logModifier dans le générateur →
PowerShell (Windows)
Get-Content -Wait Natif
Get-Content "/var/log/mail.log" -Tail 50 -Wait Get-WinEvent Natif
Get-WinEvent -LogName Application -MaxEvents 50 | Where-Object { $_.ProviderName -like "*postfix*" } | Format-Table TimeCreated, Id, LevelDisplayName, Message -AutoSize Shell Unix (bash)
journalctl Natif
journalctl -u postfix -f -n 50 tail Natif
tail -f -n 50 /var/log/mail.log Rechercher dans un journal
Recherche un terme ou un code de réponse dans un fichier journal et affiche les dernières occurrences.
- Fichier journal
-
/var/log/mail.logModifier dans le générateur → - Terme recherché
-
550Modifier dans le générateur →
PowerShell (Windows)
Select-String Natif
Select-String -Path "/var/log/mail.log" -Pattern "550" | Select-Object -Last 40 Get-WinEvent Natif
Get-WinEvent -FilterHashtable @{LogName="Application"; Level=2; StartTime=(Get-Date).AddHours(-24)} | Format-Table TimeCreated, ProviderName, Message -AutoSize Shell Unix (bash)
grep Natif
grep -i "550" /var/log/mail.log | tail -40 journalctl Outil complémentaire
journalctl --since "24 hours ago" | grep -i "550" | tail -40 Compter les codes d'erreur SMTP
Compte les codes de réponse 4xx et 5xx dans le journal de messagerie, triés par fréquence : montre immédiatement si une destination ou un schéma est en cause.
Mail-Log
- Fichier journal
-
/var/log/mail.logModifier dans le générateur →
PowerShell (Windows)
Select-String Natif
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 Outil complémentaire
Get-MessageTrackingLog -EventId FAIL -Start (Get-Date).AddHours(-24) | Group-Object RecipientStatus -NoElement | Sort-Object Count -Descending Shell Unix (bash)
grep / awk Natif
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 Outil complémentaire
journalctl -u postfix --since today | grep -oE "status=(bounced|deferred|sent)" | sort | uniq -c Espace disque
Affiche l'espace libre et les plus grands répertoires : un disque plein bloque la file d'attente et les journaux.
PowerShell (Windows)
Get-PSDrive / Get-Volume Natif
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 Natif
Get-ChildItem C:\ -Recurse -File -ErrorAction SilentlyContinue | Sort-Object Length -Descending | Select-Object -First 10 FullName, @{N="MB";E={[math]::Round($_.Length/1MB,1)}} Shell Unix (bash)
df / du Natif
df -h
du -xh --max-depth=1 /var | sort -h | tail -15 ncdu Outil complémentaire
ncdu /var Charge et processus
Affiche les processus avec la plus forte charge CPU et leur utilisation de la mémoire.
PowerShell (Windows)
Get-Process Natif
Get-Process | Sort-Object CPU -Descending | Select-Object -First 10 Name, Id, CPU, @{N="MB";E={[math]::Round($_.WorkingSet64/1MB)}} Get-Counter Natif
Get-Counter "\Processor(_Total)\% Processor Time", "\Memory\Available MBytes" -SampleInterval 2 -MaxSamples 3 Shell Unix (bash)
ps / top Natif
ps aux --sort=-%cpu | head -11
top -b -n 1 | head -15 htop Outil complémentaire
htop -d 10