Skip to content

Instantly share code, notes, and snippets.

@heinrichvk
Created September 28, 2015 07:27
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 heinrichvk/10b641e0b52b1ccbb932 to your computer and use it in GitHub Desktop.
Save heinrichvk/10b641e0b52b1ccbb932 to your computer and use it in GitHub Desktop.
Script for loading data into ATSD, with tags.
#!/bin/bash
#2015-06-24T00:00:00Z = 1435093200000 ms
#2015-06-25T00:00:00Z = 1435179600000 ms
for ((q = 1; q < 101; q++)); do
echo 'sensor'$q
for (( i = 1435093200000; i < 1435179600000; i+=10000 )); do
v=$[100 + (RANDOM % 100)]$[1000 + (RANDOM % 1000)]
t=$[20 + RANDOM % 20].${v:1:2}${v:4:3}
p=$[0 + RANDOM % 3].${v:1:2}${v:4:3}
h=$[20 + RANDOM % 60].${v:1:2}${v:4:3}
rem=$(( $q % 3 ))
if [ $rem -eq 0 ]
then
echo "series e:sensor$q m:temperature=$t m:humidity=$h m:precipitation=$p ms:$i t:location=SVL t:type=analog" | nc localhost 8081
else
if [ $rem -eq 1 ]
then
echo "series e:sensor$q m:temperature=$t m:humidity=$h m:precipitation=$p ms:$i t:location=ORE t:type=digital" | nc localhost 8081
else
echo "series e:sensor$q m:temperature=$t m:humidity=$h m:precipitation=$p ms:$i t:location=NYC t:type=unknown" | nc localhost 8081
fi
fi
done;
done
echo "Data loaded"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment