net-snmp agent walk请求的问题
snmpget 和 snmpwalk 对比
I have implemented an snmp subagent using the agent-x protocol. When I do a
snmpwalk
operation I see that all leaf handlers are called twice. The leaf handlers are called once (as expected) when I performing asnmpget
operation.
原因
Running an snmpwalk
on a scalar object will typically result in two GETNEXT
requests (one to retrieve the actual value of the scalar instance itself, and one to retrieve the next value, which is then discarded).
But the scalar (and instance) helpers ought to distinguish between valid and invalid instances, and filter out the invalid requests automatically.
The object-specific handler should only be called once.
I've just confirmed this with the two scalar objects in the
agent/nsCache.c
module:
snmpwalk .... nsCacheDefaultTimeout only calls the nsCacheDefaultTimeout handler once (for processing "GetNext nsCacheDefaultTimeout").
The second GETNEXT request ("GetNext nsCacheDefaultTimeout.0") is caught by the scalar helper.
Of course, if you're not using either of these helpers, and registering your module using a basic handler, then this will be called twice, due to the way that the SNMP GetNext protocol operation works.