I have been experimenting a bit with SNMP.
My aim is to find out how much data my ADSL modem is uploading/ downloading over the course of a month.
I want to find out that, because I suspect that I am being cheated out of some of my monthly data allowance by my ISP, thus I want to find out EXACTLY how much data I am downloading (instead of relying on the ISP's "useage meter" figures.)
I have multiple computers on my little home network, so it isn't much use using one of those programs that monitor bandwidth on a single machine.
I am experimenting with an SNMP aware program called PRTG Traffic Grapher (freeware version) to interface with my router (it is an SNMP device) to query the router on certain parameters like the amount of bytes that have been received by my router from the WAN/ internet.
The nice thing about SNMP is you can communicate with the router itself (through which all traffic passes) and therefore get an exact figure on the amount of data passing through the router's interface with the internet. If you just monitored data on one computer on the network, it would not account for data downloaded on other computers.
My router gives the number of bytes that has passed thru a given interface (I am looking at the interface between the router and the internet, altho you can also examine other interfaces, like the interface between the router and say one of its ethernet ports). So I have to look at the delta (change) in downloaded or uploaded bytes every X seconds to get an idea of bandwidth.
As far as I understand, there are certain parameters that are present on every SNMP device - things such as the device name, a contact person for the device, the number of interfaces the device has, the up-time for the device... Then there are certain parameters that might be specific to the particular snmp device (the snmp device could be anything such as a modem, a router, a switch, a Windows server, a printer, etc.) Different types of machines or devices will have difference types of data available via snmp. For example, a server can give you CPU or hard drive utilization, whereas with a router or switch you are going to be more interested in bandwidth.
The different kinds of parameters or data are all stored in the snmp device in what is called an "MIB table". To access parameters in the MIB table in the snmp device, you need an address referred to as an "OID".
For example, the OID for the counter that keeps track of the amount of bytes uploaded from my router to the WAN is:
1.3.6.1.2.1.2.2.1.16.102
The OID for the amount of bytes downloaded from the WAN to my router is:
1.3.6.1.2.1.2.2.1.10.102
I assume that the OIDs for the router:WAN interface might be different for a different brand of router. It's a bit difficult finding out the OID values for various devices, as manufacturers don't seem to publicize them. You can work them out yourself, tho, using a program called "Getif" (You go to the MIB browser tabbed page, press start, and examine the table for parameters of interest. I describe how to set up Getif below).
Getif
To communicate with an snmp device, you need to set a few values on the device first. There is a weak security system on snmp devices, where basically you need to supply passwords (a password is called a "community") before the device will acknowledge you and give you the information you want or let you change values. You need to set those passwords. There are two passwords or "communites" to set. One password allows you to query data. The other password allows you to both query data and also write (or change) data on the device. The default value for the Read Only community (i.e., password) is "public". The default value for the Read Write community (i.e., password) = "private". Most devices will actually have these passwords set as default. So it is a very weak security. (My router only accepts snmp requests from the LAN, not the WAN, so it seems pretty safe). With some devices, like my router, there is no need to change values, so you only need to set the "read" passowrd.
The method of actually setting the passwords is dependent on the device. With my Speedtouch 510v4 modem/ router (most recent firmware) you log into the router via telnet, and issue a series of commands to turn on the snmp server in the router (it is off by default on the Speedtouch) and then define the passwords or "communities". Other devices would have other methods of setting these passwords or turning snmp on/ off, so you would have to consult the device documentation offered by the manufacturer.
Once you have enabled snmp on your device and set up the passwords/ communities, it's just a matter of providing the community names to your snmp monitoring software. You also need to let your software know the IP address of your snmp device on your local network, and the port to speak to it on. The default port for speaking to an snmp device is 161. Here are a few programs you can try out:
PRTG Traffic Grapher (there is a freeware version that allows you to monitor up to 3 parameters)
Getif (great freeware program for fiddling around with snmp, experimenting and getting things to work, also useful for working out your device's OID values)
STG (tiny freeware program for monitoring bandwidth on an smnp device. Can also write the data to a log file, which you can import into e.g., excel.)
With my router, its IP address on the home network is 192.168.1.254, and I have set the read and write passwords to my name. I also set the system name, contact and location parameters (altho this isn't usually necessary):
Host name=192.168.1.254
read community(password)="aidan"
write community (password)="aidan"
SysName="Speedtouch"
SysContact="Aidan" (this could be an email address of the system administrator if you are on a large network)
SysLocation="Dryburgh" (this could be a street address or building location)
Here is a screen copy of these parameters entered into "Getif":
Screen 1
Hit the "start" button, and Getif speaks to the snmp device (my router). If the communities (passwords) are OK, Getif reports that your sys info variables are OK. Getif also gives you the device uptime (you can see in the screen copy that my router has been up for 23 days).
You can then go to the other tabbed pages in Getif, and check out other paramters from your device (pressing "Start" on each tabbed page). To explore the entire MIB table, and work out OID values, go to the MIB Browser page (MBrowser) and hit start. Then you can expand iso.org.dod.internet..mgmt.mib-2 to check out the entire list of parameters on your device and their values:
Screen 2
Getif also allows you to graph parameters like bandwidth over time, altho PRTG Traffic grapher (or MRTG, a similar program that works on linux/ unix) is much better for this purpose. The nice thing about PRTG Traffic Grapher is that it can install itself as a service, and constantly monitor your chosen paramters unobtrusively in the background, 24-7. It also has a web interface, so you can check on your parameters without having to fire up the main application. You can set up various types of reports or graphs, depending on the paramter you are monitoring and the kind of data representation you require. Here's a screen shot of the web interface, with PRTG monitoring my Speedtouch 510v4 router (bandwidth up/ down:
Screen 3
Hopefully someone will find this post useful. Basically this is what I would have liked to read 3 days ago, i.e., a description for a complete snmp beginner
Note: SNMP seems like a huge subject. With more sophisitcated snmp devices, you can set them up to send you alerts when certain conditinos are reached. Programs like PRTG let you monitor hundreds of snmp devices on large networks. There are three versions of snmp. Many devices still use version 1. Version 3 is supposed to be the most "secure" (whatever that means).