我认为 snmpbulkget 的行为类似于 snmpget,只是它可以支持多个 oid 请求。但我看到奇怪的行为。它提供下一个 OID 信息而不是询问的内容:
snmpbulkget -Cr1 servername IF-MIB::ifSpeed.7.0 IF-MIB::ifInOctets.7 IF-MIB::ifInUcastPkts.7 IF-MIB::ifInNUcastPkts.7 IF-MIB::ifInNUcastPkts.7 IF-MIB::ifInDiscards.7 IF-MIB::ifInErrors.7 IF-MIB::ifOutOctets.7 IF-MIB::ifOutUcastPkts.7 IF-MIB::ifOutNUcastPkts.7 IF-MIB::ifOutDiscards.7 IF-MIB::ifOutErrors.7
IF-MIB::ifSpeed.8 = Gauge32: 10000000
IF-MIB::ifInOctets.8 = Counter32: 3674120514
IF-MIB::ifInUcastPkts.8 = Counter32: 2462391943
IF-MIB::ifInNUcastPkts.8 = Counter32: 19169575
IF-MIB::ifInNUcastPkts.8 = Counter32: 19169575
IF-MIB::ifInDiscards.8 = Counter32: 0
IF-MIB::ifInErrors.8 = Counter32: 775777
IF-MIB::ifOutOctets.8 = Counter32: 3824588280
IF-MIB::ifOutUcastPkts.8 = Counter32: 2866781089
IF-MIB::ifOutNUcastPkts.8 = Counter32: 0
IF-MIB::ifOutDiscards.8 = Counter32: 0
IF-MIB::ifOutErrors.8 = Counter32: 0
为什么?
snmpget
将发送一个包含多个 OID 的数据包(您可以使用该-d
选项验证这一点)。因此,更改要使用的命令snmpget
(并删除该-Cr1
选项)将满足您的需求。或者,您可以 BULKGET
IF-MIB::ifEntry
给您比您想要的更多。snmpbulkget
(或者更确切地说是底层的 GETBULK/GETNEXT)方法总是返回树中的下一个变量。引用http://net-snmp.sourceforge.net/wiki/index.php/GETBULK ...