#!/usr/bin/env bash
# admin https://www.yuque.com/lwmacct
Device=$1
DISK=$2
# ubuntu 磁盘延迟 https://unix.stackexchange.com/questions/261967/where-can-i-find-the-disk-latency-using-iostat-await-svctm-util
# iostat -x 1 1 | grep "^$Device " | tail -1 | awk '{print $NF}'
case $DISK in
util)
nsenter --mount=/host/1/ns/mnt iostat -dxkt 1 1 | grep "^$Device " | tail -1 | awk '{print $NF}'
;;
await)
nsenter --mount=/host/1/ns/mnt iostat -dxkt 1 1 | grep "^$Device " | tail -1 | awk '{print $10}'
;;
r_await)
nsenter --mount=/host/1/ns/mnt iostat -dxkt 1 1 | grep "^$Device " | tail -1 | awk '{print $11}'
;;
w_await)
nsenter --mount=/host/1/ns/mnt iostat -dxkt 1 1 | grep "^$Device " | tail -1 | awk '{print $12}'
;;
esac