memory: openbsd memory detection
This commit is contained in:
parent
293807fec8
commit
f4e9f3b4ca
22
pfetch
22
pfetch
|
@ -393,6 +393,26 @@ get_memory() {
|
||||||
# If you run OpenBSD and can send me the full output of
|
# If you run OpenBSD and can send me the full output of
|
||||||
# 'vm_stat' I'll be able to add full support here.
|
# '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
|
||||||
|
# the used memory amount in a lazy way. 'vmstat' prints 3
|
||||||
|
# lines of output with the needed value being stored in the
|
||||||
|
# third and last line.
|
||||||
|
#
|
||||||
|
# This loop simply grabs the 3rd element of each line until
|
||||||
|
# the EOF is reached. Each line overwrites the value of the
|
||||||
|
# previous so we're left with what we wanted. This isn't
|
||||||
|
# slow as only 3 lines are parsed!
|
||||||
|
while read -r _ _ line _; do
|
||||||
|
mem_used=${line%%M}
|
||||||
|
|
||||||
|
# Using '<<-EOF' is the only way to loop over a command's
|
||||||
|
# output without the use of a pipe ('|').
|
||||||
|
# This ensures that any variables defined in the while loop
|
||||||
|
# are still accessible in the script.
|
||||||
|
done <<-EOF
|
||||||
|
$(vmstat)
|
||||||
|
EOF
|
||||||
;;
|
;;
|
||||||
|
|
||||||
FreeBSD*)
|
FreeBSD*)
|
||||||
|
@ -419,7 +439,7 @@ get_memory() {
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
log memory "${mem_used:-?}MiB / ${mem_full:-?}MiB" >&6
|
log memory "${mem_used:-?}M / ${mem_full:-?}M" >&6
|
||||||
}
|
}
|
||||||
|
|
||||||
get_ascii() {
|
get_ascii() {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user