Browse Source

collectweather.sh gets weather data from Dark Sky API

master
n 6 months ago
parent
commit
b33e48307b
2 changed files with 18 additions and 0 deletions
  1. +1
    -0
      README.md
  2. +17
    -0
      monitoring/collectweather.sh

+ 1
- 0
README.md View File

@@ -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
- 0
monitoring/collectweather.sh View 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

Loading…
Cancel
Save