{"id":616,"date":"2013-03-06T22:52:21","date_gmt":"2013-03-07T03:52:21","guid":{"rendered":"https:\/\/www.inmotionhosting.com\/support\/2013\/03\/06\/using-the-linux-sar-command\/"},"modified":"2021-08-16T23:19:51","modified_gmt":"2021-08-17T03:19:51","slug":"using-the-linux-sar-command","status":"publish","type":"post","link":"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/using-the-linux-sar-command\/","title":{"rendered":"Using the Linux sar command"},"content":{"rendered":"<p>In this article I&#8217;ll be explaining the Linux sar command and some of its many uses for helping you track down possible bottleneck problems on your server.<\/p>\n<p class=\"alert\">Please note in order to follow along with this guide you&#8217;d need to have a VPS (Virtual Private Server) or dedicated server to have access to the <strong>sar<\/strong> information.<\/p>\n<h2>What is sar?<\/h2>\n<p>Most of what happens on your server, is going to happen when you&#8217;re not actively logged into the server and monitoring things yourself. This is where the System Activity Reporter <strong>(sar)<\/strong> can come to the resuce.<\/p>\n<p>The <strong>sar<\/strong> command is part of the Linux <strong>systat<\/strong> package, which is a collection of tools to help monitor your server&#8217;s usage statistics.<\/p>\n<h2>What can I do with sar data?<\/h2>\n<p>The most common thing you can do with the <strong>sar<\/strong> command is simply running it by itself, this will provide you with the default view of data that has been logged.<\/p>\n<h3>sar<\/h3>\n<p>So if you run this command alone:<\/p>\n<p class=\"cli\" style=\"width: 500px; white-space: nowrap;\">sar<\/p>\n<p>You&#8217;ll get output back like this:<\/p>\n<p class=\"cli\" style=\"width: 500px; white-space: nowrap;\">Linux 2.6.32-279.22.1.el6.x86_64 (elite.inmotionhosting.com) 03\/06\/2013 _x86_64_ (8 CPU)<\/p>\n<p> 12:00:04 AM CPU %user %nice %system %iowait %steal %idle<br \/> 12:10:01 AM all 0.06 0.08 0.04 0.40 0.00 99.42<br \/> 12:20:01 AM all 0.04 0.10 0.04 0.26 0.00 99.55<br \/> 12:30:01 AM all 0.04 0.09 0.03 0.02 0.00 99.82<\/p>\n<p>This is showing the current day&#8217;s CPU statistics, which generally isn&#8217;t going to be too helpful. However <strong>sar<\/strong> has a lot of other features built in that can come in very handy<\/p>\n<h3>sar -q<\/h3>\n<p>When using the <strong>-q<\/strong> flag on the <strong>sar<\/strong> command, you&#8217;re presented with the process run queue and server load average, which is much more helpful in spotting possible server bottlenecks.<\/p>\n<p>So if you run this command:<\/p>\n<p class=\"cli\" style=\"width: 500px; white-space: nowrap;\">sar -q<\/p>\n<p>You&#8217;ll get output back like this:<\/p>\n<p class=\"cli\" style=\"width: 500px; white-space: nowrap;\">Linux 2.6.32-279.22.1.el6.x86_64 (elite.inmotionhosting.com) 03\/06\/2013 _x86_64_ (8 CPU)<\/p>\n<p> 12:00:01 AM runq-sz plist-sz ldavg-1 ldavg-5 ldavg-15<br \/> 12:02:01 AM 2 260 0.75 0.53 0.67<br \/> 12:04:01 AM 1 255 0.96 0.75 0.73<br \/> 12:06:01 AM 2 254 0.31 0.57 0.67<br \/> 12:08:01 AM 3 269 0.35 0.53 0.63<br \/> 12:10:01 AM 5 269 7.30 2.25 1.20<\/p>\n<p>In this example, you can see that at <strong>12:02AM<\/strong> our 8 core server had a 1 minute load average denoted by the <strong>ldavg-1<\/strong> column of <strong>0.75<\/strong>. However by <strong>12:10AM<\/strong> this had spiked up to <strong>7.30<\/strong>, so we can see that something caused the server to almost reach a full 100% utilization of its resources.<\/p>\n<h2>More advanced sar usage<\/h2>\n<p>I had written another article on <a href=\"\/support\/server\/server-usage\/advanced-server-load-monitoring\/\" target=\"_blank\" rel=\"noopener\">advanced server load monitoring<\/a> that even explains how you can use the following one-liner to show all the times your server&#8217;s load average was spiking:<\/p>\n<p class=\"cli\" style=\"width: 500px; white-space: nowrap;\">for log in `ls -1 \/var\/log\/sa\/sa[0-9]*`; do echo $log; sar -q -f $log | egrep -v &#8220;Average|ldavg&#8221; | awk &#8216;{if ($5&gt;=1) print $1,$2,$5}&#8217;; echo &#8220;&#8221;; done | less<\/p>\n<p>In another article I wrote on <a href=\"\/support\/server\/server-usage\/determine-cause-of-server-usage-spike\/\" target=\"_blank\" rel=\"noopener\">how to determine the cause of a server usage spike<\/a> it goes over also using <strong>sar<\/strong> data to find when your server&#8217;s load has been spiking, and then how to look at your Apache website access logs to correlate what was going on at that time, that might have led to the server&#8217;s usage spiking.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this article I&#8217;ll be explaining the Linux sar command and some of its many uses for helping you track down possible bottleneck problems on your server. Please note in order to follow along with this guide you&#8217;d need to have a VPS (Virtual Private Server) or dedicated server to have access to the sar<a class=\"moretag\" href=\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/using-the-linux-sar-command\/\"> Read More ><\/a><\/p>\n","protected":false},"author":57014,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4308],"tags":[],"class_list":["post-616","post","type-post","status-publish","format-standard","hentry","category-linux"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Using the Linux sar command | InMotion Hosting<\/title>\n<meta name=\"description\" content=\"In this article I&#039;ll be explaining the Linux sar command and some of its many uses for helping you track down possible bottleneck problems on your server.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/using-the-linux-sar-command\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Using the Linux sar command | InMotion Hosting\" \/>\n<meta property=\"og:description\" content=\"In this article I&#039;ll be explaining the Linux sar command and some of its many uses for helping you track down possible bottleneck problems on your server.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/using-the-linux-sar-command\/\" \/>\n<meta property=\"og:site_name\" content=\"InMotion Hosting Support Center\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/inmotionhosting\/\" \/>\n<meta property=\"article:published_time\" content=\"2013-03-07T03:52:21+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-08-17T03:19:51+00:00\" \/>\n<meta name=\"author\" content=\"InMotion Hosting Contributor\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/InMotionHosting\" \/>\n<meta name=\"twitter:site\" content=\"@InMotionHosting\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"InMotion Hosting Contributor\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/using-the-linux-sar-command\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/using-the-linux-sar-command\/\"},\"author\":{\"name\":\"InMotion Hosting Contributor\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/f9a4fc454cd1df128ee8e898d30d4644\"},\"headline\":\"Using the Linux sar command\",\"datePublished\":\"2013-03-07T03:52:21+00:00\",\"dateModified\":\"2021-08-17T03:19:51+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/using-the-linux-sar-command\/\"},\"wordCount\":482,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\"},\"articleSection\":[\"Linux\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/using-the-linux-sar-command\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/using-the-linux-sar-command\/\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/using-the-linux-sar-command\/\",\"name\":\"Using the Linux sar command | InMotion Hosting\",\"isPartOf\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#website\"},\"datePublished\":\"2013-03-07T03:52:21+00:00\",\"dateModified\":\"2021-08-17T03:19:51+00:00\",\"description\":\"In this article I'll be explaining the Linux sar command and some of its many uses for helping you track down possible bottleneck problems on your server.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/using-the-linux-sar-command\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/using-the-linux-sar-command\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/using-the-linux-sar-command\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.inmotionhosting.com\/support\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Using the Linux sar command\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#website\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/\",\"name\":\"InMotion Hosting Support Center\",\"description\":\"Web Hosting Support &amp; Tutorials\",\"publisher\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.inmotionhosting.com\/support\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\",\"name\":\"InMotion Hosting\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg\",\"contentUrl\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg\",\"width\":696,\"height\":696,\"caption\":\"InMotion Hosting\"},\"image\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/inmotionhosting\/\",\"https:\/\/x.com\/InMotionHosting\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/f9a4fc454cd1df128ee8e898d30d4644\",\"name\":\"InMotion Hosting Contributor\",\"description\":\"InMotion Hosting contributors are highly knowledgeable individuals who create relevant content on new trends and troubleshooting techniques to help you achieve your online goals!\",\"sameAs\":[\"https:\/\/www.linkedin.com\/company\/inmotion-hosting\/\",\"https:\/\/x.com\/https:\/\/twitter.com\/InMotionHosting\"],\"url\":\"https:\/\/www.inmotionhosting.com\/support\/author\/inmotion-hosting-contributor\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Using the Linux sar command | InMotion Hosting","description":"In this article I'll be explaining the Linux sar command and some of its many uses for helping you track down possible bottleneck problems on your server.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/using-the-linux-sar-command\/","og_locale":"en_US","og_type":"article","og_title":"Using the Linux sar command | InMotion Hosting","og_description":"In this article I'll be explaining the Linux sar command and some of its many uses for helping you track down possible bottleneck problems on your server.","og_url":"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/using-the-linux-sar-command\/","og_site_name":"InMotion Hosting Support Center","article_publisher":"https:\/\/www.facebook.com\/inmotionhosting\/","article_published_time":"2013-03-07T03:52:21+00:00","article_modified_time":"2021-08-17T03:19:51+00:00","author":"InMotion Hosting Contributor","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/InMotionHosting","twitter_site":"@InMotionHosting","twitter_misc":{"Written by":"InMotion Hosting Contributor","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/using-the-linux-sar-command\/#article","isPartOf":{"@id":"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/using-the-linux-sar-command\/"},"author":{"name":"InMotion Hosting Contributor","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/f9a4fc454cd1df128ee8e898d30d4644"},"headline":"Using the Linux sar command","datePublished":"2013-03-07T03:52:21+00:00","dateModified":"2021-08-17T03:19:51+00:00","mainEntityOfPage":{"@id":"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/using-the-linux-sar-command\/"},"wordCount":482,"commentCount":0,"publisher":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#organization"},"articleSection":["Linux"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.inmotionhosting.com\/support\/server\/linux\/using-the-linux-sar-command\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/using-the-linux-sar-command\/","url":"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/using-the-linux-sar-command\/","name":"Using the Linux sar command | InMotion Hosting","isPartOf":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#website"},"datePublished":"2013-03-07T03:52:21+00:00","dateModified":"2021-08-17T03:19:51+00:00","description":"In this article I'll be explaining the Linux sar command and some of its many uses for helping you track down possible bottleneck problems on your server.","breadcrumb":{"@id":"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/using-the-linux-sar-command\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.inmotionhosting.com\/support\/server\/linux\/using-the-linux-sar-command\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/using-the-linux-sar-command\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.inmotionhosting.com\/support\/"},{"@type":"ListItem","position":2,"name":"Using the Linux sar command"}]},{"@type":"WebSite","@id":"https:\/\/www.inmotionhosting.com\/support\/#website","url":"https:\/\/www.inmotionhosting.com\/support\/","name":"InMotion Hosting Support Center","description":"Web Hosting Support &amp; Tutorials","publisher":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.inmotionhosting.com\/support\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.inmotionhosting.com\/support\/#organization","name":"InMotion Hosting","url":"https:\/\/www.inmotionhosting.com\/support\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/","url":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg","contentUrl":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg","width":696,"height":696,"caption":"InMotion Hosting"},"image":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/inmotionhosting\/","https:\/\/x.com\/InMotionHosting"]},{"@type":"Person","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/f9a4fc454cd1df128ee8e898d30d4644","name":"InMotion Hosting Contributor","description":"InMotion Hosting contributors are highly knowledgeable individuals who create relevant content on new trends and troubleshooting techniques to help you achieve your online goals!","sameAs":["https:\/\/www.linkedin.com\/company\/inmotion-hosting\/","https:\/\/x.com\/https:\/\/twitter.com\/InMotionHosting"],"url":"https:\/\/www.inmotionhosting.com\/support\/author\/inmotion-hosting-contributor\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"primary_category":null,"_links":{"self":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/616","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/users\/57014"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/comments?post=616"}],"version-history":[{"count":3,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/616\/revisions"}],"predecessor-version":[{"id":84872,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/616\/revisions\/84872"}],"wp:attachment":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/media?parent=616"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/categories?post=616"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/tags?post=616"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}