Skip to content

Instantly share code, notes, and snippets.

@j3tm0t0
Last active November 12, 2015 18:12
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 j3tm0t0/e5d158acc50eb8a1e3de to your computer and use it in GitHub Desktop.
Save j3tm0t0/e5d158acc50eb8a1e3de to your computer and use it in GitHub Desktop.
put on-board temperature and CPU usage as JSON on Raspberry Pi
#!/bin/bash
json=$(
awk '{printf "{\"temperature\":%3.1f,", $1/1000}' /sys/class/thermal/thermal_zone0/temp
top -b -n 2 | grep %Cpu | tail -1 |a awk '{printf "\"CPU\":%.1f}\n", $2+$4+$6+$10+$12+$14}'
)
echo $json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment