{"id":27,"date":"2007-09-22T23:25:10","date_gmt":"2007-09-22T15:25:10","guid":{"rendered":"http:\/\/www.sysadmindayph.com\/blog\/?p=27"},"modified":"2007-09-22T23:25:10","modified_gmt":"2007-09-22T15:25:10","slug":"demystifying-vmstat","status":"publish","type":"post","link":"https:\/\/www.sysadmindayph.com\/blog\/demystifying-vmstat\/","title":{"rendered":"Demystifying VMSTAT"},"content":{"rendered":"<p><strong>Vmstat<\/strong>, or <strong>virtual memory statistics<\/strong>, is one of the useful UNIX command an administrator can (always) use to check the performance of a server.  This is specially useful to determine how a particular UNIX box is doing during it&#8217;s peak usage time. It shows information about various system resources and their related performance problems.<\/p>\n<p>An example output of this command is shown below:<\/p>\n<pre><tt>% <\/tt><kbd><strong>vmstat 1 8<\/strong><\/kbd>  <em><font size=\"2\"> \tWrite a report every second for 5 seconds.  <\/font><\/em><tt>procs  memory           page             faults        cpu<\/tt><kbd><\/kbd>  <em><font size=\"2\"> \t  <\/font><\/em>\r\n\r\n<tt>-- --- -------- ---- ----<\/tt><kbd><\/kbd>  <em><font size=\"2\"> \t  <\/font><\/em>\r\n\r\n<tt>r  b avm   fre re  pi  po  fr   sr  cy  in  sy  cs us sy id wa<\/tt><kbd><\/kbd>  <em><font size=\"2\"> \t  <\/font><\/em>\r\n\r\n<tt>1  0  4680 365  0   0   0   1    3   0 123 102  75  0  2 97  1<\/tt><kbd><\/kbd>  <em><font size=\"2\"> \t  <\/font><\/em>\r\n\r\n<tt>1  0  4680 364  0   0   0   0    0   0 121  86  67  0  3 76 21<\/tt><kbd><\/kbd>  <em><font size=\"2\"> \t  <\/font><\/em>\r\n\r\n<tt>1  0  4680 364  0   0   0   0    0   0 114  70  28  1  0 99  0<\/tt><kbd><\/kbd>  <em><font size=\"2\"> \t  <\/font><\/em>\r\n\r\n<tt>1  0  4680 364  0   0   0   0    0   0 123  70  32  2  0 98  0<\/tt><kbd><\/kbd>  <em><font size=\"2\"> \t  <\/font><\/em>\r\n\r\n<tt>1  0  4680 364  0   0   0   0    0   0 114  74  28  1  0 99  0<\/tt><kbd><\/kbd>  <em><font size=\"2\"> \t  <\/font><\/em>\r\n\r\n<tt>1  0  4680 364  0   0   0   0    0   0 113  84  67  0 21 69 10<\/tt><kbd><\/kbd>  <em><font size=\"2\"> \t  <\/font><\/em>\r\n\r\n<tt>1  0  4680 364  0   0   0   0    0   0 127  78  56  8  9 82  1<\/tt><kbd><\/kbd>  <em><font size=\"2\"> \t  <\/font><\/em>\r\n\r\n<tt>1  0  4680 364  0   0   0   0    0   0 119  91  71  0  3 86 11<\/tt><kbd><\/kbd>  <em><font size=\"2\"> \t  <\/font><\/em><\/pre>\n<p>That is a lot of numbers. <strong>What does the out of VMSTAT means<\/strong> anyway?<\/p>\n<p><strong>In a Nutshell<\/strong><\/p>\n<p>The command produces information (for the least) about <strong>virtual memory (swap)<\/strong>, <strong>CPU usage<\/strong>, and <strong>disk usage<\/strong>. In my case, most of the stats that I frequently checked when users complain are CPU and memory usage.<\/p>\n<p><strong>The Details<\/strong><\/p>\n<p>There are five main column in a vmstat output &#8211; <em>proc<\/em>, <em>memory,  <\/em><em>paging<\/em>, <em>faults, CPU<\/em>.<\/p>\n<p>The first two columns under <strong><tt>procs<\/tt><\/strong> (or kernel thread on some UNIX) show the number of processes on the system.<\/p>\n<ul>\n<li>Column <strong><tt>r<\/tt><\/strong> shows &#8220;runable&#8221; or active processes &#8211; the value of this should be less than or equal to the number of processor.<\/li>\n<li>Column <strong><tt>b<\/tt><\/strong> shows &#8220;blocked&#8221; processes awaiting a resource such as input\/output.<\/li>\n<\/ul>\n<p>(more stuff here&#8230;.)<\/p>\n<p><strong>The Syntax<\/strong><\/p>\n<p>The command <tt><strong>vmstat<\/strong><\/tt> takes two arguments, one for how long to wait between reports and the second for how many reports to write out before quitting.<\/p>\n<p>Example:<\/p>\n<blockquote><p># vmstat 1 8<\/p><\/blockquote>\n<p>produces 8 output (lines) in every one second interval.  Omitting the second argument, vmstat will not stop displaying output on the screen until a break is sent (usually CNTRL+D or Z or C)<\/p>\n<p><strong>Final Words<\/strong><\/p>\n<p>Read some more.<\/p>\n<p>You should check out vmstat&#8217;s man page (<tt><strong>man vmstat<\/strong><\/tt> command) to get the details for your system. Since usage and output may vary from one operating system to another.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Vmstat, or virtual memory statistics, is one of the useful UNIX command an administrator can (always) use to check the performance of a server. This is specially useful to determine how a particular UNIX box &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-27","post","type-post","status-publish","format-standard","hentry","category-commands"],"_links":{"self":[{"href":"https:\/\/www.sysadmindayph.com\/blog\/wp-json\/wp\/v2\/posts\/27","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sysadmindayph.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sysadmindayph.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sysadmindayph.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sysadmindayph.com\/blog\/wp-json\/wp\/v2\/comments?post=27"}],"version-history":[{"count":0,"href":"https:\/\/www.sysadmindayph.com\/blog\/wp-json\/wp\/v2\/posts\/27\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sysadmindayph.com\/blog\/wp-json\/wp\/v2\/media?parent=27"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sysadmindayph.com\/blog\/wp-json\/wp\/v2\/categories?post=27"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sysadmindayph.com\/blog\/wp-json\/wp\/v2\/tags?post=27"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}