diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2021-02-07 11:45:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2021-02-07 11:45:55 +0000 |
commit | a8220ab2d293bb7f4b014b79d16b2fb05090fa93 (patch) | |
tree | 77f0a30f016c0925cf7ee9292e644bba183c2774 /collectors/charts.d.plugin/loopsleepms.sh.inc | |
parent | Adding upstream version 1.19.0. (diff) | |
download | netdata-a8220ab2d293bb7f4b014b79d16b2fb05090fa93.tar.xz netdata-a8220ab2d293bb7f4b014b79d16b2fb05090fa93.zip |
Adding upstream version 1.29.0.upstream/1.29.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'collectors/charts.d.plugin/loopsleepms.sh.inc')
-rw-r--r-- | collectors/charts.d.plugin/loopsleepms.sh.inc | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/collectors/charts.d.plugin/loopsleepms.sh.inc b/collectors/charts.d.plugin/loopsleepms.sh.inc index e44eff689..c386083fb 100644 --- a/collectors/charts.d.plugin/loopsleepms.sh.inc +++ b/collectors/charts.d.plugin/loopsleepms.sh.inc @@ -10,16 +10,24 @@ fi # ----------------------------------------------------------------------------- # use the date command as a high resolution timer +# macOS 'date' doesnt support '%N' precision +# echo $(/bin/date +"%N") is "N" +if [ "$($LOOPSLEEP_DATE +"%N")" = "N" ]; then + LOOPSLEEP_DATE_FORMAT="%s * 1000" +else + LOOPSLEEP_DATE_FORMAT="%s * 1000 + 10#%-N / 1000000" +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 - now_ms="$($LOOPSLEEP_DATE +'%s')000" - else - now_ms="$(($($LOOPSLEEP_DATE +'%s * 1000 + %-N / 1000000')))" - fi + if [ $LOOPSLEEPMS_HIGHRES -eq 0 ]; then + now_ms="$($LOOPSLEEP_DATE +'%s')000" + else + now_ms="$(($($LOOPSLEEP_DATE +"$LOOPSLEEP_DATE_FORMAT")))" + fi } # ----------------------------------------------------------------------------- |