{"id":11828,"date":"2019-03-17T13:22:10","date_gmt":"2019-03-17T13:22:10","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=11828"},"modified":"2019-03-17T13:22:10","modified_gmt":"2019-03-17T13:22:10","slug":"iotop-monitor-linux-disk-i-o-activity-and-usage-per-process-basis","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/17\/iotop-monitor-linux-disk-i-o-activity-and-usage-per-process-basis\/","title":{"rendered":"Iotop \u2013 Monitor Linux Disk I\/O Activity and Usage Per-Process Basis"},"content":{"rendered":"<p><strong>Iotop<\/strong>\u00a0is an open source and free utility similar to\u00a0<a href=\"https:\/\/www.tecmint.com\/12-top-command-examples-in-linux\/\" target=\"_blank\" rel=\"noopener\">top command<\/a>, that provides an easy way to monitor Linux\u00a0<strong>Disk I\/O<\/strong>\u00a0usage details and prints a table of existing I\/O utilization by process or threads on the systems.<\/p>\n<p>Iotop tool is based on\u00a0<strong>Python<\/strong>\u00a0programming and requires\u00a0<strong>Kernel<\/strong>\u00a0accounting function to monitor and display processes. It is very useful tool for system administrator to trace the specific process that may causing a high\u00a0<strong>disk I\/O<\/strong>\u00a0read\/writes.<\/p>\n<h4>Iotop Pre-requisites<\/h4>\n<ol>\n<li>Kernel 2.6.20 or higher<\/li>\n<li>Python 2.7 or higher<\/li>\n<\/ol>\n<p>This article explains how to install\u00a0<strong>iotop<\/strong>\u00a0program to monitor and trace Linux device I\/O (input\/output) on a per-process basis in Linux systems.<\/p>\n<h3>Install Iotop Disk I\/O Monitoring Tool in Linux<\/h3>\n<p>As I already said above that\u00a0<strong>iotop<\/strong>\u00a0requires latest\u00a0<strong>Kernel 2.6.20<\/strong>\u00a0and\u00a0<strong>Python 2.7<\/strong>, let\u2019s first update both of them with the help of following command.<\/p>\n<pre>-------------- <strong>On RHEL, CentOS and Fedora<\/strong> -------------- \r\n# yum update     \r\n\r\n-------------- <strong>On Fedora 22+ Releases<\/strong> -------------- \r\n# dnf update\r\n\r\n-------------- <strong>On Debian, Ubuntu and Linux Mint<\/strong> -------------- \r\n# apt-get update<\/pre>\n<p>Next, verify your\u00a0<strong>kernel<\/strong>\u00a0and\u00a0<strong>python<\/strong>\u00a0version by running:<\/p>\n<pre># uname -r\r\n# python -V\r\n<\/pre>\n<p><strong>Important<\/strong>: At the time of this writing,\u00a0<strong>CentOS\/RHEL 5.x<\/strong>\u00a0uses an older version of python and not possible to install iotop. However, they can use\u00a0<a href=\"https:\/\/www.tecmint.com\/dstat-monitor-linux-server-performance-process-memory-network\/\" target=\"_blank\" rel=\"noopener\">dstat program<\/a>, which does a similar function of iotop.<\/p>\n<h4>Install iotop using Package Manager<\/h4>\n<p>To install\u00a0<strong>iotop<\/strong>\u00a0from your package manager, select the appropriate command from the following list.<\/p>\n<pre>-------------- <strong>On RHEL, CentOS and Fedora<\/strong> -------------- \r\n# yum install iotop\r\n\r\n-------------- <strong>On Fedora 22+ Releases<\/strong> -------------- \r\n# dnf install iotop\r\n\r\n-------------- <strong>On Debian, Ubuntu and Linux Mint<\/strong> -------------- \r\n# apt-get install iotop\r\n<\/pre>\n<p><strong>Important<\/strong>: Installing\u00a0<strong>iotop<\/strong>\u00a0from your default repositories will give you an older version. If you looking to have a most recent version of iotop, consider compiling from source using following instructions.<\/p>\n<h4>Install iotop from Source<\/h4>\n<p>To install most recent version of\u00a0<strong>iotop<\/strong>, go the\u00a0<a href=\"http:\/\/guichaz.free.fr\/iotop\/\" target=\"_blank\" rel=\"nofollow noopener\">official project page<\/a>\u00a0and download the latest source package and compile it from source using following series of commands:<\/p>\n<pre># wget http:\/\/guichaz.free.fr\/iotop\/files\/iotop-0.6.tar.bz2\r\n# tar -xjvf iotop-0.6.tar.bz2\r\n# cd iotop-0.6\/\r\n# .\/setup.py install\r\n<\/pre>\n<p><strong>Important<\/strong>: You can run\u00a0<strong>iotop<\/strong>\u00a0within the directory i.e. (by running\u00a0<code>.\/iotop.py<\/code>) or you can run the installer\u00a0<code>.\/setup.py install<\/code>\u00a0command to install iotop under\u00a0<strong>\/usr\/bin<\/strong>:<\/p>\n<h4>How to Use iotop in Linux<\/h4>\n<p>At its easiest you can execute\u00a0<strong>iotop<\/strong>\u00a0without any arguments as shown.<\/p>\n<pre># iotop\r\n<\/pre>\n<p>You should get a\u00a0<a href=\"https:\/\/www.tecmint.com\/find-linux-processes-memory-ram-cpu-usage\/\" target=\"_blank\" rel=\"noopener\">list of running processes<\/a>\u00a0along with information about their current disk I\/O usage:<\/p>\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/07\/Linux-Disk-IO-Process-Monitoring.gif\"><img decoding=\"async\" class=\"size-full wp-image-23120\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/07\/Linux-Disk-IO-Process-Monitoring.gif\" sizes=\"(max-width: 862px) 100vw, 862px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/07\/Linux-Disk-IO-Process-Monitoring.gif 862w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/07\/Linux-Disk-IO-Process-Monitoring-768x543.gif 768w\" alt=\"Linux Disk I\/O Monitor Per Process Basis\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p>The each column heading is self-explanatory, but there are two important things to consider here:<\/p>\n<ol>\n<li><strong>IO<\/strong>\u00a0\u2013 The\u00a0<strong>\u201cIO\u201d<\/strong>\u00a0column display total I\/O (disk and swap) usage for each process.<\/li>\n<li><strong>SWAPIN<\/strong>\u00a0\u2013 The \u201cSwapIn\u201d column displays swap usage for each process.<\/li>\n<\/ol>\n<p>I recommend start using\u00a0<strong>iotop<\/strong>\u00a0with\u00a0<strong>-o<\/strong>\u00a0or\u00a0<strong>\u2013only<\/strong>\u00a0option to see current processes or threads actually doing I\/O, instead of watching all processes or threads.<\/p>\n<pre># iotop --only\r\n<\/pre>\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/07\/Linux-Processes-Threads-Disk-IO-Monitoring.gif\"><img decoding=\"async\" class=\"size-full wp-image-23121\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/07\/Linux-Processes-Threads-Disk-IO-Monitoring.gif\" alt=\"Linux Processes or Threads Disk I\/O Monitoring\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<h4>Get Alerts On Linux Disk I\/O Activity<\/h4>\n<p>You can use\u00a0<a href=\"https:\/\/www.tecmint.com\/11-cron-scheduling-task-examples-in-linux\/\" target=\"_blank\" rel=\"noopener\">cron job scheduling<\/a>\u00a0program to run\u00a0<strong>iotop<\/strong>\u00a0every minute to track any I\/O activity it detects and send an alert to your email address.<\/p>\n<pre># vi \/etc\/cron.d\/iotop\r\n<\/pre>\n<p>And add the following lines into file:<\/p>\n<pre>MAILTO=username@domain.com\r\n* * * * * root iotop -botqqq --iter=3 &gt;&gt; \/var\/log\/iotop\r\n<\/pre>\n<p>If you want, you can tweak the above command as per your requirements.<\/p>\n<p>To know more usage and options about\u00a0<strong>iotop<\/strong>\u00a0program, run the following command to check the man pages.<\/p>\n<pre># man iotop<\/pre>\n<p>Some important iotop usage and keyboard shortcuts.<\/p>\n<ol>\n<li>Move\u00a0<strong>left<\/strong>\u00a0or\u00a0<strong>right<\/strong>\u00a0arrow key to change the sorting.<\/li>\n<li>Use\u00a0<strong>\u2013version<\/strong>\u00a0option to see version number and exit.<\/li>\n<li>Use\u00a0<strong>-h<\/strong>\u00a0option to see information of usage.<\/li>\n<li>Use\u00a0<strong>-r<\/strong>\u00a0option to reverse the sorting order.<\/li>\n<li>Use\u00a0<strong>-o<\/strong>\u00a0option to check processes or thread.<\/li>\n<li>Use\u00a0<strong>-b<\/strong>\u00a0option to Turn On non-interactive mode to enable logging I\/O usage.<\/li>\n<li>Use\u00a0<strong>-p PID<\/strong>\u00a0to list all processes\/threads to monitor.<\/li>\n<li>Use\u00a0<strong>-u USER<\/strong>\u00a0option to list all the users to monitor.<\/li>\n<li>Use\u00a0<strong>-P<\/strong>\u00a0option to list only processes. Normally iotop displays all threads.<\/li>\n<li>Use\u00a0<strong>-a<\/strong>\u00a0option to check accumulated I\/O instead of bandwidth.<\/li>\n<\/ol>\n<p>All the above iotop options are fairly straightforward. The interface almost looks and functions exactly same as\u00a0<a href=\"https:\/\/www.tecmint.com\/12-top-command-examples-in-linux\/\" target=\"_blank\" rel=\"noopener\">Linux top command<\/a>.<\/p>\n<p><strong>Iotop<\/strong>\u00a0can be extremely handy in tracking down Linux process which are using\u00a0<a href=\"https:\/\/www.tecmint.com\/commands-to-monitor-swap-space-usage-in-linux\/\" target=\"_blank\" rel=\"noopener\">high swap memory usage<\/a>\u00a0or is causing an high amount of disk IO activity.<\/p>\n<p><a href=\"https:\/\/www.tecmint.com\/iotop-monitor-linux-disk-io-activity-per-process\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Iotop\u00a0is an open source and free utility similar to\u00a0top command, that provides an easy way to monitor Linux\u00a0Disk I\/O\u00a0usage details and prints a table of existing I\/O utilization by process or threads on the systems. Iotop tool is based on\u00a0Python\u00a0programming and requires\u00a0Kernel\u00a0accounting function to monitor and display processes. It is very useful tool for system &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/17\/iotop-monitor-linux-disk-i-o-activity-and-usage-per-process-basis\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Iotop \u2013 Monitor Linux Disk I\/O Activity and Usage Per-Process Basis&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-11828","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11828","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=11828"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11828\/revisions"}],"predecessor-version":[{"id":11829,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11828\/revisions\/11829"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=11828"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=11828"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=11828"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}