Reputation: 635
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:
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.
How to change the listening port of subagent? Do I need to change in the example code to set the port?
Upvotes: 1
Views: 9242
Reputation: 85
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");
Upvotes: 0
Reputation: 22262
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");
Upvotes: 1
Reputation: 635
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!
Upvotes: 0