Graph Network Usage
Jeff Stuart
jeff at myinternetservices.com
Sun Jun 25 15:04:13 CEST 2006
As we all know, you can use MRTG + SNMP to graph network usage. BUT instead
of having to install 2 new programs + an external hobbit script that runs
either on each box or on a centralized location, you can use this external
script that runs on the client.
Basically it just grabs the data from the /proc/net/dev file. Note: this
probably only works on Linux.
Then you add the following lines to your hobbitserver.cfg:
TEST2RRD="cpu=la,disk,inode,...,hobbitd,bandwidth=ncv"
NCV_bandwidth="bytesin:COUNTER,bytesout:COUNTER"
GRAPHS="la,disk,inode,...,hobbitd,ncv,bandwidth"
Then in your hobbitgraph.cfg, add this entry:
[bandwidth]
TITLE Network Traffic
YAXIS Bits/Second
DEF:inbytes=bandwidth.rrd:bytesin:AVERAGE
CDEF:in=inbytes,8,*
DEF:outbytes=bandwidth.rrd:bytesout:AVERAGE
CDEF:out=outbytes,8,*
CDEF:total=in,out,+
VDEF:pct95=total,95,PERCENT
LINE2:in#00FF00:Inbound
GPRINT:in:LAST: \: %9.1lf (cur)
GPRINT:in:MAX: \: %9.1lf (max)
GPRINT:in:MIN: \: %9.1lf (min)
GPRINT:in:AVERAGE: \: %9.1lf (avg)\n
LINE2:out#FF0000:Outbound
GPRINT:out:LAST: \: %9.1lf (cur)
GPRINT:out:MAX: \: %9.1lf (max)
GPRINT:out:MIN: \: %9.1lf (min)
GPRINT:out:AVERAGE: \: %9.1lf (avg)\n
LINE2:total#00CCCC:Total Usage
GPRINT:total:LAST: \: %8.1lf (cur)
GPRINT:total:MAX: \: %8.1lf (max)
GPRINT:total:MIN: \: %8.1lf (min)
GPRINT:total:AVERAGE: \: %9.1lf (avg)\n
LINE1:pct95#0000FF:Outbound 95th percentile
GPRINT:pct95:\: %6.2lf %Sbps \n
And then finally setup this script as an external script for each client:
#!/bin/sh
/bin/grep eth0 /proc/net/dev | /bin/awk '{print "bytes_in : "
$2 "\nbytes_out : " $10}' > $BBTMP/bandwidth.txt
$BB $BBDISP "status $MACHINE.bandwidth green `date`
`cat $BBTMP/bandwidth.txt`
"
/bin/rm $BBTMP/bandwidth.txt
exit 0
Hope this helps someone!
P.S.
Thx Henrik for your EXCELLENT tutorial on the NCV graph stuff. Made my job a
1000x easier! :) Also, in the next week, I'm gonna be blowing my boss's mind
with some of the stuff I'll be able to track and graph. Hehe.. there's just
SOO MUCH you can do when you can do it on the command line vs a windows
program that can only access stuff via SNMP/TCP/UDP probes.
--
Jeff Stuart
Network Admin
MyInternetServices.com
1-800-300-HOST
More information about the Xymon
mailing list