[LAD] [OT] bash vs disk activity

Ross Vandegrift ross at kallisti.us
Thu Oct 11 17:42:22 UTC 2007


On Tue, Oct 09, 2007 at 06:58:40PM +0700, Patrick Shirkey wrote:
> Does anyone have a script for monitoring with iostat or vmstat while in
> async mode?
> 
> I'm thinking a bash equivalent to the disk monitor on gkrellm which
> allows me to know when a transfer has completed.

Something like this will return when five seconds have passed with
no write requests being issues to the device sda:

CURRENT=$(cat /proc/diskstats | grep sda\  | awk '{ print $8 }')
LAST=0
while true; do
	LAST=CURRENT
	sleep 5
	CURRENT=$(cat /proc/diskstats | grep sda\  | awk '{ print $8 }')
	if [ "$LAST" == "$CURRENT" ]; then
		break
	fi
done


/proc/diskstats lists a few things.  For complete devices (ie,
/dev/sda instead of /dev/sda1), it lists:

Field 1 -- # of reads issued
Field 2 -- # of reads merged, field 6 -- # of writes merged
Field 3 -- # of sectors read
Field 4 -- # of milliseconds spent reading
Field 5 -- # of writes completed
Field 7 -- # of sectors written
Field 8 -- # of milliseconds spent writing
Field 9 -- # of I/Os currently in progress
Field 10 -- # of milliseconds spent doing I/Os
Field 11 -- weighted # of milliseconds spent doing I/Os


Where field n is the nth field after the device name.

-- 
Ross Vandegrift
ross at kallisti.us

"The good Christian should beware of mathematicians, and all those who
make empty prophecies. The danger already exists that the mathematicians
have made a covenant with the devil to darken the spirit and to confine
man in the bonds of Hell."
	--St. Augustine, De Genesi ad Litteram, Book II, xviii, 37



More information about the Linux-audio-dev mailing list