#!/bin/sh
# devel.a0fs.net -- ncc.mon.tools:/root/bin/iostatf.sh -- v0.r202312.1

export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

getstat () {
    exec iostat -xm 1 | awk '$1 ~ "(Device|sd.+)" {if ($1 == "Device") {print "\n\n----";}; print $0 }'
}

getstatf () {
    local flt="$1"
    exec iostat -xm 1 | awk -v flt="$flt" '($1 == "Device") || ($1 ~ flt) {if ($1 == "Device") {print "\n\n----";}; print $0 }'
}

if [ -n "$1" ] ; then
    getstatf "$1"

else
    getstat

fi
