Uploaded image for project: 'ZABBIX BUGS AND ISSUES'
  1. ZABBIX BUGS AND ISSUES
  2. ZBX-26067

snmptrapd is not sending the trap to snmptt. We need a solution to appear the traps in the GUI dashboard.

XMLWordPrintable

    • Icon: Incident report Incident report
    • Resolution: Commercial support required
    • Icon: Trivial Trivial
    • None
    • None
    • Server (S)
    • None

      Dear team,
      As I am working on the zabbix preparation.
      Receiving the error when trying to send the traps from agent to server (mentioned in threads). Seems like snmptrapd receives it and sending it to snmptt and getting the error. Please find the snmptt and snmptrapd.conf for the reference (mentioned in threads).Below find the completed tasks on my LAB system for this assignment. * Zabbix server installation and configuration.

      • Zabbix agent installation and configuration.
      • Integration with snmp interface between server and agent.
      • SNMP traps appearing on GUI.
      • Snmptrapd and snmptt configuration.
      • Analysed for the flow between snmptrapd and snmptt.

      I have been facing these issues in Zabbix preparation from quite some days. I have tried my level best to move forward but for the further progress I need some expert support on this. 

      Error:-
       

      Feb 18 18:42:58 localhost snmptrapd[6479]: 2025-02-18 18:42:48 <UNKNOWN> [UDP: [192.168.40.191]:55353->[192.168.40.181]:162]:#012sysUpTimeInstance = Timeticks: (2594473) 7:12:24.73#011snmpTrapOID.0 = OID: snmpMIB#011linkDown = STRING: "eth0" Feb 18 18:42:58 localhost snmptrapd[6479]: Loaded Zabbix SNMP trap receiver Feb 18 18:42:58 localhost snmptrapd[6481]: Scalar value @args[0] better written as $args[0] at /usr/lib64/perl5/vendor_perl/Sys/Syslog.pm line 454. Feb 18 18:42:58 localhost snmptrapd[6481]: Redundant argument in sprintf at /usr/lib64/perl5/vendor_perl/Sys/Syslog.pm line 454. Feb 18 18:42:58 localhost snmptt-sys[6481]: SNMPTT v1.4 started Feb 18 18:42:58 localhost snmptt-sys[6481]: Loading /etc/snmp/snmptt.conf Feb 18 18:42:58 localhost snmptrapd[6481]: Redundant argument in sprintf at /usr/lib64/perl5/vendor_perl/Sys/Syslog.pm line 454. Feb 18 18:42:58 localhost snmptrapd[6481]: Redundant argument in sprintf at /usr/lib64/perl5/vendor_perl/Sys/Syslog.pm line 454, <SNMPTTCONF> line 6. Feb 18 18:42:58 localhost snmptt-sys[6481]: Finished loading 6 lines from /etc/snmp/snmptt.conf Feb 18 18:42:58 localhost snmptrapd[6481]: Redundant argument in sprintf at /usr/lib64/perl5/vendor_perl/Sys/Syslog.pm line 454. Feb 18 18:42:58 localhost snmptrapd[6481]: Debug file /var/log/snmptt/snmptt.debug.log re-opened under uid 995 Feb 18 18:42:58 localhost snmptt-sys[6481]: Changing to UID: snmptt (995)
      This is the command I am using to generate the traps from agent.snmptrap -v 2c -c public 192.168.40.181 '' SNMPv2-MIB::snmpMIB IF-MIB::linkDown s eth0 {}
       
      [root@localhost Sys]# cat /etc/snmp/snmptrapd.conf # Example configuration file for snmptrapd # # No traps are handled by default, you must edit this file! # # authCommunity log,execute,net public # traphandle SNMPv2-MIB::coldStart /usr/bin/bin/my_great_script cold disableAuthorization yes outputOption s #traphandle default /usr/bin/zabbix_trap_receiver.pl authCommunity execute public #traphandle default /usr/lib/zabbix/externalscripts/snmptrap.sh perl do "/usr/bin/zabbix_trap_receiver.pl"; #traphandle default /usr/local/snmptt/snmptt v #traphandle default /usr/local/bin/snmptrap_handler.sh [root@localhost Sys]# [root@localhost Sys]# cat /usr/bin/zabbix_trap_receiver.pl #Unable to render embedded object: File ( # [http://net-snmp.sourceforge.net/wiki/index.php/Tut:Extending_snmpd_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 NetSNMP::TrapReceiver; 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) not found.\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 beginning 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)) { if ($pdu_info{$key} !~ /^[[:print:]]$/) { my $OctetAsHex = unpack('H', $pdu_info{$key}); # convert octet string to hex $pdu_info{$key} = "0x$OctetAsHex"; # apply 0x prefix for consistency } 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); # Call SNMPTT to process the trap system("/usr/local/snmptt/snmptt"); 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"; [root@localhost Sys]#

            zabbix.support Zabbix Support Team
            sethu.deiv@gmail.com Sethu Pandi P
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: