Friday, 18 November 2016

VMSTAT in Linux

Reports Virtual Memory Statistics. It reports information about processes, memory, paging, block IO, taps, and CPU activity. The first report produced gives averages since the last reboot. Additional reports give information on a sampling period of length delay. The process and memory reports are instantaneous in either case.

VMSTAT does not require special permissions. These reports are intended to help identify system bottlenecks.   Linux VMSTAT does not count itself as a running process. All  linux  blocks  are currently  1024  bytes. Old kernels may report blocks as 512 bytes, 2048 bytes, or 4096 bytes. Since procps 3.1.9, vmstat lets you choose units (k, K, m,  M)  default is K (1024 bytes) in the default mode
Other way to get information are /proc/meminfo , /proc/stat,  /proc/*/stat.

Some of the examples are below:

[root@rahul@linux ~] vmstat
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu-----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
18  0    708 96000856    464 2555262208    0    0     3   160    0    0  1  0 99  0  0
[root@rcdn9-emaas-rdb-001 ~]#

Procs
       r: The number of processes waiting for run time.
       b: The number of processes in uninterruptible sleep.

Memory
       swpd: the amount of virtual memory used.
       free: the amount of idle memory.
       buff: the amount of memory used as buffers.
       cache: the amount of memory used as cache.
       inact: the amount of inactive memory. (-a option)
       active: the amount of active memory. (-a option)

Swap
       si: Amount of memory swapped in from disk (/s).
       so: Amount of memory swapped to disk (/s).

IO
       bi: Blocks received from a block device (blocks/s).
       bo: Blocks sent to a block device (blocks/s).

System
       in: The number of interrupts per second, including the clock.
       cs: The number of context switches per second.

CPU
       These are percentages of total CPU time.
       us: Time spent running non-kernel code. (user time, including nice time)
       sy: Time spent running kernel code. (system time)
       id: Time spent idle. Prior to Linux 2.5.41, this includes IO-wait time.
       wa: Time spent waiting for IO. Prior to Linux 2.5.41, shown as zero.


[root@rahul@linux ~]# vmstat -a          Active/Inactive Memory
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu-----
 r  b   swpd   free  inact active   si   so    bi    bo   in   cs us sy id wa st
 3  0    708 95259808 1758343168 822516864    0    0     3   160    0    0  1  0 99  0  0

[root@rahul@linux ~]# vmstat -f
     31309949 forks

Number of forks since last restart. Number of tasks. Each process is represented by one or more        tasks, depending on thread usage.  This display does not repeat.

[root@rahul@linux ~]# vmstat -m Displays slabinfo
Cache                       Num  Total   Size  Pages
nf_conntrack_ffff89e99b09ae00      0      0    304     13

cache: Cache name
num: Number of currently active objects
total: Total number of available objects
size: Size of each object
pages: Number of pages with at least one active object
totpages: Total number of allocated pages
pslab: Number of pages per slab

[root@rahul@linux ~]# vmstat -n   Same as 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    692 80950576    464 2569727744    0    0     3   160    0    0  1  0 99  0  0


[root@rahul@linux ~]# vmstat -s        -- Event Counter and  memory statistics
   2774295808  total memory
   2697926400  used memory
    826923712  active memory
   1772232960  inactive memory
     76369280  free memory
          464  buffer memory
   2574770944  swap cache
      4194300  total swap
          692  used swap
      4193608  free swap
    328301314 non-nice user cpu ticks
         3542 nice user cpu ticks
     70364589 system cpu ticks
  32954132294 idle cpu ticks
      4865037 IO-wait cpu ticks
         6250 IRQ cpu ticks
      9848009 softirq cpu ticks
            0 stolen cpu ticks
   1030697686 pages paged in
  53379068841 pages paged out
          104 pages swapped in
          217 pages swapped out
   1162661649 interrupts
   2277229811 CPU context switches
   1476703567 boot time
     31474117 forks

[root@rahul@linux ~]# vmstat -5
usage: vmstat [-V] [-n] [delay [count]]
              -V prints version.
              -n causes the headers not to be reprinted regularly.
              -a print inactive/active page stats.
              -d prints disk statistics
              -D prints disk table
              -p prints disk partition statistics
              -s prints vm table
              -m prints slabinfo
              -t add timestamp to output
              -S unit size
              delay is the delay between updates in seconds.
              unit size k:1000 K:1024 m:1000000 M:1048576 (default is K)
              count is the number of updates.


[root@rahul@linux ~]# vmstat 5
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    692 75732416    464 2575491584    0    0     3   160    0    0  1  0 99  0  0
 5  0    692 75689440    464 2575514112    0    0     0  5130 17034 21562  2  1 97  0  0
 4  0    692 75722464    464 2575530752    0    0     0 12456 15821 14389  1  1 98  0  0
 4  0    692 75746632    464 2575555584    0    0     0  7586 15094 16254  1  1 99  0  0
 8  0    692 75745712    464 2575565824    0    0     1 19883 16983 16501  2  1 97  0  0

[root@rahul@linux ~]# vmstat -d disk statistics
disk- ------------reads------------ ------------writes----------- -----IO------
       total merged sectors      ms  total merged sectors      ms    cur    sec
ram0       0      0       0       0      0      0       0       0      0      0
ram1       0      0       0       0      0      0       0       0      0      0
ram2       0      0       0       0      0      0       0       0      0      0
ram3       0      0       0       0      0      0       0       0      0      0
ram4       0      0       0       0      0      0       0       0      0      0
ram5       0      0       0       0      0      0       0       0      0      0
ram6       0      0       0       0      0      0       0       0      0      0
ram7       0      0       0       0      0      0       0       0      0      0
ram8       0      0       0       0      0      0       0       0      0      0
ram9       0      0       0       0      0      0       0       0      0      0
ram10      0      0       0       0      0      0       0       0      0      0
ram11      0      0       0       0      0      0       0       0      0      0
ram12      0      0       0       0      0      0       0       0      0      0
ram13      0      0       0       0      0      0       0       0      0      0
ram14      0      0       0       0      0      0       0       0      0      0
ram15      0      0       0       0      0      0       0       0      0      0
loop0      0      0       0       0      0      0       0       0      0      0
loop1      0      0       0       0      0      0       0       0      0      0
loop2      0      0       0       0      0      0       0       0      0      0
loop3      0      0       0       0      0      0       0       0      0      0
loop4      0      0       0       0      0      0       0       0      0      0
loop5      0      0       0       0      0      0       0       0      0      0
loop6      0      0       0       0      0      0       0       0      0      0
loop7      0      0       0       0      0      0       0       0      0      0
zram0      0      0       0       0      0      0       0       0      0      0
fioa    3254      0  312287     674 24372260      0 30035851875 4223132598      0   8400
fiob  6074950      0 1074323673 1057472 455289506      0 11372152579 3526281277      0   3000
fioc  5011713      0 983469690  965440 608269179      0 45632450256 263461364      0  34203
sda    80705    607 1720668   77844 5198429    245 254745602 161652896      0   5797
dm-0   79653      0 1708072   78040 5197923      0 254693648 161865943      0   5780
dm-1     447      0    3576     957    217      0    1736   99496      0     10
dm-2     180      0    2456     188    531      0   50200    3846      0      1
dm-3  11088876      0 2058099023 2130356 1495829218      0 87040454710 4234588663      0  65385
sdb   153548      0 1575199  200552 13143910      0 19489567165 616883680      0  14527
dm-4   20766      6  512943   14624 13143910 3800089 19489567165 625004708      0  14648
dm-5   20721      0  512535   14520 16944001      0 19489567165 837507283      0  14653

Reads
       total: Total reads completed successfully
       merged: grouped reads (resulting in one I/O)
       sectors: Sectors read successfully
       ms: milliseconds spent reading


   Writes
       total: Total writes completed successfully
       merged: grouped writes (resulting in one I/O)
       sectors: Sectors written successfully
       ms: milliseconds spent writing


   IO
       cur: I/O in progress
       s: seconds spent for I/O


[root@rahul@linux ~]# vmstat -p /dev/shm
Partition was not found

[root@rahul@linux ~]# vmstat -S K
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    692 70379232    464 2579287040    0    0     3   160    0    0  1  0 99  0  0

[root@rahul@linux ~]# vmstat -S k
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu-----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 0  0    708 72121024    475 2641190144    0    0     3   160    0    0  1  0 99  0  0

[root@rahul@linux~]# vmstat -S m
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu-----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 2  0      0  72135      0 2641250    0    0     3   160    0    0  1  0 99  0  0

[root@rahul@linux ~]# vmstat -S M
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu-----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 4  0      0  68850      0 2518896    0    0     3   160    0    0  1  0 99  0  0


[root@rahul@linux ~]# vmstat -V
procps version 3.2.8



No comments:

Post a Comment