Skip to content

Commit 1626c66

Browse files
authored
Merge pull request #1 from slange-dev/Make-cpu_collect-compatible-with-OSX-and-use-gstdbuf
Make cpu_collect compatible with OSX and use gstdbuf
2 parents 29e150f + 643f57b commit 1626c66

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

scripts/cpu_collect.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@ set -e
88
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
99
source "$CURRENT_DIR/helpers.sh"
1010

11-
refresh_interval=$(get_tmux_option "status-interval" "5")
12-
samples_count="60"
11+
refresh_interval=$(get_tmux_option "status-interval" "5")/2
12+
samples_count="2"
1313
cpu_metric_file="$(get_tmux_option "@sysstat_cpu_tmp_dir" "/dev/null")/cpu_collect.metric"
1414

1515
get_cpu_usage() {
1616
if is_osx; then
1717
if command_exists "iostat"; then
1818
iostat -w "$refresh_interval" -c "$samples_count" \
19-
| stdbuf -o0 awk 'NR > 2 { print 100-$(NF-3); }'
19+
| gstdbuf -o0 awk 'NR > 2 { print 100-$(NF-3); }'
2020
else
2121
top -l "$samples_count" -s "$refresh_interval" -n 0 \
2222
| sed -u -nr '/CPU usage/s/.*,[[:space:]]*([0-9]+[.,][0-9]*)%[[:space:]]*idle.*/\1/p' \
23-
| stdbuf -o0 awk '{ print 100-$0 }'
23+
| gstdbuf -o0 awk '{ print 100-$0 }'
2424
fi
2525
elif ! command_exists "vmstat"; then
2626
if is_freebsd; then

0 commit comments

Comments
 (0)