{"id":465,"date":"2022-10-12T06:59:54","date_gmt":"2022-10-12T06:59:54","guid":{"rendered":"http:\/\/www.scmgalaxy.com\/tutorials\/2015\/12\/12\/20-mpstat-command-examples-in-linux-unix\/"},"modified":"2022-12-23T05:45:51","modified_gmt":"2022-12-23T05:45:51","slug":"20-mpstat-command-examples-in-linux-unix","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/20-mpstat-command-examples-in-linux-unix\/","title":{"rendered":"Linux Tutorials: mpstat commands examples"},"content":{"rendered":"\n<pre class=\"wp-block-preformatted\"> mpstat - Report processors related statistics.\n\nThe mpstat command writes to standard output activities for each available processor, processor 0 being the first one.  Global average activities among all processors are also reported. <\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">How to install mpstat?<\/h2>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">$ sudo apt install sysstat         &#91;On Debian, Ubuntu and Mint]\r\n$ sudo yum install sysstat         &#91;On RHEL\/CentOS\/Fedora and Rocky Linux\/AlmaLinux]\r\n$ sudo emerge -a app-admin\/sysstat &#91;On Gentoo Linux]\r\n$ sudo pacman -S sysstat           &#91;On Arch Linux]\r\n$ sudo zypper install sysstat      &#91;On OpenSUSE] <\/code><\/span><\/pre>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">mpstat command output<\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"447\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/10\/image-4-1024x447.png\" alt=\"\" class=\"wp-image-31548\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/10\/image-4-1024x447.png 1024w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/10\/image-4-300x131.png 300w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/10\/image-4-768x335.png 768w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/10\/image-4-1536x670.png 1536w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/10\/image-4.png 1693w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Understanding mpstat output<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>CPU<\/strong>&nbsp;: Processor number.&nbsp;The keyword all statistics are calculated as averages among all processors.<\/li><li><strong>% usr<\/strong>&nbsp;: Show the percentage of CPU utilization that occurred while executing at the user level (application).<\/li><li><strong>% nice<\/strong>&nbsp;: Show the percentage of CPU utilization that occurred while executing at the user level with nice priority.<\/li><li><strong>% sys<\/strong>&nbsp;: Show the percentage of CPU utilization that occurred while executing at the system level (kernel).&nbsp;Note that this does not include time-consuming servicing hardware and software interrupts.<\/li><li><strong>% iowait<\/strong>&nbsp;: The CPU or CPUs were idle during which the system had an outstanding disk I \/ O request.<\/li><li><strong>% irq<\/strong>&nbsp;: Show the percentage of time spent by the CPU or CPUs to service hardware interrupts.<\/li><li><strong>% soft<\/strong>&nbsp;: Show the percentage of time spent by the CPU or CPUs to service software interrupts.<\/li><li><strong>% steal<\/strong>&nbsp;: Show the percentage of time spent waiting for the CPU or CPUs while the hypervisor is servicing another virtual processor.<\/li><li><strong>% guest<\/strong>&nbsp;: Show the percentage of time used by the CPU or CPUs to run a virtual processor.<\/li><li><strong>% idle<\/strong>&nbsp;: The CPU or CPUs were idle and the system did not have an outstanding disk I \/ O request.<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">mstat commands example<\/h2>\n\n\n\n<p>1. To report the processor stats:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># mpstat 2 10 <\/pre>\n\n\n\n<p>2. To report all processor stats:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># mpstat -A 2 10 <\/pre>\n\n\n\n<p>3. To get the processor number for which the stats are displaying:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># mpstat -P 2 10 <\/pre>\n\n\n\n<p>4. To report the CPU utilization stats:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># mpstat -u 2 10 <\/pre>\n\n\n\n<p>5. To get the version info:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># mpstat -V \n\nTo see the default set of utilization metrics, enter the following command:\r\nmpstat 1 1\r\n\r\nTo see the default set of utilization metrics in wide display mode, enter the following command:\r\nmpstat \u2013w 1 1\r\n\r\nTo see the detailed dispatch &amp; affinity metrics, enter the following command:\r\n mpstat \u2013d 1 1\r\n\r\nTo see the detailed interrupts report, enter the following command:\r\nmpstat \u2013i 1 1\r\n\r\nTo see all the statistics, enter the following command:\r\nmpstat \u2013a 1 1\r\n\r\nTo see simultaneous multithreading utilization, enter the following command:\r\nmpstat \u2013s 1 1\r\n\r\nTo see all the processor metrics of a WPAR, enter the following command:\r\nmpstat -@ wparname\r\n\r\nNote: To see all the processor metrics of a WPAR inside the WPAR, enter the following command:\r\nmpstat -@\r\n\r\nTo see the sorted output for the column cs, enter the following command:\r\nmpstat -d -O sortcolumn=cs\r\n\r\nTo see the list of the top 10 CPUs, enter the following command:\r\nmpstat -a -O sortcolumn=min,sortorder=desc,topcount=10\r\n\r\nTo see metrics based on the virtual processor, enter the following command:\r\nmpstat \u2013v\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Context<\/h2>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"729\" height=\"352\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/10\/image-5.png\" alt=\"\" class=\"wp-image-31552\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/10\/image-5.png 729w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/10\/image-5-300x145.png 300w\" sizes=\"auto, (max-width: 729px) 100vw, 729px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>mpstat &#8211; Report processors related statistics. The mpstat command writes to standard output activities for each available processor, processor 0 being the first one. Global average activities among all processors are also reported. How to install mpstat? mpstat command output Understanding mpstat output CPU&nbsp;: Processor number.&nbsp;The keyword all statistics are calculated as averages among all&#8230;<\/p>\n","protected":false},"author":1,"featured_media":31552,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","_joinchat":[],"footnotes":""},"categories":[4957],"tags":[378,632,460,1292,1289,1290,1291,1294,1293,169],"class_list":["post-465","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","tag-commands","tag-examples","tag-linux","tag-linux-mpstat-command","tag-mpstat","tag-mpstat-command","tag-mpstat-command-examples","tag-mpstat-command-line","tag-mpstat-commands-tutorials","tag-unix"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/465","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=465"}],"version-history":[{"count":9,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/465\/revisions"}],"predecessor-version":[{"id":31553,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/465\/revisions\/31553"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media\/31552"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=465"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=465"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=465"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}