The SNMP test module snmp_ex2_simple_standard_test has different test cases to test various SNMP operations. I considered the test case related to the SNMP GET operation to simplify the debugging. I am getting an error “failed retrieving agent data”. Please help me in resolving the issue.
To debug the issue, I added snmpm:verbosity(all, info). in snmp_ex2_manager.erl. I also enabled dbg logs for snmpm_config. Following is the analysis of the logs.
- snmp_ex2_simple_standard_test uses an agent 127.0.1.1:161. snmpm_config:agent_info(“127.0.1.1:161”) resulted in the vtrace messages
"SNMP M-SERVER INFO -- failed retrieving agent data for get:" - snmpm_config:agent_info(default_agent,all) is also called, which successfully returned a value.
default_agentis the default agent defined in snmpm_config-define(DEFAULT_TARGETNAME, default_agent). - Looks like the agent 127.0.1.1:161 is not initialized properly.
LOGS
Erlang/OTP 27 [DEVELOPMENT] [erts-14.1.1] [source] [64-bit] [smp:6:6] [ds:6:6:10] [async-threads:1]
Eshell V14.1.1 (press Ctrl+G to abort, type help(). for help)
(node1@vm-alarm)1> dbg:tracer().
{ok,<0.93.0>}
(node1@vm-alarm)2> dbg:tpl(snmpm_config, agent_info, []).
{ok,[{matched,'node1@vm-alarm',4}]}
(node1@vm-alarm)3> dbg:p(all, c).
{ok,[{matched,'node1@vm-alarm',51}]}
(node1@vm-alarm)4> snmp_ex2_simple_standard_test:start().
(<0.103.0>) call snmpm_config:agent_info()
(<0.103.0>) call snmpm_config:agent_info(default_agent,all)
(<0.100.0>) call snmpm_config:agent_info()
(<0.100.0>) call snmpm_config:agent_info(default_agent,all)
snmpm:snmpm:mk_target_name(snmpUDPDomain, {{127,0,1,1},161}, [{community,
"public"}]) -> "127.0.1.1:161-v1".
(<0.103.0>) call snmpm_config:agent_info("127.0.1.1:161-v1",user_id)
(<0.103.0>) call snmpm_config:agent_info({"127.0.1.1:161-v1",user_id})
(<0.114.0>) call snmpm_config:agent_info({127,0,1,1},version)
(<0.114.0>) call snmpm_config:agent_info({{127,0,1,1},version})
*** [2024-02-09 21:59:58.372] SNMP M-SERVER INFO ***
failed retrieving agent data for get:
TargetName: {127,0,1,1}
Error: {error,not_found}
ok
CODE To simplify the debugging, I modified the function snmp_ex2_simple_standard_test:start/3 to test the SNMP GET operation alone.
start(Mibs, AgentAddr, AgentConfig) ->
Conf = [{mibs, Mibs}],
{ok, _Pid} = snmp_ex2_manager:start_link(Conf),
snmp_ex2_manager:agent(AgentAddr, AgentConfig),
%%simple_standard_test(AgentAddr),
%%simple_standard_test_ori(AgentAddr),
g(AgentAddr, [1,3,6,1,2,1,1,1]), %%sysDescr
%%g(AgentAddr, [1,3,6,1,2,1,11,1]), %%snmpInPkts
snmp_ex2_manager:stop().