{"id":11285,"date":"2019-03-12T22:07:13","date_gmt":"2019-03-12T22:07:13","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=11285"},"modified":"2019-03-12T22:07:13","modified_gmt":"2019-03-12T22:07:13","slug":"linux-performance-monitoring-with-vmstat-and-iostat-commands","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/12\/linux-performance-monitoring-with-vmstat-and-iostat-commands\/","title":{"rendered":"Linux Performance Monitoring with Vmstat and Iostat Commands"},"content":{"rendered":"<p>This is our on-going series of commands and performance monitoring in\u00a0<strong>Linux<\/strong>.\u00a0<strong>Vmstat<\/strong>\u00a0and\u00a0<strong>Iostat<\/strong>\u00a0both commands are available on all major\u00a0<strong>Unix-like<\/strong>\u00a0(<strong>Linux\/Unix\/FreeBSD\/Solaris<\/strong>) Operating Systems.<\/p>\n<p>If\u00a0<strong>vmstat<\/strong>\u00a0and\u00a0<strong>iostat<\/strong>\u00a0commands are not available on your box, please install\u00a0<strong>sysstat<\/strong>\u00a0package. The\u00a0<strong>vmstat<\/strong>,\u00a0<strong>sar<\/strong>and\u00a0<strong>iostat<\/strong>\u00a0commands are the collection of package included in\u00a0<strong>sysstat<\/strong>\u00a0\u2013 the system monitoring tools. The\u00a0<strong>iostat<\/strong>\u00a0generates reports of\u00a0<strong>CPU<\/strong>\u00a0&amp; all device statistics. You may download and install\u00a0<strong>sysstat<\/strong>\u00a0using source tarball from link\u00a0<a href=\"http:\/\/sebastien.godard.pagesperso-orange.fr\/download.html\" target=\"_blank\" rel=\"noopener\">sysstat<\/a>, but we recommend installing through\u00a0<strong>YUM<\/strong>\u00a0command.<\/p>\n<div id=\"attachment_1008\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/09\/Linux-VmStat-Iostat-Commands.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-1008\" title=\"Linux Vmstat and Iostat Commands\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/09\/Linux-VmStat-Iostat-Commands-300x194.png\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/09\/Linux-VmStat-Iostat-Commands-300x194.png 300w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/09\/Linux-VmStat-Iostat-Commands.png 425w\" alt=\"Linux Vmstat and Iostat Commands\" width=\"300\" height=\"194\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Linux Performance Monitoring with Vmstat and Iostat<\/p>\n<\/div>\n<h4>Install Sysstat in Linux<\/h4>\n<pre># yum -y install sysstat<\/pre>\n<ol>\n<li><strong>vmstat<\/strong>\u00a0\u2013 Summary information of\u00a0<strong>Memory<\/strong>,\u00a0<strong>Processes<\/strong>,\u00a0<strong>Paging<\/strong>\u00a0etc.<\/li>\n<li><strong>iostat<\/strong>\u00a0\u2013 Central Processing Unit (<strong>CPU<\/strong>) statistics and\u00a0<strong>input\/output<\/strong>\u00a0statistics for\u00a0<strong>devices<\/strong>\u00a0and\u00a0<strong>partitions<\/strong>.<\/li>\n<\/ol>\n<div align=\"center\"><strong>6 Vmstat Command Examples in Linux<\/strong><\/div>\n<h4>1. List Active and Inactive Memory<\/h4>\n<p>In the below example, there are six columns. The significant of the columns are explained in man page of\u00a0<strong>vmstat<\/strong>\u00a0in details. Most important fields are\u00a0<strong>free<\/strong>\u00a0under memory and\u00a0<strong>si, so<\/strong>\u00a0under swap column.<\/p>\n<pre><strong>[root@tecmint ~]# vmstat -a<\/strong>\r\n\r\nprocs -----------memory---------- ---swap-- -----io---- --system-- -----cpu-----\r\n r  b   swpd   free  inact active   si   so    bi    bo   in   cs us sy id wa st\r\n 1  0      0 810420  97380  70628    0    0   115     4   89   79  1  6 90  3  0<\/pre>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>\n<li><strong>Free<\/strong>\u00a0\u2013 Amount of free\/idle memory spaces.<\/li>\n<li><strong>si<\/strong>\u00a0\u2013 Swaped in every second from disk in Kilo Bytes.<\/li>\n<li><strong>so<\/strong>\u00a0\u2013 Swaped out every second to disk in Kilo Bytes.<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<p><strong>Note:<\/strong>\u00a0If you run\u00a0<strong>vmstat<\/strong>\u00a0without parameters it\u2019ll displays summary report since system boot.<\/p>\n<h4>2. Execute vmstat \u2018X\u2019 seconds and (\u2018N\u2019number of times)<\/h4>\n<p>With this command,\u00a0<strong>vmstat<\/strong>\u00a0execute every two seconds and stop automatically after executing six intervals.<\/p>\n<pre><strong>[root@tecmint ~]# vmstat 2 6<\/strong>\r\n\r\nprocs -----------memory---------- ---swap-- -----io---- --system-- -----cpu-----\r\n r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st\r\n 0  0      0 810420  22064 101368    0    0    56     3   50   57  0  3 95  2  0\r\n 0  0      0 810412  22064 101368    0    0     0     0   16   35  0  0 100  0  0\r\n 0  0      0 810412  22064 101368    0    0     0     0   14   35  0  0 100  0  0\r\n 0  0      0 810412  22064 101368    0    0     0     0   17   38  0  0 100  0  0\r\n 0  0      0 810412  22064 101368    0    0     0     0   17   35  0  0 100  0  0\r\n 0  0      0 810412  22064 101368    0    0     0     0   18   36  0  1 100  0  0<\/pre>\n<h4>3. Vmstat with timestamps<\/h4>\n<p><strong>vmstat<\/strong>\u00a0command with\u00a0<strong>-t<\/strong>\u00a0parameter shows timestamps with every line printed as shown below.<\/p>\n<pre><strong>[tecmint@tecmint ~]$ vmstat -t 1 5<\/strong>\r\n\r\nprocs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------ ---timestamp---\r\n r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st\r\n 0  0      0 632028  24992 192244    0    0    70     5   55   78  1  3 95  1  0        2012-09-02 14:57:18 IST\r\n 1  0      0 632028  24992 192244    0    0     0     0  171  514  1  5 94  0  0        2012-09-02 14:57:19 IST\r\n 1  0      0 631904  24992 192244    0    0     0     0  195  600  0  5 95  0  0        2012-09-02 14:57:20 IST\r\n 0  0      0 631780  24992 192244    0    0     0     0  156  524  0  5 95  0  0        2012-09-02 14:57:21 IST\r\n 1  0      0 631656  24992 192244    0    0     0     0  189  592  0  5 95  0  0        2012-09-02 14:57:22 IST<\/pre>\n<h4>4. Statistics of Various Counter<\/h4>\n<p><strong>vmstat<\/strong>\u00a0command and\u00a0<strong>-s<\/strong>\u00a0switch displays summary of various event counters and memory statistics.<\/p>\n<pre><strong>[tecmint@tecmint ~]$ vmstat -s<\/strong>\r\n\r\n      1030800  total memory\r\n       524656  used memory\r\n       277784  active memory\r\n       185920  inactive memory\r\n       506144  free memory\r\n        26864  buffer memory\r\n       310104  swap cache\r\n      2064376  total swap\r\n            0  used swap\r\n      2064376  free swap\r\n         4539 non-nice user cpu ticks\r\n            0 nice user cpu ticks\r\n        11569 system cpu ticks\r\n       329608 idle cpu ticks\r\n         5012 IO-wait cpu ticks\r\n           79 IRQ cpu ticks\r\n           74 softirq cpu ticks\r\n            0 stolen cpu ticks\r\n       336038 pages paged in\r\n        67945 pages paged out\r\n            0 pages swapped in\r\n            0 pages swapped out\r\n       258526 interrupts\r\n       392439 CPU context switches\r\n   1346574857 boot time\r\n         2309 forks<\/pre>\n<h4>5. Disks Statistics<\/h4>\n<p><strong>vmstat<\/strong>\u00a0with\u00a0<strong>-d<\/strong>\u00a0option display all disks statistics.<\/p>\n<pre><strong>[tecmint@tecmint ~]$ vmstat -d<\/strong>\r\n\r\ndisk- ------------reads------------ ------------writes----------- -----IO------\r\n       total merged sectors      ms  total merged sectors      ms    cur    sec\r\nram0       0      0       0       0      0      0       0       0      0      0\r\nram1       0      0       0       0      0      0       0       0      0      0\r\nram2       0      0       0       0      0      0       0       0      0      0\r\nram3       0      0       0       0      0      0       0       0      0      0\r\nram4       0      0       0       0      0      0       0       0      0      0\r\nram5       0      0       0       0      0      0       0       0      0      0\r\nram6       0      0       0       0      0      0       0       0      0      0\r\nram7       0      0       0       0      0      0       0       0      0      0\r\nram8       0      0       0       0      0      0       0       0      0      0\r\nram9       0      0       0       0      0      0       0       0      0      0\r\nram10      0      0       0       0      0      0       0       0      0      0\r\nram11      0      0       0       0      0      0       0       0      0      0\r\nram12      0      0       0       0      0      0       0       0      0      0\r\nram13      0      0       0       0      0      0       0       0      0      0\r\nram14      0      0       0       0      0      0       0       0      0      0\r\nram15      0      0       0       0      0      0       0       0      0      0\r\nloop0      0      0       0       0      0      0       0       0      0      0\r\nloop1      0      0       0       0      0      0       0       0      0      0\r\nloop2      0      0       0       0      0      0       0       0      0      0\r\nloop3      0      0       0       0      0      0       0       0      0      0\r\nloop4      0      0       0       0      0      0       0       0      0      0\r\nloop5      0      0       0       0      0      0       0       0      0      0\r\nloop6      0      0       0       0      0      0       0       0      0      0\r\nloop7      0      0       0       0      0      0       0       0      0      0\r\nsr0        0      0       0       0      0      0       0       0      0      0\r\nsda     7712   5145  668732  409619   3282  28884  257402  644566      0    126\r\ndm-0   11578      0  659242 1113017  32163      0  257384 8460026      0    126\r\ndm-1     324      0    2592    3845      0      0       0       0      0      2<\/pre>\n<h4>6. Display Statistics in Megabytes<\/h4>\n<p>The\u00a0<strong>vmstat<\/strong>\u00a0displays in\u00a0<strong>Megabytes<\/strong>\u00a0with parameters\u00a0<strong>-S<\/strong>\u00a0and\u00a0<strong>M<\/strong>(Uppercase &amp; megabytes). By default\u00a0<strong>vmstat<\/strong>displays statistics in kilobytes.<\/p>\n<pre><strong>[root@tecmint ~]# vmstat -S M 1 5<\/strong>\r\n\r\nprocs -----------memory---------- ---swap-- -----io---- --system-- -----cpu-----\r\n r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st\r\n 0  0      0    346     53    476    0    0    95     8   42   55  0  2 96  2  0\r\n 0  0      0    346     53    476    0    0     0     0   12   15  0  0 100  0  0\r\n 0  0      0    346     53    476    0    0     0     0   32   62  0  0 100  0  0\r\n 0  0      0    346     53    476    0    0     0     0   15   13  0  0 100  0  0\r\n 0  0      0    346     53    476    0    0     0     0   34   61  0  1 99  0  0<\/pre>\n<div align=\"center\"><strong>6 Iostat Command Examples in Linux<\/strong><\/div>\n<h4>7. Display CPU and I\/O statistics<\/h4>\n<p><strong>iostat<\/strong>\u00a0without arguments displays\u00a0<strong>CPU<\/strong>\u00a0and\u00a0<strong>I\/O<\/strong>\u00a0statistics of all partitions as shown below.<\/p>\n<pre><strong>[root@tecmint ~]# iostat<\/strong>\r\n\r\nLinux 2.6.32-279.el6.i686 (tecmint.com)         09\/03\/2012      _i686_  (1 CPU)\r\n\r\navg-cpu:  %user   %nice %system %iowait  %steal   %idle\r\n           0.12    0.01    1.54    2.08    0.00   96.24\r\n\r\nDevice:            tps   Blk_read\/s   Blk_wrtn\/s   Blk_read   Blk_wrtn\r\nsda               3.59       161.02        13.48    1086002      90882\r\ndm-0              5.76       159.71        13.47    1077154      90864\r\ndm-1              0.05         0.38         0.00       2576          0<\/pre>\n<h4>8. Shows only CPU Statistics<\/h4>\n<p><strong>iostat<\/strong>\u00a0with\u00a0<strong>-c<\/strong>\u00a0arguments displays only\u00a0<strong>CPU<\/strong>\u00a0statistics as shown below.<\/p>\n<pre><strong>[root@tecmint ~]# iostat -c<\/strong>\r\n\r\nLinux 2.6.32-279.el6.i686 (tecmint.com)         09\/03\/2012      _i686_  (1 CPU)\r\n\r\navg-cpu:  %user   %nice %system %iowait  %steal   %idle\r\n           0.12    0.01    1.47    1.98    0.00   96.42<\/pre>\n<h4>9. Shows only Disks I\/O Statistics<\/h4>\n<p><strong>iostat<\/strong>\u00a0with\u00a0<strong>-d<\/strong>\u00a0arguments displays only disks\u00a0<strong>I\/O<\/strong>\u00a0statistics of all partitions as shown.<\/p>\n<pre><strong>[root@tecmint ~]# iostat -d<\/strong>\r\n\r\nLinux 2.6.32-279.el6.i686 (tecmint.com)         09\/03\/2012      _i686_  (1 CPU)\r\n\r\nDevice:            tps   Blk_read\/s   Blk_wrtn\/s   Blk_read   Blk_wrtn\r\nsda               3.35       149.81        12.66    1086002      91746\r\ndm-0              5.37       148.59        12.65    1077154      91728\r\ndm-1              0.04         0.36         0.00       2576          0<\/pre>\n<h4>10. Shows I\/O statistics only of a single device.<\/h4>\n<p>By default it displays statistics of all partitions, with\u00a0<strong>-p<\/strong>\u00a0and device name arguments displays only disks\u00a0<strong>I\/O<\/strong>statistics for specific device only as shown.<\/p>\n<pre><strong>[root@tecmint ~]# iostat -p sda<\/strong>\r\n\r\nLinux 2.6.32-279.el6.i686 (tecmint.com)         09\/03\/2012      _i686_  (1 CPU)\r\n\r\navg-cpu:  %user   %nice %system %iowait  %steal   %idle\r\n           0.11    0.01    1.44    1.92    0.00   96.52\r\n\r\nDevice:            tps   Blk_read\/s   Blk_wrtn\/s   Blk_read   Blk_wrtn\r\nsda               3.32       148.52        12.55    1086002      91770\r\nsda1              0.07         0.56         0.00       4120         18\r\nsda2              3.22       147.79        12.55    1080650      91752<\/pre>\n<h4>11. Display LVM Statistics<\/h4>\n<p>With\u00a0<strong>-N<\/strong>\u00a0(Uppercase) parameter displays only\u00a0<strong>LVM<\/strong>\u00a0statistics as shown.<\/p>\n<pre><strong>[root@tecmint ~]# iostat -N<\/strong>\r\n\r\nLinux 2.6.32-279.el6.i686 (tecmint.com)         09\/03\/2012      _i686_  (1 CPU)\r\n\r\navg-cpu:  %user   %nice %system %iowait  %steal   %idle\r\n           0.11    0.01    1.39    1.85    0.00   96.64\r\n\r\nDevice:            tps   Blk_read\/s   Blk_wrtn\/s   Blk_read   Blk_wrtn\r\nsda               3.20       142.84        12.16    1086002      92466\r\nvg_tecmint-lv_root     5.13       141.68        12.16    1077154      92448\r\nvg_tecmint-lv_swap     0.04         0.34         0.00       2576          0<\/pre>\n<h4>12. iostat version.<\/h4>\n<p>With\u00a0<strong>-V<\/strong>\u00a0(Uppercase) parameter displays version of\u00a0<strong>iostat<\/strong>\u00a0as shown.<\/p>\n<pre><strong>[root@tecmint ~]# iostat -V<\/strong>\r\n\r\nsysstat version 9.0.4\r\n(C) Sebastien Godard (sysstat  orange.fr)<\/pre>\n<p><strong>Note: vmstat<\/strong>\u00a0and\u00a0<strong>iostat<\/strong>\u00a0contains number of columns and flags which may not possible to explain in details. If you want to know more about it you may refer man page of\u00a0<strong>vmstat<\/strong>\u00a0and\u00a0<strong>iostat<\/strong>. Please share it if you find this article is useful through our comment box below.<\/p>\n<p><a href=\"https:\/\/www.tecmint.com\/linux-performance-monitoring-with-vmstat-and-iostat-commands\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is our on-going series of commands and performance monitoring in\u00a0Linux.\u00a0Vmstat\u00a0and\u00a0Iostat\u00a0both commands are available on all major\u00a0Unix-like\u00a0(Linux\/Unix\/FreeBSD\/Solaris) Operating Systems. If\u00a0vmstat\u00a0and\u00a0iostat\u00a0commands are not available on your box, please install\u00a0sysstat\u00a0package. The\u00a0vmstat,\u00a0sarand\u00a0iostat\u00a0commands are the collection of package included in\u00a0sysstat\u00a0\u2013 the system monitoring tools. The\u00a0iostat\u00a0generates reports of\u00a0CPU\u00a0&amp; all device statistics. You may download and install\u00a0sysstat\u00a0using source tarball from link\u00a0sysstat, &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/12\/linux-performance-monitoring-with-vmstat-and-iostat-commands\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Linux Performance Monitoring with Vmstat and Iostat Commands&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-11285","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11285","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=11285"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11285\/revisions"}],"predecessor-version":[{"id":11286,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11285\/revisions\/11286"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=11285"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=11285"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=11285"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}