nethogs - Cheatsheet Per-Process Bandwidth Monitor
nethogs è un piccolo strumento “net top” che raggruppa bandwidth usage per processo piuttosto che per connessione o subnet. Quando qualcosa sta saturando il tuo link, nethogs è il modo più veloce per vedere quale programma è responsabile e quanto sta inviando e ricevendo — nessun packet filter o config richiesto. Legge il traffico per PID e ha bisogno di root per farlo.
Installazione
| Piattaforma | Comando |
|---|
| Debian/Ubuntu | sudo apt install nethogs |
| Fedora/RHEL | sudo dnf install nethogs |
| Arch Linux | sudo pacman -S nethogs |
| macOS (Homebrew) | brew install nethogs |
| Verifica | nethogs -V |
Esecuzione
| Comando | Descrizione |
|---|
sudo nethogs | Monitora l”interfaccia default |
sudo nethogs eth0 | Monitora un”interfaccia specifica |
sudo nethogs eth0 wlan0 | Monitora multiple interfacce |
sudo nethogs -d 5 | Refresh ogni 5 secondi |
sudo nethogs -v 3 | Modalità view: traffico totale accumulato |
Il Display
| Colonna | Significato |
|---|
PID | Process ID |
USER | Process owner |
PROGRAM | Percorso eseguibile (e remote per alcune viste) |
DEV | Network device |
SENT | Velocità upload (KB/s di default) |
RECEIVED | Velocità download |
Interactive Keys
| Key | Azione |
|---|
m | Cicla unità (KB/s, KB, B, MB) |
s | Sort per SENT |
r | Sort per RECEIVED |
q | Quit |
Modalità View (-v)
| Modalità | Mostra |
|---|
-v 0 | KB/s (velocità, default) |
-v 1 | Total KB |
-v 2 | Total B |
-v 3 | Total MB (accumulato dal start) |
Opzioni Vale la Pena Conoscere
| Opzione | Descrizione |
|---|
-d SECONDS | Refresh delay |
-t | ”Trace” / non-interactive text output |
-b | Bughunt mode (debug) |
-a | Monitora tutti i device (incl. loopback) |
-p | Promiscuous mode (vedi più traffico) |
-C | Capture in una modalità limited/count |
Workflow Comuni
# Trova il bandwidth hog sulla tua main interface, sorted per download
sudo nethogs eth0 # poi premi ''r'' per sort per RECEIVED
# Monitora Wi-Fi con un refresh più lento
sudo nethogs wlan0 -d 3
# Non-interactive capture per uno script/ticket
sudo nethogs -t eth0 > nethogs.log
| Tool | Raggruppa per | Note |
|---|
| nethogs | Process (PID) | “Chi usa bandwidth?“ |
| iftop | Connection (host pairs) | “Quali connessioni sono busy?“ |
| bandwhich | Process + connection + remote | Rust, richest breakdown |
| nload | Interface totals | Simple aggregate graph |
nethogs risponde quale processo; iftop risponde quale connessione; usali insieme quando insegui un network problem.
Risorse