mirror of
https://github.com/pstadler/metrics.sh.git
synced 2025-11-06 20:33:04 -05:00
implement disk_io metric on osx
This commit is contained in:
@@ -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"
|
||||
}
|
||||
Reference in New Issue
Block a user