Template:FAQ:Agent 13

From Net-SNMP Wiki
Revision as of 19:53, 22 October 2006 by Dts12 (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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 sides accordingly.

For the Net-SNMP master agent, this is done using the command-line option '-x'. The command

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

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

               agentxsocket localhost:705

to the file snmpd.conf

The main Net-SNMP agent can also be run in a "subagent" mode, and this uses the same command-line option to specify a different AgentX socket. So

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

would start it as a subagent, and connect to the master agent listening on TCP port 705 on the same system.

A subagent running embedded within some other application will typically not understand the same command-line options. This will need to set the same configuration programmatically. For example, the example subagent driving code from the Net-SNMP "subagent program" tutorial (on the project web pages) could be made to connect to the same TCP port by adding the line

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

before the 'init_agent' call.

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

               agentxsocket /tmp/agentx
               agentxperms 777 777 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.

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