@cryptotaxi247 / netdata-1 / commits / e2190cf3b

prevent sending microseconds on BEGIN the first time

Costa Tsaousis (ktsaou) committed Jan 22, 2016 at 01:53 UTC e2190cf3b090d21d10fad1c5b2451baa89c2cd09
2 files changed +14 -10
plugins.d/charts.d.plugin
+13 -9
@@ -445,10 +445,10 @@ if [ -z "$run_charts" ]
445 exit 1
446 fi
447
448 -declare -A charts_last_update=() charts_update_every=() charts_next_update=() chart_run_counter=()
448 +declare -A charts_last_update=() charts_update_every=() charts_next_update=() charts_run_counter=()
449 global_update() {
450 local exit_at \
451 - c=0 dt ret exec_start_ms exec_end_ms \
451 + c=0 dt ret last_ms exec_start_ms exec_end_ms \
452 chart now_charts=() next_charts=($run_charts)
453
454 # return the current time in ms in $now_ms
@@ -464,7 +464,7 @@ global_update() {
464 charts_next_update[$chart]=$(( charts_last_update[$chart] + (charts_update_every[$chart] * 1000) ))
465 charts_run_counter[$chart]=0
466
467 - echo "CHART netdata.plugin_$chart '' 'Execution time for $chart plugin' 'milliseconds / run' netdata netdata area 90000 ${charts_update_every[$chart]}"
467 + echo "CHART netdata.plugin_chartsd_$chart '' 'Execution time for $chart plugin' 'milliseconds / run' netdata netdata area 90000 ${charts_update_every[$chart]}"
468 echo "DIMENSION run_time 'run time' absolute 1 1"
469 done
470
@@ -483,10 +483,11 @@ global_update() {
483 # echo >&2 "DEBUG: chart: $chart last: ${charts_last_update[$chart]}, next: ${charts_next_update[$chart]}, now: ${now_ms}"
484 if [ ${now_ms} -ge ${charts_next_update[$chart]} ]
485 then
486 - dt=$(( (now_ms - charts_last_update[$chart]) ))
487 - #echo >&2 "DEBUG: chart: $chart last: ${charts_last_update[$chart]}, next: ${charts_next_update[$chart]}, now: ${now_ms}, dt: ${dt}"
486 + last_ms=${charts_last_update[$chart]}
487 + dt=$(( (now_ms - last_ms) ))
488 + # echo >&2 "DEBUG: chart: $chart last: ${charts_last_update[$chart]}, next: ${charts_next_update[$chart]}, now: ${now_ms}, dt: ${dt}"
489
489 - charts_last_update[$chart]=$now_ms
490 + charts_last_update[$chart]=${now_ms}
491
492 while [ ${charts_next_update[$chart]} -lt ${now_ms} ]
493 do
@@ -495,9 +496,12 @@ global_update() {
496
497 # the first call should not give a duration
498 # so that netdata calibrates to current time
498 - charts_run_counter[$chart]=$(( charts_run_counter[$chart] + 1 ))
499 dt=$(( dt * 1000 ))
500 - test ${charts_run_counter[$chart]} -eq 1 && dt=
500 + charts_run_counter[$chart]=$(( charts_run_counter[$chart] + 1 ))
501 + if [ ${charts_run_counter[$chart]} -eq 1 ]
502 + then
503 + dt=
504 + fi
505
506 exec_start_ms=$now_ms
507 $chart$charts_update $dt
@@ -506,7 +510,7 @@ global_update() {
510 # return the current time in ms in $now_ms
511 current_time_ms; exec_end_ms=$now_ms
512
509 - echo "BEGIN netdata.plugin_$chart $dt"
513 + echo "BEGIN netdata.plugin_chartsd_$chart $dt"
514 if [ $ret -eq 0 ]
515 then
516 echo "SET run_time = $(( exec_end_ms - exec_start_ms ))"
src/rrd.c
+1 -1
@@ -1085,7 +1085,7 @@ unsigned long long rrdset_done(RRDSET *st)
1085
1086 for( ; likely(next_ut <= now_ut) ; next_ut += st->update_every * 1000000ULL, iterations-- ) {
1087 #ifdef NETDATA_INTERNAL_CHECKS
1088 - 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); }
1088 + 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); }
1089 #endif
1090
1091 if(unlikely(st->debug)) {