Created
July 1, 2015 00:47
-
-
Save pl12133/ea405146157bb975b3bf to your computer and use it in GitHub Desktop.
Fake Data Scheduler script, example of POSTing data directly to the InfluxDB HTTP API
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 | |
__randomWithRange() { | |
# http://www.tldp.org/LDP/abs/html/randomvar.html | |
# USAGE: __randomWithRange FLOOR CEILING | |
local number=0 #initialize | |
while [ "$number" -le $1 ] | |
do | |
number=$RANDOM | |
let "number %= $2" # Scales $number down within $RANGE. | |
done | |
echo $number | |
} | |
declare url='http://weatherspot.us:8086/db/weather/series?u=root&p=root' | |
declare temperature="$(__randomWithRange 65 76)" | |
declare humidity="$(__randomWithRange 25 45)" | |
declare pressure="$(__randomWithRange 40 75)" | |
declare lighting="$(__randomWithRange 35 65)" | |
declare json="[{\"name\" : \"Downtown\",\"columns\" : [\"temperature\", \"humidity\", \"pressure\", \"lighting\"],\"points\" : [[${temperature}, ${humidity}, ${pressure}, ${lighting}]]}]" | |
echo "URL:" | |
echo ${url} | |
echo "POSTING:" | |
echo ${json} | |
curl -X POST "${url}" --data "${json}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment