Skip to content

Instantly share code, notes, and snippets.

@rw950431
Last active January 24, 2017 19:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rw950431/8702588 to your computer and use it in GitHub Desktop.
Save rw950431/8702588 to your computer and use it in GitHub Desktop.
Simple shell script to save Raspberry Pi performance data to http://thingspeak.com
#!/bin/bash
# RW950431 30Jan2014
# update thingspeak with system perf data
# add an entry to crontab something like
# */10 * * * * /home/pi/stats.sh >>/home/pi/stats.log 2>&1
#
KEY=YOUR_THINGSPEAK_WRITE_KEY
# network packets (change wlan0 to eth0 if wired network)
NET=$(netstat -i | awk '/^wlan0/ {print "field1="$4"&field2="$8}');
#echo $NET
# Raspberry pi total SD card sectors written
DISK=$(vmstat -d | awk '/^mmcblk0/ {print $8}')
#echo $DISK
# Raspberry pi CPU temperature
CPU=$(( $(cat /sys/class/thermal/thermal_zone0/subsystem/thermal_zone0/temp) / 1000))
#echo $CPU
#field1=RX packets, field2=TX packets, field3=disk sectors written, field4=CPU temperature
wget -q -O- "http://api.thingspeak.com/update?key=$KEY&$NET&field3=$DISK&field4=$CPU"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment