Ad Widget

Collapse

SNMP Traps not mapped to host

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • GeneBean
    Junior Member
    • Jan 2012
    • 21

    #1

    SNMP Traps not mapped to host

    I have my SNMP interfaces defined on my hosts in Zabbix with both the name and IP and DNS set as primary for it to go out and do SNMP based checks. This works. When hosts generate traps, many of them are not making it into the snmptrap.fallback. Any help on figuring out why this is would be greatly appreciated.

    When I look at /var/log/zabbix/zabbix_server.log I see things like this for hosts defined as mentioned above (ip address slightly redacted):
    Code:
    7133:20130604:230337.943 unmatched trap received from [x.10.205.44]: 23:03:37 2013/06/04 PDU INFO:
      notificationtype               TRAP
      version                        0
      receivedfrom                   UDP: [x.10.205.44]:54576->[x.10.2.10]
      errorstatus                    0
      messageid                      0
      community                      public
      transactionid                  34125
      errorindex                     0
      requestid                      0
    VARBINDS:
      DISMAN-EVENT-MIB::sysUpTimeInstance type=67 value=Timeticks: (178358828) 20 days, 15:26:28.28
      SNMPv2-MIB::snmpTrapOID.0      type=6  value=OID: PowerNet-MIB::upsOnBattery
      PowerNet-MIB::mtrapargsString.0 type=4  value=STRING: "UPS: Switched to battery backup power."
      SNMP-COMMUNITY-MIB::snmpTrapAddress.0 type=64 value=IpAddress: x.10.205.44
      SNMP-COMMUNITY-MIB::snmpTrapCommunity.0 type=4  value=STRING: "public"
      SNMPv2-MIB::snmpTrapEnterprise.0 type=6  value=OID: PowerNet-MIB::apc
      6937:20130604:230337.991 Zabbix agent item [system.cpu.load[,avg5]] on host [UWG-DC10] failed: first network error, wait for 15 seconds
      6940:20130604:230338.779 Zabbix agent item [perf_counter["\SQLServer:Memory Manager\Total Server Memory (KB)"]] on host [upd-apps01.uwg.westga.edu] failed: first network error, wait for 15 seconds
    The same entry shows up in /var/log/snmp/zabbix_traps.log as:
    Code:
    23:03:37 2013/06/04 ZBXTRAP x.10.205.44
    PDU INFO:
      notificationtype               TRAP
      version                        0
      receivedfrom                   UDP: [x.10.205.44]:54576->[x.10.2.10]
      errorstatus                    0
      messageid                      0
      community                      public
      transactionid                  34125
      errorindex                     0
      requestid                      0
    VARBINDS:
      DISMAN-EVENT-MIB::sysUpTimeInstance type=67 value=Timeticks: (178358828) 20 days, 15:26:28.28
      SNMPv2-MIB::snmpTrapOID.0      type=6  value=OID: PowerNet-MIB::upsOnBattery
      PowerNet-MIB::mtrapargsString.0 type=4  value=STRING: "UPS: Switched to battery backup power."
      SNMP-COMMUNITY-MIB::snmpTrapAddress.0 type=64 value=IpAddress: x.10.205.44
      SNMP-COMMUNITY-MIB::snmpTrapCommunity.0 type=4  value=STRING: "public"
      SNMPv2-MIB::snmpTrapEnterprise.0 type=6  value=OID: PowerNet-MIB::apc
    Here is my /etc/snmp/snmptrapd.conf:
    Code:
    # 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
    
    ## Let all traps from all community strings come in
    disableAuthorization yes
    
    ## Zabbix trap script
    perl do "/usr/local/bin/zabbix_trap_receiver.pl";
  • GeneBean
    Junior Member
    • Jan 2012
    • 21

    #2
    New install, same problem

    I recently installed Zabbix on a new server and migrated over. As it turns out, I am still having this same problem. The host with ip x.10.22.36 has an SNMP Interface configured with this address and an snmptrap.fallback item yet it still does not go to the host. Hopefully, someone can help me. Thanks!

    zabbix_server.log
    Code:
    24571:20140903:003320.577 unmatched trap received from [x.10.22.36]: 00:33:19 2014/09/03 PDU INFO:
      notificationtype               TRAP
      version                        1
      receivedfrom                   UDP: [x.10.22.36]:161->[x.10.2.10]
      errorstatus                    0
      messageid                      0
      community                      SNMP-trap
      transactionid                  30240
      errorindex                     0
      requestid                      0
    VARBINDS:
      DISMAN-EVENT-MIB::sysUpTimeInstance type=67 value=Timeticks: (1438731846) 166 days, 12:28:38.46
      SNMPv2-MIB::snmpTrapOID.0	 type=6  value=OID: SNMPv2-MIB::authenticationFailure
    zabbix_traps.log
    Code:
    00:33:19 2014/09/03 ZBXTRAP x.10.22.36
    PDU INFO:
      notificationtype               TRAP
      version                        1
      receivedfrom                   UDP: [x.10.22.36]:161->[x.10.2.10]
      errorstatus                    0
      messageid                      0
      community                      SNMP-trap
      transactionid                  30240
      errorindex                     0
      requestid                      0
    VARBINDS:
      DISMAN-EVENT-MIB::sysUpTimeInstance type=67 value=Timeticks: (1438731846) 166 days, 12:28:38.46
      SNMPv2-MIB::snmpTrapOID.0      type=6  value=OID: SNMPv2-MIB::authenticationFailure
    /etc/snmp/snmptrapd.conf
    Code:
    # 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
    
    ## Let all traps from all community strings come in
    disableAuthorization yes
    
    ## Zabbix trap script
    perl do "/usr/local/bin/zabbix_trap_receiver.pl"
    /usr/local/bin/zabbix_trap_receiver.pl
    Code:
    #!/usr/bin/perl
    
    #
    # Zabbix
    # Copyright (C) 2001-2014 Zabbix SIA
    #
    # This program is free software; you can redistribute it and/or modify
    # it under the terms of the GNU General Public License as published by
    # the Free Software Foundation; either version 2 of the License, or
    # (at your option) any later version.
    #
    # This program is distributed in the hope that it will be useful,
    # but WITHOUT ANY WARRANTY; without even the implied warranty of
    # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    # GNU General Public License for more details.
    #
    # You should have received a copy of the GNU General Public License
    # along with this program; if not, write to the Free Software
    # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    #
    
    #########################################
    #### 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/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';
    
    $SNMPTrapperFile = '/var/log/zabbix/zabbix_traps.log';
    
    ### 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";

    Comment

    Working...