From 7324a8511e379354451f59772fad87dda4c8d1b3 Mon Sep 17 00:00:00 2001 From: Joe Date: Thu, 25 Aug 2022 10:25:46 +0200 Subject: added load average --- .local/bin/status/sb-cpu | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to '.local/bin/status/sb-cpu') diff --git a/.local/bin/status/sb-cpu b/.local/bin/status/sb-cpu index 58abb72..7770bdb 100755 --- a/.local/bin/status/sb-cpu +++ b/.local/bin/status/sb-cpu @@ -9,14 +9,17 @@ printf " " # for i in $(top -P -d 2 -s 0.2 | grep '^CPU' | tail -n$ncpu | sed '{s/% idle$//;s/.*[[:blank:]]//;s/\..*//;s/^/100 - /;}' | bc); do -case $(top -d 2 -s 0.2 | grep '^CPU' | sed '{1d;s/% idle$//;s/.*[[:blank:]]//;s/\..*//;s/^/(100 - /;s/$/) \/ 12\.5/;}' | bc) in - "0") printf "[ ]";; - "1") printf "[= ]";; - "2") printf "[== ]";; - "3") printf "[=== ]";; - "4") printf "[==== ]";; - "5") printf "[===== ]";; - "6") printf "[====== ]";; - "7") printf "[======= ]";; - "8") printf "[========]";; +stats=$(top -d 2 -s 0.2 | grep -E 'load averages:|^CPU') +printf "%s " "$(echo "$stats" | sed '{1,2d;4d;s/.*averages: *//;s/,.*//;}')" +case $(echo "$stats" | sed '{1,3d;s/% idle$//;s/.*[[:blank:]]//;s/\..*//;s/^/(100 - /;s/$/) \/ 12\.5/;}' | bc) in + "0") printf "[ ]\n";; + "1") printf "[= ]\n";; + "2") printf "[== ]\n";; + "3") printf "[=== ]\n";; + "4") printf "[==== ]\n";; + "5") printf "[===== ]\n";; + "6") printf "[====== ]\n";; + "7") printf "[======= ]\n";; + "8") printf "[========]\n";; esac + -- cgit v1.2.3