Re: Issue with trapsess in snmpd.conf file

Magnus Fromreide <[email protected]>
Newsgroups gmane.network.net-snmp.devel
Message-ID <[email protected]>
On Mon, May 04, 2020 at 01:54:04AM +0200, Philippe Denis wrote:
> > Hi Magnus,
> >
> > Thanks for your answer.
> 
> Firstly, when asking things on a mailing list you should keep the whole
> conversation on the mailing list as I ain't interested in doing unpaid
> consultancy work.
> 
> > Now, the warning is not more present but no trap is received (observation
> done with tcpdump).
> >
> > Is there any keyword to address  in the Agent X ?
> >
> > Do you have a simple example to test ?
> 
> This require some help from your side, could you please tell me the exact
> commands you use to start your subagent as well as the master agent (snmpd).
> 
> [Phil]: For starting the subagent, I called './Mydaemon -Dtdomain'   and
> for the Master Agent "/usr/local/sbin/snmpd  -f -Lo -C -c
> /var/net-snmp/Mysnmpd.conf"
> The log of the subagent is the following one:
> registered debug token agentx, 1
> registered debug token tdomain, 1
> Log handling defined - disabling stderr
> tdomain: netsnmp_tdomain_init() called
> tdomain: domain_list -> { iso.3.6.1.6.1.1, "udp" } -> {
> iso.3.6.1.2.1.100.1.5, "tcp" } -> { iso.3.6.1.4.1.8072.3.3.7, "alias" } ->
> { iso.3.6.1.2.1.100.1.13, "unix" } -> [NIL]
> agentx_register_app_config_handler: registering .conf token for
> "agentxsocket"
> agentx_register_app_config_handler: registering .conf token for
> "agentxperms"
> agentx_register_app_config_handler: registering .conf token for
> "agentxRetries"
> agentx_register_app_config_handler: registering .conf token for
> "agentxTimeout"

Here you try to bind a udp port to 193.168.1.1

> tdomain: tdomain_transport_full("snmptrap", "193.168.1.1", 0, "[NIL]",
> "[NIL]")
> tdomain: checking for host specific config hosts/193.168.1.1
> tdomain: Use application default domains "udp" "udp6"
> tdomain: Found domain "udp" from specifier "udp"
> tdomain: trying domain "udp" address "193.168.1.1" default address ":162"
> tdomain: tdomain_transport_full("snmptrap", "193.168.1.10", 0, "[NIL]",
> "[NIL]")
> tdomain: checking for host specific config hosts/193.168.1.10
> tdomain: Use application default domains "udp" "udp6"
> tdomain: Found domain "udp" from specifier "udp"
> tdomain: trying domain "udp" address "193.168.1.10" default address ":162"
> tdomain: tdomain_transport_full("snmptrap", "193.168.2.1", 0, "[NIL]",
> "[NIL]")
> tdomain: checking for host specific config hosts/193.168.2.1
> tdomain: Use application default domains "udp" "udp6"
> tdomain: Found domain "udp" from specifier "udp"
> tdomain: trying domain "udp" address "193.168.2.1" default address ":162"

Here you create the socket AgentX is supposed to listen on

> Turning on AgentX master support.
> agentx/config: port spec: /var/agentx/master
> agentx/config: port permissions: 777 777
> agentx/config: socket permissions: 777 (511)
> agentx/config: directory permissions: 777 (511)


Here you try to create a server on udp:161

> tdomain: tdomain_transport_full("snmp", "udp:161", 1, "[NIL]", "[NIL]")
> tdomain: Found domain "udp" from specifier "udp"
> tdomain: trying domain "udp" address "161" default address ":161"

and here that failed, probably because your snmpd is already listening
on that port.

> Error opening specified endpoint "udp:161"
> Server Exiting with code 1
> NET-SNMP version 5.7.3 AgentX subagent connected

This looks like the log I would expect from snmpd with a master agent,
not the log from a subagent.

/MF

> [Phil]: Here is the content of the Mysnmpd.conf file
> 
> #  Listen for connections on all interfaces
> agentAddress  udp:161
> 
> # MAC Address and eth0 used to create the SNMPv3
> engineIDType 3
> engineIDNIC eth0
> 
> view   systemonly  included   .1.3.6.1.2.1.1
> view   systemonly  included   .1.3.6.1.2.1.25.1
> rwuser systemadm
> 
> trapsess -v3 -u systemadm localhost
> trapsess -v3 -u systemadm 193.168.1.1
> trapsess -v3 -u systemadm193.168.1.10
> trapsess -v3 -u systemadm193.168.2.1
> 
> master agentx
> agentXSocket /var/agentx/master
> agentXperms 777 777
> 
> [Phil]: How to know if a trap is sent ? Is there a specific keyword in the
> same principle that '-Dagentx' ?
> Thanks.
> Philippe
> 
>  /MF
> 
> Le mer. 29 avr. 2020 ?? 16:19, Magnus Fromreide <[email protected]> a
> ??crit :
> 
> > On Wed, Apr 29, 2020 at 01:22:52PM +0200, Philippe Denis wrote:
> > > Hi Magnus,
> > >
> > > Thanks for your answer.
> >
> > Firstly, when asking things on a mailing list you should keep the whole
> > conversation on the mailing list as I ain't interested in doing unpaid
> > consultancy work.
> >
> > > Now, the warning is not more present but no trap is received
> > (observation done with tcpdump).
> > >
> > > Is there any keyword to address  in the Agent X ?
> > >
> > > Do you have a simple example to test ?
> >
> > This require some help from your side, could you please tell me the exact
> > commands you use to start your subagent as well as the master agent
> > (snmpd).
> >
> > /MF
> >
> > > Best regards
> > > Philippe DENIS
> > >
> > > > Le 29 avr. 2020 ?? 08:26, Magnus Fromreide <[email protected]> a
> > ??crit :
> > > >
> > > > ???On Wed, Apr 29, 2020 at 02:46:30AM +0200, Philippe Denis wrote:
> > > >> Hello all,
> > > >>
> > > >> I???m facing several issues when I???ve tried to send V3 traps from my
> > Agent X to the master agent to trap recipient. The program linked to the
> > trap generation was written by mib2c tool mainly. (Only dummies variables
> > and values added)
> > > >>
> > > >> I???ve added in my configuration file snmpd.conf file, the following
> > line:
> > > >> trapsess 192.1.2.1
> > > >>
> > > >> When I start the agent, I got the following error message ???no
> > community specified.??? but when reading the man page it looks that the trap
> > community is for trapsink, trap2sink and trapinform.
> > > >>
> > > >> Is it correct ? Is there any option to use to know what is wrong ?
> > > >
> > > > In the man page it says that trapsess should take arguments like
> > snmptrapd.
> > > >
> > > > In order to experiment I would run
> > > >
> > > >  snmpd -Lo -d -f --trapsess="trapsess-params" 127.0.0.1
> > > >
> > > > and then stop snmpd with Ctrl-C so for my first attempt, similar to
> > > > yours, I run
> > > >
> > > >  snmpd -Lo -d -f --trapsess="127.0.0.1" 127.0.0.1
> > > >
> > > > and snmpd happily prints
> > > >
> > > >  Security name is missing.Cannot add new trap destination internal0
> > > >
> > > > so something differs between our agents or configs. If I try with
> > > >
> > > >  snmpd -Lo -d -f --trapsess="-v2c 127.0.0.1" 127.0.0.1
> > > >
> > > > then my snmpd prints
> > > >
> > > >  No community name specified.
> > > >
> > > > and I suppose that is similar enough to your case but it is also a v2
> > > > notification so lets say explicitly that we want a v3 notification
> > > >
> > > >  snmpd -Lo -d -f --trapsess="-v3 127.0.0.1" 127.0.0.1
> > > >
> > > > prints
> > > >
> > > >  Security name is missing.Cannot add new trap destination internal0
> > > >
> > > > and the snmpcmd.1 man page states that -u is used to specify a
> > securityName
> > > > so lets try that
> > > >
> > > >  snmpd -Lo -d -f --trapsess="-v3 -u mySecurityName 127.0.0.1" 127.0.0.1
> > > >
> > > > This results in my snmpd sending something with mySecurityName in it
> > so I
> > > > suppose that is the startup notification.
> > > >
> > > > In order to make this permanent I then add
> > > >
> > > > trapsess -v3 -u mySecurityName 127.0.0.1
> > > >
> > > > to my snmpd.conf
> > > >
> > > > Does this help?
> > > >
> > > > (The snmpd parameters mean
> > > > -Lo - send logs to stdout
> > > > -d  - log all traffic
> > > > -f  - run in the foreground)
> > > >
> > > >> I???m using tcpdump to sniff network but nothing is sent although the
> > gdb debugger says that send_v2trap is OK.
> > > >>
> > > >> Thanks by advance for your help.
> > > >>
> > > >> Best Regards.
> > > >> Ph. DENIS
> > > >>
> > > >> _______________________________________________
> > > >> Net-snmp-coders mailing list
> > > >> [email protected]
> > > >> https://lists.sourceforge.net/lists/listinfo/net-snmp-coders
> >
> 
> 
> -- 
> Cordialement
> Ph. DENIS


> _______________________________________________
> Net-snmp-coders mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/net-snmp-coders
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.