Date: Sun, 5 Nov 2006 12:15:14 -0800 From: "Josh Carroll" <josh.carroll@psualum.com> To: "Don O'Neil" <don@lizardhill.com> Cc: freebsd-questions@freebsd.org Subject: Re: Determining system info Message-ID: <8cb6106e0611051215i5d2e8692o2f294d2764bc013@mail.gmail.com> In-Reply-To: <06ca01c70113$84c07400$0400020a@mickey> References: <06ca01c70113$84c07400$0400020a@mickey>
next in thread | previous in thread | raw e-mail | index | archive | help
> if [ "$TYPE" = "load" ]; then > INDATA=`cat /proc/loadavg | cut -d ' ' -f2 | sed 's/\.//g' | sed > 's/^0//g'` > OUTDATA=`cat /proc/loadavg | cut -d ' ' -f3 | sed 's/\.//g' | sed > 's/^0//g'` > fi uptime | sed 's/.*load averages: //g' | cut -d, -f2 | sed 's/.*\.//g' uptime | sed 's/.*load averages: //g' | cut -d, -f3 | sed 's/.*\.//g' > > if [ "$TYPE" = "processes" ]; then > INDATA=`cat /proc/loadavg | cut -d ' ' -f4 | cut -d '/' -f 2` > OUTDATA=`cat /proc/loadavg | cut -d ' ' -f4 | cut -d '/' -f 1` > fi top -d 1 | grep ' processes:' | awk '{print $1}' top -d 1 | grep ' processes:' | sed 's/.*processes: *//g' | awk '{print $1}' > if [ "$TYPE" = "network" ]; then > LINE=`cat /proc/net/dev | grep $PARAM | sed s/$PARAM://` > INDATA=`echo $LINE | awk '{print $1}' ` > OUTDATA=`echo $LINE | awk '{print $9}' ` > fi I'd use snmpd for this one. > if [ "$TYPE" = "swap" ]; then > SWAPFREE=`cat /proc/meminfo | grep "SwapFree" | sed 's/ //g' | cut -d > ':' -f2 | cut -d 'k' -f1` > SWAPTOTAL=`cat /proc/meminfo | grep "SwapTotal" | sed 's/ //g' | cut -d > ':' -f2 | cut -d 'k' -f1` > SWAPUSED=`expr $SWAPTOTAL - $SWAPFREE` > INDATA=$SWAPFREE > OUTDATA=$SWAPUSED > fi swapinfo -k | grep -v '^Device' | awk '{print $4}' swapinfo -k | grep -v '^Device' | awk '{print $3}' (note: this assumes you only have one swap device) > if [ "$TYPE" = "uptime" ]; then > INDATA=`cat /proc/uptime | cut -d ' ' -f1` > OUTDATA=`cat /proc/uptime | cut -d ' ' -f2` > fi You'd probably want some magic to parse the output of uptime and convert the time value into an integer here. > if [ "$TYPE" = "memory" ]; then > INDATA=`free -bt | grep buffers\/cache | awk '{print $3}'` > OUTDATA=`free -bt | grep buffers\/cache | awk '{print $4}'` > fi vmstat | grep -vE '^ *(procs|r b)' | awk '{print $4}' vmstat | grep -vE '^ *(procs|r b)' | awk '{print $5}' Good luck, Josh
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?8cb6106e0611051215i5d2e8692o2f294d2764bc013>