Skip to content

Instantly share code, notes, and snippets.

@damilarelana
Forked from coderofsalvation/graphite.bash
Created December 8, 2015 20:09
Show Gist options
  • Save damilarelana/5d599dd77e1ed226aea8 to your computer and use it in GitHub Desktop.
Save damilarelana/5d599dd77e1ed226aea8 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