Skip to content

Instantly share code, notes, and snippets.

@vtta
Last active June 11, 2022 10:44
Show Gist options
  • Select an option

  • Save vtta/545b61e8e0830efede32c2493ce301e3 to your computer and use it in GitHub Desktop.

Select an option

Save vtta/545b61e8e0830efede32c2493ce301e3 to your computer and use it in GitHub Desktop.
S_TIME_FORMAT=ISO iostat -xydt sda sdc 1 | awk -f iostat2csv.awk
# we should print the header once
BEGIN {
header = 1
}
# match each block, e.g.
# 2022-06-11T18:42:05+0800
# Device r/s rkB/s rrqm/s %rrqm r_await rareq-sz w/s wkB/s wrqm/s %wrqm w_await wareq-sz d/s dkB/s drqm/s %drqm d_await dareq-sz f/s f_await aqu-sz %util
# sda 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 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
# sdc 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 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
#
/^[0-9]+/, /^$/ {
if ($1 ~ /^[0-9]+/) {
timestamp = $0
} else if ($1 ~ /Device/) {
if (header) {
print "Timestamp\t" $0
header = 0
}
} else if ($1 !~ /^$/) {
print timestamp "\t" $0
} else {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment