diff options
author | Ryan Moeller <[email protected]> | 2020-02-14 11:37:40 -0500 |
---|---|---|
committer | GitHub <[email protected]> | 2020-02-14 08:37:40 -0800 |
commit | 0f1832106d66a309a9a5a6cc11edee6bb11ced98 (patch) | |
tree | e6d158f7fd9df392a36545c16005cfc0946a3e80 /cmd/zpool | |
parent | db0ad393b1bb7f83167e1cece1fd896dd0e63d73 (diff) |
Make zpool.d/iostat work on FreeBSD
There are slight differences in the iostat commands between FreeBSD and
Linux.
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Ryan Moeller <[email protected]>
Closes #9979
Diffstat (limited to 'cmd/zpool')
-rwxr-xr-x | cmd/zpool/zpool.d/iostat | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/cmd/zpool/zpool.d/iostat b/cmd/zpool/zpool.d/iostat index f6452fb25..41a3acfae 100755 --- a/cmd/zpool/zpool.d/iostat +++ b/cmd/zpool/zpool.d/iostat @@ -17,14 +17,14 @@ fi if [ "$script" = "iostat-1s" ] ; then # Do a single one-second sample - extra="1 1" + interval=1 # Don't show summary stats - y="-y" + brief="yes" elif [ "$script" = "iostat-10s" ] ; then # Do a single ten-second sample - extra="10 1" + interval=10 # Don't show summary stats - y="-y" + brief="yes" fi if [ -f "$VDEV_UPATH" ] ; then @@ -32,7 +32,19 @@ if [ -f "$VDEV_UPATH" ] ; then exit fi -out=$(eval "iostat $y -k -x $VDEV_UPATH $extra") +if [ "$(uname)" = "FreeBSD" ]; then + out=$(iostat -dKx \ + ${interval:+"-w $interval"} \ + ${interval:+"-c 1"} \ + "$VDEV_UPATH" | tail -n 2) +else + out=$(iostat -kx \ + ${brief:+"-y"} \ + ${interval:+"$interval"} \ + ${interval:+"1"} \ + "$VDEV_UPATH" | awk NF | tail -n 2) +fi + # Sample output (we want the last two lines): # @@ -46,16 +58,16 @@ out=$(eval "iostat $y -k -x $VDEV_UPATH $extra") # # Get the column names -cols=$(echo "$out" | grep Device) +cols=$(echo "$out" | head -n 1) # Get the values and tab separate them to make them cut-able. -vals="$(echo "$out" | grep -A1 Device | tail -n 1 | sed -r 's/[[:blank:]]+/\t/g')" +vals=$(echo "$out" | tail -n 1 | sed -r 's/[[:blank:]]+/\t/g') i=0 for col in $cols ; do i=$((i+1)) # Skip the first column since it's just the device name - if [ "$col" = "Device:" ] ; then + if [ $i -eq 1 ]; then continue fi |