Make zpool.d/iostat work on FreeBSD
There are slight differences in the iostat commands between FreeBSD and Linux. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Ryan Moeller <ryan@iXsystems.com> Closes #9979
This commit is contained in:
parent
db0ad393b1
commit
0f1832106d
|
@ -17,14 +17,14 @@ fi
|
||||||
|
|
||||||
if [ "$script" = "iostat-1s" ] ; then
|
if [ "$script" = "iostat-1s" ] ; then
|
||||||
# Do a single one-second sample
|
# Do a single one-second sample
|
||||||
extra="1 1"
|
interval=1
|
||||||
# Don't show summary stats
|
# Don't show summary stats
|
||||||
y="-y"
|
brief="yes"
|
||||||
elif [ "$script" = "iostat-10s" ] ; then
|
elif [ "$script" = "iostat-10s" ] ; then
|
||||||
# Do a single ten-second sample
|
# Do a single ten-second sample
|
||||||
extra="10 1"
|
interval=10
|
||||||
# Don't show summary stats
|
# Don't show summary stats
|
||||||
y="-y"
|
brief="yes"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f "$VDEV_UPATH" ] ; then
|
if [ -f "$VDEV_UPATH" ] ; then
|
||||||
|
@ -32,7 +32,19 @@ if [ -f "$VDEV_UPATH" ] ; then
|
||||||
exit
|
exit
|
||||||
fi
|
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):
|
# 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
|
# 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.
|
# 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
|
i=0
|
||||||
for col in $cols ; do
|
for col in $cols ; do
|
||||||
i=$((i+1))
|
i=$((i+1))
|
||||||
# Skip the first column since it's just the device name
|
# Skip the first column since it's just the device name
|
||||||
if [ "$col" = "Device:" ] ; then
|
if [ $i -eq 1 ]; then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue