how to set the port of snmp agentX subagent?

8.5k views Asked by At

I am working on extending net-snmp to write a subagent with agentX. Now I use the example codes from net-snmp, and compiled to a subagent. Below is the codes I get from: http://www.net-snmp.org/wiki/index.php/TUT:Writing_a_MIB_Module

And I succeed to perform snmpget and snmpset to my subagent using agentX.

My questions:

  1. I think the subagent and master agent are listening on a port, how can I find which port they are listening? I have been told the default port is 705, but when I use "netstat", I can't find any process listening on port 705.

  2. How to change the listening port of subagent? Do I need to change in the example code to set the port?

3

There are 3 answers

0
zhaojing On

The problem is solved: http://www.net-snmp.org/wiki/index.php/FAQ%3aAgent_12

By adding netsnmp_ds_set_string(NETSNMP_DS_APPLICATION_ID, NETSNMP_DS_AGENT_X_SOCKET, "tcp:localhost:705");

in the example codes before the 'init_agent' call.

Thanks!

0
Wes Hardaker On

By default, actually, on "anything but windows" the default is to listen to a unix socket located at /var/agentx/master.

You can change the listening address using the API suggested by the other poster, or even using the snmpd.conf configuration file:

agentXSocket tcp:localhost:705

When you create a subagent, it'll read your FOO.conf file where FOO is what you passed to init_snmp("FOO");

0
soni On

You need to change the snmpd.conf file

master agentx
AgentXSocket tcp:X.X.X.X:705

And in your agentx code write down these lines before init_agent()

netsnmp_ds_set_string(NETSNMP_DS_APPLICATION_ID, NETSNMP_DS_AGENT_X_SOCKET, "tcp:X.X.X.X:705");