From 16aa5f080cc515d6ec6c33150f2899d93164a305 Mon Sep 17 00:00:00 2001 From: xiao0yy Date: Wed, 13 Oct 2021 16:56:34 +0800 Subject: [PATCH] Support for top version procps-ng --- scripts/cpu_info.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/cpu_info.sh b/scripts/cpu_info.sh index 04d3037..b96e69e 100755 --- a/scripts/cpu_info.sh +++ b/scripts/cpu_info.sh @@ -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 ;;