[rrd-users] Database never updates

Geoffrey Gallaway geoffeg at geoffeg.org
Mon May 24 19:19:02 MEST 2004


Hello, I'm trying to create a bandwidth utilization graph for my router. I
don't want to install SNMPd and use up the little RAM I have in the box so I
just decided to write a shell script to wrap ifconfig. However, it's not
working, the database is created but no values are ever entered. just ton's
of NaN's. The script is below:

#!/bin/sh
if [ ! -a /home/geoffeg/rrdscripts/eth0.rrd ]; then
        rrdtool create /home/geoffeg/rrdscripts/eth0.rrd \
        --step 60 \
        DS:inbound:GAUGE:120:0:U \
        DS:outbound:GAUGE:120:0:U \
        RRA:AVERAGE:0.5:1:43200
fi

ip=`/sbin/ifconfig eth0 | grep inet | awk '{ print $2 }' | cut -c6-`

newrx=`/sbin/ifconfig eth0 | grep 'RX bytes' | awk '{ print $2 }' | cut -c7-`
newtx=`/sbin/ifconfig eth0 | grep 'RX bytes' | awk '{ print $6 }' | cut -c7-`

oldrx=`cat /home/geoffeg/rrdscripts/eth0rx.txt`
oldtx=`cat /home/geoffeg/rrdscripts/eth0tx.txt`

echo $newrx > /home/geoffeg/rrdscripts/eth0rx.txt
echo $newtx > /home/geoffeg/rrdscripts/eth0tx.txt

rx=`echo $newrx-$oldrx | bc`
tx=`echo $newtx-$oldtx | bc`
rxdiv=`echo $rx/1024/60 | bc`
txdiv=`echo $tx/1024/60 | bc`

rrdtool update /home/geoffeg/rrdscripts/eth0.rrd N:$rx:$tx

rrdtool graph /var/www/localhost/images/eth0.png \
        -w 600 -h 150 -a PNG -v "Kbytes/sec" \
        --title "External Interface Bandwidth Usage" \
        DEF:in=/home/geoffeg/rrdscripts/eth0.rrd:inbound:AVERAGE \
        "CDEF:inbd=in,1024,/,60,/" \
        DEF:out=/home/geoffeg/rrdscripts/eth0.rrd:outbound:AVERAGE \
        "CDEF:outbd=out,1024,/,60,/" \
        LINE1:inbd#00a000:"Inbound" \
        COMMENT:"@ $rxdiv Kbytes/sec" \
        LINE1:outbd#ff0000:"Outbound" \
        COMMENT:"@ $txdiv Kbytes/sec"


Thanks,
Geoffeg

--
Unsubscribe mailto:rrd-users-request at list.ee.ethz.ch?subject=unsubscribe
Help        mailto:rrd-users-request at list.ee.ethz.ch?subject=help
Archive     http://www.ee.ethz.ch/~slist/rrd-users
WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi



More information about the rrd-users mailing list