Template:FAQ:Agent 13

From Net-SNMP Wiki
Revision as of 15:39, 29 December 2006 by Dts12 (Talk | contribs) (5.4 release synchronisation)

Jump to: navigation, search

There are two sides to an AgentX connection, and they need to agree about which socket address to use. So if you want to use a different socket, you need to configure both parties accordingly.

The socket that the Net-SNMP master agent uses to listen for AgentX registrations (and send appropriate requests) can be specified using the option </CODE>'-x'</CODE>.
The command

               "snmpd -x localhost:705 ...."

would start the agent listening on the TCP port 705 for connections from the local system.
The same effect can also be obtained by adding the line

               agentxsocket localhost:705

to the file snmpd.conf.

The same option can be used with the Net-SNMP agent when running in "subagent" mode, to specify the socket to register with (and receive requests from).
So a subagent might connect to the master agent above (both running on the same host), using:

               "snmpd -X -x localhost:705 ...."

A subagent running embedded within some other application will typically not understand the same command-line options, so would need to set the same configuration programmatically:

      netsnmp_ds_set_string(NETSNMP_DS_APPLICATION_ID,
                            NETSNMP_DS_AGENT_X_SOCKET, "localhost:705");

With the example subagent code from the Net-SNMP tutorial, this line would be added immediately before the 'init_agent' call.


But also see the mention of AgentX security (or the lack of it!) in the earlier entry.

The same approach can also be used to listen on a different named socket, using:

               agentxsocket /tmp/agentx
               agentxperms 770 770 myuser mygroup

or

               snmpd -x /tmp/agentx ....

or

      netsnmp_ds_set_string(NETSNMP_DS_APPLICATION_ID,
                            NETSNMP_DS_AGENT_X_SOCKET, "/tmp/agentx");

as appropriate.