From b33e48307bee35fd778734c826fe55bbfa902f74 Mon Sep 17 00:00:00 2001 From: n Date: Mon, 27 May 2019 22:36:08 +0200 Subject: [PATCH] collectweather.sh gets weather data from Dark Sky API --- README.md | 1 + monitoring/collectweather.sh | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100755 monitoring/collectweather.sh diff --git a/README.md b/README.md index bd612c1..dabd66d 100644 --- a/README.md +++ b/README.md @@ -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 ----- diff --git a/monitoring/collectweather.sh b/monitoring/collectweather.sh new file mode 100755 index 0000000..cc9690b --- /dev/null +++ b/monitoring/collectweather.sh @@ -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//,?lang=&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