#!/bin/bash RRDTOOL=/usr/bin/rrdtool STATSDIR=/var/www/wan-stats # Meta file MF="${STATSDIR}/png.meta" # Colours # Eth0 in RED=FF0000 # Eth0 out GREEN=00CC00 # Eth1 in BLUE=0066FF # Eth1 out YELLOW=FFCC00 cd "${STATSDIR}/" # Set meta file 6 mins later, refresh at 5 mins echo -n "Expires: " > $MF date --date '6 mins' -u +%a,\ %d\ %b\ %Y\ %T\ GMT >> $MF echo "Refresh: 300" >> $MF # Dayly graph # Change the hostnames to the ones you use $RRDTOOL graph --imgformat PNG $STATSDIR/net.png \ --start -86400 \ --title "Sput network" \ --vertical-label "Bytes per second" \ --x-grid HOUR:1:HOUR:6:HOUR:6:0:"%a %H:%M" \ --width 500 --height 250 \ --interlaced \ --logarithmic \ --units=si \ --lower-limit 20 \ --rigid \ COMMENT:" Current Peak (+) Peak (-) Average\n" \ DEF:eth0in=$STATSDIR/sput-net.rrd:eth0in:AVERAGE \ LINE2:eth0in#${RED}:"Eth0 In " \ GPRINT:eth0in:LAST:"%7.0lf" \ GPRINT:eth0in:MAX:" %7.0lf" \ GPRINT:eth0in:MIN:" %7.0lf" \ GPRINT:eth0in:AVERAGE:" %7.0lf\n" \ DEF:eth0out=$STATSDIR/sput-net.rrd:eth0out:AVERAGE \ LINE2:eth0out#${GREEN}:"Eth0 Out " \ GPRINT:eth0out:LAST:"%7.0lf" \ GPRINT:eth0out:MAX:" %7.0lf" \ GPRINT:eth0out:MIN:" %7.0lf" \ GPRINT:eth0out:AVERAGE:" %7.0lf\n" \ DEF:eth1in=$STATSDIR/sput-net.rrd:eth1in:AVERAGE \ LINE2:eth1in#${BLUE}:"Eth1 In " \ GPRINT:eth1in:LAST:"%7.0lf" \ GPRINT:eth1in:MAX:" %7.0lf" \ GPRINT:eth1in:MIN:" %7.0lf" \ GPRINT:eth1in:AVERAGE:" %7.0lf\n" \ DEF:eth1out=$STATSDIR/sput-net.rrd:eth1out:AVERAGE \ LINE2:eth1out#${YELLOW}:"Eth1 Out " \ GPRINT:eth1out:LAST:"%7.0lf" \ GPRINT:eth1out:MAX:" %7.0lf" \ GPRINT:eth1out:MIN:" %7.0lf" \ GPRINT:eth1out:AVERAGE:" %7.0lf\n" \ COMMENT:" \n" \ COMMENT:" Last update\: `date '+%a %b %-d %H\:%M\:%S %Z %Y'`\n" \ COMMENT:" `date --utc '+(%a %b %-d %H\:%M\:%S %Z %Y)'`" # Weekly graphs # Change the hostnames to the ones you use $RRDTOOL graph --imgformat PNG $STATSDIR/week-net.png \ --start -604800 \ --title "Sput network" \ --vertical-label "Bytes per second" \ --x-grid HOUR:6:HOUR:24:DAY:1:0:%a \ --width 500 --height 160 \ --interlaced \ --logarithmic \ --units=si \ --lower-limit 20 \ --rigid \ COMMENT:" \n" \ DEF:eth0in=$STATSDIR/sput-net.rrd:eth0in:AVERAGE \ LINE2:eth0in#${RED}:"Eth0 In" \ DEF:eth0out=$STATSDIR/sput-net.rrd:eth0out:AVERAGE \ LINE2:eth0out#${GREEN}:"Eth0 Out" \ COMMENT:" \n" \ DEF:eth1in=$STATSDIR/sput-net.rrd:eth1in:AVERAGE \ LINE2:eth1in#${BLUE}:"Eth1 In" \ DEF:eth1out=$STATSDIR/sput-net.rrd:eth1out:AVERAGE \ LINE2:eth1out#${YELLOW}:"Eth1 Out" \ COMMENT:" \n" \ COMMENT:" \n" \ COMMENT:" Last update\: `date '+%a %b %-d %H\:%M\:%S %Z %Y'`\n" \ COMMENT:" `date --utc '+(%a %b %-d %H\:%M\:%S %Z %Y)'`"