The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/contrib/openzfs/cmd/zpool/zpool.d/iostat-1s

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    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="${0##*/}"
   13 if [ "$1" = "-h" ] ; then
   14         echo "$helpstr" | grep "$script:" | tr -s '\t' | cut -f 2-
   15         exit
   16 fi
   17 
   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}"
   23 else
   24         somepath="${VDEV_UPATH}"
   25 fi
   26 
   27 if [ "$script" = "iostat-1s" ] ; then
   28         # Do a single one-second sample
   29         interval=1
   30         # Don't show summary stats
   31         brief="yes"
   32 elif [ "$script" = "iostat-10s" ] ; then
   33         # Do a single ten-second sample
   34         interval=10
   35         # Don't show summary stats
   36         brief="yes"
   37 fi
   38 
   39 if [ -f "$somepath" ] ; then
   40         # We're a file-based vdev, iostat doesn't work on us.  Do nothing.
   41         exit
   42 fi
   43 
   44 if [ "$(uname)" = "FreeBSD" ]; then
   45         out=$(iostat -dKx \
   46                 ${interval:+"-w $interval"} \
   47                 ${interval:+"-c 1"} \
   48                 "$somepath" | tail -n 2)
   49 else
   50         out=$(iostat -kx \
   51                 ${brief:+"-y"} \
   52                 ${interval:+"$interval"} \
   53                 ${interval:+"1"} \
   54                 "$somepath" | grep -v '^$' | tail -n 2)
   55 fi
   56 
   57 
   58 # Sample output (we want the last two lines):
   59 #
   60 # Linux 2.6.32-642.13.1.el6.x86_64 (centos68)   03/09/2017      _x86_64_        (6 CPU)
   61 #
   62 # avg-cpu:  %user   %nice %system %iowait  %steal   %idle
   63 #           0.00    0.00    0.00    0.00    0.00  100.00
   64 #
   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
   67 #
   68 
   69 # Get the column names
   70 cols=$(echo "$out" | head -n 1)
   71 
   72 # Get the values and tab separate them to make them cut-able.
   73 vals=$(echo "$out" | tail -n 1 | tr -s '[:space:]' '\t')
   74 
   75 i=0
   76 for col in $cols ; do
   77         i=$((i+1))
   78         # Skip the first column since it's just the device name
   79         if [ "$i" -eq 1 ]; then
   80                 continue
   81         fi
   82 
   83         # Get i'th value
   84         val=$(echo "$vals" | cut -f "$i")
   85         echo "$col=$val"
   86 done

Cache object: d659e14cea3eb3a29bae4190b9df6217


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.