Skip to content

Instantly share code, notes, and snippets.

@coderofsalvation
Created May 13, 2014 14:22
Show Gist options
  • Save coderofsalvation/7ca4aff5d84fb888e9d3 to your computer and use it in GitHub Desktop.
Save coderofsalvation/7ca4aff5d84fb888e9d3 to your computer and use it in GitHub Desktop.
feed metrics to graphite using bash
#!/bin/bash
# Set this hostname
HOSTNAME=`hostname --short`
# Set Graphite host
GRAPHITE=my.graphite.host
GRAPHITE_PORT=2003
# Loop forever
while :
do
# Get epoch
DATE=`date +%s`
# Collect some random data for
# this example
MY_DATA=`ls /tmp | wc -l`
# Send data to Graphite
echo "stats.${HOSTNAME}.tmp.file.count ${MY_DATA} ${DATE}" | nc $GRAPHITE $GRAPHITE_PORT
sleep 10
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment