Ad Widget

Collapse

zabbix snmp trap installing problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sanjose
    Junior Member
    • Mar 2013
    • 5

    #1

    zabbix snmp trap installing problem

    I have problem with installing SNMP trap receiver on Zabbix version 2.0.5. For trap handling I am using default Perl script, zabbix_trap_receiver.pl. The problem is that zabbix did not displays SNMP traps. I was following this documentation https://www.zabbix.com/documentation...types/snmptrap
    and do all necessary configuration by it didn’t work.

    Hire is configuration of snmptrapd.conf file.

    authCommunity execute public
    authCommunity execute PUBLIC
    traphandle default perl do /etc/zabbix/snmp-trap-handler/zabbix_trap_receiver.pl

    disableAuthorization yes

    The perl script is default :

    #!/usr/bin/perl
    #########################################
    #### ABOUT ZABBIX SNMP TRAP RECEIVER ####
    #########################################

    # This is an embedded perl SNMP trapper receiver designed for sending data to the server.
    # The receiver will pass the received SNMP traps to Zabbix server or proxy running on the
    # same machine. Please configure the server/proxy accordingly.
    #
    # Read more about using embedded perl with Net-SNMP:
    # http://net-snmp.sourceforge.net/wiki...mpd_using_perl

    #################################################
    #### ZABBIX SNMP TRAP RECEIVER CONFIGURATION ####
    #################################################

    ### Option: SNMPTrapperFile
    # Temporary file used for passing data to the server (or proxy). Must be the same
    # as in the server (or proxy) configuration file.
    #
    # Mandatory: yes
    # Default:
    $SNMPTrapperFile = '/tmp/zabbix_traps.tmp';

    ### Option: DateTimeFormat
    # The date time format in strftime() format. Please make sure to have a corresponding
    # log time format for the SNMP trap items.
    #
    # Mandatory: yes
    # Default:
    $DateTimeFormat = '%H:%M:%S %Y/%m/%d';

    ###################################
    #### ZABBIX SNMP TRAP RECEIVER ####
    ###################################

    use Fcntl qw(O_WRONLY O_APPEND O_CREAT);
    use POSIX qw(strftime);

    sub zabbix_receiver
    {
    my (%pdu_info) = %{$_[0]};
    my (@varbinds) = @{$_[1]};

    # open the output file
    unless (sysopen(OUTPUT_FILE, $SNMPTrapperFile, O_WRONLY|O_APPEND|O_CREAT, 0666))
    {
    print STDERR "Cannot open [$SNMPTrapperFile]: $!\n";
    return NETSNMPTRAPD_HANDLER_FAIL;
    }

    # get the host name
    my $hostname = $pdu_info{'receivedfrom'} || 'unknown';
    if ($hostname ne 'unknown') {
    $hostname =~ /\[(.*?)\].*/; # format: "UDP: [127.0.0.1]:41070->[127.0.0.1]"
    $hostname = $1 || 'unknown';
    }

    # print trap header
    # timestamp must be placed at the beggining of the first line (can be omitted)
    # the first line must include the header "ZBXTRAP [IP/DNS address] "
    # * IP/DNS address is the used to find the corresponding SNMP trap items
    # * this header will be cut during processing (will not appear in the item value)
    printf OUTPUT_FILE "%s ZBXTRAP %s\n", strftime($DateTimeFormat, localtime), $hostname;

    # print the PDU info
    print OUTPUT_FILE "PDU INFO:\n";
    foreach my $key(keys(%pdu_info))
    {
    printf OUTPUT_FILE " %-30s %s\n", $key, $pdu_info{$key};
    }

    # print the variable bindings:
    print OUTPUT_FILE "VARBINDS:\n";
    foreach my $x (@varbinds)
    {
    printf OUTPUT_FILE " %-30s type=%-2d value=%s\n", $x->[0], $x->[2], $x->[1];
    }

    close (OUTPUT_FILE);

    return NETSNMPTRAPD_HANDLER_OK;
    }

    NetSNMP::TrapReceiver::register("all", \&zabbix_receiver) or
    die "failed to register Zabbix SNMP trap receiver\n";

    print STDOUT "Loaded Zabbix SNMP trap receiver\n";

    Also I have edited zabbix_server.conf file with following.

    SNMPTrapperFile=/tmp/zabbix_traps.tmp
    StartSNMPTrapper=1




    When I am running perl script from bash it displaying following error:

    ./zabbix_trap_receiver.pl
    Undefined subroutine &NetSNMP::TrapReceiver::register called at ./zabbix_trap_receiver.pl line 105.

    I have installed following packages:
    net-snmp-utils-5.5-44.el6.x86_64
    net-snmp-5.5-44.el6.x86_64

    What could be the problem, or how can I debug it ?
  • manfred.r
    Junior Member
    • Apr 2013
    • 1

    #2
    Re: zabbix snmp trap installing problem

    Hi,

    try to call the perl intepreter in a differnt way:

    snmptrapd.conf:
    authCommunity execute public
    authCommunity execute PUBLIC
    perl do"/etc/zabbix/snmp-trap-handler/zabbix_trap_receiver.pl"

    Comment

    • ProTON
      Member
      • Oct 2005
      • 77

      #3
      You are missing "net-snmp-perl" package in your OS.
      Last edited by ProTON; 08-05-2013, 12:09.

      Comment

      • safpsr
        Member
        • Aug 2007
        • 70

        #4
        Hi,

        I have the same problem. Did these solutions correct it ? I tried it without success ...

        Thanks

        Comment

        • gotanbl
          Junior Member
          • Dec 2010
          • 5

          #5
          I receive traps. But varbindings not work.
          For example:
          CISCO-SYSLOG-MIB::clogHistSeverity.124 type=2 value=INTEGER: 4

          4 is for error

          I want to see this

          CISCO-SYSLOG-MIB::clogHistSeverity.124 type=2 value=INTEGER: 4 (error)

          I have same configuration and problem as above. All necessary packages is installed. OS is CentOS 6.4.

          Thanks for help

          Comment

          • Ishan
            Member
            • May 2013
            • 40

            #6
            Hello Sanjose

            I am have the same issue, you found any solution for your issue?

            Thanks & Regards,
            Ishan
            Last edited by Ishan; 14-04-2014, 09:48.

            Comment

            • gotanbl
              Junior Member
              • Dec 2010
              • 5

              #7
              Originally posted by Ishan
              I am have the same issue, you found any solution for your issue?

              Thanks & Regards,
              Ishan
              No, I haven't found solution!

              Comment

              • Piotrek
                Junior Member
                • Feb 2017
                • 1

                #8
                Hi!
                Have anyone found any solution for issue describe in first post?

                Thanks for help

                Comment

                • jhgrc
                  Member
                  • Jun 2009
                  • 52

                  #9
                  The default program is missing

                  use NetSNMP::TrapReceiver;

                  put it after "use POSIX..."

                  Comment

                  Working...