英文:
SNMP atomically get interfaces and counters
问题
我有一些需要通过SNMP监控的交换机和路由器。交换机和路由器上的接口数量以及它们在OID中的“后缀”可能在任意时刻发生变化。
我如何原子地获取接口名称到OID后缀映射以及这些接口上感兴趣的计数器?
英文:
I have some switches and routers that should be monitored over SNMP. Number of interfaces in switches and routers and their "suffix" in OID can change at an arbitrary moment.
How can I atomically get both interface name to OID suffix mapping and interested counters on this interfaces?
答案1
得分: 1
一个SNMP的GET-NEXT
请求可以同时查询表的多列。如果你想要查询,例如,ifInDiscards
和ifInErrors
,还有ifDescr
,只需一次性查询所有三者。在Shell中使用snmpgetnext
可以这样做(snmpwalk
似乎不支持这个功能):
snmpgetnext <参数> <主机IP> IF-MIB::ifDescr IF-MIB::ifInDiscards IF-MIB::ifInErrors
在我的机器上,输出如下:
IF-MIB::ifDescr.1 = STRING: lo
IF-MIB::ifInDiscards.1 = Counter32: 0
IF-MIB::ifInErrors.1 = Counter32: 0
然后,你需要使用前面响应中的.1
更新你的查询,以便获取下一个接口的结果:
snmpgetnext <参数> <主机IP> IF-MIB::ifDescr.1 IF-MIB::ifInDiscards.1 IF-MIB::ifInErrors.1
英文:
An SNMP GET-NEXT
request can query multiple columns of a table at once. If you want, for example, the ifInDiscards
and ifInErrors
, along with the ifDescr
, simply query for all three at once. Here's how to do it in the shell using snmpgetnext
(snmpwalk
doesn't appear to support this):
snmpgetnext <parameters> <host-ip> IF-MIB::ifDescr IF-MIB::ifInDiscards IF-MIB::ifInErrors
Here's the output on my machine:
IF-MIB::ifDescr.1 = STRING: lo
IF-MIB::ifInDiscards.1 = Counter32: 0
IF-MIB::ifInErrors.1 = Counter32: 0
Then, you will have to update your query with the .1
from the previous response in order to get the results for the next interface:
snmpgetnext <parameters> <host-ip> IF-MIB::ifDescr.1 IF-MIB::ifInDiscards.1 IF-MIB::ifInErrors.1
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论