Difference between revisions of "Template:FAQ:Agent 13"

From Net-SNMP Wiki
Jump to: navigation, search
(5.4 release synchronisation)
(Explicit transport specifier for TCP connections)
Line 7: Line 7:
 
the option </CODE>'-x'</CODE>.<BR>
 
the option </CODE>'-x'</CODE>.<BR>
 
The command
 
The command
                 "snmpd -x localhost:705 ...."
+
                 "snmpd -x tcp:localhost:705 ...."
 
would start the agent listening on the TCP port 705 for connections
 
would start the agent listening on the TCP port 705 for connections
 
from the local system.<BR>The same effect can also be obtained by adding
 
from the local system.<BR>The same effect can also be obtained by adding
 
the line
 
the line
                 agentxsocket localhost:705
+
                 agentxsocket tcp:localhost:705
 
to the file <CODE>snmpd.conf</CODE>.
 
to the file <CODE>snmpd.conf</CODE>.
  
Line 18: Line 18:
 
So a subagent might connect to the master agent above (both running
 
So a subagent might connect to the master agent above (both running
 
on the same host), using:
 
on the same host), using:
                 "snmpd -X -x localhost:705 ...."
+
                 "snmpd -X -x tcp:localhost:705 ...."
  
 
A subagent running embedded within some other application will
 
A subagent running embedded within some other application will
Line 24: Line 24:
 
need to set the same configuration programmatically:
 
need to set the same configuration programmatically:
 
       netsnmp_ds_set_string(NETSNMP_DS_APPLICATION_ID,
 
       netsnmp_ds_set_string(NETSNMP_DS_APPLICATION_ID,
                             NETSNMP_DS_AGENT_X_SOCKET, "localhost:705");
+
                             NETSNMP_DS_AGENT_X_SOCKET, "tcp:localhost:705");
  
 
With the example subagent code from the Net-SNMP tutorial, this line
 
With the example subagent code from the Net-SNMP tutorial, this line

Revision as of 10:23, 22 November 2007

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 tcp: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 tcp: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 tcp: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, "tcp: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.