Wednesday, October 18, 2006

network traffic graphing

R wanted an easier solution than MRTG.
http://www.debian-administration.org/articles/103
has quite a few links, including cacti
and quite a few nice mrtg configuration tricks. The following from "doc" is a nice one.

Here's a mrtg example that simply uses ifconfig to obtain statistical info: ** /etc/mrtg.cfg **

WorkDir: /var/www/mrtg
WriteExpires: Yes
Refresh: 300

WithPeak[^]: wym
Suppress[^]: y
MaxBytes[^]: 96

Title[^]: Traffic Analysis for HOST.NAME

Target[eth0]: `/usr/local/bin/mrtg-data eth0`
MaxBytes1[eth0]: 13107200
MaxBytes2[eth0]: 13107200
Title[eth0]: Traffic Analysis for network device eth0 [External]
PageTop[eth0]: Internet Link

Target[lo]: `/usr/local/bin/mrtg-data lo`
MaxBytes1[lo]: 13107200
MaxBytes2[lo]: 13107200
Title[lo]: Traffic Analysis for network device lo [localhost]
PageTop[lo]: Local lo / loopback device

And /usr/local/bin/mrtg-data:

#!/bin/bash

DEV="$1"
if test -z "$DEV"; then echo No device specified; exit 1; fi

INFO=`grep $DEV /proc/net/dev | tr -s ' ' ' ' | cut -d: -f2`
RECEIVE=`echo $INFO | cut -d" " -f1`
TRANSMIT=`echo $INFO | cut -d" " -f9`
UPTIME=`uptime | tr -s ' ' ' ' | cut -d" " -f4-`

echo $RECEIVE
echo $TRANSMIT
echo $UPTIME
echo "HOST.NAME"

No comments:

Post a Comment