sb-cpu: """cleanup"""
This commit is contained in:
parent
a9d5afa7fe
commit
abd90c1ad5
1 changed files with 7 additions and 7 deletions
|
@ -21,23 +21,23 @@ first=true
|
||||||
IFS='
|
IFS='
|
||||||
'
|
'
|
||||||
for i in $(seq "$n_cpu"); do
|
for i in $(seq "$n_cpu"); do
|
||||||
old_idle=$(echo "$old" | awk -v i="$i" 'NR==i { print $1 }')
|
eval "$(echo "$old" | awk -v i="$i" 'NR==i { printf "old_idle=%s old_total=%s", $1, $2 }')"
|
||||||
old_total=$(echo "$old" | awk -v i="$i" 'NR==i { print $2 }')
|
eval "$(echo "$new" | awk -v i="$i" 'NR==i { printf "new_idle=%s new_total=%s", $1, $2 }')"
|
||||||
new_idle=$(echo "$new" | awk -v i="$i" 'NR==i { print $1 }')
|
|
||||||
new_total=$(echo "$new" | awk -v i="$i" 'NR==i { print $2 }')
|
|
||||||
|
|
||||||
|
# shellcheck disable=SC2154
|
||||||
delta_idle=$((new_idle - old_idle))
|
delta_idle=$((new_idle - old_idle))
|
||||||
|
# shellcheck disable=SC2154
|
||||||
delta_total=$((new_total - old_total))
|
delta_total=$((new_total - old_total))
|
||||||
|
|
||||||
percent=$(((delta_total - delta_idle) * 100 / delta_total))
|
percent=$(((delta_total - delta_idle) * 100 / delta_total))
|
||||||
|
|
||||||
meter=$(meter_bar "$percent")
|
eval "$(meter_bar "$percent" | awk -F: '{ printf "color=\"%s\" bar=\"%s\"", $1, $2 }')"
|
||||||
|
|
||||||
color=$(echo "$meter" | cut -d: -f1)
|
|
||||||
if [ "$color" != "$prevcolor" ]; then
|
if [ "$color" != "$prevcolor" ]; then
|
||||||
$first || printf "%b" "</span>"
|
$first || printf "%b" "</span>"
|
||||||
printf "%b" "<span $color>"
|
printf "%b" "<span $color>"
|
||||||
fi
|
fi
|
||||||
printf "%b" "$(echo "$meter" | cut -d: -f2)"
|
printf "%b" "$bar"
|
||||||
|
|
||||||
first=false
|
first=false
|
||||||
prevcolor=$color
|
prevcolor=$color
|
||||||
|
|
Loading…
Add table
Reference in a new issue