====== MRTG With Local SNMP ====== If your switch or router won't report SNMP data so you can graph bandwidth usage with MRTG, then you'll have to install an SNMPd to track the bandwidth on your network card. 1. Grab Net-SNMP from

2. ./configure && make && make install

3. Edit /usr/local/share/snmp/snmpd.conf and add the following line:

rocommunity public localhost 4. Add /usr/local/sbin/snmpd -r -s -u daemon localhost to your startup. This will run snmpd as 'daemon' instead of 'root'. 5. Now you can download the MRTG source package from

6. Follow the installation instructions on

7. Optional: create a non-privileged user to run mrtg:

/usr/sbin/useradd -u 110 -d /usr/local/mrtg-2/www -c "MRTG" -m -k /dev/null mrtg 8. Create the directory /usr/local/mrtg-2/www and /usr/local/mrtg-2/cfg and configure your MRTG: /usr/local/mrtg-2/bin/cfgmaker --global 'WorkDir: /usr/local/mrtg-2/www' \ --global 'Options[_]: bits,growright' --global 'WithPeak[_]: wmy' --output /usr/local/mrtg-2/cfg/localhost.cfg \ public@localhost 9. Add the entry into root's cron to run MRTG every 5 minutes to update your graphs: */5 * * * * /usr/local/mrtg-2/bin/mrtg /usr/local/mrtg-2/mrtg.cfg --logging /var/log/mrtg.log In my /var/log/mrtg.log I got:
'WARNING: rateup died from Signal 0'
When I tried to run /usr/local/mrtg-2/bin/rateup from the command line it said:
/usr/local/mrtg-2/bin/rateup: error in loading shared libraries: libgd.so.3: cannot open shared object file: No such file or directory
I found libgd.so.3 in /usr/local/lib - so I added that to /etc/ld.so.conf and ran /sbin/ldconfig -v | grep gd to make sure ld could find that file. 10. Now just set up apache (or a VirtualHost) to point to your /usr/local/mrtg-2/www as a DocumentRoot.

To make images work - copy them from /usr/local/mrtg-2/lib/mrtg2/mrtg-* to your /usr/local/mrtg-2/www directory.

Notes:

When using MRTG for more than one device - I put all .cfg files into a /usr/local/mrtg-2/cfg directory, and use this in my crontab:

*/5 * * * * for each in `find /usr/local/mrtg-2/cfg -name \*.cfg`; do /usr/local/mrtg-2/bin/mrtg $each --logging /var/log/mrtg.log; done To be even safer - I will put this into a crontab for a role user 'mrtg' so that it doesn't run as root. To show the date from the epoch seconds found in the first column of the mrtg.log file use:

perl -e 'print scalar localtime(x),"\n"'