Support for top version procps-ng

This commit is contained in:
xiao0yy 2021-10-13 16:56:34 +08:00 committed by GitHub
parent a92fc1913b
commit 16aa5f080c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -9,7 +9,7 @@ get_percent()
{
case $(uname -s) in
Linux)
percent=$(LC_NUMERIC=en_US.UTF-8 top -bn1 | grep "Cpu(s)" | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk '{print 100 - $1"%"}')
percent=$(LC_NUMERIC=en_US.UTF-8 top -bn2 -p 1 | grep "Cpu(s)" | tail -1 | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk '{print 100 - $1"%"}')
normalize_percent_len $percent
;;