0

bash 上的模拟:

snmpwalk -c SNMP1TV01 -v 2c 127.0.0.1 IF-MIB::ifName | grep bond0
IF-MIB::ifName.8 = STRING: bond0
snmpwalk -c SNMP1TV01 -v 2c 12.0.0.0.1 IF-MIB::ifHCOutOctets | grep 8
IF-MIB::ifHCOutOctets.8 = Counter64: 13775300423919 

我不能通过 oid 来做,因为以太网接口经常变化

4

1 回答 1

1

虽然我不熟悉node.js,但它不能检索表,而不仅仅是走树的那部分,例如

snmptable -M +.  -m +ALL -v 2c -c public -Pu -Ci 127.0.0.1 IF-MIB:ifXTable 
SNMP table: IF-MIB::ifXTable

index   ifName ifInMulticastPkts ifInBroadcastPkts ifOutMulticastPkts ifOutBroadcastPkts  ifHCInOctets ifHCInUcastPkts ifHCInMulticastPkts ifHCInBroadcastPkts ifHCOutOctets ifHCOutUcastPkts ifHCOutMulticastPkts ifHCOutBroadcastPkts ifLinkUpDownTrapEnable ifHighSpeed ifPromiscuousMode ifConnectorPresent ifAlias ifCounterDiscontinuityTime
1        lo                 0                 0                  0                  0 3675102238172      2759723359                   0                   0 3675102238172       2759723359                    0                    0                      ?          10             false                  ?                       0:0:00:00.00
2     bond0               959                 0                  0                  0   21395174710        43909149                 959                   0    5835176503         49589529                    0                    0                      ?        1000             false               true                       0:0:00:00.00

<not showing my other interfaces>

提取相关值....

snmptable -M +.  -m +ALL -v 2c -c public -Pu -Ci 127.0.0.1     IF-MIB:ifXTable | grep bond0 | awk '{print $11}'
5835176503
于 2013-03-06T20:29:52.967 回答