From 69b20e322857cfe000e49e6fea9c0b48295da1e2 Mon Sep 17 00:00:00 2001 From: Jo Geraerts Date: Thu, 16 Jan 2020 11:01:57 +0100 Subject: [PATCH] do a fflush() in the awk script stdbuf is not available on osx so flush the output using fflush in awk. --- scripts/cpu_collect.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/cpu_collect.sh b/scripts/cpu_collect.sh index 768caba..16546f9 100755 --- a/scripts/cpu_collect.sh +++ b/scripts/cpu_collect.sh @@ -16,7 +16,7 @@ get_cpu_usage() { if is_osx; then if command_exists "iostat"; then iostat -w "$refresh_interval" -c "$samples_count" \ - | stdbuf -o0 awk 'NR > 2 { print 100-$(NF-3); }' + | awk 'NR > 2 { print 100-$(NF-3); fflush(""); }' else top -l "$samples_count" -s "$refresh_interval" -n 0 \ | sed -u -nr '/CPU usage/s/.*,[[:space:]]*([0-9]+[.,][0-9]*)%[[:space:]]*idle.*/\1/p' \