使用SNMP和InOctets计数器跟踪下载使用情况 [英] Using SNMP and InOctets counter to keep track of download usage

查看:358
本文介绍了使用SNMP和InOctets计数器跟踪下载使用情况的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用通过SNMP访问的路由器中的InOctets计数器来计算每月的下载使用量。



显然,它必须跟踪值,例如每月的1号,然后在该月的月末进行减法运算,但是我如何将八位字节精确转换为千兆字节呢?



为防患于未然,以防万一有人在路由器上重置了计数器,但是可以毫无问题地对其进行编码。

解决方案

请记住,SNMP InOctets是在接口上发送和接收的八位字节总数,包括成帧字符。请记住,当InOctet SNMP值达到16位或32位值的最大值时,它们会循环并从0重新开始,因此必须定期轮询该值,并通过以下方法计算八位字节的总数:



您可以将在一个时间范围内收集的InOctets的总值乘以8,以获得位数。千兆字节中有8,589,934,592位。

 (InOctets * 8)/ 8,589,934,592 =总GB传输入站

此外,我建议您使用MRTG,Cacti,RTG之类的工具或其他一些免费工具来满足您的需求。 / p>

希望这会有所帮助。


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.

解决方案

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.

这篇关于使用SNMP和InOctets计数器跟踪下载使用情况的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆