Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Is there a command in linux (more specifically on CentOS 5), that shows how many bytes/sec each file is being read in the past few second. A similar tool in Windows 7 is the Resource Monitor, which can show each file's read speed, and it is helpful diagnosing system performance degrade.

share|improve this question
add comment

migrated from stackoverflow.com Mar 16 '12 at 16:30

This question came from our site for professional and enthusiast programmers.

1 Answer

My favorite is iotop. It will show I/O counts by process.

Other useful commands to investigate I/O hogs:

  • vmstat: a high count at the wa column is a sign of stressed machines
  • iostat: reports CPU statistics and input/output statistics for devices, partitions and NFS

Start with vmstat; if there are less than 2 processes in I/O wait (wa column), the machine is not I/O starved, and there is a high chance your performance problem is not related to I/O. Look at the swap in/out, high numbers there indicates your system is memory starved.

If your system is indeed I/O starved, iostat can give you a hint of what device, partition or network filesystem is stressed. Sometimes this is enough to guess the culprit.

Sample output for vmstat:

operator@server:~$ sudo vmstat 10 5
procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa
 0  0      0 408892 294200 4310552    0    0     0     6    3    2  1  2 97  0
 0  0      0 409372 294200 4310552    0    0     0    54 2192 4880  1  3 97  0
 0  0      0 409124 294200 4310496    0    0     0    18 2200 4895  0  3 96  0
 0  0      0 409000 294200 4310496    0    0     0    26 2182 4884  0  2 97  0
 0  0      0 409620 294200 4310496    0    0     0    18 2195 5120  0  2 97  0

Sample output for iotop:

Total DISK READ: 0.00 B/s | Total DISK WRITE: 0.00 B/s
  TID  PRIO  USER     DISK READ  DISK WRITE  SWAPIN     IO>    COMMAND
27327 be/4 www-data    0.00 B/s    3.67 K/s  0.00 %  0.00 % apache2 -k start
29714 be/4 postgres    0.00 B/s    0.00 B/s  0.00 %  0.00 % postgres: stats collector process
    1 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % init
    2 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % [kthreadd]
...
share|improve this answer
2  
This looks helpful, but is there any tool that can show which files are being read from or written to, and how many bytes/sec for each of them in the past few seconds? –  icando Mar 16 '12 at 4:55
1  
@icando: I'm not aware of any tool to measure disk I/O by file. I'm curious, why you want to measure I/O by file instead of by process? –  Paulo Scardine Mar 16 '12 at 12:29
    
sometimes I know a process will do intensive IO but if I know which file it is reading/writing exactly, then I can easier know if it is doing something crazy –  icando Mar 16 '12 at 23:59
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.