Skip to content

Instantly share code, notes, and snippets.

@douglascodes
Created June 29, 2018 15:49
Show Gist options
  • Save douglascodes/b0ebe90d3e5f00704bcabf28f2ab75c7 to your computer and use it in GitHub Desktop.
Save douglascodes/b0ebe90d3e5f00704bcabf28f2ab75c7 to your computer and use it in GitHub Desktop.
Creates a log file for iostat data
#! /usr/bin/env bash
# gather_hdd_stats.sh $(date +%F).log
# Every 5 seconds on the mod 5 pipe formatted iostat data to <file>
if [ $# -lt 1 ] ; then
echo "usage: $0 <file>"
exit -1
fi
outputfile="$1"
export S_TIME_FORMAT=ISO;
sleep $(/bin/date +'%-S' | /usr/bin/env awk '{print 5 - int($1%5)}');
while true; do
/usr/bin/iostat -t -d -H -g hdds sda sdb | /usr/bin/env awk -f /home/dhking/bin/clean_iostat.awk >> ${outputfile}
sleep $(/bin/date +'%-S' | /usr/bin/env awk '{print 5 - int($1%5)}');
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment