Révision ae13ec95
p: fix openweather_: set correct name for multigraphs
Set 'plugin_name' with 'basename $0' and use this variable instead of $0 to avoid having the full path as name for the multigraphs.
| plugins/weather/openweather_ | ||
|---|---|---|
| 19 | 19 |
# env.apikey XYZ |
| 20 | 20 |
|
| 21 | 21 |
query_string=$(printf '%s' "${0#*_}" | tr '_' '=')
|
| 22 |
plugin_name=$( basename $0 ) |
|
| 22 | 23 |
|
| 23 | 24 |
OWAPI=$( curl -s "http://api.openweathermap.org/data/2.5/weather?mode=xml&${query_string}")
|
| 24 | 25 |
# API returns temp in K, we have to convert it in C |
| ... | ... | |
| 30 | 31 |
if [ "$1" = "config" ]; |
| 31 | 32 |
then |
| 32 | 33 |
cat <<- EOF |
| 33 |
multigraph $0
|
|
| 34 |
multigraph $plugin_name
|
|
| 34 | 35 |
graph_title Temperature in ${CITY}
|
| 35 | 36 |
graph_vlabel Celsius |
| 36 | 37 |
graph_category weather |
| ... | ... | |
| 38 | 39 |
temp_avg.label avg |
| 39 | 40 |
temp_avg.cdef $KELVIN_BIAS,- |
| 40 | 41 |
|
| 41 |
multigraph $0.temp
|
|
| 42 |
multigraph $plugin_name.temp
|
|
| 42 | 43 |
graph_title Temperature in ${CITY}
|
| 43 | 44 |
graph_vlabel Celsius |
| 44 | 45 |
graph_category weather |
| ... | ... | |
| 50 | 51 |
temp_max.label max |
| 51 | 52 |
temp_max.cdef $KELVIN_BIAS,- |
| 52 | 53 |
|
| 53 |
multigraph $0.humidity
|
|
| 54 |
multigraph $plugin_name.humidity
|
|
| 54 | 55 |
graph_title Humidity in ${CITY}
|
| 55 | 56 |
graph_vlabel % |
| 56 | 57 |
graph_category weather |
| 57 | 58 |
graph_info This graph show the humidity in ${CITY}
|
| 58 | 59 |
humidity.label humidity |
| 59 | 60 |
|
| 60 |
multigraph $0.pressure
|
|
| 61 |
multigraph $plugin_name.pressure
|
|
| 61 | 62 |
graph_title Pressure in ${CITY}
|
| 62 | 63 |
graph_vlabel hPa |
| 63 | 64 |
graph_category weather |
| 64 | 65 |
graph_info This graph show the pressure in ${CITY}
|
| 65 | 66 |
pressure.label pressure |
| 66 | 67 |
|
| 67 |
multigraph $0.wind_speed
|
|
| 68 |
multigraph $plugin_name.wind_speed
|
|
| 68 | 69 |
graph_title Wind Speed in ${CITY}
|
| 69 | 70 |
graph_vlabel m/s |
| 70 | 71 |
graph_category weather |
| 71 | 72 |
graph_info This graph show the wind speed in ${CITY}
|
| 72 | 73 |
speed.label wind speed |
| 73 | 74 |
|
| 74 |
multigraph $0.wind_direction
|
|
| 75 |
multigraph $plugin_name.wind_direction
|
|
| 75 | 76 |
graph_title Wind direction in ${CITY}
|
| 76 | 77 |
graph_vlabel m/s |
| 77 | 78 |
graph_category weather |
| ... | ... | |
| 94 | 95 |
WD_DIREC=$( expr "$OWAPI" : '.*\<direction .*value=\"\(.*\)\" code.*/direction.*' ) |
| 95 | 96 |
|
| 96 | 97 |
cat <<- EOF |
| 97 |
multigraph $0
|
|
| 98 |
multigraph $plugin_name
|
|
| 98 | 99 |
temp_avg.value $TEMP_AVG |
| 99 | 100 |
|
| 100 |
multigraph $0.temp
|
|
| 101 |
multigraph $plugin_name.temp
|
|
| 101 | 102 |
temp_avg.value $TEMP_AVG |
| 102 | 103 |
temp_min.value $TEMP_MIN |
| 103 | 104 |
temp_max.value $TEMP_MAX |
| 104 | 105 |
|
| 105 |
multigraph $0.humidity
|
|
| 106 |
multigraph $plugin_name.humidity
|
|
| 106 | 107 |
humidity.value $HUMIDITY |
| 107 | 108 |
|
| 108 |
multigraph $0.pressure
|
|
| 109 |
multigraph $plugin_name.pressure
|
|
| 109 | 110 |
pressure.value $PRESSURE |
| 110 | 111 |
|
| 111 |
multigraph $0.wind_speed
|
|
| 112 |
multigraph $plugin_name.wind_speed
|
|
| 112 | 113 |
speed.value $WD_SPEED |
| 113 | 114 |
|
| 114 |
multigraph $0.wind_direction
|
|
| 115 |
multigraph $plugin_name.wind_direction
|
|
| 115 | 116 |
direction.label $WD_DIREC |
| 116 | 117 |
EOF |
| 117 | 118 |
|
Formats disponibles : Unified diff