]> git.proxmox.com Git - mirror_zfs-debian.git/blame - cmd/zpool/zpool.d/iostat-1s
New upstream version 0.7.2
[mirror_zfs-debian.git] / cmd / zpool / zpool.d / iostat-1s
CommitLineData
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
7helpstr="
8iostat: Show iostat values since boot (summary page).
9iostat-1s: Do a single 1-second iostat sample and show values.
10iostat-10s: Do a single 10-second iostat sample and show values."
11
12script=$(basename "$0")
13if [ "$1" = "-h" ] ; then
14 echo "$helpstr" | grep "$script:" | tr -s '\t' | cut -f 2-
15 exit
16fi
17
18if [ "$script" = "iostat-1s" ] ; then
19 # Do a single one-second sample
20 extra="1 1"
21 # Don't show summary stats
22 y="-y"
23elif [ "$script" = "iostat-10s" ] ; then
24 # Do a single ten-second sample
25 extra="10 1"
26 # Don't show summary stats
27 y="-y"
28fi
29
30if [ -f "$VDEV_UPATH" ] ; then
31 # We're a file-based vdev, iostat doesn't work on us. Do nothing.
32 exit
33fi
34
35out=$(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
49cols=$(echo "$out" | grep Device)
50
51# Get the values and tab separate them to make them cut-able.
52vals="$(echo "$out" | grep -A1 Device | tail -n 1 | sed -r 's/[[:blank:]]+/\t/g')"
53
54i=0
55for 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"
65done