Template:FAQ:Agent 45

From Net-SNMP Wiki
Jump to: navigation, search

Short answer - no.
Longer answer - not easily.

Net-SNMP within a single thread of an threaded application is fine, as long as all snmp code is kept within the same thread. This lets you add SNMP support to an existing threaded application.

If you are concerned with the time taken for to process requests for a particular agent, object or subtree, and you want the agent to continue to respond to other requests in the meantime, there are two options.

The first method is using AgentX sub-agents. If you have several tables, each implemented by a separate subagent, then a single request for entries from each of the tables will be processed in parallel (and the agent will continue to respond to other requests while it waits for the subagents to return the necessary information). But a request for several objects from the same table will be passed off to the relevant subagent, where it will (normally) be processed serially.

The second method is to use delegated requests + IPC to another process. If takes a long time to retrieve a value for a given object, then the object handler could do whatever necessary to start or communicate with another (non-SNMP) process/thread to actually retrieve the value, and mark the request as delegated. The main agent (or subagent) can then receive and process other requests while waiting for the delegated request to finish. Dealing with resource contention is all up to you.

All of this only applies to the GET family of requests. A SET request will block until all pending GET requests have finished, and then will not accept new requests until the SET is complete.

Adding full multi-thread support directly to the agent would be nice. We just need someone with time/money to do/sponsor the work.