#!/bin/rc # gfetch - fetch some system stats # usage: gfetch # requires: # - pkg (https://9p.sdf.org/who/bubstance/rc/pkginit.rc.txt) # # Warning, parts of this script have been STOLEN! # # TODO: # - fs usage # - kernel fn storage{ disks=`{ls -d /dev/sd* | uniq} anydisk='false' for(i in $disks){ if(test -f $i/data){ full=`{ls -l $i/data} disk=`{echo $full | awk -F '/' '{print $3}'} size=`{echo $full | awk '{print $6}'} echo $disk^' ('^`{echo $size^' / 1024 / 1024 /1024' | bc}^GB')' anydisk = 'true' } } if(~ $anydisk -c 'false') echo Running diskless } fn fs { if(ls /srv | grep -s '*.cmd') ls /srv/*.cmd | sed 's/.cmd//g' | sed 's/\/srv\///g' if(test -f /srv/fscons) echo fossil # Logic from storage to scrape for venti arenas v='false' disks = `{ls -d /dev/sd* | uniq} for(i in $disks){ if(ls $i | grep -s arena) v='true' } if(~ $v -c 'true') echo venti } fn cpuid { if(test -f /bin/aux/cpuid) aux/cpuid >[2]/dev/null | grep procname | sed 's/.*procname//' } os=`{ if(grep -s 'zrv' /dev/drivers) echo 9ants if not if(grep -s 'vmx' /dev/drivers) echo 9front if not echo Bell Labs } fn pkgls{ if(test -x /bin/pkg/ls){ if(~ `{>[2=] pkg/ls -c} ::*) echo 0 if not >[2=] pkg/ls -c } if not echo n/a } # fs and storage require #S bound on /dev bind -b '#S' /dev arch=`{echo $cputype} shell=/bin/rc uptime=`{uptime | sed 's/.*up//; s/..........$//'} pkgs=`{pkgls} scr=`{dd -count 1