Search code examples
downloadsnmp

Using SNMP and InOctets counter to keep track of download usage


How would one calculate the download usage per month say by using the InOctets counter from a router accessed via SNMP.

Obviously it would have to keep a track of the value at say the 1st of the month, then do a subtraction on the end of the month, but how exactly do I convert Octet to Gigabytes ???

There would have to be precautions put in place also incase someone resets the counter on the router but this can be coded for no problems.


Solution

  • Just remember that SNMP InOctets is the total number of octets sent and received on an interface, including framing characters. Keep in mind that InOctet SNMP values cycle and restart at 0 when they get to the max value available for a 16-or-32-bit value, so you have to be polling the value at regular intervals and calculating the total number of octets by the difference in octets from the last poll.

    You would multiply the total InOctets value collected over a timeframe by 8 to get the number of bits. There are 8,589,934,592 bits in a GigaByte.

    (InOctets * 8) / 8,589,934,592 = Total GB transfer inbound
    

    Also, I would recommend using something like MRTG, Cacti, RTG, or several other free tools that can do this for you.

    Hope this helps.