Monitoring
vmstat, iostat, sar, hardware info, sensors, inotifywait, /proc and /sys. See also
journalctlfor log analysis andprocessesfor top/htop/btop.
vmstat
Snapshot:
vmstatEvery 2 sec, 10 samples:
vmstat 2 10Active/inactive memory:
vmstat -aWith timestamps:
vmstat -t 1Disk stats:
vmstat -dIn MB:
vmstat -S M
| Section | Field | Meaning |
|---|---|---|
| procs | r | runnable (CPU-bound) |
| procs | b | blocked (I/O) |
| memory | swpd | swap used |
| memory | free | free RAM |
| memory | buff/cache | buffers/cache |
| swap | si/so | swap in/out — non-zero so → memory pressure |
| io | bi/bo | blocks in/out per sec |
| system | in/cs | interrupts / context switches |
| cpu | us/sy/id | user/system/idle |
| cpu | wa | I/O wait (high → disk bottleneck) |
| cpu | st | stolen (VM) |
iostat
Install sysstat.
Basic:
iostatExtended every 2 sec:
iostat -x -t 2Specific device:
iostat -x /dev/nvme0n1MB/s:
iostat -mCPU only / device only:
iostat -c/iostat -d
Extended fields (-x)
| Field | Meaning |
|---|---|
r/s, w/s | reads/writes per sec |
rMB/s, wMB/s | throughput |
await | wait (queue+service) ms |
%util | device utilization |
sar
Install sysstat and enable the collector:
sudo systemctl enable --now sysstat
CPU live:
sar -u 1 5Memory:
sar -r 1 5Disk:
sar -d 1 5Network per-iface:
sar -n DEV 1 5Sockets:
sar -n SOCK 1 5Historical CPU from file:
sar -u -f /var/log/sa/sa13Memory in window:
sar -r -s 08:00:00 -e 17:00:00
Hardware
CPU summary:
lscpuPer-core info:
cat /proc/cpuinfoCore count:
nprocMemory summary:
free -hDetailed memory:
cat /proc/meminfoPCI devices:
lspci/lspci -v/lspci -kFind GPU:
lspci | grep -i vgaUSB:
lsusb/lsusb -v/lsusb -tBIOS/DMI:
sudo dmidecodesudo dmidecode -t memorysudo dmidecode -t biossudo dmidecode -t systemBlock devices + fs info:
lsblk -fDisk model/firmware:
sudo hdparm -I /dev/sdaSensors:
sudo sensors-detect # one-time sensorsBattery:
upower -i /org/freedesktop/UPower/devices/battery_BAT0cat /sys/class/power_supply/BAT0/capacityKernel / OS:
uname -a uname -r hostnamectl cat /etc/os-release uptime
inotifywait
Install inotify-tools.
Watch file (blocks):
inotifywait -m /path/to/fileRecursive directory:
inotifywait -mr /path/to/dirSpecific events:
inotifywait -m -e modify,create,delete /path/to/dirFormatted with timestamps:
inotifywait -mr --format '%T %w%f %e' --timefmt '%F %T' /path/to/dirAuto-rebuild on change:
inotifywait -mr -e modify --include '\.py$' ./src | while read -r path event file; do echo "Change: $file" make build doneOne-shot:
inotifywait -e modify /etc/hosts && echo "changed"
| Event | When |
|---|---|
access | file read |
modify | content change |
attrib | metadata change |
close_write | RW file closed |
open | file opened |
moved_to/from | moved in/out of dir |
create | created |
delete | deleted |
All-in-one monitors
btop (recommended):
btopglances (with web mode):
glancesdstat (one-line stats):
dstat -cdngy(cpu, disk, net, page, sys)
ncdu (interactive disk usage)
ncdu /home
watch
Repeat with highlight:
watch -d free -hSocket stats every sec:
watch -n 1 "ss -s"
/proc & /sys
System-wide:
cat /proc/cpuinfo
cat /proc/loadavg
cat /proc/meminfo
cat /proc/swaps
cat /proc/uptime
cat /proc/version
cat /proc/filesystems
cat /proc/net/tcp
cat /proc/net/dev
Per-process (replace 1234 with PID):
cat /proc/1234/status
cat /proc/1234/cmdline
cat /proc/1234/environ
ls -la /proc/1234/fd
cat /proc/1234/maps
cat /proc/1234/limits
Kernel tuning via /sys:
cat /sys/block/sda/queue/scheduler
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor