fix: freebsd compatibility

This commit is contained in:
Christian Flämg 2024-11-11 08:32:53 +01:00
parent bcb110d754
commit 8cf4f2a477
2 changed files with 3 additions and 1 deletions

View file

@ -17,7 +17,7 @@ print_cpu_percentage() {
elif is_osx; then
cached_eval iostat -c 2 disk0 | sed '/^\s*$/d' | tail -n 1 | awk -v format="$cpu_percentage_format" '{usage=100-$6} END {printf(format, usage)}' | sed 's/,/./'
elif is_freebsd || is_openbsd; then
cached_eval iostat -c 2 | sed '/^\s*$/d' | tail -n 1 | awk -v format="$cpu_percentage_format" '{usage=100-$NF} END {printf(format, usage)}' | sed 's/,/./'
cached_eval iostat -c 2 | sed '/^[[:space:]]*$/d' | tail -n 1 | awk -v format="$cpu_percentage_format" '{usage=100-$NF} END {printf(format, usage)}' | sed 's/,/./'
else
echo "Unknown iostat version please create an issue"
fi

View file

@ -17,6 +17,8 @@ print_ram_percentage() {
if command_exists "free"; then
cached_eval free | awk -v format="$ram_percentage_format" '$1 ~ /Mem/ {printf(format, 100*$3/$2)}'
elif command_exists "freecolor"; then # freebsd: install freecolor first: $ pkg install freecolor
cached_eval freecolor -m -o | awk -v format="$ram_percentage_format" '$1 ~ /Mem/ {printf(format, 100*$3/$2)}'
elif command_exists "vm_stat"; then
# page size of 4096 bytes
stats="$(cached_eval vm_stat)"