Merge pull request #18 from Crestwave/solaris

pfetch: initial solaris support
This commit is contained in:
dylan 2019-09-30 20:05:49 +03:00 committed by GitHub
commit 3a8ac8c53d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

33
pfetch
View File

@ -250,6 +250,10 @@ get_os() {
trap '' EXIT
;;
SunOS)
IFS='(' read -r distro _ < /etc/release
;;
*)
# Catch all to ensure '$distro' is never blank.
# This also handles the BSDs.
@ -371,6 +375,12 @@ get_uptime() {
# regular seconds.
s=$(($(system_time) / 1000000))
;;
SunOS)
IFS=' .' read -r _ s _ <<-EOF
$(kstat -p unix:0:system_misc:snaptime)
EOF
;;
esac
# Convert the uptime from seconds into days, hours and minutes.
@ -460,6 +470,11 @@ get_pkgs() {
Minix)
printf '%s\n' /usr/pkg/var/db/pkg/*/
;;
SunOS)
has pkginfo && pkginfo -i
has pkg && pkg list
;;
esac | wc -l
`
@ -616,6 +631,24 @@ get_memory() {
mem_used=$(((mem_full - mem_free) / 1024))
mem_full=$(( mem_full / 1024))
;;
SunOS)
hw_pagesize=$(pagesize)
while read -r key val; do
case $key in
*total) pages_total=$val ;;
*free) pages_free=$val ;;
esac
done <<-EOF
$(kstat -p unix:0:system_pages:pagestotal \
unix:0:system_pages:pagesfree)
EOF
mem_full=$((pages_total * hw_pagesize / 1024 / 1024))
mem_free=$((pages_free * hw_pagesize / 1024 / 1024))
mem_used=$((mem_full - mem_free))
;;
esac
log memory "${mem_used:-?}M / ${mem_full:-?}M" >&6