Last active
January 24, 2017 19:50
-
-
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
This file contains hidden or 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/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