2015-03-08 12:51:15 -04:00
|
|
|
#!/bin/sh
|
2015-03-08 07:30:00 -04:00
|
|
|
|
2015-03-21 16:19:08 -04:00
|
|
|
defaults () {
|
2015-03-08 15:37:56 -04:00
|
|
|
if [ -z $DISK_IO_MOUNTPOINT ]; then
|
|
|
|
if is_osx; then
|
|
|
|
DISK_IO_MOUNTPOINT="disk0"
|
|
|
|
else
|
|
|
|
DISK_IO_MOUNTPOINT="/dev/vda"
|
|
|
|
fi
|
2015-03-08 12:51:15 -04:00
|
|
|
fi
|
2015-03-21 16:19:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
start () {
|
2015-03-21 11:50:35 -04:00
|
|
|
readonly __disk_io_fifo=$TEMP_DIR/$(unique_id)
|
2015-03-08 15:37:56 -04:00
|
|
|
mkfifo $__disk_io_fifo
|
2015-03-21 16:19:08 -04:00
|
|
|
|
|
|
|
if is_osx; then
|
|
|
|
__disk_io_bgproc () {
|
|
|
|
iostat -K -d -w $INTERVAL $DISK_IO_MOUNTPOINT | while read line; do
|
|
|
|
echo $line | awk '{ print $3 }' > $__disk_io_fifo
|
|
|
|
done
|
|
|
|
}
|
|
|
|
else
|
|
|
|
__disk_io_bgproc () {
|
|
|
|
iostat -y -m -d $INTERVAL $DISK_IO_MOUNTPOINT | while read line; do
|
|
|
|
echo $line | awk '/[0-9.]/{ print $3 }' > $__disk_io_fifo
|
|
|
|
done
|
|
|
|
}
|
|
|
|
fi
|
|
|
|
|
2015-03-08 15:37:56 -04:00
|
|
|
__disk_io_bgproc &
|
|
|
|
}
|
2015-03-08 07:30:00 -04:00
|
|
|
|
2015-03-08 12:51:15 -04:00
|
|
|
collect () {
|
2015-03-12 15:59:09 -04:00
|
|
|
report $(cat $__disk_io_fifo)
|
2015-03-08 12:51:15 -04:00
|
|
|
}
|
|
|
|
|
2015-03-21 16:19:08 -04:00
|
|
|
stop () {
|
2015-03-11 17:02:00 -04:00
|
|
|
if [ ! -z $__disk_io_fifo ] && [ -p $__disk_io_fifo ]; then
|
2015-03-08 15:37:56 -04:00
|
|
|
rm $__disk_io_fifo
|
|
|
|
fi
|
2015-03-08 12:51:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
docs () {
|
|
|
|
echo "Disk I/O in MB/s."
|
2015-03-21 16:19:08 -04:00
|
|
|
echo "DISK_IO_MOUNTPOINT=$DISK_IO_MOUNTPOINT"
|
2015-03-08 12:51:15 -04:00
|
|
|
}
|