Skip to content

Instantly share code, notes, and snippets.

@dettmering
Last active February 2, 2019 14:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dettmering/90a449c13f10e2eb150c1ae7442c7732 to your computer and use it in GitHub Desktop.
Save dettmering/90a449c13f10e2eb150c1ae7442c7732 to your computer and use it in GitHub Desktop.
Log the RaspberryPi temperature to InfluxDB
#!/bin/bash
cpuTemp0=$(cat /sys/class/thermal/thermal_zone0/temp)
cpuTemp1=$(($cpuTemp0/1000))
cpuTemp2=$(($cpuTemp0/100))
cpuTempM=$(($cpuTemp2 % $cpuTemp1))
serial=$(cat /proc/cpuinfo | grep Serial | cut -d ' ' -f 2)
host="localhost:8086"
db="rpi"
curl -i -XPOST "http://${host}/write?db=${db}" --data-binary "cpu_temp,serial=${serial} temperature=${cpuTemp1}.${cpuTempM}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment