0

Analog on 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 

I can't do it by oid because ethernet interfaces changes often

k1eran
  • 4,492
  • 8
  • 50
  • 73
Bdfy
  • 23,141
  • 55
  • 131
  • 179

1 Answers1

1

Whilst I'm not familiar with node.js can't it retrieve the table, rather than just walking that part of the tree e.g.

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>

Extracting out the relevant value ....

snmptable -M +.  -m +ALL -v 2c -c public -Pu -Ci 127.0.0.1     IF-MIB:ifXTable | grep bond0 | awk '{print $11}'
5835176503
k1eran
  • 4,492
  • 8
  • 50
  • 73