Advertising:

Instalacion SNMTP Traps para Zabbix 7.0

From Zabbix-ES
Jump to navigation Jump to search

Configuracion de SNMP Traps en Zabbix

# dnf install -y net-snmp-utils net-snmp-perl net-snmp
# curl -o /usr/bin/zabbix_trap_receiver.pl https://git.zabbix.com/projects/ZBX/repos/zabbix/raw/misc/snmptrap/zabbix_trap_receiver.pl
# chmod 755 /usr/bin/zabbix_trap_receiver.pl
# vi /usr/bin/zabbix_trap_receiver.pl
  #$SNMPTrapperFile = '/tmp/zabbix_traps.tmp';
  $SNMPTrapperFile = '/var/log/snmptrap/snmptrap.log';
# vi /etc/zabbix/zabbix_server.conf
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
StartSNMPTrapper=1
# mkdir -p /var/log/snmptrap
# chmod 750 /var/log/snmptrap
# chown zabbix:zabbix /var/log/snmptrap
# vi /etc/snmp/snmptrapd.conf
# SNMPv3
createUser -e 0x800000020109840301 monitoring SHA512 zabbix_trap AES256 %Password123%
authUser execute monitoring

# SNMPv 1,2
authCommunity execute zabbix

# Zabbix SNMP trap receiver
perl do "/usr/bin/zabbix_trap_receiver.pl"
# systemctl restart zabbix-server
# systemctl enable --now snmptrapd
# systemctl disable --now snmpd
# systemctl status snmptrapd

# vi /etc/logrotate.d/zabbix_traps
/var/log/snmptrap/snmptrap.log {
    weekly
    size 10M
    compress
    compresscmd /usr/bin/bzip2
    compressoptions -9
    notifempty
    dateext
    dateformat -%Y%m%d
    missingok
    maxage 365
    rotate 10
}
# snmptrap -v 2c -c zabbix localhost  SNMPv2-MIB::snmpMIB IF-MIB::linkDown s ens120
# cat /var/log/snmptrap/snmptrap.log
2024-08-17T12:58:55+0200 ZBXTRAP 127.0.0.1
PDU INFO:
  errorindex                     0
  notificationtype               TRAP
  errorstatus                    0
  community                      globalia
  transactionid                  9
  messageid                      0
  receivedfrom                   UDP: [127.0.0.1]:40838->[127.0.0.1]:162
  requestid                      1099791328
  version                        1
VARBINDS:
  DISMAN-EVENT-MIB::sysUpTimeInstance type=67 value=Timeticks: (236307) 0:39:23.07
  SNMPv2-MIB::snmpTrapOID.0      type=6  value=OID: SNMPv2-MIB::snmpMIB
  IF-MIB::linkDown               type=4  value=STRING: "ens120"

Referencias

https://www.zabbix-es.com.es/index.php/Configurar_SNMP_Traps
https://www.initmax.com/wiki/how-to-set-up-snmp-trap-in-zabbix/