Linux network and I/O monitoring tools
Tools and commands to monitor network traffic, disk I/O and open connections on Linux.
This article gathers Linux tools and commands for monitoring network traffic, disk I/O and open connections.
Network tools
| Tool | Use |
|---|---|
| NetHogs | Network traffic per process |
| iftop | Network traffic per connection |
| bmon | Bandwidth per interface |
iftop, NetHogs and bmon are available in the repositories of most distributions.
Disk I/O
Install the tools (RPM-based distributions):
sudo dnf install sysstat iotop
Overview of disks and partitions:
lsblk
sudo fdisk -l
Statistics per device:
iostat -d 2
iostat -d -z 2
The -z option hides devices with no activity.
Activity per process:
sudo iotop
sudo iotop -o
sudo iotop -oP
pidstat -dl 20
-o shows only processes that are reading or writing. -P groups the display by process instead of by thread.
History and throughput with sar (from the sysstat package):
sar -b 1
sar 2 5 -o /tmp/data_io > /dev/null 2>&1
sar -f /tmp/data_io
The second command records five samples taken every two seconds into a file, which the third command reads back.
Partition statistics and a combined view with vmstat:
vmstat -d 1
vmstat -p sda1 1
vmstat 1
vmstat reports CPU, memory, I/O and process activity together. For disk benchmarking, Iozone is an alternative.
Network connections
All open connections:
sudo lsof -nP -i
Established TCP connections:
sudo lsof -nP -iTCP -sTCP:ESTABLISHED
Listening TCP and UDP sockets, with the owning process:
sudo ss -tlunp
sudo lsof -nP -iTCP -sTCP:LISTEN