use OpenWeather API as source for collectweather.sh (fixes #1)
This commit is contained in:
parent
6bebeb943e
commit
5dff343760
2 changed files with 8 additions and 9 deletions
|
@ -44,7 +44,7 @@ Monitoring
|
|||
* [check_gemini.sh](https://forge.tourmentine.com/n/scripts/src/master/monitoring/check_gemini.sh) => Nagios/Icinga check for Gemini capsule availability. Requires gnutls for now (not tested with other tls clients).
|
||||
* [check_lastdate.sh](https://forge.tourmentine.com/n/scripts/src/master/monitoring/check_lastdate.sh) => Check for a +%Y-%m-%d %H:%M:%S-formated date in the last two lines of a file.
|
||||
* [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.
|
||||
* [collectweather.sh](https://forge.tourmentine.com/n/scripts/src/master/monitoring/collectweather.sh) => get weather data from https://openweathermap.org/ and feed collectd with it. needs jq as OpenWeather provides data in json format.
|
||||
|
||||
Attic
|
||||
-----
|
||||
|
|
|
@ -2,16 +2,15 @@
|
|||
|
||||
HOSTNAME="${COLLECTD_HOSTNAME:-`hostname -f`}"
|
||||
INTERVAL="${COLLECTD_INTERVAL:-300}"
|
||||
FILE="/home/weather/tmp/weather.json"
|
||||
FILE="/home/weather/tmp/openweathermap.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
|
||||
# get $FILE using a cronjob (no more than 1M requests per month/1 request per second for free - one every 5 minutes is fine) like
|
||||
# curl "https://api.openweathermap.org/data/2.5/weather?lat=<latitude>&lon=<longitude>&units=metric&lang=<language>&appid=<your api key>" -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`" ;
|
||||
for field in main.temp main.feels_like main.pressure main.humidity wind.speed wind.gust clouds.all rain.\"1h\" rain.\"3h\" snow.\"1h\" snow.\"3h\" sys.sunrise sys.sunset visibility;do
|
||||
key=`echo ${field} | sed 's/\./-/g' | sed 's/"//g'`
|
||||
echo "PUTVAL $HOSTNAME/weather/gauge-${key} interval=$INTERVAL N:`jq .${field} $FILE | sed s/null/0/g`" ;
|
||||
done
|
||||
done
|
||||
|
||||
|
|
Loading…
Reference in a new issue