implement disk_io metric on osx

This commit is contained in:
Patrick Stadler
2015-03-08 17:51:15 +01:00
parent 9312c27c9c
commit c54c9d73b7
4 changed files with 77 additions and 35 deletions

View File

@@ -1,31 +1,41 @@
# #!/bin/sh
#!/bin/sh
# if [ -z $DISK_IO_MOUNTPOINT ]; then
# if is_osx; then
# DISK_IO_MOUNTPOINT="disk0"
# else
# DISK_IO_MOUNTPOINT="/dev/vda"
# fi
# fi
if [ -z $DISK_IO_MOUNTPOINT ]; then
if is_osx; then
DISK_IO_MOUNTPOINT="disk0"
else
DISK_IO_MOUNTPOINT="/dev/vda"
fi
fi
# if is_osx; then
# __disk_io_bgproc () {
# iostat -K -d -c 99999 -w $INTERVAL $DISK_IO_MOUNTPOINT | while read line; do
# echo $line | awk '{print $3}' > ./foobar
# done
# }
# else
# __disk_io_bgproc () {
# echo $(iostat -y -d 1 $DISK_IO_MOUNTPOINT)
# }
# fi
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 () {
echo $(iostat -y -d 1 $DISK_IO_MOUNTPOINT)
}
fi
# init () {
# mkfifo ./foobar
# #exec 3<> ./foobar
# __disk_io_bgproc > ./foobar &
# }
__disk_io_fifo=$__TEMP_DIR/disk_io
# collect () {
# cat ./foobar
# }
init () {
__disk_io_bgproc &
mkfifo $__disk_io_fifo
}
collect () {
report $(cat $__disk_io_fifo)
}
terminate () {
rm $__disk_io_fifo
}
docs () {
echo "Disk I/O in MB/s."
echo "\$DISK_IO_MOUNTPOINT=$DISK_IO_MOUNTPOINT"
}