I have simple example:
import netsnmp var = netsnmp.Varbind('ifHCInOctets','0') res = netsnmp.snmpgetnext(var,Version = 2,DestHost='localhost',Community='public',Timeout=1000000) print res[0]
time python2 test.pyshow me:
real 0m4.086s user 0m0.073s sys 0m0.007s
Why 4 seconds = 1000000 ? snmpd server not work on localhost
When you pass Timeout=?
you are setting the maximum time that snmp's internal select loop should wait before registering a timeout. Setting this to 1000000
means "wait 1 million microseconds", which is 1 second.
However there is also a Retries=?
argument that specifies the number of times the snmp client will re-attempt the request after a timeout, so for Timeout=1000000, Retries=0
select will attempt only 1 request and timeout in 1 second. If Retries=1
it will try twice and timeout in 2 seconds.
So depending on the combination of Timeout and Retries you will see different amounts of delay.
The default number of Retries is 3, so 1 try + 3 retries of 1 seconds each = 4 seconds.