-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsend-data.sh
More file actions
executable file
·34 lines (26 loc) · 842 Bytes
/
send-data.sh
File metadata and controls
executable file
·34 lines (26 loc) · 842 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash
HAWKULAR_URL="http://localhost:8080/hawkular/alerts"
HEADER_JSON="Content-Type: application/json"
## Send demo data on infinite loop
function send_data() {
while true
do
local timestamp=$(date +%s)
local valuex=$(shuf -i1-10 -n1)
local valuey=$(shuf -i1-10 -n1)
local data="["
data="$data {\"id\":\"data-x\",\"timestamp\":$timestamp,\"value\":\"$valuex\"},"
data="$data {\"id\":\"data-y\",\"timestamp\":$timestamp,\"value\":\"$valuey\"}"
data="$data ]"
echo "Send $data"
local response=$(curl -X POST --write-out %{http_code} --silent --output /dev/null -H "$HEADER_JSON" --data "$data" $HAWKULAR_URL/data)
if [ "$response" != "200" ];
then
echo "$response data not sent - aborting..."
exit 1
fi
sleep 0.5
done
}
## Main
send_data;