memory: freebsd support
This commit is contained in:
parent
add7638066
commit
223de3d82a
29
pfetch
29
pfetch
|
@ -212,7 +212,7 @@ get_host() {
|
||||||
host="$name $version $model"
|
host="$name $version $model"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
Darwin*)
|
Darwin*|FreeBSD*)
|
||||||
host=$(sysctl -n hw.model)
|
host=$(sysctl -n hw.model)
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
@ -401,8 +401,6 @@ get_memory() {
|
||||||
;;
|
;;
|
||||||
|
|
||||||
OpenBSD*)
|
OpenBSD*)
|
||||||
# If you run OpenBSD and can send me the full output of
|
|
||||||
# 'vm_stat' I'll be able to add full support here.
|
|
||||||
mem_full=$(($(sysctl -n hw.physmem) / 1024 / 1024))
|
mem_full=$(($(sysctl -n hw.physmem) / 1024 / 1024))
|
||||||
|
|
||||||
# This is a really simpler parser for 'vmstat' which grabs
|
# This is a really simpler parser for 'vmstat' which grabs
|
||||||
|
@ -426,10 +424,31 @@ get_memory() {
|
||||||
EOF
|
EOF
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
# Used memory is calculated using the following "formula" (FreeBSD):
|
||||||
|
# (inactive_count + free_count + cache_count) * page_size / 1024
|
||||||
FreeBSD*)
|
FreeBSD*)
|
||||||
# If you run FreeBSD and can help me get
|
|
||||||
# the used memory amount, I'll be able to add support here.
|
|
||||||
mem_full=$(($(sysctl -n hw.physmem) / 1024 / 1024))
|
mem_full=$(($(sysctl -n hw.physmem) / 1024 / 1024))
|
||||||
|
|
||||||
|
# Use 'set --' to store the output of the command in the
|
||||||
|
# argument list. POSIX sh has no arrays but this is close enough.
|
||||||
|
#
|
||||||
|
# Disable the shellcheck warning for word-splitting
|
||||||
|
# as it's safe and intended ('set -f' disables globbing).
|
||||||
|
# shellcheck disable=2046
|
||||||
|
{
|
||||||
|
set -f
|
||||||
|
set +f -- $(sysctl -n hw.pagesize \
|
||||||
|
vm.stats.vm.v_inactive_count \
|
||||||
|
vm.stats.vm.v_free_count \
|
||||||
|
vm.stats.vm.v_cache_count)
|
||||||
|
}
|
||||||
|
|
||||||
|
# Calculate the amount of free memory.
|
||||||
|
# $1: hw.pagesize
|
||||||
|
# $2: vm.stats.vm.v_inactive_count
|
||||||
|
# $3: vm.stats.vm.v_free_count
|
||||||
|
# $4: vm.stats.vm.v_cache_count
|
||||||
|
mem_free=$((($2 + $3 + $4) * $1 / 1024 / 1024))
|
||||||
;;
|
;;
|
||||||
|
|
||||||
NetBSD*)
|
NetBSD*)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user