Merge pull request #7 from Wayneoween/master

use correct value if running on FreeBSD
This commit is contained in:
Camille TJHOA 2016-01-13 21:58:42 +01:00
commit dd190b1cc9
2 changed files with 7 additions and 1 deletions

View file

@ -10,8 +10,10 @@ print_cpu_percentage() {
printf "%5.1f%%" $usage
elif [ -e "/proc/stat" ]; then
grep 'cpu ' /proc/stat | awk '{usage=($2+$4)*100/($2+$4+$5)} END {printf("%5.1f%", usage)}'
elif [ is_osx ]; then
elif is_osx; then
iostat -w 1 -c 2 -n 1 | tail -1 | awk '{usage=100-$6} END {printf("%d%%",usage)}';
elif is_freebsd; then
iostat -w 1 -c 2 -n 1 | tail -1 | awk '{usage=100-$10} END {printf("%d%%",usage)}';
fi
}

View file

@ -13,6 +13,10 @@ is_osx() {
[ $(uname) == "Darwin" ]
}
is_freebsd() {
[ $(uname) == "FreeBSD" ]
}
is_cygwin() {
command -v WMIC > /dev/null
}