TWSoft Logo
   Home    Products    Development    Hosting    Consultancy    Contact  


System Monitoring


Belair UK requested TWSoft to develop a method to enable them to establish their bandwidth utilisation. As we used open source tools, we are making our integration available to the wider community

We use two open source utilities, traffacct from Hughes Technologies and rrdtool from Tobi Oetiker. Traffact enables us to monitor the snmp ifInOctet and ifOutOctet parameters. This is a full standalone utility for monitoring network usage and generating reports etc. It is a great utility for an ISP to generate their utilisation reports and bandwith charging invoices but lacks any graphical presentation. This is where rrdtool comes in

Rrdtool is from the same stable as mrtg. the rrd part stands for round robin database. An rrd never grows beyond the initial database defininition. As new data is inserted old data is dropped. It therefore enble you to present rolling historical data.

Follow the installation instructions for both packages. Create an RRD to store your data
. /usr/local/rrdtool-1.0.39/bin/rrdtool create \ throughput.rrd \ DS:In:GAUGE:600:U:U \ DS:Out:GAUGE:600:U:U \ RRA:AVERAGE:0.5:1:600 \ RRA:AVERAGE:0.5:6:700 \ RRA:AVERAGE:0.5:24:775 \ RRA:AVERAGE:0.5:288:797

Next instead of calling the poller command from traffact from within crontab, we call a script. The crontab entry is
*/5 * * * * /vol1/virtual_servers/twsoft/mrtg/

The script is:
#! /bin/sh
today=`date +%d-%b-%Y`
values=`/usr/local/traffacct/tools/export belair $today $today`
in=`echo $values | /bin/awk '{print $1}'`
out=`echo $values | /bin/awk '{print $2}'`
#fill in the rrd
update /vol1/virtual_servers/twsoft/mrtg/throughput.rrd N:$in:$out

Finally we construct the cgi that will be called by our html
In this case we will call it makeimg.cgi
echo Content-type: image/gif
export `echo ${QUERY_STRING} | awk -F"&" '{for(i=1;i<=NF;i++) print $i}'`
/usr/local/rrd/bin/rrdtool graph - --start -${log} \
--alt-y-grid \
-v "Throughput (Mbytes)" \
--lower-limit=0 \
--upper-limit=100 \
--title="Interface throughput "`date "+%D"` \
DEF:IN=/vol1/virtual_servers/twsoft/mrtg/throughput.rrd:In:AVERAGE \
DEF:OUT=/vol1/virtual_servers/twsoft/mrtg/throughput.rrd:Out:AVERAGE \
AREA:OUT#00EF00:Output \

All that is left to do is to call the cgi script makeimg.cgi from an HTML page with appropriate parameters
/cgi-bin/makeimg.cgi?log=1d will produce a daily graph

whereas a log parameter of 1w will produce a weekly graph

log=1m gives a monthly graph

and finally log=1y gives the yearly graph