{"id":40961,"date":"2016-09-28T11:02:20","date_gmt":"2016-09-28T05:32:20","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=40961"},"modified":"2024-01-02T17:44:33","modified_gmt":"2024-01-02T12:14:33","slug":"install-and-configure-sar-on-ubuntu","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/install-and-configure-sar-on-ubuntu\/","title":{"rendered":"Install and Configure SAR on Ubuntu"},"content":{"rendered":"<p>Monitoring servers are very important for\u00a0every\u00a0server administrator. There are some command line tools available to monitor server resource usages like top, vmstat, etc.<\/p>\n<p style=\"text-align: center\"><img decoding=\"async\" src=\"\/blog\/wp-ttn-blog\/uploads\/2024\/01\/5654683066_6703251656.jpg\" alt=\"Image result for linux\" \/><\/p>\n<h2>Why ?<\/h2>\n<p>SAR or sar provides almost all the resource usages reports which we get from many different tools at one place but more importantly\u00a0is could keep a\u00a0record of the data which can be used\u00a0for\u00a0<strong><span style=\"font-weight: 400\">historical analysis to identify bottlenecks. With the tool, you can check the performance\u00a0report of a specific time.<\/span><\/strong><\/p>\n<h2>Installation<\/h2>\n<p>Installation is pretty simple, you just need to install <strong>sysstat\u00a0<\/strong>tool using apt as below:<\/p>\n<pre>sudo apt-get install sysstat<\/pre>\n<h2>Configuration<\/h2>\n<p>After we have installed sar we will need to configure\u00a0it to collect and store performance data on a regular\u00a0interval.<\/p>\n<p>To do that we will enable sadc\u00a0by modifying\u00a0configuration\u00a0file &#8220;<strong>\/etc\/default\/sysstat<\/strong>&#8221;<\/p>\n<pre>sudo vi \/etc\/default\/sysstat<\/pre>\n<p>[js]# Should sadc collect system activity informations? Valid values<br \/>\n# are &quot;true&quot; and &quot;false&quot;. Please do not put other values, they<br \/>\n# will be overwritten by debconf!<br \/>\nENABLED=&quot;true&quot;[\/js]<\/p>\n<p>After this, a cronjob will start collecting the SAR\u00a0report every 10 min, but we would want that report to be collected much sooner so we will change the cronjob to run every min:<\/p>\n<pre>sudo vi \/etc\/cron.d\/sysstat\r\n<\/pre>\n<pre># Activity reports every 10 minutes everyday \r\n* * * * * root command -v debian-sa1 &gt; \/dev\/null &amp;&amp; debian-sa1 1 1<\/pre>\n<p>That is All! We now have a working SAR tool which records all performance\u00a0related data.<\/p>\n<h2>Usage<\/h2>\n<p>You can now use the\u00a0<strong>sar<\/strong> command to get the performance report as below:<\/p>\n<p style=\"text-align: center\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-40975 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2016\/09\/Selection_014.png\" alt=\"Sar CPU report\" width=\"563\" height=\"129\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2016\/09\/Selection_014.png 563w, \/blog\/wp-ttn-blog\/uploads\/2016\/09\/Selection_014-300x68.png 300w\" sizes=\"(max-width: 563px) 100vw, 563px\" \/><\/p>\n<p>Some important command line option which we can use:<br \/>\n<strong>-u<\/strong> CPU Usage of ALL CPUs<br \/>\n<strong>-q<\/strong> Reports run queue and load average<br \/>\n<strong>-r<\/strong> Memory Free and Used<br \/>\n<strong>-S<\/strong> Swap Space Used<br \/>\n<strong>-b<\/strong> Overall I\/O Activities<br \/>\n<strong>-d<\/strong> Individual Block Device I\/O Activities<br \/>\n<strong>-n<\/strong> Report network statistics<\/p>\n<p>You can set repetition and interval with any command for desired output:<\/p>\n<pre>sar[ interval [ count ]]<\/pre>\n<p>You can now check the reports that have been collected in the past by specifying time and day:<br \/>\n-s hh:mm[:ss] start time<br \/>\n-e hh:mm[:ss] end time<br \/>\n-f \/var\/log\/sysstat\/sa[DD] on a specific day,<br \/>\n<strong>Note:<\/strong>\u00a0If you have just installed and configured the sar you might not get the directory, full day report get written to the folder in midnight.<\/p>\n<p>Please refer the <a title=\"sar\" href=\"http:\/\/man7.org\/linux\/man-pages\/man1\/sar.1.html\" target=\"_blank\" rel=\"noopener\">man page<\/a> of\u00a0sar for more options. Thanks for your time!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Monitoring servers are very important for\u00a0every\u00a0server administrator. There are some command line tools available to monitor server resource usages like top, vmstat, etc. Why ? SAR or sar provides almost all the resource usages reports which we get from many different tools at one place but more importantly\u00a0is could keep a\u00a0record of the data which [&hellip;]<\/p>\n","protected":false},"author":747,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":120},"categories":[2348,1],"tags":[1892,2774,3827,260,2683,4053,590,4054],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/40961"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/747"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=40961"}],"version-history":[{"count":1,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/40961\/revisions"}],"predecessor-version":[{"id":59828,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/40961\/revisions\/59828"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=40961"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=40961"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=40961"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}