Skip to content

Instantly share code, notes, and snippets.

@linuxkidd
Last active October 1, 2020 16:13
Show Gist options
  • Save linuxkidd/325fd0ddfb009068180368814a02cd47 to your computer and use it in GitHub Desktop.
Save linuxkidd/325fd0ddfb009068180368814a02cd47 to your computer and use it in GitHub Desktop.
Process sar disk %util into a histogram
#!/usr/bin/awk -f
/^[0-9].*dev[0-9]*-[0-9]*/{
diskpos=2
if ( $2 ~ /(A|P)M/ )
diskpos=3
dev[$diskpos]=1
histo[$diskpos][int($NF)]++
}
END {
printf("Util%")
for(mydev in dev) {
printf(",%s",mydev)
}
printf("\n")
for(j=0;j<=100;j++) {
printf("%s",j)
for(mydev in dev) {
printf(",%s",histo[mydev][j])
}
printf("\n")
}
}
@linuxkidd
Copy link
Author

cat sar21 | ./proc_sar_disk_util_histo.awk > util_histo.csv

-- Generates %util column data into a histogram -- output to stdout

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment