add OpenBSD
This commit is contained in:
parent
0810927136
commit
5cd6616479
2 changed files with 25 additions and 1 deletions
|
@ -21,6 +21,14 @@ get_percent()
|
||||||
normalize_percent_len $percent
|
normalize_percent_len $percent
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
OpenBSD)
|
||||||
|
cpuvalue=$(ps -A -o %cpu | awk -F. '{s+=$1} END {print s}')
|
||||||
|
cpucores=$(sysctl -n hw.ncpuonline)
|
||||||
|
cpuusage=$(( cpuvalue / cpucores ))
|
||||||
|
percent="$cpuusage%"
|
||||||
|
normalize_percent_len $percent
|
||||||
|
;;
|
||||||
|
|
||||||
CYGWIN*|MINGW32*|MSYS*|MINGW*)
|
CYGWIN*|MINGW32*|MSYS*|MINGW*)
|
||||||
# TODO - windows compatability
|
# TODO - windows compatability
|
||||||
;;
|
;;
|
||||||
|
@ -29,7 +37,7 @@ get_percent()
|
||||||
|
|
||||||
get_load() {
|
get_load() {
|
||||||
case $(uname -s) in
|
case $(uname -s) in
|
||||||
Linux | Darwin)
|
Linux | Darwin | OpenBSD)
|
||||||
loadavg=$(uptime | awk -F'[a-z]:' '{ print $2}' | sed 's/,//g')
|
loadavg=$(uptime | awk -F'[a-z]:' '{ print $2}' | sed 's/,//g')
|
||||||
echo $loadavg
|
echo $loadavg
|
||||||
;;
|
;;
|
||||||
|
|
|
@ -56,6 +56,22 @@ get_percent()
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
OpenBSD)
|
||||||
|
# vmstat -s | grep "pages managed" | sed -ne 's/^ *\([0-9]*\).*$/\1/p'
|
||||||
|
# Looked at the code from neofetch
|
||||||
|
hw_pagesize="$(pagesize)"
|
||||||
|
free_mem=$(($(vmstat -s | grep "pages free$" | sed -ne 's/^ *\([0-9]*\).*$/\1/p') * hw_pagesize / 1024 / 1024 ))
|
||||||
|
total_mem=$(($(sysctl -n hw.physmem) / 1024 / 1024))
|
||||||
|
used_mem=$((total_mem - free_mem))
|
||||||
|
total_mem=$(($total_mem/1024))
|
||||||
|
if (( $used_mem < 1024 )); then
|
||||||
|
echo $used_mem\M\B/$total_mem\G\B
|
||||||
|
else
|
||||||
|
memory=$(($used_mem/1024))
|
||||||
|
echo $memory\G\B/$total_mem\G\B
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
CYGWIN*|MINGW32*|MSYS*|MINGW*)
|
CYGWIN*|MINGW32*|MSYS*|MINGW*)
|
||||||
# TODO - windows compatability
|
# TODO - windows compatability
|
||||||
;;
|
;;
|
||||||
|
|
Loading…
Reference in a new issue