Skip to content

Instantly share code, notes, and snippets.

@logikal
Created June 18, 2014 19:27
Show Gist options
  • Select an option

  • Save logikal/799ef1af227dc751280b to your computer and use it in GitHub Desktop.

Select an option

Save logikal/799ef1af227dc751280b to your computer and use it in GitHub Desktop.
#!/bin/bash
# Set Graphite host
GRAPHITE=graphite.sjc1.sendgrid.net
GRAPHITE_PORT=2003
# Loop forever
while :
do
# Get epoch
DATE=`date +%s`
# Collect some random data for
# this example
MY_DATA=`knife ssh "(role:filter OR role:go_filter) AND chef_environment:production* NOT fqdn:filter-163.sjc1.sendgrid.net" "/opt/sendgrid/elasticd/current/elasq.pl -c" -c ~/.chef/knife-11.rb -x skilgore -C 10 | awk '{print $3}' | awk '{s+=$1} END {print s}'`
# Send data to Graphite
echo "sending data: stats.elasticd.total_queue ${MY_DATA} ${DATE}"
echo "sean.elasticd.total_queue ${MY_DATA} ${DATE}" | nc $GRAPHITE $GRAPHITE_PORT
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment