SETUP: I process SNMP traps using Erlang snmpm module. I have implemented the behavior snmpm_user and called it as snmpm_user1, so that the SNMP traps are processed by snmpm_user1 rather than by the default implementation snmpm_user_default.
I use net-snmp command to send the traps. The command sends traps, each time from a different ephemeral port (ex: 51773 during this run). This is expected as per SNMP standards.
sudo snmptrap -v 2c -c public 127.0.0.1:5000 "" .1.3.6.1.4.1.8072.2.3.0.1 .1.3.6.1.2.1.1.3.0 s "Trap 2"
ISSUE: SNMP traps are processed by snmpm_user_default rather than by snmpm_user1. However, SNMP GET responses are processed by snmpm_user1 as expected.
The code and the complete logs are uploaded in git
LOG ANALYSIS: snmpm expects the traps from 127.0.0.1:161 as evident from the logs “unknown agent: 127.0.0.1:51773. Known Agents: {{127,0,0,1},51773}
”. snmpm does not find a snmpm_user for the agent “{{127,0,0,1},51773}” as evident from the logs “failed retrieving user id for agent {{127,0,0,1},51773}
”.
FURTHER DEBUGGING: snmpm_user_table has two entries, one each for snmpm_user1 & snmpm_user_default. Both the entries have the agent address 127.0.0.1:161.
ERROR LOGS SUMMARY:
*** [2024-11-28 21:42:35.829] SNMP M-NET-IF MPD LOG ***
[agent engine max msg size lookup] unknown agent: 127.0.0.1:51773
Known Agents: [{"Agent1",{{127,0,0,1},161}}]
*** [2024-11-28 21:42:35.834] SNMP M-SERVER LOG ***
[trap] failed retrieving user id for agent <snmpUDPDomain,{{127,0,0,1},
51773}>:
Error: {error,
{target_name_not_found,snmpUDPDomain,{{127,0,0,1},51773}}}
when
Users: [snmp_manager]
Agents: ["Agent1"]