diff --git a/scripts/cpu_percentage.sh b/scripts/cpu_percentage.sh index a1e4aa2..7250bc6 100755 --- a/scripts/cpu_percentage.sh +++ b/scripts/cpu_percentage.sh @@ -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 } diff --git a/scripts/helpers.sh b/scripts/helpers.sh index 124e07a..c7e396d 100644 --- a/scripts/helpers.sh +++ b/scripts/helpers.sh @@ -13,6 +13,10 @@ is_osx() { [ $(uname) == "Darwin" ] } +is_freebsd() { + [ $(uname) == "FreeBSD" ] +} + is_cygwin() { command -v WMIC > /dev/null }