Last active
August 29, 2015 13:55
-
-
Save VaclavSynacek/8766523 to your computer and use it in GitHub Desktop.
Simple script to upload one value to one channel on http://xively.com using only standard unix command line tools. More detaild description at http://vaclav.synacek.com/blog/2014/02/02/xively-data-logging-the-unix-way/
This file contains 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 | |
# | |
# simple script to upload one value to one channel on xively.com | |
# | |
# exaple to upload value "23.4" to channel "temperature" use: | |
# xively temperature 23.4 | |
# | |
# example to upload value "runnig" to channel "status" use escaping: | |
# xively status \"running\" | |
# | |
# | |
# change these two strings to your API key and your API endpoint | |
APIKEY="cPHLfGw1WJdMAbU8FZbfsdFyJ8suayHEH3OChRrkpYwQCmrb" | |
APIENDPOINT="https://api.xively.com/v2/feeds/1242061948" | |
if [ -z "$1" ]; then | |
echo usage: $0 channel current_value | |
exit | |
fi | |
STREAM=$1 | |
if [ -z "$2" ]; then | |
echo usage: $0 channel current_value | |
exit | |
fi | |
VALUE=$2 | |
echo "{\"datastreams\": [ {\"id\":\"$STREAM\",\"current_value\":$VALUE}]" |\ | |
xargs -0 -I {} \ | |
curl --request PUT --data-binary {} \ | |
--header "X-ApiKey: $APIKEY" $APIENDPOINT |
This file contains 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 | |
# | |
# simple script to upload system load average to http://xively.com | |
# assuming: | |
# xively script is on the path | |
# xively feed has channel "loadavg" already created | |
# | |
# just put this to /etc/cron.minutely | |
# or /etc/cron.hourly and be happy | |
# | |
# | |
cat /proc/loadavg |\ | |
xargs xively loadavg | |
This file contains 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 | |
# | |
# simple script to upload system temperature to http://xively.com | |
# assuming: | |
# xively script is on the path | |
# xively feed has channel "thermal" already created | |
# it is in Celsius units | |
# /sys/class/thermal/thermal_zone0/temp is the path to system | |
# temperature in your distribution (true for debian based distros) | |
# | |
# just put this to /etc/cron.minutely or /etc/cron.hourly and be happy | |
# | |
# | |
awk '{printf "%2.3f", $1/1000}' /sys/class/thermal/thermal_zone0/temp |\ | |
xargs xively thermal |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment