diff options
author | Joe <bousset.rudy@gmail.com> | 2022-08-25 10:25:46 +0200 |
---|---|---|
committer | Joe <bousset.rudy@gmail.com> | 2022-08-25 10:25:46 +0200 |
commit | 7324a8511e379354451f59772fad87dda4c8d1b3 (patch) | |
tree | 35dc64e7033f977f387a7bf55eacaeccd0b5d3c9 /.local/bin | |
parent | update (diff) | |
download | dotfiles-bsd-7324a8511e379354451f59772fad87dda4c8d1b3.tar.gz dotfiles-bsd-7324a8511e379354451f59772fad87dda4c8d1b3.tar.bz2 dotfiles-bsd-7324a8511e379354451f59772fad87dda4c8d1b3.tar.xz dotfiles-bsd-7324a8511e379354451f59772fad87dda4c8d1b3.tar.zst dotfiles-bsd-7324a8511e379354451f59772fad87dda4c8d1b3.zip |
added load average
Diffstat (limited to '.local/bin')
-rwxr-xr-x | .local/bin/status/sb-cpu | 23 |
1 files changed, 13 insertions, 10 deletions
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 + |