support charts.d.plugin custom retries; fixes #3493
Costa Tsaousis (ktsaou) committed
Mar 9, 2018 at 01:24 UTC
048eb446a9e16afd52163847053e67a18758598b
1 file changed
+8
-3
plugins.d/charts.d.plugin
+8
-3
@@ -477,6 +477,7 @@ all_enabled_charts() {
477
# -----------------------------------------------------------------------------
478
# load the charts
479
480
+suffix_retries="_retries"
481
suffix_update_every="_update_every"
482
active_charts=
483
for chart in $( all_enabled_charts )
@@ -582,7 +583,7 @@ debug "run_charts='$run_charts'"
583
584
[ -z "$run_charts" ] && fatal "No charts to collect data from."
585
585
-declare -A charts_last_update=() charts_update_every=() charts_next_update=() charts_run_counter=() charts_serial_failures=()
586
+declare -A charts_last_update=() charts_update_every=() charts_retries=() charts_next_update=() charts_run_counter=() charts_serial_failures=()
587
global_update() {
588
local exit_at \
589
c=0 dt ret last_ms exec_start_ms exec_end_ms \
@@ -597,7 +598,11 @@ global_update() {
598
for chart in $run_charts
599
do
600
eval "charts_update_every[$chart]=\$$chart$suffix_update_every"
600
- test -z "${charts_update_every[$chart]}" && charts_update_every[$charts]=$update_every
601
+ test -z "${charts_update_every[$chart]}" && charts_update_every[$chart]=$update_every
602
+
603
+ eval "charts_retries[$chart]=\$$chart$suffix_retries"
604
+ test -z "${charts_retries[$chart]}" && charts_retries[$chart]=10
605
+
606
charts_last_update[$chart]=$((now_ms - (now_ms % (charts_update_every[$chart] * 1000) ) ))
607
charts_next_update[$chart]=$(( charts_last_update[$chart] + (charts_update_every[$chart] * 1000) ))
608
charts_run_counter[$chart]=0
@@ -660,7 +665,7 @@ global_update() {
665
else
666
charts_serial_failures[$chart]=$(( charts_serial_failures[$chart] + 1 ))
667
663
- if [ ${charts_serial_failures[$chart]} -gt 10 ]
668
+ if [ ${charts_serial_failures[$chart]} -gt ${charts_retries[$chart]} ]
669
then
670
error "module's '$chart' update() function reported failure ${charts_serial_failures[$chart]} times. Disabling it."
671
else