黄色网页视频 I 影音先锋日日狠狠久久 I 秋霞午夜毛片 I 秋霞一二三区 I 国产成人片无码视频 I 国产 精品 自在自线 I av免费观看网站 I 日本精品久久久久中文字幕5 I 91看视频 I 看全色黄大色黄女片18 I 精品不卡一区 I 亚洲最新精品 I 欧美 激情 在线 I 人妻少妇精品久久 I 国产99视频精品免费专区 I 欧美影院 I 欧美精品在欧美一区二区少妇 I av大片网站 I 国产精品黄色片 I 888久久 I 狠狠干最新 I 看看黄色一级片 I 黄色精品久久 I 三级av在线 I 69色综合 I 国产日韩欧美91 I 亚洲精品偷拍 I 激情小说亚洲图片 I 久久国产视频精品 I 国产综合精品一区二区三区 I 色婷婷国产 I 最新成人av在线 I 国产私拍精品 I 日韩成人影音 I 日日夜夜天天综合

Using iotop to check I/O and swap

系統(tǒng) 2235 0

Slicehost Articles: Using iotop to check I/O and swap

Using iotop to check I/O and swap

The iotop utility provides an easy-to-use interface for monitoring swap and disk I/O on a per-process basis.

?


?

Watching the disk

Sometimes you get more disk activity on your system than you would like. Maybe you saw the problem by running iostat, or you've noticed that the system is swapping heavily, or you got an email from support pointing out the problem. In cases like that it's useful to know which process is causing all the hubbub.

Enter iotop. It works like the traditional top command but it tracks device I/O (input/output) on a per-process basis. That can help you zero in quickly on which process is responsible for all the I/O and troubleshoot from there.

Prerequisites

The iotop command requires a kernel version 2.6.20 or higher and python 2.5 or higher.

CentOS and Red Hat Enterprise Linux 5.5 (current at the time of this writing) use an older version of python and so cannot run iotop on a standard installation. They can, however, run dstat , which performs a similar function to iotop.

Check your kernel version by running "uname -r":

      $ uname -r
2.6.35.1-rscloud

    

And check your python version by running "python -V":

      $ python -V
Python 2.5.2

    

Install

You can install iotop through your distribution's package manager (if it's available in the repository) or you can download the source package from the project's website.

From package manager

To install iotop using your package manager pick the appropriate command from the list below (aptitude for Ubuntu/Debian, yum for Fedora, etc.):

      sudo aptitude install iotop
sudo yum install iotop
sudo emerge iotop
sudo pacman -Sy iotop

    

If there is no iotop package in your repository but your system meets the prerequisites, you can install from source instead.

From source

The latest version of iotop is available from the project's web site . Look for a link to the latest source package for iotop and download it with wget:

      wget http://guichaz.free.fr/iotop/files/iotop-0.4.1.tar.bz2

    

Once you've downloaded the tarball, unpack it:

      tar -xjvf iotop-0.4.1.tar.bz2

    

From inside that directory you can either run iotop where it is (by running "./iotop.py") or you can run the installer to put iotop in /usr/bin:

      sudo ./setup.py install

    

Basic usage

At its simplest you can run iotop with no arguments:

      iotop

    

You should see a list of processes along with details about their current I/O use:

The column titles should be pretty self-explanatory, but there are two particular stats to note.

IO

The "IO" column lists total I/O for each process (which includes disk use and swap). Results are sorted by I/O by default when iotop is launched.

SwapIn

The "SwapIn" column lists swap activity for each process.

Runtime commands

Using the right and left arrow keys while viewing iotop will change the column used to sort the results.

If you want the processes sorted in reverse order hit "r" while viewing iotop.

Hitting "o" will filter the list so it will only show processes that are actively doing I/O. Typing "o" again will return to a list of all processes.

Script usage

You can use iotop in "batch mode" to have it print just one set of results instead of launching a constantly-updating interface. Batch mode can be useful when you want a script that logs regular I/O usage to a file.

Sending the "-b" flag to iotop will tell it to run in batch mode. You'll usually want to combine that with some other flags:

The "-o" flag causes iotop to report only process with active I/O.

The "-t" flag will add a timestamp to the results.

The "--iter=#" option will limit the number of samples iotop returns when run.

The "-q" flag will prevent iotop from displaying column headers after its first run. You can prevent headers from being printed at all with "-qq". To prevent both headers and I/O summaries from being printed use "-qqq".

For example, the result of:

      iotop -bto --iter=1

    

Would look like:

      Total DISK READ: 0.00 B/s | Total DISK WRITE: 27.64 K/s
    TIME  TID  PRIO  USER     DISK READ  DISK WRITE  SWAPIN      IO    COMMAND
17:08:25   177 be/4 root        0.00 B/s    7.90 K/s  0.00 %  0.05 % [kjournald]

    

A sample cron script

You can use cron task scheduling to get iotop to run every minute and log any I/O activity it detects. Open this file for editing (with sudo):

      /etc/cron.d/iotop

    

And put the following into that file:

      #  Run iotop and log any detected activity.

* * * * * root iotop -botqqq --iter=3 >> /var/log/iotop

    

Save the file. That cron.d entry will cause iotop to run every minute, logging any I/O activity it finds to "/var/log/iotop". It takes three samples when it runs (five seconds apart), doesn't log headers or summary information, and only logs processes with measured I/O activity.

After a minute take a look in /var/log. If the script ran as expected there should now be an "iostat" log there (though it may be an empty file if it didn't find any I/O to log).

Tweak the command to your liking. If you want a different number of samples per minute change the "--iter" value. If you want I/O summaries printed when the script runs change "qqq" to "qq".

Rotate the created log

If you plan to leave the iotop logger running (and aren't just going to run it for a day or so to check on a burst of disk activity) you'll want to rotate its log occasionally to keep it from getting too big.

To that end, create a file for editing at "/etc/logrotate.d/iotop" (again using sudo).

Put the following into the file:

      /var/log/iotop {
  rotate 5
  weekly
  compress
  missingok
  notifempty
}

    

For more details on what that logrotate config will do you can look through our articles on logrotate . For example, you might change the frequency of rotations from "weekly" to "daily" if you find you're logging a lot of disk I/O. You could then increase the number of archived logs it keeps accordingly.

Similar commands

Another program that can be used to check I/O is dstat . While its presentation isn't necessarily as attractive as iotop's, it allows for more flexibility in what can be written to a log when used in a script. It also runs on older versions of python than iotop so it will run on more distributions.

The "sysstat" package includes several commands useful for gathering system usage statistics, and newer versions of the package include a program named "pidstat". When run with the "-d" option pidstat will display disk I/O information on a per-process basis.

Summary

As "top" is to processor and memory use, so "iotop" is to disk I/O and swap use. The ability to see I/O on a per-process basis is relatively new to Linux (thus the requirement for a newer kernel to run iotop), but it was a very welcome addition. Iotop can be very useful when trying to track down which process is using swap memory or is causing an excessive amount of disk activity.

  • -- Jered

Using iotop to check I/O and swap


更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號(hào)聯(lián)系: 360901061

您的支持是博主寫作最大的動(dòng)力,如果您喜歡我的文章,感覺我的文章對(duì)您有幫助,請(qǐng)用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點(diǎn)擊下面給點(diǎn)支持吧,站長(zhǎng)非常感激您!手機(jī)微信長(zhǎng)按不能支付解決辦法:請(qǐng)將微信支付二維碼保存到相冊(cè),切換到微信,然后點(diǎn)擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對(duì)您有幫助就好】

您的支持是博主寫作最大的動(dòng)力,如果您喜歡我的文章,感覺我的文章對(duì)您有幫助,請(qǐng)用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長(zhǎng)會(huì)非常 感謝您的哦!!!

發(fā)表我的評(píng)論
最新評(píng)論 總共0條評(píng)論