Added support for DNS resolving for SNMP traps image

This commit is contained in:
Alexey Pustovalov
2023-11-11 14:25:11 +09:00
parent 6f47003786
commit a97e8dd9ab
28 changed files with 136 additions and 9 deletions

View File

@ -6,6 +6,8 @@ ZBX_SNMP_TRAP_DATE_FORMAT=${ZBX_SNMP_TRAP_DATE_FORMAT:-"+%Y%m%d.%H%M%S"}
ZBX_SNMP_TRAP_FORMAT=${ZBX_SNMP_TRAP_FORMAT:-"\n"}
ZBX_SNMP_TRAP_USE_DNS=${ZBX_SNMP_TRAP_USE_DNS:-"false"}
date=$(date "$ZBX_SNMP_TRAP_DATE_FORMAT")
# The name of the host that sent the notification, as determined by gethostbyaddr(3).
@ -40,4 +42,6 @@ done
! [ -z $trap_address ] && sender_addr=$trap_address
echo -e "$date ZBXTRAP $sender_addr$ZBX_SNMP_TRAP_FORMAT$vars" >> $ZABBIX_TRAPS_FILE
[[ "$ZBX_SNMP_TRAP_USE_DNS" == "true" ]] && ! [[ ${host} =~ \[(.*?)\].*\-\> ]] && sender_addr=$host
echo -e "$date ZBXTRAP $sender_addr$ZBX_SNMP_TRAP_FORMAT$sender$ZBX_SNMP_TRAP_FORMAT$vars" >> $ZABBIX_TRAPS_FILE