Search code examples
network-programmingsnmpbandwidth

How can i decide which ifDescr index i will use in SNMP?


I want to monitor bandwidth utilization for a number of devices. However in SNMP, the ethernet card's indexes are different for each computer. For example in localhost these are the values:

Sent GET request to localhost : 161

ifDescr.1 Software Loopback Interface 1 ifDescr.2 WAN Miniport (SSTP)

ifDescr.3 WAN Miniport (L2TP) ifDescr.4 WAN Miniport (PPTP)

ifDescr.5 WAN Miniport (PPPOE)

ifDescr.6 WAN Miniport (IPv6)

ifDescr.7 WAN Miniport (Network Monitor)

ifDescr.8 WAN Miniport (IP)

ifDescr.9 RAS Async Adapter

ifDescr.10 WAN Miniport (IKEv2)

ifDescr.11 Microsoft Teredo T?nel Ba§da?t?r?c?s?

ifDescr.12

ifDescr.13

ifDescr.14

ifDescr.15 Realtek PCIe GBE Family Controller

ifDescr.16 Intel(R) Centrino(R) Wireless-N 2230

ifDescr.17 Microsoft Virtual WiFi Miniport Adapter #9

ifDescr.18 Bluetooth Ayg?t? (Ki?isel Alan A§?)

ifDescr.19 Bluetooth Ayg?t? (RFCOMM Protokol? TDI)

ifDescr.20 Microsoft Virtual WiFi Miniport Adapter #10

ifDescr.21 Realtek PCIe GBE Family Controller-QoS Packet Scheduler-0 000

ifDescr.22 Realtek PCIe GBE Family Controller-WFP LightWeight Filter -0000

ifDescr.23 WAN Miniport (IPv6)-QoS Packet Scheduler-0000

ifDescr.24 WAN Miniport (IP)-QoS Packet Scheduler-0000

ifDescr.25 WAN Miniport (Network Monitor)-QoS Packet Scheduler-0000

Bandwidth incoming:

Sent GET request to localhost : 161

ifInOctets.1 0

ifInOctets.2 0

ifInOctets.3 0

ifInOctets.4 0

ifInOctets.5 0

ifInOctets.6 0

ifInOctets.7 0

ifInOctets.8 0

ifInOctets.9 0

ifInOctets.10 0

ifInOctets.11 0

ifInOctets.12 0

ifInOctets.13 0

ifInOctets.14 0

ifInOctets.15 54112558

ifInOctets.16 0

ifInOctets.17 0

ifInOctets.18 0

ifInOctets.19 0

ifInOctets.20 0

ifInOctets.21 54112558

ifInOctets.22 54112558

ifInOctets.23 0

ifInOctets.24 0

ifInOctets.25 0

So, i need to look indexes 15,21 and 22. However in other computers indexes will differ and also card names will differ(mine is Realtek PCIe GBE Family Controller). How can i find out which index i should use?


Solution

  • The binding of interface name is done by the OS so pretty much depends on how the interfaces are brought up and then discovered/ enumerated by the SNMP agent. If a specific interface (identifier via ifDescr possibly) is what you are interested in then you do a lookup by pulling the ifDescr column and then getting the index. For example if the interest is in

    "Realtek PCIe GBE Family Controller"

    then that's ifIndex 15 and you should query IfInOctets.15 on a specific host. On another host it is possible that the Index will be something else. For example on my MAC I typically get "en0" as the interface (on my Linux server it can be something like "eth0") and get the ifDescr value as following with IfIndex of 5

    IF-MIB::ifDescr.5 = STRING: en1

    So you should plan on adjusting accordingly.