November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  

Categories

November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  

iostat / vmstat / mpstat

iostat / vmstat / mpstat are some tools to monitor server performance.

* iostat reports CPU, disk I/O, and NFS statistics.

* vmstat reports virtual memory statistics.

* mpstat reports processors statictics.

iostat

Iostat without any argument displays information about the CPU usage, and I/O statistics about all the partitions on the system are showing:

# iostat

Linux 2.6.18-164.el5 (cloudcc.ctechz.blogspot.com) 03/11/2012

avg-cpu: %user %nice %system %iowait %steal %idle
1.98 17.92 8.59 0.33 0.00 71.17

Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn
sda 13.89 33.54 365.15 14323873 155932064
sda1 13.84 32.34 363.73 13808779 155327336
sda2 0.05 1.20 1.42 514566 604728

Display only cpu statistics

# iostat -c

Linux 2.6.18-164.el5 (cloudcc.ctechz.blogspot.com) 03/11/2012

avg-cpu: %user %nice %system %iowait %steal %idle
1.98 17.92 8.59 0.33 0.00 71.17

Display only disk I/O statistics

# iostat -d

Linux 2.6.18-164.el5 (cloudcc.ctechz.blogspot.com) 03/11/2012

Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn
sda 13.89 33.53 365.04 14323921 155949184
sda1 13.84 32.32 363.62 13808827 155344456
sda2 0.05 1.20 1.42 514566 604728

Display only network statistics

-n, displays only the device and NFS statistics.

# iostat -n

Linux 2.6.18-164.el5 (cloudcc.ctechz.blogspot.com) 03/11/2012

avg-cpu: %user %nice %system %iowait %steal %idle
1.98 17.93 8.59 0.33 0.00 71.17

Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn
sda 13.89 33.52 365.00 14323937 155957552
sda1 13.84 32.32 363.58 13808843 155352824
sda2 0.05 1.20 1.42 514566 604728

Device: rBlk_nor/s wBlk_nor/s rBlk_dir/s wBlk_dir/s rBlk_svr/s
wBlk_svr/s rops/s wops/s

192.168.1.4:/home/pac 90.67 0.00 0.00 0.00 5.33 0.00
192.168.1.4:/bkp 8.74 0.00 0.00 0.00 8.74 0.00
192.168.1.8:/media 0.02 0.00 0.00 0.00 0.01 0.00

Display I/O data in MB/second

By default iostat, displays the device I/O statistics in Blocks. To change it to MB, use -m as shown

# iostat -m

Linux 2.6.18-164.el5 (cloudcc.ctechz.blogspot.com) 03/11/2012

avg-cpu: %user %nice %system %iowait %steal %idle
1.98 17.93 8.59 0.33 0.00 71.16

Device: tps MB_read/s MB_wrtn/s MB_read MB_wrtn
sda 13.88 0.02 0.18 6994 76165
sda1 13.83 0.02 0.18 6742 75869
sda2 0.05 0.00 0.00 251 295

Display I/O statistics only for a device

# iostat -p sda

Display timestamp information

# iostat -t

Linux 2.6.18-164.el5 (cloudcc.ctechz.blogspot.com) 03/11/2012

Time: 05:51:24 PM
avg-cpu: %user %nice %system %iowait %steal %idle
1.98 17.93 8.59 0.33 0.00 71.16

Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn
sda 13.88 33.49 364.77 14324049 156006600
sda1 13.83 32.29 363.35 13808955 155401872
sda2 0.05 1.20 1.41 514566 604728

Execute Every x seconds – y number of times

# iostat 2
# iostat 2 3 — execute every 2 seconds for 3 times

Display LVM statistic

# iostat -N

# vmstat

procs ———–memory—————– —swap– ——io—- —system– —–cpu–
r b swpd free buff cache si so bi bo in cs us sy id wa st
1 0 196112 75232 151884 611352 0 0 8 91 45 40 20 9 71 0 0

vmstat output contains the following fields:

Procs – r: Total number of processes waiting to run
Procs – b: Total number of busy processes
Memory – swpd: Used virtual memory
Memory – free: Free virtual memory
Memory – buff: Memory used as buffers
Memory – cache: Memory used as cache.
Swap – si: Memory swapped from disk (for every second)
Swap – so: Memory swapped to disk (for every second)
IO – bi: Blocks in. i.e blocks received from device (for every second)
IO – bo: Blocks out. i.e blocks sent to the device (for every second)
System – in: Interrupts per second
System – cs: Context switches
CPU – us, sy, id, wa, st: CPU user time, system time, idle time, wait time

Display active and inactive memory
# vmstat -a

procs ———–memory———- —swap– —–io—- –system– —–cpu——
r b swpd free inact active si so bi bo in cs us sy id wa st
1 0 196112 75236 224864 787620 0 0 8 91 45 41 20 9 71 0 0

Display number of forks since last boot

This displays all the fork system calls made by the system since the last boot.

# vmstat -f
500235 forks

Execute Every x seconds
# vmstat 2
# vmstat 2 5

Display slab info
# vmstat -m

Display statistics in a table format
# vmstat -s

Display disk statistics
# vmstat -d

Display statistics for a partition
# vmstat -p /dev/sda1

Display in MB
# vmstat -S m

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>