Skip to content

Instantly share code, notes, and snippets.

@lunetics
Created November 30, 2013 15:15
Show Gist options
  • Save lunetics/7720278 to your computer and use it in GitHub Desktop.
Save lunetics/7720278 to your computer and use it in GitHub Desktop.
#!/bin/sh
if ! [ -z "$*" ];
then
separator="|";
regex="$( printf "%s${separator}" "${@}" )";
filter="-f \"${regex%?}\""
fi;
echo ${filter};
/usr/local/bin/sudo gstat -b -I 1s ${filter} | sed '1,2d' | awk -v host=${COLLECTD_HOSTNAME:=`hostname -f`} -v interval=${COLLECTD_INTERVAL:-10} '{
print "PUTVAL " host "/iostat-" $10 "/iostat_tql" " interval=" interval " N:" $1;
print "PUTVAL " host "/iostat-" $10 "/iostat_iops" " interval=" interval " N:" $3 ":" $6;
print "PUTVAL " host "/iostat-" $10 "/iostat_iops_complex" " interval=" interval " N:" $2;
print "PUTVAL " host "/iostat-" $10 "/iostat_transaction_time" " interval=" interval " N:" $5 ":" $8;
print "PUTVAL " host "/iostat-" $10 "/iostat_kbps" " interval=" interval " N:" $4 ":" $7 ;
print "PUTVAL " host "/iostat-" $10 "/iostat_busy" " interval=" interval " N:" $9;
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment