Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 3a8ac8c

Browse files
authored
Merge pull request #18 from Crestwave/solaris
pfetch: initial solaris support
2 parents fcd62e9 + 02a9bd8 commit 3a8ac8c

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

pfetch

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,10 @@ get_os() {
250250
trap '' EXIT
251251
;;
252252

253+
SunOS)
254+
IFS='(' read -r distro _ < /etc/release
255+
;;
256+
253257
*)
254258
# Catch all to ensure '$distro' is never blank.
255259
# This also handles the BSDs.
@@ -371,6 +375,12 @@ get_uptime() {
371375
# regular seconds.
372376
s=$(($(system_time) / 1000000))
373377
;;
378+
379+
SunOS)
380+
IFS=' .' read -r _ s _ <<-EOF
381+
$(kstat -p unix:0:system_misc:snaptime)
382+
EOF
383+
;;
374384
esac
375385

376386
# Convert the uptime from seconds into days, hours and minutes.
@@ -460,6 +470,11 @@ get_pkgs() {
460470
Minix)
461471
printf '%s\n' /usr/pkg/var/db/pkg/*/
462472
;;
473+
474+
SunOS)
475+
has pkginfo && pkginfo -i
476+
has pkg && pkg list
477+
;;
463478
esac | wc -l
464479
`
465480

@@ -616,6 +631,24 @@ get_memory() {
616631
mem_used=$(((mem_full - mem_free) / 1024))
617632
mem_full=$(( mem_full / 1024))
618633
;;
634+
635+
SunOS)
636+
hw_pagesize=$(pagesize)
637+
638+
while read -r key val; do
639+
case $key in
640+
*total) pages_total=$val ;;
641+
*free) pages_free=$val ;;
642+
esac
643+
done <<-EOF
644+
$(kstat -p unix:0:system_pages:pagestotal \
645+
unix:0:system_pages:pagesfree)
646+
EOF
647+
648+
mem_full=$((pages_total * hw_pagesize / 1024 / 1024))
649+
mem_free=$((pages_free * hw_pagesize / 1024 / 1024))
650+
mem_used=$((mem_full - mem_free))
651+
;;
619652
esac
620653

621654
log memory "${mem_used:-?}M / ${mem_full:-?}M" >&6

0 commit comments

Comments
 (0)