Added cpu speed for FreeBSD

This commit is contained in:
Dylan 2016-01-19 17:33:41 +11:00
parent ec5b826d27
commit f4982c76f5
1 changed files with 26 additions and 21 deletions

47
fetch
View File

@ -380,7 +380,7 @@ getuptime () {
uptime="$(uptime -p)" uptime="$(uptime -p)"
;; ;;
"Mac OS X" | "OpenBSD" | "BSD") "Mac OS X" | *"BSD")
# Get boot time in seconds # Get boot time in seconds
boot="$(sysctl -n kern.boottime)" boot="$(sysctl -n kern.boottime)"
boot="${boot/{ sec = /}" boot="${boot/{ sec = /}"
@ -485,12 +485,12 @@ getpackages () {
fi fi
;; ;;
"FreeBSD") "OpenBSD" | "NetBSD")
packages=$(pkg info | wc -l) packages=$(pkg_info | wc -l)
;; ;;
*"BSD") "FreeBSD")
packages=$(pkg_info | wc -l) packages=$(pkg info | wc -l)
;; ;;
"Windows"*) "Windows"*)
@ -585,6 +585,15 @@ getcpu () {
cpu="$cpu @ ${speed}GHz" cpu="$cpu @ ${speed}GHz"
;; ;;
"FreeBSD")
cpu="$(sysctl -n hw.model)"
speed="$(sysctl -n hw.clockrate)"
speed=$((speed / 100))
speed=${speed:0:1}.${speed:1}
cpu="$cpu @ ${speed}GHz"
;;
"NetBSD") "NetBSD")
# Get cpu name # Get cpu name
cpu="$(grep -F 'model name' /proc/cpuinfo)" cpu="$(grep -F 'model name' /proc/cpuinfo)"
@ -602,10 +611,6 @@ getcpu () {
cpu="$cpu @ ${speed}GHz" cpu="$cpu @ ${speed}GHz"
;; ;;
*)
cpu="$(sysctl -n hw.model)"
;;
esac esac
;; ;;
@ -727,6 +732,18 @@ getmemory () {
"OpenBSD" | "BSD") "OpenBSD" | "BSD")
case "$distro" in case "$distro" in
"OpenBSD")
memtotal=$(dmesg | awk '/real mem/ {printf $5}')
memtotal=${memtotal/\(/}
memtotal=${memtotal/MB\)/}
memfree=$(top -d 1 | awk '/Real:/ {print $6}')
memfree=${memfree/M/}
memused=$((memtotal - memfree))
memory="${memused}MB / ${memtotal}MB"
;;
"FreeBSD") "FreeBSD")
memtotal=$(dmesg | awk '/real mem/ {printf $5}') memtotal=$(dmesg | awk '/real mem/ {printf $5}')
memtotal=${memtotal/\(/} memtotal=${memtotal/\(/}
@ -747,18 +764,6 @@ getmemory () {
memused=$((memtotal - memfree)) memused=$((memtotal - memfree))
memory="${memused}MB / ${memtotal}MB" memory="${memused}MB / ${memtotal}MB"
;; ;;
*)
memtotal=$(dmesg | awk '/real mem/ {printf $5}')
memtotal=${memtotal/\(/}
memtotal=${memtotal/MB\)/}
memfree=$(top -d 1 | awk '/Real:/ {print $6}')
memfree=${memfree/M/}
memused=$((memtotal - memfree))
memory="${memused}MB / ${memtotal}MB"
;;
esac esac
;; ;;