SNMP is quite interesting if you like to control the bandwidth usage of your roomies – or family members. I for one have used it in the past to monitor my sister’s bandwidth usage. After all, this is my internet connection, and noone elses.
Since I’ve switched to the Tomato firmware, however, I haven’t been able to keep track of bandwidth movement other than via the built-in bandwidth meter on the webif. Tomato is quite a bit more lightweight than DD-WRT, which has an SNMP server integrated, and hence, in order to use SNMP with Tomato, you’ll have to add it somehow. This is what I am going to explain here in a couple of steps. I’m going to assume that you already have Tomato installed and configured. This might work for other firmwares that don’t have SNMP integrated already, but I don’t know.
- First, you’ll have to create a network share on a box inside your LAN that runs 24/7. Either 24/7, or at least whenever you boot up your WRT device. You can do this on either a Windows box and create a user that has exclusive rights to mount network shares, or you can do this on a Linux box using Samba and creating a smbshare. You could also do this by using the empty space on the flash chip, i however wouldn’t recommend that you do so – since repeatedly writing to that chip will wear its quality down.
- Mount the network share. Go to your Tomato configuration, go to Administration, then CIFS Client. Enable one of the shares and enter its details. UNC is the path of the share. This is something like “\\ip-address-of-the-computer-that-contains-the-share\share-name”. As username and password, you will need to input what a noted in 1. – a user that you created solely for the purpose of accessing windows network shares. How you do the latter is a matter that I leave to google to explain to you. The rest of the settings can be left free. Hit Save. Maybe reboot. Can’t be of any harm.
- SSH to your router and create a directory on the newly-mounted network share. Call it “sbin”:
# cd /cifs1
# mkdir sbin
- Download the following file onto your WRT. It’s a static build of an SNMP daemon with all of the libraries built-in, hence its size (732520 bytes). Also check that its md5sum reads as “ae0d622648efdb8dceb7b3b5a63e23ac”:
# wget http://bok.xs4all.nl/downloads/snmpd.zip
Connecting to bok.xs4all.nl[188.8.131.52]:80
# unzip snmpd.zip && rm snmpd.zip
# md5sum snmpd
- Next, you’ll have to create a configuration file for snmpd. You can do this by just opening an instance of notepad wordpad on your Windows box, copying these contents and saving it in the directory where snmpd resides as snmpd.conf:
com2sec ro default public
com2sec rw localhost private
group public v1 ro
group public v2c ro
group public usm ro
group private v1 rw
group private v2c rw
group private usm rw
view all included .1
access public “” any noauth exact all none none
access private “” any noauth exact all all all
I got this config from the ipkg-package of the DD-WRT distribution.
- Now start that thing using the configuration file you just created. I’ve added the -s switch to have it log into the syslog located at /var/log/messages. This flag isn’t mandatory though, if everything works, you can leave it out:
# /cifs1/sbin/snmpd -s -c /cifs1/sbin/snmpd.conf &
- The snmp daemon should be running now. Check the syslog for the following line. if it is not accompanied by any additional lines, you should be good to go:
# cat /var/log/messages | grep -i snmpd
Jan 21 20:54:43 daemon.info snmpd: NET-SNMP version 5.0.9
- If you want the daemon to run every time the router boots up, go to Administration -> Scripts -> Init, then add these lines:
# snmp daemon
/cifs1/sbin/snmpd -s -c /cifs1/sbin/snmpd.conf &
- Now let’s look how we can visualize this. I’m using SNMPTrafficGrapher (STG from now on) for Windows, it’s quite old and apparently development has stopped, but hey, whatever. I haven’t found a more convenient application yet. In order to get the correct OIDs for STG, you have to use SNMPTester to get all available OIDs from your box. Fire up the application, punch in the IP address of your router and use SNMP version V2c. Also select Scan Available Interfaces. Hit 3. Run Test. It’ll spit out a whole bunch of lines, whereof only the last eight or so are important and should look something like this (on a WRT54GL):
1,lo,,Software Loopback,Connected,10000 kb/s,1 (lo)
2,eth0,,Ethernet,Connected,10000 kb/s,2 (eth0)
3,eth1,,Ethernet,Connected,10000 kb/s,3 (eth1)
4,vlan0,,Ethernet,Connected,10000 kb/s,4 (vlan0)
5,vlan1,,Ethernet,Connected,10000 kb/s,5 (vlan1)
6,br0,,Ethernet,Connected,10000 kb/s,6 (br0)
7,ppp0,,PPP,Not Connected,0 kb/s,7 (ppp0)
- Back to STG: hit F9 for its settings. Set the router ip as Target Address, Community to “public” and the following values to “Green” OID and “Blue” OID1:
with x being the number before the interface listed with “br0” in the list we just got. In my case, it was 6. Also set your Update Period to 1000ms, which translates to 1s update intervals. Take a look at the rest of the settings and adapt them to your likings, then hit OK and go to File -> Save to save that configuration somewhere. From now on, you should always start STG with the configuration file you have just saved. Cause some traffic. STG should now show a blue line displaying your downstream- and a green one showing your upstream-traffic.
Alright, all done. I hope this helps some people.
– initial howto from bokh and my way of solving my issue