Operations 9 min read

Master Linux Monitoring: CPU, Memory, Disk & Network Using vmstat, iostat, pidstat

This guide explains how to monitor Linux CPU usage, scheduler queues, lock contention, network I/O, and disk I/O using graphical tools and command‑line utilities such as gnome‑system‑monitor, vmstat, pidstat, nicstat, and iostat, with syntax, parameters, example outputs, and installation steps.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Master Linux Monitoring: CPU, Memory, Disk & Network Using vmstat, iostat, pidstat

CPU Usage Monitoring

Run the graphical tool gnome-system-monitor to view real‑time CPU utilization, memory usage and process information.

# gnome-system-monitor

CPU Scheduler Run Queue with vmstat

vmstat

(Virtual Memory Statistics) reports real‑time system metrics. Basic syntax: vmstat [delay [count]] Parameters :

delay : interval in seconds between two samples.

count : number of samples to collect; must be used together with delay .

When called without arguments, vmstat shows averages since boot. With a delay , the first line is the average since boot; subsequent lines show averages for each interval.

Key fields (derived from /proc/stat) relevant to CPU:

r : number of tasks waiting for CPU (run queue, excludes the vmstat process).

b : number of blocked tasks (I/O, paging, etc.).

us : user‑mode CPU time (%).

sy : kernel‑mode CPU time (%).

id : idle time (%), not counting I/O wait.

wa : I/O wait time (%).

in : interrupts per second.

cs : context switches per second.

# vmstat

Lock Contention Monitoring with pidstat

The pidstat command from the sysstat package reports per‑process CPU usage, useful for spotting lock‑related bottlenecks.

# pidstat

Typical columns: PID, %usr, %system, %guest, %CPU, CPU (core), Command.

Network I/O Monitoring with nicstat

nicstat

(originally from Solaris) displays per‑interface transmit/receive rates and packet statistics on Linux.

Installation steps (tested with version 1.92):

# yum install gcc gcc-c++ make automake autoconf -y
# yum install libgcc.i686 glibc.i686 glibc-devel.i686 -y
# wget -c http://nchc.dl.sourceforge.net/project/nicstat/nicstat-1.92.tar.gz
# tar zxvf nicstat-1.92.tar.gz
# cd nicstat-1.92
# cp Makefile.Linux Makefile
# make
# ./nicstat.sh

Disk I/O Monitoring with iostat

iostat

reports CPU and block‑device statistics.

Basic syntax: iostat [-t] [-c] [interval [count]] Parameters :

-t : include timestamp in output.

-c : display only CPU information.

interval : seconds between samples.

count : number of samples (requires interval ).

When run without arguments, iostat shows averages since system boot. With an interval , the first line is the overall average; subsequent lines reflect each interval.

Key CPU fields (derived from /proc/stat) reported by iostat:

user : user‑mode CPU time (%), excluding negative nice values.

nice : CPU time for processes with negative nice value (%).

sys : kernel‑mode CPU time (%).

iowait : time waiting for I/O (%).

idle : idle time (%), not counting I/O wait.

# iostat

Additional Resources

For deeper Linux performance analysis, see Brendan Gregg’s collections:

https://www.brendangregg.com/linuxperf.html

http://www.cnblogs.com/argb/p/3448661.html

http://blog.yufeng.info/archives/2518

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

performancelinuxiostatvmstatpidstatnicstat
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.