collectweather.sh gets weather data from Dark Sky API

This commit is contained in:
n 2019-05-27 22:36:08 +02:00
父節點 0ea1a4eac9
當前提交 b33e48307b
共有 2 個文件被更改,包括 18 次插入0 次删除

查看文件

@ -37,6 +37,7 @@ Monitoring
* [collectd_ntppool_score](https://forge.tourmentine.com/n/scripts/src/master/monitoring/collectd_ntppool_score) => Same as [check_ntppool_score](https://forge.tourmentine.com/n/scripts/src/master/monitoring/check_ntppool_score) but for collectd graphing.
* [check_postgresql_replication.sh](https://forge.tourmentine.com/n/scripts/src/master/monitoring/check_postgresql_replication.sh) => check postgresql's replication lag.
* [GonKyrellM](https://forge.tourmentine.com/n/scripts/src/master/monitoring/GonKyrellM) => Conky, GKrellM style - with "invisible" theme (well, sort of)
* [collectweather.sh](https://forge.tourmentine.com/n/scripts/src/master/monitoring/collectweather.sh) => get weather data from https://darksky.net/ and feed collectd with it. needs jq as Dark Sky provides data in json format.
Attic
-----

17
monitoring/collectweather.sh Executable file
查看文件

@ -0,0 +1,17 @@
#!/bin/sh
HOSTNAME="${COLLECTD_HOSTNAME:-`hostname -f`}"
INTERVAL="${COLLECTD_INTERVAL:-300}"
FILE="/tmp/weather.json"
# get $FILE using a cronjob (no more than 1000 requests per day for free - one every 5 minutes is fine) like
#curl "https://api.darksky.net/forecast/<your api key>/<latitude>,<longitude>?lang=<language>&units=si" -o $FILE -s
while sleep "$INTERVAL"; do
for field in precipIntensity precipProbability temperature apparentTemperature dewPoint humidity pressure windSpeed windGust windBearing cloudCover uvIndex visibility ozone;do
echo "PUTVAL $HOSTNAME/weather/gauge-${field} interval=$INTERVAL N:`jq .currently.${field} $FILE`" ;
done
for field in summary icon ;do
echo "PUTVAL $HOSTNAME/weather/string-${field} interval=$INTERVAL N:`jq .currently.${field} $FILE`" ;
done
done