Ad Widget

Collapse

SNMP Traps Translate

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Yevgeniy Semerikov
    Junior Member
    • Jun 2014
    • 8

    #1

    SNMP Traps Translate

    Hello!

    I'm use zabbix_trap_receiver.pl for deliver SNMP traps to Zabbix. It's works fine, but after I'm add MIBs to net-snmp i get partially translated data.

    In /var/log/messages I'm see:

    Jun 10 11:51:02 host snmptrapd[23121]: 2014-06-10 11:51:02 localhost [127.0.0.1] (via UDP: [x.x.x.x]:48107->[x.x.x.x]) TRAP, SNMP v1, community ZBX#012#011ADIC-TAPE-LIBRARY-MIB::logicalLibraryStateChange Enterprise Specific Trap (17) Uptime: 61 days, 0:48:01.06#012#011ADIC-TAPE-LIBRARY-MIB::logicalLibraryState.1 = INTEGER: onlinePending(2)

    But, zabbix_trap_receiver.pl produces translated OID, but untranslated value (see ADIC-TAPE-LIBRARY-MIB::logicalLibraryState.1):

    11:51:02 2014/06/10 ZBXTRAP x.x.x.x
    PDU INFO:
    notificationtype TRAP
    version 0
    receivedfrom UDP: [x.x.x.x]:48107->[x.x.x.x]
    errorstatus 0
    messageid 0
    community ZBX
    transactionid 1
    errorindex 0
    requestid 0
    VARBINDS:
    DISMAN-EVENT-MIB::sysUpTimeInstance
    Timeticks: (527328106) 61 days, 0:48:01.06
    SNMPv2-MIB::snmpTrapOID.0
    OID: ADIC-TAPE-LIBRARY-MIB::logicalLibraryStateChange.0.17
    ADIC-TAPE-LIBRARY-MIB::logicalLibraryState.1
    INTEGER: 2
    SNMP-COMMUNITY-MIB::snmpTrapAddress.0
    IpAddress: 127.0.0.1
    SNMP-COMMUNITY-MIB::snmpTrapCommunity.0
    STRING: "ZBX"
    SNMPv2-MIB::snmpTrapEnterprise.0
    OID: ADIC-TAPE-LIBRARY-MIB::logicalLibraryStateChange

    Anyone know how to fix it?
  • Yevgeniy Semerikov
    Junior Member
    • Jun 2014
    • 8

    #2
    Solved. Simple Perl function SNMP::mapEnum($oid, $value).

    Comment

    • GuiEdington
      Junior Member
      • Jul 2017
      • 10

      #3
      Can you explain how did you fix this? I have the same problem here

      Comment

      • Yevgeniy Semerikov
        Junior Member
        • Jun 2014
        • 8

        #4
        Originally posted by GuiEdington
        Can you explain how did you fix this? I have the same problem here
        Just add or replace some lines in zabbix_trap_receiver.pl by:

        if ($translate = &SNMP::mapEnum($oid, $value)) {
        $value = "$type: $value ($translate)";
        } else {
        $value = "$type: $value";
        }

        Comment

        • GuiEdington
          Junior Member
          • Jul 2017
          • 10

          #5
          Can you post your zabbix_trap_receiver.pl code here? I'm don't know perl programming so I'm kinda lost

          Comment

          • Yevgeniy Semerikov
            Junior Member
            • Jun 2014
            • 8

            #6
            Originally posted by GuiEdington
            Can you post your zabbix_trap_receiver.pl code here? I'm don't know perl programming so I'm kinda lost
            In attach.
            Attached Files

            Comment

            • GuiEdington
              Junior Member
              • Jul 2017
              • 10

              #7
              Thank you very much! Solved.

              Comment

              • kabassanov
                Junior Member
                • Jun 2021
                • 2

                #8
                Hello guys,

                Is this still working with net-snmp-5.8? We get no translations for already mapped oids to names by snmptrapd. As we generate keys in mib2zabbix with the oids ( $item->{ key } = "snmptrap["\\s$oid\\s"]" ), snmp traps match fails for hosts in zabbix.

                (I found something similar here: https://archive.gwos.com/groundwork-.../snmptt/snmptt and it could explain...)

                Thanks.

                Comment


                • kabassanov
                  kabassanov commented
                  Editing a comment
                  OK, I confirm that &SNMP::mapEnum does not translate oids (anymore?). But &SNMP::translateObj does it. So just need to define which kind of entries have to be translated. IMHO, snmpTrapOID is enough...
              • isaqueprofeta
                Senior Member
                Zabbix Certified SpecialistZabbix Certified Professional
                • Aug 2020
                • 154

                #9
                Patch below has tested on 5.4 version zabbix_trap_receiver.pl, add it on line 104 inside foreach my $x (@varbinds) and before the printf inside the loop:

                Code:
                my $oid = $x->[0];
                my $value = $x->[1];
                $value =~ m/^([\w-]+): .+$/;
                $type = $1;
                $value =~ s/$type: //g;
                if ($translate = &SNMP::translateObj($oid, $value)) {
                    $value = "$type: $value ($translate)";
                } else {
                    $value = "$type: $value";
                }

                Comment

                Working...