Servicios y registros
Controlar servicios, seguir registros, contar códigos de error, comprobar espacio en disco y carga.
Estado de un servicio
Muestra el estado, el tipo de inicio y las dependencias de un servicio.
- Servicio
-
postfixCambiar en el generador →
PowerShell (Windows)
Get-Service Integrado
Get-Service postfix | Format-List Name, Status, StartType, DependentServices sc.exe Integrado
sc.exe qc postfix
sc.exe queryex postfix Shell de Unix (bash)
systemctl Integrado
systemctl status postfix --no-pager
systemctl is-enabled postfix service Herramienta adicional
service postfix status Reiniciar un servicio
Reinicia un servicio y muestra después su estado.
- Servicio
-
postfixCambiar en el generador →
PowerShell (Windows)
Restart-Service Integrado
Restart-Service postfix -Force
Get-Service postfix | Select-Object Name, Status sc.exe Integrado
sc.exe stop postfix
sc.exe start postfix Shell de Unix (bash)
systemctl Integrado
sudo systemctl restart postfix
systemctl status postfix --no-pager | head -10 service Herramienta adicional
sudo service postfix restart Interrumpe las conexiones en curso. En un servidor de correo, los envíos se rechazan durante unos segundos y se reintentan más tarde.
Seguir un registro
Sigue en directo un archivo de registro o el journal del servicio mientras reproduce un fallo.
Postfix
- Archivo de registro
-
/var/log/mail.logCambiar en el generador → - Servicio
-
postfixCambiar en el generador →
PowerShell (Windows)
Get-Content -Wait Integrado
Get-Content "/var/log/mail.log" -Tail 50 -Wait Get-WinEvent Integrado
Get-WinEvent -LogName Application -MaxEvents 50 | Where-Object { $_.ProviderName -like "*postfix*" } | Format-Table TimeCreated, Id, LevelDisplayName, Message -AutoSize Shell de Unix (bash)
journalctl Integrado
journalctl -u postfix -f -n 50 tail Integrado
tail -f -n 50 /var/log/mail.log Buscar en un registro
Busca un término o un código de respuesta en un archivo de registro y muestra las últimas coincidencias.
- Archivo de registro
-
/var/log/mail.logCambiar en el generador → - Término de búsqueda
-
550Cambiar en el generador →
PowerShell (Windows)
Select-String Integrado
Select-String -Path "/var/log/mail.log" -Pattern "550" | Select-Object -Last 40 Get-WinEvent Integrado
Get-WinEvent -FilterHashtable @{LogName="Application"; Level=2; StartTime=(Get-Date).AddHours(-24)} | Format-Table TimeCreated, ProviderName, Message -AutoSize Shell de Unix (bash)
grep Integrado
grep -i "550" /var/log/mail.log | tail -40 journalctl Herramienta adicional
journalctl --since "24 hours ago" | grep -i "550" | tail -40 Contar códigos de error SMTP
Cuenta los códigos de respuesta 4xx y 5xx en el registro de correo, ordenados por frecuencia: muestra al momento si la causa es un destino o un patrón.
Mail-Log
- Archivo de registro
-
/var/log/mail.logCambiar en el generador →
PowerShell (Windows)
Select-String Integrado
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 Herramienta adicional
Get-MessageTrackingLog -EventId FAIL -Start (Get-Date).AddHours(-24) | Group-Object RecipientStatus -NoElement | Sort-Object Count -Descending Shell de Unix (bash)
grep / awk Integrado
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 Herramienta adicional
journalctl -u postfix --since today | grep -oE "status=(bounced|deferred|sent)" | sort | uniq -c Espacio en disco
Muestra el espacio libre y los directorios más grandes: un disco lleno detiene la cola y los registros.
PowerShell (Windows)
Get-PSDrive / Get-Volume Integrado
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 Integrado
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 de Unix (bash)
df / du Integrado
df -h
du -xh --max-depth=1 /var | sort -h | tail -15 ncdu Herramienta adicional
ncdu /var Carga y procesos
Muestra los procesos con mayor carga de CPU y su uso de memoria.
PowerShell (Windows)
Get-Process Integrado
Get-Process | Sort-Object CPU -Descending | Select-Object -First 10 Name, Id, CPU, @{N="MB";E={[math]::Round($_.WorkingSet64/1MB)}} Get-Counter Integrado
Get-Counter "\Processor(_Total)\% Processor Time", "\Memory\Available MBytes" -SampleInterval 2 -MaxSamples 3 Shell de Unix (bash)
ps / top Integrado
ps aux --sort=-%cpu | head -11
top -b -n 1 | head -15 htop Herramienta adicional
htop -d 10