Slackware 12.2 - MRTG ifconfig ============================== Public domain ******************************************************************************** ### /usr/local/mrtg-2/etc/mrtg-ifconfig.sh #!/bin/bash PATH="/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin" HOST=$(hostname) UPTIME=$(cat /proc/uptime | sed -e 's,\..*,,') H=$(( $UPTIME / 3600 )) M=$(( ($UPTIME - $H * 3600) / 60 )) RX=$(ifconfig $1 | grep "RX bytes:" | sed -e 's,.*RX bytes:,,' -e 's, .*,,') TX=$(ifconfig $1 | grep "TX bytes:" | sed -e 's,.*TX bytes:,,' -e 's, .*,,') echo $RX echo $TX echo $H:$M echo $HOST ******************************************************************************** ### /usr/local/mrtg-2/etc/mrtg-ifconfig.cfg WorkDir: /var/www/htdocs/ifconfig Target[ifconfig_eth1]: `/usr/local/mrtg-2/etc/mrtg-ifconfig.sh eth1` Title[ifconfig_eth1]: eth1 Bandwidth usage PageTop[ifconfig_eth1]:

eth1 Bandwidth usage

Options[ifconfig_eth1]: bits MaxBytes[ifconfig_eth1]: 125000000 Legend1[ifconfig_eth1]: LegendI[ifconfig_eth1]: Receive Legend2[ifconfig_eth1]: LegendO[ifconfig_eth1]: Send Target[ifconfig_eth1_2]: `/usr/local/mrtg-2/etc/mrtg-ifconfig.sh eth1.2` Title[ifconfig_eth1_2]: eth1.2 Bandwidth usage PageTop[ifconfig_eth1_2]:

eth1.2 Bandwidth usage

Options[ifconfig_eth1_2]: bits MaxBytes[ifconfig_eth1_2]: 125000000 Legend1[ifconfig_eth1_2]: LegendI[ifconfig_eth1_2]: Receive Legend2[ifconfig_eth1_2]: LegendO[ifconfig_eth1_2]: Send ******************************************************************************** ### Commands mkdir /var/www/htdocs/ifconfig chmod +x /usr/local/mrtg-2/etc/mrtg-ifconfig.sh /usr/local/mrtg-2/bin/indexmaker /usr/local/mrtg-2/etc/mrtg-ifconfig.cfg > /var/www/htdocs/ifconfig/index.html ******************************************************************************** ### crontab -e */5 * * * * /usr/local/mrtg-2/bin/mrtg /usr/local/mrtg-2/etc/mrtg-ifconfig.cfg &> /dev/null ******************************************************************************** _BY: Pejman Moghadam_ _TAG: mrtg, ifconfig_ _DATE: 2010-10-15 10:43:51_