X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=plugins.d%2Floopsleepms.sh.inc;h=ef3db192d4a1bc9ea440748489739b83798d226e;hb=HEAD;hp=00f894b48dc666c151c25e382e511137d108621f;hpb=601109816f5554bc366408a822f7656216d26dac;p=netdata.git diff --git a/plugins.d/loopsleepms.sh.inc b/plugins.d/loopsleepms.sh.inc index 00f894b4..ef3db192 100644 --- a/plugins.d/loopsleepms.sh.inc +++ b/plugins.d/loopsleepms.sh.inc @@ -1,6 +1,6 @@ # no need for shebang - this file is included from other scripts -LOOPSLEEP_DATE="$(which date)" +LOOPSLEEP_DATE="$(which date 2>/dev/null || command -v date 2>/dev/null)" if [ -z "$LOOPSLEEP_DATE" ] then echo >&2 "$0: ERROR: Cannot find the command 'date' in the system path." @@ -13,6 +13,7 @@ fi now_ms= LOOPSLEEPMS_HIGHRES=1 test "$($LOOPSLEEP_DATE +%N)" = "%N" && LOOPSLEEPMS_HIGHRES=0 +test -z "$($LOOPSLEEP_DATE +%N)" && LOOPSLEEPMS_HIGHRES=0 current_time_ms_from_date() { if [ $LOOPSLEEPMS_HIGHRES -eq 0 ] then @@ -138,7 +139,7 @@ loopsleepms() { # calculate ms since last run [ ${LOOPSLEEPMS_LASTRUN} -gt 0 ] && \ - LOOPSLEEPMS_LASTWORK=$((now_ms - LOOPSLEEPMS_LASTRUN - LOOPSLEEPMS_LASTSLEEP)) + LOOPSLEEPMS_LASTWORK=$((now_ms - LOOPSLEEPMS_LASTRUN - LOOPSLEEPMS_LASTSLEEP + current_time_ms_accuracy)) # echo "# last loop's work took $LOOPSLEEPMS_LASTWORK ms" # remember this run