{"id":427,"date":"2009-10-07T06:11:46","date_gmt":"2009-10-07T06:11:46","guid":{"rendered":"http:\/\/g33kinfo.com\/info\/index.php\/?p=427"},"modified":"2009-10-07T06:11:46","modified_gmt":"2009-10-07T06:11:46","slug":"dstat","status":"publish","type":"post","link":"https:\/\/g33kinfo.com\/info\/dstat\/","title":{"rendered":"Dstat"},"content":{"rendered":"<p>If you have a Linux server running at your office or at a data center for which you are responsible, you want to maintain an uptime of as close to a hundred percent. In such a case you want to make sure you keep an eye on how the system is running. To be precise you want to monitor all the system resources that contribute to the system running fine which then results in a high uptime. Memory, CPU, disk usage\u2026 are some of the things you want to observe. We would usually use a combination of the tools that come with a Linux or UNIX installation, such as \u201cfree\u201d, \u201ctop\u201d, \u201cvmstat\u201d\u2026 I\u2019ll introduce you to a tool that gives you just about all the info that the other tools combined give you, all under one roof \u2013 Dstat. The developer of this command line tool, Dag Wieers, calls it \u201ca versatile replacement for vmstat, iostat, netstat and ifstat\u201d. He adds that \u201cDstat overcomes some of their limitations and adds some extra features\u2026\u201d To me Dstat is the mother of all command line system monitoring tools. It\u2019s simple to install, easy to use, can be tweaked with ease, and it generates reports that you can plot as a graph to impress your boss.<br \/>\nInstalling Dstat<\/p>\n<p>Start by downloading the Dstat installer. (#yum install dstat &#8211; in the command line works also if you have the dag repositories enabled) Point your web browser to the Dstat project\u2019s homepage \u2013 http:\/\/dag.wieers.com\/home-made\/dstat\/. Scroll down to the section of the page where the downloads are listed. Pick the flavor of Linux on which you want to install the application and click on the download link. Now download the latest version of Dstat for the version of the Linux distribution you are running. I\u2019ll show you how to do it for a Red Hat Enterprise Linux version 4 machine:<\/p>\n<p>(latest version is dstat-0.7.2-12.el7.noarch.rpm available from http:\/\/dag.wieers.com\/home-made\/dstat\/ and https:\/\/github.com\/dagwieers\/dstat)<\/p>\n<p><!--more--><\/p>\n<p><code><br \/>\nwget http:\/\/dag.wieers.com\/rpm\/packages\/dstat\/dstat-0.7.2-1.el6.rfx.noarch.rpm<br \/>\n<\/code><br \/>\nNow install Dstat:<br \/>\n<code><br \/>\n rpm -Uvh dstat-0.7.2-1.el6.rfx.noarch.rpm<br \/>\n<\/code><br \/>\nIf the installation went though without errors, that\u2019s it, you have Dstat installed and ready for use. If there were some dependencies that came up during the installation just install the required packages and try again. I don\u2019t think that Dstat has too many dependencies, so you should not face any problems.<br \/>\nUsing Dstat<\/p>\n<p>With Dstat installed on your system you should be good to go. Begin by launching the command from a terminal:<br \/>\n<code><br \/>\ndstat<br \/>\n<\/code><br \/>\nThe output would be something like the following. Hit the key combination of ctrl+c to exit.<br \/>\n<code><br \/>\n dstat<br \/>\n----total-cpu-usage---- -dsk\/total- -net\/total- ---paging-- ---system--<br \/>\nusr sys idl wai hiq siq| read  writ| recv  send|  in   out | int   csw<br \/>\n  3   1  95   0   0   0|  31k  166k|   0     0 |   0     0 |1184  3715<br \/>\n 26   8  66   0   0   0|  16k   88k|8467B   11k|   0     0 |1174    49k<br \/>\n 33  13  54   0   0   0|   0    80k|2388B 2037B|   0     0 |1068   133k<br \/>\n 28   9  63   0   0   0|   0     0 |  52k  102k|   0     0 |1957    51k<br \/>\n 23   7  70   0   0   0|   0     0 |  20k   43k|   0     0 |1418    20k<br \/>\n 23   6  70   0   0   0|   0   264k|8298B   11k|   0     0 |1170    22k<br \/>\n 30  10  60   0   0   0|   0     0 |2623B 3049B|   0     0 |1075    93k<br \/>\n<\/code><br \/>\nThere are a number of options available for Dstat. As I mentioned earlier Dstat is quite easy to tweak. So if you want to limit the data reading to the CPU, disk, and network, run the following command:<br \/>\n<code><br \/>\ndstat -cdn<br \/>\n----total-cpu-usage---- -dsk\/total- -net\/total-<br \/>\nusr sys idl wai hiq siq| read  writ| recv  send<br \/>\n  3   1  95   0   0   0|  31k  165k|   0     0<br \/>\n  0   0 100   0   0   0|   0    80k| 240B  332B<br \/>\n  0   0 100   0   0   0|   0     0 | 360B  332B<br \/>\n  0   0 100   0   0   0|   0     0 | 120B  332B<br \/>\n 15   5  79   0   0   0|   0     0 |  15k   32k<br \/>\n 20   5  75   1   0   0|   0   776k|  14k   33k<br \/>\n 20   5  75   0   0   0|   0     0 |7217B   28k<br \/>\n 18   5  77   0   0   0|   0     0 |4181B   13k<br \/>\n<\/code><br \/>\nYou can find more options in the application\u2019s help document which you can access by entering the following:<br \/>\n<code><br \/>\ndstat -h<br \/>\n<\/code><br \/>\nPlay with the options a little so you get comfortable with them. The default interval between data reads is two seconds. You can change that interval if you need to. To increase the interval to ten seconds enter the following:<br \/>\n<code><br \/>\ndstat 10<br \/>\n<\/code><br \/>\nAnother useful feature is to get aggregated updates for each entry. So you can have Dstat give you an update every ten seconds in a new line, but as the data changes your line itself gets updated every second.<\/p>\n<p>You might optionally want Dstat to give you five updates with a frequency of three seconds. Here\u2019s how you would go about doing that:<br \/>\n<code><br \/>\ndstat 3 5<br \/>\n----total-cpu-usage---- -dsk\/total- -net\/total- ---paging-- ---system--<br \/>\nusr sys idl wai hiq siq| read  writ| recv  send|  in   out | int   csw<br \/>\n  3   1  95   0   0   0|  31k  165k|   0     0 |   0     0 |1185  3744<br \/>\n  3   1  95   0   0   0|   0    88k|  11k   39k|   0     0 |1255   312<br \/>\n  1   0  98   0   0   0|   0   115k|  12k   16k|   0     0 |1266   316<br \/>\n  3   1  95   0   0   0|   0    27k|  10k   20k|   0     0 |1235   292<br \/>\n  6   2  92   0   0   0|   0    32k|8482B   16k|   0     0 |1190   237<br \/>\n  1   0  99   0   0   0|   0  2731B|  11k  174k|   0     0 |1258   306<br \/>\n<\/code><\/p>\n<p>The feature that I find most useful is the output. Dstat allows you to have the output of a session written into a comma separated file which can later be imported into a spreadsheet application such as Microsoft Excel and the data can be plotted into a graph. Here is how it can be used.<br \/>\n<code><br \/>\ndstat \u2013output \/tmp\/dstat_data.csv -CDN<br \/>\n<\/code><\/p>\n<p>Let the above command run while you run your applications or do your testing on this machine. Hit the key combination of ctrl+c when you are done. Open the file dstat_data.csv with a spreadsheet application such as Microsoft Excel or Open Office. You can then select the columns you want plotted into a graph and let your spreadsheet application do the magic.<br \/>\nGet a Report by Mail<\/p>\n<p>There may be cases wherein you want to observe how your server is performing over a period of time. You can setup a background process in Linux that will give you a reading with a certain interval, generate a report, and mail out the file to you. This can be especially useful during a stress-test. Here\u2019s how you could do that. The following script will run Dstat for three hours, reading the data every 30 seconds, and will mail out the report to me(@)myemailid.com.<br \/>\n<code><br \/>\n    #!\/bin\/bash<br \/>\n    dstat \u2013output \/tmp\/dstat_data_mail.csv -CDN 30 360<br \/>\n    mutt -a \/tmp\/dstat_data_mail.csv -s \u201cDstat Report for 3 hour run\u201d me@myemailid.com < \/dev\/null\n<\/code><br \/>\nSave the above script in a file called dstat_script.sh on your server, give it executable permission and then run it as a background process:<br \/>\n<\/code><code><br \/>\n# chmod +x dstat_script.sh<br \/>\n# nohup .\/dstat_script.sh &<br \/>\n<\/code><br \/>\nDone. Yes, it\u2019s that simple. You will now be mailed this report after it\u2019s done running. You can optionally schedule this script as a daily cron job so that you can receive this data every day.<\/p>\n<p>As you may already have realized Dstat is a wonderful tool when applied to performance monitoring and debugging. The granularity, frequency, and nature of the data collected are completely up to you. Dstat empowers you to know what is going on on your server. Used wisely this power can result in a lot less sleepless nights for you.<br \/>\n<code><br \/>\n#!\/bin\/bash<br \/>\ndstat --output \/root\/dstat-3hour-data.csv -cdgilmnpsty --top-cpu -d --top-bio --top-latency  30 360<\/code><br \/>\ncron<br \/>\n<code>0 7 * * * \/usr\/src\/dstat_script.sh<\/code><br \/>\n 7am run<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you have a Linux server running at your office or at a data center for which you are responsible, you want to maintain an uptime of as close to a hundred percent. In such a case you want to make sure you keep an eye on how the system is running. To be precise&#8230; <\/p>\n<div class=\"read-more navbutton\"><a href=\"https:\/\/g33kinfo.com\/info\/dstat\/\">Read More<i class=\"fa fa-angle-double-right\"><\/i><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-427","post","type-post","status-publish","format-standard","hentry","category-info"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Dstat - Linux Shtuff<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/g33kinfo.com\/info\/dstat\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Dstat - Linux Shtuff\" \/>\n<meta property=\"og:description\" content=\"If you have a Linux server running at your office or at a data center for which you are responsible, you want to maintain an uptime of as close to a hundred percent. In such a case you want to make sure you keep an eye on how the system is running. To be precise... Read More\" \/>\n<meta property=\"og:url\" content=\"https:\/\/g33kinfo.com\/info\/dstat\/\" \/>\n<meta property=\"og:site_name\" content=\"Linux Shtuff\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/fb.me\/g33kinf0\" \/>\n<meta property=\"article:author\" content=\"https:\/\/fb.me\/g33kinf0\" \/>\n<meta property=\"article:published_time\" content=\"2009-10-07T06:11:46+00:00\" \/>\n<meta name=\"author\" content=\"g33kadmin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/drsinger1111\" \/>\n<meta name=\"twitter:site\" content=\"@drsinger1111\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/dstat\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/dstat\\\/\"},\"author\":{\"name\":\"g33kadmin\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#\\\/schema\\\/person\\\/c022e4c40b13ea1b678e6f020756f547\"},\"headline\":\"Dstat\",\"datePublished\":\"2009-10-07T06:11:46+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/dstat\\\/\"},\"wordCount\":936,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#\\\/schema\\\/person\\\/c022e4c40b13ea1b678e6f020756f547\"},\"articleSection\":[\"General Info\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/g33kinfo.com\\\/info\\\/dstat\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/dstat\\\/\",\"url\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/dstat\\\/\",\"name\":\"Dstat - Linux Shtuff\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#website\"},\"datePublished\":\"2009-10-07T06:11:46+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/dstat\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/g33kinfo.com\\\/info\\\/dstat\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/dstat\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Dstat\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#website\",\"url\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/\",\"name\":\"Linux Shtuff\",\"description\":\"Because I have CRS Syndrome...\",\"publisher\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#\\\/schema\\\/person\\\/c022e4c40b13ea1b678e6f020756f547\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#\\\/schema\\\/person\\\/c022e4c40b13ea1b678e6f020756f547\",\"name\":\"g33kadmin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/minion-researchA.gif\",\"url\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/minion-researchA.gif\",\"contentUrl\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/minion-researchA.gif\",\"width\":512,\"height\":512,\"caption\":\"g33kadmin\"},\"logo\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/minion-researchA.gif\"},\"description\":\"I am a g33k, Linux blogger, developer, student and Tech Writer for Liquidweb.com\\\/kb. My passion for all things tech drives my hunt for all the coolz. I often need a vacation after I get back from vacation....\",\"sameAs\":[\"https:\\\/\\\/thelinuxreport.com\",\"https:\\\/\\\/fb.me\\\/g33kinf0\",\"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/drsinger1111\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Dstat - Linux Shtuff","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:\/\/g33kinfo.com\/info\/dstat\/","og_locale":"en_US","og_type":"article","og_title":"Dstat - Linux Shtuff","og_description":"If you have a Linux server running at your office or at a data center for which you are responsible, you want to maintain an uptime of as close to a hundred percent. In such a case you want to make sure you keep an eye on how the system is running. To be precise... Read More","og_url":"https:\/\/g33kinfo.com\/info\/dstat\/","og_site_name":"Linux Shtuff","article_publisher":"https:\/\/fb.me\/g33kinf0","article_author":"https:\/\/fb.me\/g33kinf0","article_published_time":"2009-10-07T06:11:46+00:00","author":"g33kadmin","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/drsinger1111","twitter_site":"@drsinger1111","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/g33kinfo.com\/info\/dstat\/#article","isPartOf":{"@id":"https:\/\/g33kinfo.com\/info\/dstat\/"},"author":{"name":"g33kadmin","@id":"https:\/\/g33kinfo.com\/info\/#\/schema\/person\/c022e4c40b13ea1b678e6f020756f547"},"headline":"Dstat","datePublished":"2009-10-07T06:11:46+00:00","mainEntityOfPage":{"@id":"https:\/\/g33kinfo.com\/info\/dstat\/"},"wordCount":936,"commentCount":1,"publisher":{"@id":"https:\/\/g33kinfo.com\/info\/#\/schema\/person\/c022e4c40b13ea1b678e6f020756f547"},"articleSection":["General Info"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/g33kinfo.com\/info\/dstat\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/g33kinfo.com\/info\/dstat\/","url":"https:\/\/g33kinfo.com\/info\/dstat\/","name":"Dstat - Linux Shtuff","isPartOf":{"@id":"https:\/\/g33kinfo.com\/info\/#website"},"datePublished":"2009-10-07T06:11:46+00:00","breadcrumb":{"@id":"https:\/\/g33kinfo.com\/info\/dstat\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/g33kinfo.com\/info\/dstat\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/g33kinfo.com\/info\/dstat\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/g33kinfo.com\/info\/"},{"@type":"ListItem","position":2,"name":"Dstat"}]},{"@type":"WebSite","@id":"https:\/\/g33kinfo.com\/info\/#website","url":"https:\/\/g33kinfo.com\/info\/","name":"Linux Shtuff","description":"Because I have CRS Syndrome...","publisher":{"@id":"https:\/\/g33kinfo.com\/info\/#\/schema\/person\/c022e4c40b13ea1b678e6f020756f547"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/g33kinfo.com\/info\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/g33kinfo.com\/info\/#\/schema\/person\/c022e4c40b13ea1b678e6f020756f547","name":"g33kadmin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/g33kinfo.com\/info\/wp-content\/uploads\/2022\/07\/minion-researchA.gif","url":"https:\/\/g33kinfo.com\/info\/wp-content\/uploads\/2022\/07\/minion-researchA.gif","contentUrl":"https:\/\/g33kinfo.com\/info\/wp-content\/uploads\/2022\/07\/minion-researchA.gif","width":512,"height":512,"caption":"g33kadmin"},"logo":{"@id":"https:\/\/g33kinfo.com\/info\/wp-content\/uploads\/2022\/07\/minion-researchA.gif"},"description":"I am a g33k, Linux blogger, developer, student and Tech Writer for Liquidweb.com\/kb. My passion for all things tech drives my hunt for all the coolz. I often need a vacation after I get back from vacation....","sameAs":["https:\/\/thelinuxreport.com","https:\/\/fb.me\/g33kinf0","https:\/\/x.com\/https:\/\/twitter.com\/drsinger1111"]}]}},"_links":{"self":[{"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/posts\/427","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/comments?post=427"}],"version-history":[{"count":0,"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/posts\/427\/revisions"}],"wp:attachment":[{"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/media?parent=427"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/categories?post=427"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/tags?post=427"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}