Révision e3c55155
[internode_usage] loan from other graphs in root
Also, don't use mathlib with `bc`, as it's not needed, and only adds
spurious fractional bytes to the computed ideal usage.
Signed-off-by: Olivier Mehani <shtrom@ssji.net>
| plugins/isp/internode_usage | ||
|---|---|---|
| 46 | 46 |
|
| 47 | 47 |
* The hourly rate are a bit spikey in the -day view, as the API seems to update |
| 48 | 48 |
every 20 to 30 minutes; it is fine in the -month and more aggregated views |
| 49 |
* The daily rate is the _previous_ day, and does always lag by 24h |
|
| 49 |
* The daily rate is the _previous_ day, and does always lag by 24h.
|
|
| 50 | 50 |
* Due to the way the API seems to update the data, values for the daily rate |
| 51 |
are missing for a short period every day |
|
| 51 |
are missing for a short period every day. This may not play very well with |
|
| 52 |
spoolfetch. |
|
| 52 | 53 |
|
| 53 | 54 |
=head1 AUTHOR |
| 54 | 55 |
|
| 55 | 56 |
Olivier Mehani |
| 56 | 57 |
|
| 57 |
Copyright (C) 2019 Olivier Mehani <shtrom+munin@ssji.net> |
|
| 58 |
Copyright (C) 2019--2021 Olivier Mehani <shtrom+munin@ssji.net>
|
|
| 58 | 59 |
|
| 59 | 60 |
=head1 LICENSE |
| 60 | 61 |
|
| ... | ... | |
| 170 | 171 |
FIRST_DAY="$(date +%s --date "${SERVICE_ROLLOVER} -1 ${SERVICE_INTERVAL}")"
|
| 171 | 172 |
LAST_DAY="$(date +%s --date "${SERVICE_ROLLOVER}")"
|
| 172 | 173 |
BILLING_PERIOD="(${LAST_DAY}-${FIRST_DAY})"
|
| 173 |
IDEAL_USAGE="$(echo "${SERVICE_QUOTA}-(${SERVICE_QUOTA}*(${LAST_DAY}-${CURRENT_TIMESTAMP})/${BILLING_PERIOD})" | bc -ql)"
|
|
| 174 |
IDEAL_USAGE="$(echo "${SERVICE_QUOTA}-(${SERVICE_QUOTA}*(${LAST_DAY}-${CURRENT_TIMESTAMP})/${BILLING_PERIOD})" | bc -q)"
|
|
| 174 | 175 |
|
| 175 | 176 |
USAGE_CRITICAL="${SERVICE_QUOTA}"
|
| 176 | 177 |
fi |
| ... | ... | |
| 238 | 239 |
echo "daily_rate.type GAUGE" |
| 239 | 240 |
|
| 240 | 241 |
;; |
| 242 |
'') |
|
| 243 |
echo "graph_title Uplink usage" |
|
| 244 |
echo "graph_info Username: ${SERVICE_USERNAME}; Service ID: ${SERVICE_ID}; Plan: ${SERVICE_PLAN}"
|
|
| 245 |
echo 'graph_category network' |
|
| 246 |
echo 'graph_vlabel bytes' |
|
| 247 |
echo 'graph_period hour' |
|
| 248 |
echo 'graph_order root_usage=usage.usage root_ideal=usage.ideal' |
|
| 249 |
|
|
| 250 |
echo "root_usage.label Total usage" |
|
| 251 |
echo "root_usage.draw AREA" |
|
| 252 |
echo "root_ideal.extinfo Quota rollover: ${SERVICE_ROLLOVER}"
|
|
| 253 |
echo "root_ideal.label Ideal usage" |
|
| 254 |
echo "root_ideal.draw LINE2" |
|
| 255 |
echo "root_ideal.colour FFA500" |
|
| 256 |
;; |
|
| 241 | 257 |
*) |
| 242 |
#.usage) |
|
| 243 | 258 |
echo "graph_title Uplink usage" |
| 244 | 259 |
echo "graph_info Username: ${SERVICE_USERNAME}; Service ID: ${SERVICE_ID}; Plan: ${SERVICE_PLAN}"
|
| 245 | 260 |
echo 'graph_category network' |
| ... | ... | |
| 250 | 265 |
echo "usage.draw AREA" |
| 251 | 266 |
echo "ideal.extinfo Quota rollover: ${SERVICE_ROLLOVER}"
|
| 252 | 267 |
echo "ideal.label Ideal usage" |
| 253 |
echo "ideal.draw LINE" |
|
| 268 |
echo "ideal.draw LINE2"
|
|
| 254 | 269 |
echo "ideal.colour FFA500" |
| 255 | 270 |
|
| 256 | 271 |
echo "usage.critical ${USAGE_CRITICAL}"
|
| 257 | 272 |
echo "usage.warning ${IDEAL_USAGE}"
|
| 258 |
echo "ideal.critical 0:" |
|
| 259 |
echo "ideal.warning 0:" |
|
| 260 | 273 |
;; |
| 261 | 274 |
esac |
| 262 | 275 |
echo |
| ... | ... | |
| 276 | 289 |
.daily) |
| 277 | 290 |
echo "daily_rate.value ${DAILY_TIMESTAMP}:${DAILY_USAGE:-U}"
|
| 278 | 291 |
;; |
| 292 |
'') |
|
| 293 |
# Nothing to do: all values loaned from the traffic graph |
|
| 294 |
;; |
|
| 279 | 295 |
*) |
| 280 | 296 |
echo "usage.value ${CURRENT_TIMESTAMP}:${SERVICE_USAGE:-U}"
|
| 281 | 297 |
echo "ideal.value ${CURRENT_TIMESTAMP}:${IDEAL_USAGE:-U}"
|
| ... | ... | |
| 290 | 306 |
if [ -n "${host_name:-}" ]; then
|
| 291 | 307 |
echo "host_name ${host_name}"
|
| 292 | 308 |
fi |
| 293 |
graph_config |
|
| 309 |
graph_config ''
|
|
| 294 | 310 |
graph_config usage |
| 295 | 311 |
graph_config daily |
| 296 | 312 |
graph_config current |
| 297 | 313 |
;; |
| 298 | 314 |
*) |
| 299 | 315 |
get_data |
| 300 |
graph_data |
|
| 316 |
graph_data ''
|
|
| 301 | 317 |
graph_data usage |
| 302 | 318 |
graph_data daily |
| 303 | 319 |
graph_data current |
Formats disponibles : Unified diff