gescheit / fastsnmp

Fast SNMP poller
MIT License
19 stars 7 forks source link

Cannot get sysUpTimeInstance (1.3.6.1.2.1.1.3.0) #16

Closed Maiiwen closed 1 year ago

Maiiwen commented 1 year ago

Hi ! I tried to run this SNMP query but I got no result.

snmp_data = snmp_poller.poller(["XXX.XXX.XXX.XXX"], [list({".1.3.6.1.2.1.1.3.0": "sysUpTimeInstance"})], "public")
for d in snmp_data:
    print(d)

Yet, with the snmpwalk command, I got a Timetick typed value. I assume Timeticks are not supported by fastsnmp for now ?

gescheit commented 1 year ago

Hi! There are two problems. First, your snippet contains the leading dot in OID and it is ok, but is unexpected to fastsnmp. I address this problem here https://github.com/gescheit/fastsnmp/pull/17. Second problem in result parsing of bulk request. Fastsnmp expects that the answer for $OID starts with $OID + ".". So, to get 1.3.6.1.2.1.1.3.0 you can call function with default request type GetBulk

snmp_data = snmp_poller.poller(["XXX.XXX.XXX.XXX"], [["1.3.6.1.2.1.1.3"]], "public")
Result(name='host', main_oid='1.3.6.1.2.1.1.3', index_part='0', value=3541585771...

or you can use Get type, because you known exact oid

snmp_data = snmp_poller.poller(["XXX.XXX.XXX.XXX"], [["1.3.6.1.2.1.1.3.0"]], "public", msg_type="Get")
Result(name='host', main_oid='1.3.6.1.2.1.1.3.0', index_part='', value=3541590250...
Maiiwen commented 1 year ago

Both solutions working, thanks for help !