Show each file's read/write rate in Linux (CentOS)
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.
Solution 1:
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]
...