]> arthur.barton.de Git - netdata.git/commitdiff
prevent sending microseconds on BEGIN the first time
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Thu, 21 Jan 2016 23:53:07 +0000 (01:53 +0200)
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Thu, 21 Jan 2016 23:53:07 +0000 (01:53 +0200)
plugins.d/charts.d.plugin
src/rrd.c

index 89022eeb890f449b84e11f621ee24c3ff888e118..dea216a829984ee5abb5b902b9fd2ca2ac66b134 100755 (executable)
@@ -445,10 +445,10 @@ if [ -z "$run_charts" ]
        exit 1
 fi
 
-declare -A charts_last_update=() charts_update_every=() charts_next_update=() chart_run_counter=()
+declare -A charts_last_update=() charts_update_every=() charts_next_update=() charts_run_counter=()
 global_update() {
        local exit_at \
-               c=0 dt ret exec_start_ms exec_end_ms \
+               c=0 dt ret last_ms exec_start_ms exec_end_ms \
                chart now_charts=() next_charts=($run_charts)
 
        # return the current time in ms in $now_ms
@@ -464,7 +464,7 @@ global_update() {
                charts_next_update[$chart]=$(( charts_last_update[$chart] + (charts_update_every[$chart] * 1000) ))
                charts_run_counter[$chart]=0
 
-               echo "CHART netdata.plugin_$chart '' 'Execution time for $chart plugin' 'milliseconds / run' netdata netdata area 90000 ${charts_update_every[$chart]}"
+               echo "CHART netdata.plugin_chartsd_$chart '' 'Execution time for $chart plugin' 'milliseconds / run' netdata netdata area 90000 ${charts_update_every[$chart]}"
                echo "DIMENSION run_time 'run time' absolute 1 1"
        done
 
@@ -483,10 +483,11 @@ global_update() {
                        # echo >&2 "DEBUG: chart: $chart last: ${charts_last_update[$chart]}, next: ${charts_next_update[$chart]}, now: ${now_ms}"
                        if [ ${now_ms} -ge ${charts_next_update[$chart]} ]
                        then
-                               dt=$(( (now_ms - charts_last_update[$chart]) ))
-                               #echo >&2 "DEBUG: chart: $chart last: ${charts_last_update[$chart]}, next: ${charts_next_update[$chart]}, now: ${now_ms}, dt: ${dt}"
+                               last_ms=${charts_last_update[$chart]}
+                               dt=$(( (now_ms - last_ms) ))
+                               # echo >&2 "DEBUG: chart: $chart last: ${charts_last_update[$chart]}, next: ${charts_next_update[$chart]}, now: ${now_ms}, dt: ${dt}"
 
-                               charts_last_update[$chart]=$now_ms
+                               charts_last_update[$chart]=${now_ms}
 
                                while [ ${charts_next_update[$chart]} -lt ${now_ms} ]
                                do
@@ -495,9 +496,12 @@ global_update() {
 
                                # the first call should not give a duration
                                # so that netdata calibrates to current time
-                               charts_run_counter[$chart]=$(( charts_run_counter[$chart] + 1 ))
                                dt=$(( dt * 1000 ))
-                               test ${charts_run_counter[$chart]} -eq 1 && dt=
+                               charts_run_counter[$chart]=$(( charts_run_counter[$chart] + 1 ))
+                               if [ ${charts_run_counter[$chart]} -eq 1 ]
+                                       then
+                                       dt=
+                               fi
 
                                exec_start_ms=$now_ms
                                $chart$charts_update $dt
@@ -506,7 +510,7 @@ global_update() {
                                # return the current time in ms in $now_ms
                                current_time_ms; exec_end_ms=$now_ms
 
-                               echo "BEGIN netdata.plugin_$chart $dt"
+                               echo "BEGIN netdata.plugin_chartsd_$chart $dt"
                                if [ $ret -eq 0 ]
                                then
                                        echo "SET run_time = $(( exec_end_ms - exec_start_ms ))"
index 5600375f68d03c9e902b26b7999f6316cd463071..26dee5ff22616921ab09487b774c0a56f1184299 100755 (executable)
--- a/src/rrd.c
+++ b/src/rrd.c
@@ -1085,7 +1085,7 @@ unsigned long long rrdset_done(RRDSET *st)
 
        for( ; likely(next_ut <= now_ut) ; next_ut += st->update_every * 1000000ULL, iterations-- ) {
 #ifdef NETDATA_INTERNAL_CHECKS
-               if(iterations <= 0) { error("iterations calculation wrapped! first_ut = %llu, last_ut = %llu, next_ut = %llu, now_ut = %llu", first_ut, last_ut, next_ut, now_ut); }
+               if(iterations < 0) { error("%s: iterations calculation wrapped! first_ut = %llu, last_ut = %llu, next_ut = %llu, now_ut = %llu", st->name, first_ut, last_ut, next_ut, now_ut); }
 #endif
 
                if(unlikely(st->debug)) {