Skip to content

Commit 223077a

Browse files
author
Odran Sourdeval
committed
Adjustments for MacOS (following PR samoshkin#7) and bugfix vmstat
1 parent 29e150f commit 223077a

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

scripts/cpu_collect.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,21 @@ 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
18-
iostat -w "$refresh_interval" -c "$samples_count" \
19-
| stdbuf -o0 awk 'NR > 2 { print 100-$(NF-3); }'
18+
iostat -w "$refresh_interval" -c "$samples_count" \
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
25-
elif ! command_exists "vmstat"; then
25+
elif command_exists "vmstat"; then
2626
if is_freebsd; then
2727
vmstat -n "$refresh_interval" -c "$samples_count" \
2828
| stdbuf -o0 awk 'NR>2 {print 100-$(NF-0)}'

0 commit comments

Comments
 (0)