This work is licenced under a Creative Commons Licence.
Today I set up monitoring of my network on my Be-provided ADSL modem/router. The process was fairly rapid, but is probably not the kind of thing that someone would find easy to work out by themselves if they didn't know roughly what to do before starting, so here I shall document it.
First things first, we need to enable SNMP on the bebox. To do this we first telnet into it:
Enter your username/password to login (default administrative user is Administrator, but if you've added other admin users, they will also work). Just a note to those unfamiliar with such interfaces: when using telnet to connect to the bebox, you will notice that backspace does not delete anything, and just adds annoying characters. To replicate the functionality of the backspace key you need to use "control+h" (often written as ^H). If your router doesn't get picked up as "bebox", replace all references to it from here on in with it's IP (the default is 192.168.1.254).
Then we need the following two commands (gleaned from HERE):
service system modify name=SNMP_AGENT state=enabled snmp community add securityname=ROCommunity communityname=public
Note that contrary to the example given in the first post of the link posted, I have used ROCommunity. I am not certain that this is essential, but it worked for me like this.
Now, on your monitoring machine (for me, my desktop) we need to install mrtg. On my Ubuntu box that is a simple case of
sudo aptitude install mrtg mrtg-rrd
I like to keep my /etc dir as tidy as possible, so create /etc/mrtg/ and delete /etc/mrtg.cfg if it exists. Next we need to create a configuration file, and 'find' the router.
sudo cfgmaker --global 'Options[_]: bits,growright' --output /etc/mrtg/mrtg.cfg [email protected]
The "growright" option stops the graphs from coming out in a way that most people would consider back to front, with new data appearing on the left, and old on the right. You can just remove the "bits" option if you want your data in bytes (e.g. kilobytes per second instead of kilobits per second).
By default, this creates a directory of /var/www/mrtg with all our images etc in it, but this is somewhat messy. We want a properly laid out page, so we can use the "indexmaker" tool.
As root, (note this command will fail using sudo):
indexmaker /etc/mrtg/mrtg.cfg > /var/www/mrtg/index.html
I haven't tested, but I think using sudo you can use:
indexmaker --output=/var/www/mrtg/index.html /etc/mrtg/mrtg.cf
Then, visiting localhost/mrtg will give us our graphs, however they may not be updating. Ubuntu created a cron job that runs every 5 minutes for me, but as I had used /etc/mrtg/mrtg.cfg instead of the more standard /etc/mrtg.cfg I had to edit it. To do this, open up your favoured text editor and edit /etc/cron.d/mrtg. I changed it from:
*/5 * * * * root if [ -d /var/lock/mrtg ]; then if [ -x /usr/bin/mrtg ] \ && [ -r /etc/mrtg.cfg ]; then env LANG=C /usr/bin/mrtg \ /etc/mrtg.cfg >> /var/log/mrtg/mrtg.log 2>&1; fi \ else mkdir /var/lock/mrtg; fi
*/5 * * * * root if [ -d /var/lock/mrtg ]; then if [ -x /usr/bin/mrtg ] \ && [ -r /etc/mrtg/mrtg.cfg ]; then env LANG=C /usr/bin/mrtg \ /etc/mrtg/mrtg.cfg >> /var/log/mrtg/mrtg.log 2>&1; fi \ else mkdir /var/lock/mrtg; fi