]>
Commit | Line | Data |
---|---|---|
cae5b340 AX |
1 | #!/bin/sh |
2 | # | |
3 | # Display most relevant iostat bandwidth/latency numbers. The output is | |
4 | # dependent on the name of the script/symlink used to call it. | |
5 | # | |
6 | ||
7 | helpstr=" | |
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." | |
11 | ||
12 | script=$(basename "$0") | |
13 | if [ "$1" = "-h" ] ; then | |
14 | echo "$helpstr" | grep "$script:" | tr -s '\t' | cut -f 2- | |
15 | exit | |
16 | fi | |
17 | ||
18 | if [ "$script" = "iostat-1s" ] ; then | |
19 | # Do a single one-second sample | |
20 | extra="1 1" | |
21 | # Don't show summary stats | |
22 | y="-y" | |
23 | elif [ "$script" = "iostat-10s" ] ; then | |
24 | # Do a single ten-second sample | |
25 | extra="10 1" | |
26 | # Don't show summary stats | |
27 | y="-y" | |
28 | fi | |
29 | ||
30 | if [ -f "$VDEV_UPATH" ] ; then | |
31 | # We're a file-based vdev, iostat doesn't work on us. Do nothing. | |
32 | exit | |
33 | fi | |
34 | ||
35 | out=$(eval "iostat $y -k -x $VDEV_UPATH $extra") | |
36 | ||
37 | # Sample output (we want the last two lines): | |
38 | # | |
39 | # Linux 2.6.32-642.13.1.el6.x86_64 (centos68) 03/09/2017 _x86_64_ (6 CPU) | |
40 | # | |
41 | # avg-cpu: %user %nice %system %iowait %steal %idle | |
42 | # 0.00 0.00 0.00 0.00 0.00 100.00 | |
43 | # | |
44 | # Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await r_await w_await svctm %util | |
45 | # 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 | |
46 | # | |
47 | ||
48 | # Get the column names | |
49 | cols=$(echo "$out" | grep Device) | |
50 | ||
51 | # Get the values and tab separate them to make them cut-able. | |
52 | vals="$(echo "$out" | grep -A1 Device | tail -n 1 | sed -r 's/[[:blank:]]+/\t/g')" | |
53 | ||
54 | i=0 | |
55 | for col in $cols ; do | |
56 | i=$((i+1)) | |
57 | # Skip the first column since it's just the device name | |
58 | if [ "$col" = "Device:" ] ; then | |
59 | continue | |
60 | fi | |
61 | ||
62 | # Get i'th value | |
63 | val=$(echo "$vals" | cut -f "$i") | |
64 | echo "$col=$val" | |
65 | done |