From 8893cfa8a172ede6ad93d792bc62bf1790810f3c Mon Sep 17 00:00:00 2001 From: kaliko Date: Mon, 29 May 2017 13:50:38 +0200 Subject: [PATCH 1/5] Add missing apiid in URL --- plugins/weather/openweather_ | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/weather/openweather_ b/plugins/weather/openweather_ index 45b9610d..cce41ab5 100755 --- a/plugins/weather/openweather_ +++ b/plugins/weather/openweather_ @@ -16,9 +16,10 @@ ## 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 +# env.owapikey XYZ query_string=$(printf '%s' "${0#*_}" | tr '_' '=') +query_string="$query_string&appid=$owapikey" plugin_name=$( basename $0 ) OWAPI=$( curl -s "http://api.openweathermap.org/data/2.5/weather?mode=xml&${query_string}") From 7e0a33e40f79eef844903c848550bf12dda11911 Mon Sep 17 00:00:00 2001 From: kaliko Date: Tue, 30 May 2017 12:38:45 +0200 Subject: [PATCH 2/5] Switch to metric system, get rid of kelvin offset Improved readability Revert env. var. name change --- plugins/weather/openweather_ | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/plugins/weather/openweather_ b/plugins/weather/openweather_ index cce41ab5..1aa3b7e4 100755 --- a/plugins/weather/openweather_ +++ b/plugins/weather/openweather_ @@ -16,16 +16,13 @@ ## 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.owapikey XYZ +# env.apikey XYZ -query_string=$(printf '%s' "${0#*_}" | tr '_' '=') -query_string="$query_string&appid=$owapikey" +location=$(printf '%s' "${0#*_}" | tr '_' '=') +query_string="${location}&appid=${apikey}&units=metric" plugin_name=$( basename $0 ) OWAPI=$( curl -s "http://api.openweathermap.org/data/2.5/weather?mode=xml&${query_string}") -# API returns temp in K, we have to convert it in C -# &units=metric would change that ;-) -KELVIN_BIAS=273 CITY=$( expr "$OWAPI" : '.*\ Date: Tue, 30 May 2017 21:16:43 +0200 Subject: [PATCH 3/5] Set upper/lower limit for humidity and wind direction --- plugins/weather/openweather_ | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/weather/openweather_ b/plugins/weather/openweather_ index 1aa3b7e4..1eef9bd8 100755 --- a/plugins/weather/openweather_ +++ b/plugins/weather/openweather_ @@ -49,6 +49,7 @@ then graph_title Humidity in ${CITY} graph_vlabel % graph_category sensors + graph_args --upper-limit 100 --lower-limit 0 graph_info This graph show the humidity in ${CITY} humidity.label humidity @@ -70,8 +71,10 @@ then graph_title Wind direction in ${CITY} graph_vlabel direction graph_category sensors + graph_args --upper-limit 360 --lower-limit 0 graph_info This graph show the wind direction in ${CITY} direction.label wind direction + EOF # Continue if dirty config is enabled From 782c8138870f316c2af20e92a70b0b53ce8dab52 Mon Sep 17 00:00:00 2001 From: kaliko Date: Tue, 30 May 2017 21:18:32 +0200 Subject: [PATCH 4/5] Avoid same multigraph and field name (prevent hitting munin-monitoring/munin#828) --- plugins/weather/openweather_ | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/weather/openweather_ b/plugins/weather/openweather_ index 1eef9bd8..1c84d826 100755 --- a/plugins/weather/openweather_ +++ b/plugins/weather/openweather_ @@ -51,14 +51,14 @@ then graph_category sensors graph_args --upper-limit 100 --lower-limit 0 graph_info This graph show the humidity in ${CITY} - humidity.label humidity + humi.label humidity multigraph $plugin_name.pressure graph_title Pressure in ${CITY} graph_vlabel hPa graph_category sensors graph_info This graph show the pressure in ${CITY} - pressure.label pressure + press.label pressure multigraph $plugin_name.wind_speed graph_title Wind Speed in ${CITY} @@ -101,10 +101,10 @@ cat <<- EOF temp_max.value $TEMP_MAX multigraph $plugin_name.humidity - humidity.value $HUMIDITY + humi.value $HUMIDITY multigraph $plugin_name.pressure - pressure.value $PRESSURE + press.value $PRESSURE multigraph $plugin_name.wind_speed speed.value $WD_SPEED From 32d620ccf3a3f87ec8c6a15c0a59bac2dcb9ec7c Mon Sep 17 00:00:00 2001 From: kaliko Date: Wed, 31 May 2017 11:25:16 +0200 Subject: [PATCH 5/5] Revert switch to metric system 7e0a33e4 --- plugins/weather/openweather_ | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/plugins/weather/openweather_ b/plugins/weather/openweather_ index 1c84d826..ea232028 100755 --- a/plugins/weather/openweather_ +++ b/plugins/weather/openweather_ @@ -19,10 +19,11 @@ # env.apikey XYZ location=$(printf '%s' "${0#*_}" | tr '_' '=') -query_string="${location}&appid=${apikey}&units=metric" +query_string="${location}&appid=${apikey}" plugin_name=$( basename $0 ) OWAPI=$( curl -s "http://api.openweathermap.org/data/2.5/weather?mode=xml&${query_string}") +KELVIN_BIAS=273 CITY=$( expr "$OWAPI" : '.*\