From 760fe8ac11bf1b273cdcf1f741de6348c90f9323 Mon Sep 17 00:00:00 2001 From: Aaron Kollasch Date: Fri, 16 May 2025 02:19:21 -0400 Subject: [PATCH] Fix cpu_info bug Grepping the output of top could sometimes return the grep process, leading to a nonsensical %CPU reading. --- 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 9e73956e..ebbb040f 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 -bn2 -d 0.01 | grep "Cpu(s)" | tail -1 | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk '{print 100 - $1"%"}') + percent=$(LC_NUMERIC=en_US.UTF-8 top -bn2 -d 0.01 | grep "[C]pu(s)" | tail -1 | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk '{print 100 - $1"%"}') normalize_percent_len $percent ;;