3 # Display most relevant iostat bandwidth/latency numbers. The output is
4 # dependent on the name of the script/symlink used to call it.
8 iostat: Show iostat values since boot (summary page).
9 iostat-1s: Do a single 1-second iostat sample and show values.
10 iostat-10s: Do a single 10-second iostat sample and show values."
13 if [ "$1" = "-h" ] ; then
14 echo "$helpstr" |
grep "$script:" |
tr -s '\t' | cut
-f 2-
18 # Sometimes, UPATH ends up /dev/(null).
19 # That should be corrected, but for now...
20 # shellcheck disable=SC2154
21 if [ ! -b "$VDEV_UPATH" ]; then
22 somepath
="${VDEV_PATH}"
24 somepath
="${VDEV_UPATH}"
27 if [ "$script" = "iostat-1s" ] ; then
28 # Do a single one-second sample
30 # Don't show summary stats
32 elif [ "$script" = "iostat-10s" ] ; then
33 # Do a single ten-second sample
35 # Don't show summary stats
39 if [ -f "$somepath" ] ; then
40 # We're a file-based vdev, iostat doesn't work on us. Do nothing.
44 if [ "$(uname)" = "FreeBSD" ]; then
46 ${interval:+"-w $interval"} \
48 "$somepath" |
tail -n 2)
52 ${interval:+"$interval"} \
54 "$somepath" |
grep -v '^$' |
tail -n 2)
58 # Sample output (we want the last two lines):
60 # Linux 2.6.32-642.13.1.el6.x86_64 (centos68) 03/09/2017 _x86_64_ (6 CPU)
62 # avg-cpu: %user %nice %system %iowait %steal %idle
63 # 0.00 0.00 0.00 0.00 0.00 100.00
65 # Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await r_await w_await svctm %util
66 # sdb 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
69 # Get the column names
70 cols
=$
(echo "$out" |
head -n 1)
72 # Get the values and tab separate them to make them cut-able.
73 vals
=$
(echo "$out" |
tail -n 1 |
tr -s '[:space:]' '\t')
78 # Skip the first column since it's just the device name
79 if [ "$i" -eq 1 ]; then
84 val
=$
(echo "$vals" | cut
-f "$i")