Last active
January 2, 2016 12:59
-
-
Save djosephsen/8306440 to your computer and use it in GitHub Desktop.
nest.py to librato via sh and shellbrato
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
#use nest.py to gather interesting metrics, and push them to librato | |
NP="/home/dave/tmp/nest.py show --user dave --password XXX" # the nest.py command | |
source ${SBHOME}/shellbrato.sh #the librato shell library | |
${NP} | egrep -w 'current_humidity|current_temperature|hvac_heater_state|target_temperature' | sed -e 's/\.\+: /:/'| while read METRIC | |
do | |
read NAME VALUE <<< $(echo ${METRIC} | tr ':' ' ') | |
[ "${VALUE}" == "True" ] && VALUE=1 | |
[ "${VALUE}" == "False" ] && VALUE=0 | |
queueGauge "$(date +%s)||${NAME}||${VALUE}" #queue up each metric | |
done | |
sendMetrics #send them to librato |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Added the "show" subcommand to nest.py (thanks Zack! https://gist.github.com/8494419.git )