Ad Widget

Collapse

SNMP trap item value printed in e-mail.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gnik
    Junior Member
    • Mar 2020
    • 13

    #1

    SNMP trap item value printed in e-mail.

    I am setting up trap alerts and all is well - the traps match ok, but I want to send e-mail when a trap is received and I want to include the trap varbinds in the e-mail... only the varbinds. I usually use {ITEM.VALUE} for similar things, but currently the {ITEM.VALUE} prints also the "PDU INFO:", which includes the community of the rtap and other stuff that the recipients must not see.
    I have tried to match snmptrap[VARBIND.*] as item key, also snmptrap[^VARBIND.*] the regex matches, but the ITEM.VALUE still shows the PDU INFO.
    Can anyone help with a tip? How do I tell Zabbix to get only the VARBINDS.* portion of the trap?
    Here is what the perl script writes in the trap log file:

    PDU INFO:
    notificationtype TRAP
    version 1
    receivedfrom UDP: [xxxxxxxx]:51860->[xxxxxxxxxx]:162
    errorstatus 0
    messageid 0
    community xxxxxxxxxxx
    transactionid 12
    errorindex 0
    requestid 230467315
    VARBINDS:
    DISMAN-EVENT-MIB::sysUpTimeInstance type=67 value=Timeticks: (0) 0:00:00.00
    SNMPv2-MIB::snmpTrapOID.0 type=6 value=OID: SNMPv2-SMI::enterprises.2.6.190.3

    and this is what I see in the Last value for the item.

    Thanks,
    Georgi
  • tim.mooney
    Senior Member
    • Dec 2012
    • 1427

    #2
    I didn't want the community name going out in emails either, so what I did was modify the perl script so that it obscures the community name before it even writes the trap to the intermediate file:

    #
    # try obscuring the community in the logged file.
    # Also, change the %-30s to %-40s
    #
    if ($key =~ /community/i) {
    printf OUTPUT_FILE " %-40s %s\n", $key, 'OBSCURED';
    } else {
    # standard case, print it out, as-is
    printf OUTPUT_FILE " %-40s %s\n", $key, $pdu_info{$key};
    }

    The downside is that you no longer have the community, but we weren't actually keying off community anyway; our alerts and other config need other info (like IP address), but not the community. So far this has worked well for us.

    Comment

    • gnik
      Junior Member
      • Mar 2020
      • 13

      #3
      Hi,

      thanks so much for the help. I never thought to inspect the perl script... apparently the PDU part is not necessary for my purposes so I just stopped printing it. The traps still come fine and are reflected in the mails the item's value and the mails in the way I need them.

      Comment

      Working...