Hi,
I am currently using snmp to read some oids from a DD-wrt router for bandwidth monitoring and such.
All is well, but: the oids of the interfaces sometimes change after a reboot (probably something to do with the initialization times of the interfaces?) . The result is that my sensor reports nothing because of this.
baseoid: 1.3.6.1.2.1.31.1.1.1.6.8 on dd-wrt reports the total bandwidth used, but after a reboot it sometimes changes to 1.3.6.1.2.1.31.1.1.1.6.11 or 1.3.6.1.2.1.31.1.1.1.6.12 on the router.
I was thinking of creating sensors which read the oids where the interface names are contained:
iso.3.6.1.2.1.31.1.1.1.1.1 = STRING: “lo”
iso.3.6.1.2.1.31.1.1.1.1.8 = STRING: “br0”
and based on that use some kind of variable in the sensor which contains the last integer of the correct oid, in this case that would be “8”…
Got an “Unknown” in template editor and below error in the log:
sensor.snmp:
- Invalid config for [sensor.snmp]: value should be a string for dictionary value @ data[‘baseoid’]. Got OrderedDict([(‘value_template’, “{{ states(‘sensor.ddwrt_bridge0’
) }}”)]). (See ?, line ?).
“Solved” it like this, i someone has an idea to make the template a bit smaller/more optimal…
Determine all interface names
platform: snmp
name: ddwrt_ifname_1
host: 192.168.0.253
baseoid: 1.3.6.1.2.1.31.1.1.1.1.[1-12] (returns the name of the interface)
community: ‘public’
version: ‘2c’
scan_interval: 3600
Please add proper formatting to things you mark as a solution. Your current solution will not work for anyone when they copy and paste because the formatting for the post is incorrect. Edit your post, add ``` before and after your code seconds to turn it into a codeblock. This is all described in the FAQ point 11.