Skip to content

Instantly share code, notes, and snippets.

@skreuzer
Created July 12, 2013 18:30
Show Gist options
  • Save skreuzer/5986683 to your computer and use it in GitHub Desktop.
Save skreuzer/5986683 to your computer and use it in GitHub Desktop.
#!/bin/sh
CLUSTER=$(hostname | cut -d- -f 1)
GRAPHITE_PORT=2003
REFRESH=5
function _usage
{
echo "$0 -g graphite-server [-p graphite-port] [-c cluster-name] [-r polling-interval]"
}
while getopts "c:g:p:r:h" OPTION; do
case ${OPTION} in
'c')
CLUSTER=${OPTARG}
;;
'p')
GRAPHITE_PORT=${OPTARG}
;;
'g')
GRAPHITE_HOST=${OPTARG}
;;
'r')
REFRESH=${OPTARG}
;;
'h')
_usage
exit 0
;;
esac
done
if [ -z ${GRAPHITE_HOST} ];
then
echo "usage"
exit 1
fi
isi statistics protocol \
--noheader \
--degraded \
--protocols=nfs3 \
--orderby=TimeAvg \
--nodes=all \
--totalby=Op \
--csv --top -i ${REFRESH} \
--output 'TimeStamp,NumOps,InAvg,OutAvg,TimeAvg,Op'
| /usr/bin/awk -v host=${CLUSTER} 'BEGIN { FS = "," };
/^\s*$/ { next; }
{
printf("isilon.statistics.protocol.nfs3.%s.op.%s.NumOps %s %i\n", host, $6, $2, $1);
printf("isilon.statistics.protocol.nfs3.%s.op.%s.InAvg %s %i\n", host, $6, $3, $1);
printf("isilon.statistics.protocol.nfs3.%s.op.%s.OutAvg %s %i\n", host, $6, $4, $1);
printf("isilon.statistics.protocol.nfs3.%s.op.%s.TimeAvg %s %i\n", host, $6, $5, $1);
}' | /usr/bin/nc ${GRAPHITE_HOST} ${GRAPHITE_PORT}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment