-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCheckSensor.sh
More file actions
executable file
·87 lines (78 loc) · 2.13 KB
/
CheckSensor.sh
File metadata and controls
executable file
·87 lines (78 loc) · 2.13 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
declare integer NR_MIN=10
declare TIMERANGE=$(( 1000 * 60 * ${NR_MIN} ))
URLA="https://lkvis.rivm.nl/api/datasources/proxy/23/query"
#URLA="data.waag.org"
WHAT="PM10,PM25,Temp,Hum,Pres"
FROM="FROM autogen.vuurwerk"
WHERE="WHERE time >= (now() - ${TIMERANGE}ms)"
GRP_BY="GROUP BY id"
mycurl() {
curl -G -s \
--data-urlencode "db=waag" \
--data-urlencode "q=${1}" \
--data-urlencode "epoch=ms" \
-H 'cache-control: no-cache' \
"${URLA}"
}
match_sensor() {
case "${i}" in
1340640)
NAME="Buiksloterham - Greenhost"
;;
1730246)
NAME="Buiksloterham - Energy docks"
;;
2183229)
NAME="Zeeburger - Nautilus"
;;
2183371)
NAME="Waag?"
;;
694997)
NAME="Waag?"
;;
697435)
NAME="Zeeburg - Acropolis"
;;
9732434)
NAME="Buiksloterham - Klaproosweg"
;;
9734042)
NAME="Buiksloterham - In de tas"
;;
*)
echo "Sensor ${i} NOT FOUND!!"
;;
esac
echo ${NAME}
}
clear
SENSORS="1340640 1730246 2183229 2183371 694997 697435 9732434 9734042"
for i in ${SENSORS}
do
echo -e "\n**************************************************************"
CMD="mycurl \"SELECT ${WHAT} ${FROM} ${WHERE} AND id = '${i}'\" | jq '.results[] | length'"
RST="$(eval ${CMD})"
if [ "${RST} " == "0 " ]
then
echo "Sensor ${i} $(match_sensor ${i}) is NOT ONLINE"
else
echo "Sensor ${i} $(match_sensor ${i}) is ONLINE"
# i=${i%%\"}
# i=${i##\"}
for j in $(echo ${WHAT} | tr ',' ' ')
do
# echo "mycurl \"SELECT ${j} ${FROM} ${WHERE} AND id = '${i}' AND ${j} > 0 \" | jq '.results[] | length'"
CMD="mycurl \"SELECT ${j} ${FROM} ${WHERE} AND id = '${i}' AND ${j} > 0 \" | jq '.results[] | length'"
RST="$(eval ${CMD})"
if [ "${RST} " == "0 " ]
then
echo -e "\tSensor does not send ${j}"
fi
done
fi
# echo -e "**************************************************************"
done
echo -e "\nAll online sensors:"
echo $(mycurl "SELECT ${WHAT} ${FROM} ${WHERE} ${GRP_BY}" | jq ".results[].series[].tags.id")
echo -e "\nDONE!!!!"