Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 5 Nov 2006 11:49:34 -0800
From:      "Don O'Neil" <don@lizardhill.com>
To:        <freebsd-questions@freebsd.org>
Subject:   Determining system info
Message-ID:  <06ca01c70113$84c07400$0400020a@mickey>

next in thread | raw e-mail | index | archive | help
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!




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?06ca01c70113$84c07400$0400020a>