Determining system info
Don O'Neil
don at lizardhill.com
Sun Nov 5 19:49:37 UTC 2006
I am trying to get someones MRTG script that was evidently written for a
Linux system of some sort working on 6.1....
Here's his script:
#!/bin/sh
TYPE=$1
PARAM=$2
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
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
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
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
if [ "$TYPE" = "uptime" ]; then
INDATA=`cat /proc/uptime | cut -d ' ' -f1`
OUTDATA=`cat /proc/uptime | cut -d ' ' -f2`
fi
if [ "$TYPE" = "memory" ]; then
INDATA=`free -bt | grep buffers\/cache | awk '{print $3}'`
OUTDATA=`free -bt | grep buffers\/cache | awk '{print $4}'`
fi
echo $INDATA
echo $OUTDATA
echo `uptime | cut -d"," -f1,2`
echo $TYPE
Now, how can I recreate the same data gathering in 6.1? Are there utilities
I can run to get the load, # of processes, network, free swap, etc...
Thanks!
More information about the freebsd-questions
mailing list