Hi Bill,

thanks a lot for this solution – I tried it out and it works! ☺


Cheers
Markus

Von: Bill Fenner [mailto:fen...@gmail.com]
Gesendet: Dienstag, 9. Juni 2020 16:46
An: Markus Reusch <markus.reu...@raiffeisen.ch>
Cc: net-snmp-users@lists.sourceforge.net; Daniel Koller 
<daniel.kol...@raiffeisen.ch>
Betreff: Re: snmptrapd: Community-String not always passed to handler script

Reading the 5.8 source, it looks like the "traphandle" directive accepts an 
undocumented "-F" argument - try

traphandle -F "CommOrSecret=%u" default /appl/snmp/bin/handler.sh

(Obviously you will need to play with the format to get the other information 
into it too)

  Bill


On Thu, Jun 4, 2020 at 5:34 AM Markus Reusch 
<markus.reu...@raiffeisen.ch<mailto:markus.reu...@raiffeisen.ch>> wrote:
Hello list,

sorry to bump this up. Anyone got an idea how to enforce passing the 
community-string to the handler script?


Cheers
Markus


---------------------------------------------

Hello list,

we wrote a handler script that relies on getting the community-string as we the 
script uses this to generate an event and route it to the correct recipients.

Usually for “real” traps sent by different devices, we can see the 
community-string in the snmptrapd.log. For test traps we send from the shell it 
most times doesn’t show up.

So with adding something like

format print Hostname=%B | CommOrSecret=%u | snmpV=%s | TrapDesc="%W"\n | 
Bindings=%v\n

we can enforce that the community-string is written to the log, but our handler 
does not get this info.
The handler is called with

traphandle default /appl/snmp/bin/handler.sh

Maintaining mappings like OIDs to different handler-scripts in snmptrapd.conf 
is no option for us. We do this with a text file in a table format which is 
being looked up by handler script which is much faster and easier for us.

I saw that you can pass arguments to those scripts – is there a kind of 
variable that contains the community-string for example?
Is there any way to ensure that the community-string is passed to the handler?

I could not find anything in the documentation regarding this problem nor on 
the web.


Thanks for a hint in advance.


Cheers
Markus

*****************************************************
This e-mail may contain confidential material. It is intended only for the 
person or entity which it is addressed to. In case you should not be supposed 
to get this e-mail we ask you to delete it without taking notice of its 
content. Any views or opinions expressed in this e-mail are those of the sender 
and do not necessarily coincide with those of The Swiss Raiffeisen Group. 
Therefore this e-mail does not represent a binding agreement nor an offer to 
deal. E-Mail transmission can be insecure and can contain errors. Information 
could be intercepted, corrupted, lost, destroyed, incomplete or may contain 
viruses. Neither The Swiss Raiffeisen Group nor the sender can accept any 
liability for any kind of damage as the result of viruses or transmission 
errors.
*****************************************************
_______________________________________________
Net-snmp-users mailing list
Net-snmp-users@lists.sourceforge.net<mailto:Net-snmp-users@lists.sourceforge.net>
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________
Net-snmp-users mailing list
Net-snmp-users@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users

Reply via email to