mirror of
https://github.com/munin-monitoring/contrib.git
synced 2018-11-08 00:59:34 +01:00
Merge pull request #654 from obma/p-openweather_-add_api_key
p: openweather_: Add OpenWeather API Key
This commit is contained in:
commit
884c03b736
@ -13,6 +13,11 @@
|
||||
# http://api.openweathermap.org/data/<api>/weather?<query_string>
|
||||
#
|
||||
|
||||
## From Oct 9 2015 OpenWeather needs you to register and get an APIKEY
|
||||
# include this key by setting 'env.apikey' in munin plugin config, i.e.:
|
||||
# [openweather_*]
|
||||
# env.apikey XYZ
|
||||
|
||||
query_string=$(printf '%s' "${0#*_}" | tr '_' '=')
|
||||
TMPFILE=$(mktemp)
|
||||
trap 'rm -f $TMPFILE' EXIT
|
||||
@ -20,7 +25,7 @@ trap 'rm -f $TMPFILE' EXIT
|
||||
# API returns temp in K, we have to convert it in C
|
||||
KELVIN_BIAS=273
|
||||
|
||||
curl -s "http://api.openweathermap.org/data/2.5/weather?mode=xml&${query_string}" > $TMPFILE
|
||||
curl -s "http://api.openweathermap.org/data/2.5/weather?mode=xml&${query_string}&APPID=${apikey}" > $TMPFILE
|
||||
|
||||
CITY=$(fgrep "<city id=" $TMPFILE | tr -sc '[:alnum:]' ' ' | cut -d " " -f 6)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user