Skip to content

Instantly share code, notes, and snippets.

@djosephsen
Last active January 2, 2016 12:59
Show Gist options
  • Save djosephsen/8306440 to your computer and use it in GitHub Desktop.
Save djosephsen/8306440 to your computer and use it in GitHub Desktop.
nest.py to librato via sh and shellbrato
#!/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
@djosephsen
Copy link
Author

Added the "show" subcommand to nest.py (thanks Zack! https://gist.github.com/8494419.git )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment