blob: 58abb72cc65c55c141b321b4b704e70e785cf6b9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
#!/bin/sh
# ncpu_file="/tmp/ncpu"
# if [ -f $ncpu_file ]; then
# ncpu=$(cat $ncpu_file)
# else
# ncpu=$(sysctl -n hw.ncpu | tee $ncpu_file)
# fi
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 "[========]";;
esac
|