I have come across quite a few switches in which SNMP indices can shift, for example, depending on the number of added VLANs, that is, the first port will no longer be ifIndex.1, but for example ifIndex.5. On Mikrotik RB2011UiAS-RM, the sfp1 port is ifIndex.1, and ether1 is already ifIndex.2. In Huawei switches and OLT, I saw sky-high figures and, in addition, they also shifted. Therefore, in order not to create separate templates for the same device model, Zabbix has a solution for this.
The SNMP item syntax for dynamic indexes is:
<Data OID>["index","<Index OID>","<search string>"]
I will give an example on one of the BDCOM P3310C, let’s say the device port is called GigaEthernet0/1, we will make sure of this by looking at the port description:
snmpwalk -v2c -c public ixnfo.com ifDescr
I got it displayed:
IF-MIB::ifDescr.9 = STRING: GigaEthernet0/1
IF-MIB::ifDescr.10 = STRING: GigaEthernet0/2
IF-MIB::ifDescr.11 = STRING: GigaEthernet0/3
…
Now, to get the port traffic, use the following line instead of SNMP OID ifInOctets.9 or ifHCInOctets.9:
ifHCInOctets["index","ifDescr","GigaEthernet0/1"]
Everything else is configured as usual, for example, for speed, do not forget to specify the processing “Custom multiplier 8” and “Change per second”.
Other data can be obtained in the same way.
Each Zabbix poller uses its own cache, so there will be no extra load on the device, since after the first request, the SNMP index will be taken from the cache.
See my other articles on Zabbix.