Closed ashimgiri000 closed 1 year ago
Have you set the msg_type to Get? See https://fastsnmp.readthedocs.io/en/latest/#module-fastsnmp.snmp_poller If you do a table walk with the default GetBulk you'll get nothing back. The Next OID after 1.3.6.1.2.1.2.2.1.2.4321 will be 1.3.6.1.2.1.2.2.1.2.4322 or something, which doesn't start with 1.3.6.1.2.2.1.2.4321 so snmp_poller determines that you are at the end of the table and returns the still empty results. Changing the msg_type to Get specifies that you want to retrieve that exact OID. See below for an example (my index is 8, but otherwise it's the same).
>>> print(oid_group)
{'1.3.6.1.2.1.2.2.1.2.8': 'ifDescr'}
>>> results = snmp_poller.poller((host,), [list(oid_group)], community)
>>> print(list(results))
[]
>>> results = snmp_poller.poller((host,), [list(oid_group)], community, msg_type='Get')
>>> print(list(results))
[Result(name='192.168.1.2', main_oid='1.3.6.1.2.1.2.2.1.2.8', index_part='', value=b'GigabitEthernet8', ts=1675356011.387124, duration=0.0019384340848773718)]
>>>
Thank You It's working you saved my day.
Hi is it possible to add or concatenate the index in oid group
for example , index = 4321
oid_group = {f"1.3.6.1.2.1.2.2.1.2.{index}": "ifDescr",}
i tried these way but it's not working please share if there is another way to do