Any Linux sysadmins reading this?
In FreeBSD, I can use systat to find out how busy
a
given disk is. It looks like this:
Disks da0 da1 pass0 pass1 md0 KB/t 26.67 22.10 0.00 0.00 0.00 tps 1 8 0 0 0 MB/s 0.02 0.18 0.00 0.00 0.00 % busy 0 4 0 0 0 queue 0 0 0 0 0
See, disk da1 was 4% busy during that 5 second snapshot. (I ran systat -v 5).
That's very useful when diagnosing a disk-bound MySQL server that's not doing lots of I/O but ends up waiting for lots of disk seeks on a slow RPM drive.
How do I do that in Linux?
I don't want to know how much I/O it's doing--that's easy... I want to know how often it's servicing an I/O request ('cause it may spend a lot of time seeking). I need to know how busy the disk is--even if it's not doing any I/O at the moment.
vmstat will give me I/O figures (read & write) but not % busy.
On Solaris, I'll use iostat to look at the average wait time for disk requests. It turns out that Linux can do the same thing. The await value tells you this.
However, I ran iostat -d -k -x 5 but got no data--just headers. It seems that -x only works in post 2.5 kernels. Damn.
Hmm.
My questions are two-fold:
- Can I get those stats for a 2.4.xx kernel? How?
- Can I get something like FreeBSD's systat % busy value in Linux? How?
Thanks to any pointers you might offer.
Update: Steve tried iostat -x on his RedHat 8 box and got meaningful output. Now I'm really puzzled.
Posted by jzawodn at June 24, 2003 08:46 PM
The "sysstat" package works fine on my Red Hat 8.0 based 2.4 kernel, and it shows how busy the drives are.
Jeremy,
I have sysstat 3.3.6 running on my Gentoo 1.4_rc4 box and here is what I get:
Mosix6 root # iostat -x dev3-0 5 2
Linux 2.4.20-openmosix-r6 (Mosix6) 06/25/03
avg-cpu: %user %nice %sys %idle
10.19 88.28 1.51 0.02
Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s avgrq-sz avgqu-sz await svctm %util
avg-cpu: %user %nice %sys %idle
0.40 99.40 0.20 0.00
Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s avgrq-sz avgqu-sz await svctm %util
Mosix6 root #
Is it possible that the results returned depend on the drive model?
Just my 2 yens.
Charles
Could it be the following kernel option has something to do with it:
[ ] Per partition statistics in /proc/partitions (NEW)
which has the following help:
CONFIG_BLK_STATS:
If you say yes here, your kernel will keep statistical information
for every partition. The information includes things as numbers of
read and write accesses, the number of merged requests etc.
This is required for the full functionality of sar(8) and interesting
if you want to do performance tuning, by tweaking the elevator, e.g.
If unsure, say N.
(at least availebla in 2.4.20)
I use `iostat -d -x /dev/sda 10` on my RedHat Network managed[1] RedHat 7.x boxes.
- ask
[1] so very stockish kernels.
Using sysstat 4 on my somewhat mandrakey box works:
[craig@belphegore craig]$ uname -a
Linux belphegore.hughes-family.org 2.4.21-pre4 #2 SMP Sat Feb 15 14:37:57 PST 2003 i686 unknown unknown GNU/Linux
[craig@belphegore craig]$ rpm -q sysstat
sysstat-4.0.0-1mdk
[craig@belphegore craig]$ iostat -x
Linux 2.4.21-pre4 (belphegore.hughes-family.org) 06/25/2003
avg-cpu: %user %nice %sys %idle
0.66 0.01 0.18 99.15
Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s avgrq-sz avgqu-sz await svctm %util
scsi/host0/bus0/target2/lun0/disc
0.84 0.87 0.09 0.09 7.45 7.66 82.78 0.14 783.98 58.56 0.11
scsi/host0/bus0/target6/lun0/disc
0.84 0.87 0.09 0.07 7.46 7.52 90.96 0.13 811.01 58.22 0.10
ide/host0/bus0/target0/lun0/disc
0.65 2.94 0.34 3.48 7.89 51.34 15.52 0.15 44.77 40.32 1.54
ide/host0/bus0/target0/lun0/part1
0.65 2.94 0.34 3.48 7.89 51.34 15.52 0.17 44.77 26.68 1.02
ide/host0/bus0/target1/lun0/disc
0.01 0.01 0.00 0.00 0.09 0.09 58.06 0.21 574.34 49756.37 1.58
ide/host0/bus0/target1/lun0/part1
0.01 0.01 0.00 0.00 0.09 0.09 58.11 0.00 574.53 131.74 0.00
ide/host0/bus0/target1/lun0/part2
0.00 0.00 0.00 0.00 0.00 0.00 8.00 0.00 233.33 233.33 0.00
From the FAQ:
The iostat command has been updated to take advantage of Stephen Tweedie's kernel patch to display extended I/O statistics (option '-x' for iostat).
You can find Stephen's patch here: ftp://ftp.uk.linux.org/pub/linux/sct/fs/profiling
Stephen used to maintain his patch for various kernel versions, but it is no longer the case. You will have to get one of the relevant patches (if they are still there) and update it by hand to suit your kernel. Note that some distros have this patch already applied.
The problem with iostat is that it shows me averages, not instantaneous values. This is the beauty of the BSD systat - I can see, at a glance, what's going on *right now*, and use that to make tuning decisions.
Bah humbug.