From bcf0b165f213bf33b1880e22c420c115bc13e028 Mon Sep 17 00:00:00 2001 From: Alexey Pustovalov Date: Sat, 11 Nov 2023 14:25:11 +0900 Subject: [PATCH] Added support for DNS resolving for SNMP traps image --- Dockerfiles/snmptraps/README.md | 17 +++++++++++++++++ Dockerfiles/snmptraps/alpine/Dockerfile | 3 ++- .../alpine/conf/usr/sbin/zabbix_trap_handler.sh | 4 ++++ Dockerfiles/snmptraps/centos/Dockerfile | 3 ++- .../centos/conf/usr/sbin/zabbix_trap_handler.sh | 6 +++++- Dockerfiles/snmptraps/ol/Dockerfile | 3 ++- .../ol/conf/usr/sbin/zabbix_trap_handler.sh | 6 +++++- Dockerfiles/snmptraps/rhel/Dockerfile | 3 ++- .../rhel/conf/usr/sbin/zabbix_trap_handler.sh | 6 +++++- Dockerfiles/snmptraps/ubuntu/Dockerfile | 3 ++- .../ubuntu/conf/usr/sbin/zabbix_trap_handler.sh | 6 +++++- docker-compose_v3_alpine_mysql_latest.yaml | 5 +++++ docker-compose_v3_alpine_mysql_local.yaml | 5 +++++ docker-compose_v3_alpine_pgsql_latest.yaml | 5 +++++ docker-compose_v3_alpine_pgsql_local.yaml | 5 +++++ docker-compose_v3_centos_mysql_latest.yaml | 5 +++++ docker-compose_v3_centos_mysql_local.yaml | 5 +++++ docker-compose_v3_centos_pgsql_latest.yaml | 5 +++++ docker-compose_v3_centos_pgsql_local.yaml | 5 +++++ docker-compose_v3_ol_mysql_latest.yaml | 5 +++++ docker-compose_v3_ol_mysql_local.yaml | 5 +++++ docker-compose_v3_ol_pgsql_latest.yaml | 5 +++++ docker-compose_v3_ol_pgsql_local.yaml | 5 +++++ docker-compose_v3_ubuntu_mysql_latest.yaml | 5 +++++ docker-compose_v3_ubuntu_mysql_local.yaml | 5 +++++ docker-compose_v3_ubuntu_pgsql_latest.yaml | 5 +++++ docker-compose_v3_ubuntu_pgsql_local.yaml | 5 +++++ env_vars/.env_snmptraps | 5 +++++ 28 files changed, 136 insertions(+), 9 deletions(-) create mode 100644 env_vars/.env_snmptraps diff --git a/Dockerfiles/snmptraps/README.md b/Dockerfiles/snmptraps/README.md index a328260376..173f7312ba 100644 --- a/Dockerfiles/snmptraps/README.md +++ b/Dockerfiles/snmptraps/README.md @@ -58,6 +58,23 @@ The Zabbix snmptraps log is available through Docker's container log: $ docker logs some-zabbix-snmptraps ``` +## Environment Variables + +When you start the `zabbix-snmptraps` image, you can adjust the configuration by passing one or more environment variables on the `docker run` command line. + +### `ZBX_SNMP_TRAP_DATE_FORMAT` + +This variable is represent date and time format in the output `snmptraps.log` file. By default, value is `+%Y%m%d.%H%M%S`. Please, refer to `date` command man for more details about date and time format. + +### `ZBX_SNMP_TRAP_FORMAT` + +This variable is SNMP trap format in the output `snmptraps.log` file. By default, value is `\n`, in this case each new variable is placed on new line. + +### `ZBX_SNMP_TRAP_USE_DNS` + +This variable manages source network address representation. It can be IP address or DNS of SNMP trap sender. The variable works only when container command is modified and "-n" command argument is removed from argument list. By default, value is `false`. + + ## Allowed volumes for the Zabbix snmptraps container ### ``/var/lib/zabbix/snmptraps`` diff --git a/Dockerfiles/snmptraps/alpine/Dockerfile b/Dockerfiles/snmptraps/alpine/Dockerfile index 4c2d4e2135..18136fb87f 100644 --- a/Dockerfiles/snmptraps/alpine/Dockerfile +++ b/Dockerfiles/snmptraps/alpine/Dockerfile @@ -7,7 +7,8 @@ ARG ZBX_SOURCES=https://git.zabbix.com/scm/zbx/zabbix.git ENV TERM=xterm \ ZBX_VERSION=${ZBX_VERSION} ZBX_SOURCES=${ZBX_SOURCES} \ MIBDIRS=/usr/share/snmp/mibs:/var/lib/zabbix/mibs MIBS=+ALL \ - ZBX_SNMP_TRAP_DATE_FORMAT=+%Y%m%d.%H%M%S ZBX_SNMP_TRAP_FORMAT="\n" + ZBX_SNMP_TRAP_DATE_FORMAT=+%Y%m%d.%H%M%S ZBX_SNMP_TRAP_FORMAT="\n" \ + ZBX_SNMP_TRAP_USE_DNS=false LABEL org.opencontainers.image.authors="Alexey Pustovalov " \ org.opencontainers.image.description="Zabbix SNMP traps receiver" \ diff --git a/Dockerfiles/snmptraps/alpine/conf/usr/sbin/zabbix_trap_handler.sh b/Dockerfiles/snmptraps/alpine/conf/usr/sbin/zabbix_trap_handler.sh index ac8140c08b..b3f317e082 100644 --- a/Dockerfiles/snmptraps/alpine/conf/usr/sbin/zabbix_trap_handler.sh +++ b/Dockerfiles/snmptraps/alpine/conf/usr/sbin/zabbix_trap_handler.sh @@ -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 +[[ "$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 diff --git a/Dockerfiles/snmptraps/centos/Dockerfile b/Dockerfiles/snmptraps/centos/Dockerfile index 9e91ec6294..878dc4c082 100644 --- a/Dockerfiles/snmptraps/centos/Dockerfile +++ b/Dockerfiles/snmptraps/centos/Dockerfile @@ -7,7 +7,8 @@ ARG ZBX_SOURCES=https://git.zabbix.com/scm/zbx/zabbix.git ENV TERM=xterm \ ZBX_VERSION=${ZBX_VERSION} ZBX_SOURCES=${ZBX_SOURCES} \ MIBDIRS=/usr/share/snmp/mibs:/var/lib/zabbix/mibs MIBS=+ALL \ - ZBX_SNMP_TRAP_DATE_FORMAT=+%Y%m%d.%H%M%S ZBX_SNMP_TRAP_FORMAT="\n" + ZBX_SNMP_TRAP_DATE_FORMAT=+%Y%m%d.%H%M%S ZBX_SNMP_TRAP_FORMAT="\n" \ + ZBX_SNMP_TRAP_USE_DNS=false LABEL org.opencontainers.image.authors="Alexey Pustovalov " \ org.opencontainers.image.description="Zabbix SNMP traps receiver" \ diff --git a/Dockerfiles/snmptraps/centos/conf/usr/sbin/zabbix_trap_handler.sh b/Dockerfiles/snmptraps/centos/conf/usr/sbin/zabbix_trap_handler.sh index aea0a853b6..b3f317e082 100644 --- a/Dockerfiles/snmptraps/centos/conf/usr/sbin/zabbix_trap_handler.sh +++ b/Dockerfiles/snmptraps/centos/conf/usr/sbin/zabbix_trap_handler.sh @@ -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 diff --git a/Dockerfiles/snmptraps/ol/Dockerfile b/Dockerfiles/snmptraps/ol/Dockerfile index f546767bad..8b479f863c 100644 --- a/Dockerfiles/snmptraps/ol/Dockerfile +++ b/Dockerfiles/snmptraps/ol/Dockerfile @@ -7,7 +7,8 @@ ARG ZBX_SOURCES=https://git.zabbix.com/scm/zbx/zabbix.git ENV TERM=xterm \ ZBX_VERSION=${ZBX_VERSION} ZBX_SOURCES=${ZBX_SOURCES} \ MIBDIRS=/usr/share/snmp/mibs:/var/lib/zabbix/mibs MIBS=+ALL \ - ZBX_SNMP_TRAP_DATE_FORMAT=+%Y%m%d.%H%M%S ZBX_SNMP_TRAP_FORMAT="\n" + ZBX_SNMP_TRAP_DATE_FORMAT=+%Y%m%d.%H%M%S ZBX_SNMP_TRAP_FORMAT="\n" \ + ZBX_SNMP_TRAP_USE_DNS=false LABEL org.opencontainers.image.authors="Alexey Pustovalov " \ org.opencontainers.image.description="Zabbix SNMP traps receiver" \ diff --git a/Dockerfiles/snmptraps/ol/conf/usr/sbin/zabbix_trap_handler.sh b/Dockerfiles/snmptraps/ol/conf/usr/sbin/zabbix_trap_handler.sh index aea0a853b6..b3f317e082 100644 --- a/Dockerfiles/snmptraps/ol/conf/usr/sbin/zabbix_trap_handler.sh +++ b/Dockerfiles/snmptraps/ol/conf/usr/sbin/zabbix_trap_handler.sh @@ -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 diff --git a/Dockerfiles/snmptraps/rhel/Dockerfile b/Dockerfiles/snmptraps/rhel/Dockerfile index bd3caa8b53..f63ca9162a 100644 --- a/Dockerfiles/snmptraps/rhel/Dockerfile +++ b/Dockerfiles/snmptraps/rhel/Dockerfile @@ -9,7 +9,8 @@ ARG ZBX_SOURCES=https://git.zabbix.com/scm/zbx/zabbix.git ENV TERM=xterm \ ZBX_VERSION=${ZBX_VERSION} ZBX_SOURCES=${ZBX_SOURCES} \ MIBDIRS=/usr/share/snmp/mibs:/var/lib/zabbix/mibs MIBS=+ALL \ - ZBX_SNMP_TRAP_DATE_FORMAT=+%Y%m%d.%H%M%S ZBX_SNMP_TRAP_FORMAT="\n" + ZBX_SNMP_TRAP_DATE_FORMAT=+%Y%m%d.%H%M%S ZBX_SNMP_TRAP_FORMAT="\n" \ + ZBX_SNMP_TRAP_USE_DNS=false LABEL description="Zabbix SNMP traps receiver" \ maintainer="alexey.pustovalov@zabbix.com" \ diff --git a/Dockerfiles/snmptraps/rhel/conf/usr/sbin/zabbix_trap_handler.sh b/Dockerfiles/snmptraps/rhel/conf/usr/sbin/zabbix_trap_handler.sh index aea0a853b6..b3f317e082 100644 --- a/Dockerfiles/snmptraps/rhel/conf/usr/sbin/zabbix_trap_handler.sh +++ b/Dockerfiles/snmptraps/rhel/conf/usr/sbin/zabbix_trap_handler.sh @@ -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 diff --git a/Dockerfiles/snmptraps/ubuntu/Dockerfile b/Dockerfiles/snmptraps/ubuntu/Dockerfile index 419fd224a1..786f4a933a 100644 --- a/Dockerfiles/snmptraps/ubuntu/Dockerfile +++ b/Dockerfiles/snmptraps/ubuntu/Dockerfile @@ -7,7 +7,8 @@ ARG ZBX_SOURCES=https://git.zabbix.com/scm/zbx/zabbix.git ENV TERM=xterm \ ZBX_VERSION=${ZBX_VERSION} ZBX_SOURCES=${ZBX_SOURCES} \ MIBDIRS=/var/lib/mibs/ietf:/var/lib/mibs/iana:/usr/share/snmp/mibs:/var/lib/zabbix/mibs MIBS=+ALL \ - ZBX_SNMP_TRAP_DATE_FORMAT=+%Y%m%d.%H%M%S ZBX_SNMP_TRAP_FORMAT="\n" + ZBX_SNMP_TRAP_DATE_FORMAT=+%Y%m%d.%H%M%S ZBX_SNMP_TRAP_FORMAT="\n" \ + ZBX_SNMP_TRAP_USE_DNS=false LABEL org.opencontainers.image.authors="Alexey Pustovalov " \ org.opencontainers.image.description="Zabbix SNMP traps receiver" \ diff --git a/Dockerfiles/snmptraps/ubuntu/conf/usr/sbin/zabbix_trap_handler.sh b/Dockerfiles/snmptraps/ubuntu/conf/usr/sbin/zabbix_trap_handler.sh index aea0a853b6..b3f317e082 100644 --- a/Dockerfiles/snmptraps/ubuntu/conf/usr/sbin/zabbix_trap_handler.sh +++ b/Dockerfiles/snmptraps/ubuntu/conf/usr/sbin/zabbix_trap_handler.sh @@ -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 diff --git a/docker-compose_v3_alpine_mysql_latest.yaml b/docker-compose_v3_alpine_mysql_latest.yaml index 694bfda467..0a21858f79 100644 --- a/docker-compose_v3_alpine_mysql_latest.yaml +++ b/docker-compose_v3_alpine_mysql_latest.yaml @@ -362,6 +362,9 @@ services: zabbix-snmptraps: image: zabbix/zabbix-snmptraps:alpine-trunk +# Override snmptrapd command arguments to receive SNMP traps by DNS +# It must be done with ZBX_SNMP_TRAP_USE_DNS=true environment variable +# command: /usr/sbin/snmptrapd -C -c /etc/snmp/snmptrapd.conf -Lo -A profiles: - full - all @@ -377,6 +380,8 @@ services: reservations: cpus: '0.25' memory: 128M + env_file: + - ./env_vars/.env_snmptraps networks: zbx_net_frontend: aliases: diff --git a/docker-compose_v3_alpine_mysql_local.yaml b/docker-compose_v3_alpine_mysql_local.yaml index f4d6772b89..8e7d67800f 100644 --- a/docker-compose_v3_alpine_mysql_local.yaml +++ b/docker-compose_v3_alpine_mysql_local.yaml @@ -447,6 +447,9 @@ services: cache_from: - alpine:3.18 image: zabbix-snmptraps:alpine-local +# Override snmptrapd command arguments to receive SNMP traps by DNS +# It must be done with ZBX_SNMP_TRAP_USE_DNS=true environment variable +# command: /usr/sbin/snmptrapd -C -c /etc/snmp/snmptrapd.conf -Lo -A profiles: - full - all @@ -462,6 +465,8 @@ services: reservations: cpus: '0.25' memory: 128M + env_file: + - ./env_vars/.env_snmptraps networks: zbx_net_frontend: aliases: diff --git a/docker-compose_v3_alpine_pgsql_latest.yaml b/docker-compose_v3_alpine_pgsql_latest.yaml index f277d43a3f..6eb6b75730 100644 --- a/docker-compose_v3_alpine_pgsql_latest.yaml +++ b/docker-compose_v3_alpine_pgsql_latest.yaml @@ -353,6 +353,9 @@ services: zabbix-snmptraps: image: zabbix/zabbix-snmptraps:alpine-trunk +# Override snmptrapd command arguments to receive SNMP traps by DNS +# It must be done with ZBX_SNMP_TRAP_USE_DNS=true environment variable +# command: /usr/sbin/snmptrapd -C -c /etc/snmp/snmptrapd.conf -Lo -A profiles: - full - all @@ -368,6 +371,8 @@ services: reservations: cpus: '0.25' memory: 128M + env_file: + - ./env_vars/.env_snmptraps networks: zbx_net_frontend: aliases: diff --git a/docker-compose_v3_alpine_pgsql_local.yaml b/docker-compose_v3_alpine_pgsql_local.yaml index 8591b17d96..ed54ac231f 100644 --- a/docker-compose_v3_alpine_pgsql_local.yaml +++ b/docker-compose_v3_alpine_pgsql_local.yaml @@ -452,6 +452,9 @@ services: cache_from: - alpine:3.18 image: zabbix-snmptraps:alpine-local +# Override snmptrapd command arguments to receive SNMP traps by DNS +# It must be done with ZBX_SNMP_TRAP_USE_DNS=true environment variable +# command: /usr/sbin/snmptrapd -C -c /etc/snmp/snmptrapd.conf -Lo -A profiles: - full - all @@ -467,6 +470,8 @@ services: reservations: cpus: '0.25' memory: 128M + env_file: + - ./env_vars/.env_snmptraps networks: zbx_net_frontend: aliases: diff --git a/docker-compose_v3_centos_mysql_latest.yaml b/docker-compose_v3_centos_mysql_latest.yaml index 6b01f96643..a85a43fb84 100644 --- a/docker-compose_v3_centos_mysql_latest.yaml +++ b/docker-compose_v3_centos_mysql_latest.yaml @@ -362,6 +362,9 @@ services: zabbix-snmptraps: image: zabbix/zabbix-snmptraps:centos-trunk +# Override snmptrapd command arguments to receive SNMP traps by DNS +# It must be done with ZBX_SNMP_TRAP_USE_DNS=true environment variable +# command: /usr/sbin/snmptrapd -C -c /etc/snmp/snmptrapd.conf -Lo -A profiles: - full - all @@ -377,6 +380,8 @@ services: reservations: cpus: '0.25' memory: 128M + env_file: + - ./env_vars/.env_snmptraps networks: zbx_net_frontend: aliases: diff --git a/docker-compose_v3_centos_mysql_local.yaml b/docker-compose_v3_centos_mysql_local.yaml index 921c95b07e..4085aa0246 100644 --- a/docker-compose_v3_centos_mysql_local.yaml +++ b/docker-compose_v3_centos_mysql_local.yaml @@ -448,6 +448,9 @@ services: cache_from: - quay.io/centos/centos:stream9 image: zabbix-snmptraps:centos-local +# Override snmptrapd command arguments to receive SNMP traps by DNS +# It must be done with ZBX_SNMP_TRAP_USE_DNS=true environment variable +# command: /usr/sbin/snmptrapd -C -c /etc/snmp/snmptrapd.conf -Lo -A profiles: - full - all @@ -463,6 +466,8 @@ services: reservations: cpus: '0.25' memory: 128M + env_file: + - ./env_vars/.env_snmptraps networks: zbx_net_frontend: aliases: diff --git a/docker-compose_v3_centos_pgsql_latest.yaml b/docker-compose_v3_centos_pgsql_latest.yaml index 25c3dcff50..9d0437fccf 100644 --- a/docker-compose_v3_centos_pgsql_latest.yaml +++ b/docker-compose_v3_centos_pgsql_latest.yaml @@ -353,6 +353,9 @@ services: zabbix-snmptraps: image: zabbix/zabbix-snmptraps:centos-trunk +# Override snmptrapd command arguments to receive SNMP traps by DNS +# It must be done with ZBX_SNMP_TRAP_USE_DNS=true environment variable +# command: /usr/sbin/snmptrapd -C -c /etc/snmp/snmptrapd.conf -Lo -A profiles: - full - all @@ -368,6 +371,8 @@ services: reservations: cpus: '0.25' memory: 128M + env_file: + - ./env_vars/.env_snmptraps networks: zbx_net_frontend: aliases: diff --git a/docker-compose_v3_centos_pgsql_local.yaml b/docker-compose_v3_centos_pgsql_local.yaml index 1869717c71..0c9f568a35 100644 --- a/docker-compose_v3_centos_pgsql_local.yaml +++ b/docker-compose_v3_centos_pgsql_local.yaml @@ -452,6 +452,9 @@ services: cache_from: - quay.io/centos/centos:stream9 image: zabbix-snmptraps:centos-local +# Override snmptrapd command arguments to receive SNMP traps by DNS +# It must be done with ZBX_SNMP_TRAP_USE_DNS=true environment variable +# command: /usr/sbin/snmptrapd -C -c /etc/snmp/snmptrapd.conf -Lo -A profiles: - full - all @@ -467,6 +470,8 @@ services: reservations: cpus: '0.25' memory: 128M + env_file: + - ./env_vars/.env_snmptraps networks: zbx_net_frontend: aliases: diff --git a/docker-compose_v3_ol_mysql_latest.yaml b/docker-compose_v3_ol_mysql_latest.yaml index c2e4084826..27cd691d5b 100644 --- a/docker-compose_v3_ol_mysql_latest.yaml +++ b/docker-compose_v3_ol_mysql_latest.yaml @@ -362,6 +362,9 @@ services: zabbix-snmptraps: image: zabbix/zabbix-snmptraps:ol-trunk +# Override snmptrapd command arguments to receive SNMP traps by DNS +# It must be done with ZBX_SNMP_TRAP_USE_DNS=true environment variable +# command: /usr/sbin/snmptrapd -C -c /etc/snmp/snmptrapd.conf -Lo -A profiles: - full - all @@ -377,6 +380,8 @@ services: reservations: cpus: '0.25' memory: 128M + env_file: + - ./env_vars/.env_snmptraps networks: zbx_net_frontend: aliases: diff --git a/docker-compose_v3_ol_mysql_local.yaml b/docker-compose_v3_ol_mysql_local.yaml index ea39f48695..6bd4e8184e 100644 --- a/docker-compose_v3_ol_mysql_local.yaml +++ b/docker-compose_v3_ol_mysql_local.yaml @@ -448,6 +448,9 @@ services: cache_from: - oraclelinux:9-slim image: zabbix-snmptraps:ol-local +# Override snmptrapd command arguments to receive SNMP traps by DNS +# It must be done with ZBX_SNMP_TRAP_USE_DNS=true environment variable +# command: /usr/sbin/snmptrapd -C -c /etc/snmp/snmptrapd.conf -Lo -A profiles: - full - all @@ -463,6 +466,8 @@ services: reservations: cpus: '0.25' memory: 128M + env_file: + - ./env_vars/.env_snmptraps networks: zbx_net_frontend: aliases: diff --git a/docker-compose_v3_ol_pgsql_latest.yaml b/docker-compose_v3_ol_pgsql_latest.yaml index eedcb1e209..f217aa35cd 100644 --- a/docker-compose_v3_ol_pgsql_latest.yaml +++ b/docker-compose_v3_ol_pgsql_latest.yaml @@ -353,6 +353,9 @@ services: zabbix-snmptraps: image: zabbix/zabbix-snmptraps:ol-trunk +# Override snmptrapd command arguments to receive SNMP traps by DNS +# It must be done with ZBX_SNMP_TRAP_USE_DNS=true environment variable +# command: /usr/sbin/snmptrapd -C -c /etc/snmp/snmptrapd.conf -Lo -A profiles: - full - all @@ -368,6 +371,8 @@ services: reservations: cpus: '0.25' memory: 128M + env_file: + - ./env_vars/.env_snmptraps networks: zbx_net_frontend: aliases: diff --git a/docker-compose_v3_ol_pgsql_local.yaml b/docker-compose_v3_ol_pgsql_local.yaml index 1d9a70a879..b7224f3129 100644 --- a/docker-compose_v3_ol_pgsql_local.yaml +++ b/docker-compose_v3_ol_pgsql_local.yaml @@ -452,6 +452,9 @@ services: cache_from: - oraclelinux:9-slim image: zabbix-snmptraps:ol-local +# Override snmptrapd command arguments to receive SNMP traps by DNS +# It must be done with ZBX_SNMP_TRAP_USE_DNS=true environment variable +# command: /usr/sbin/snmptrapd -C -c /etc/snmp/snmptrapd.conf -Lo -A profiles: - full - all @@ -467,6 +470,8 @@ services: reservations: cpus: '0.25' memory: 128M + env_file: + - ./env_vars/.env_snmptraps networks: zbx_net_frontend: aliases: diff --git a/docker-compose_v3_ubuntu_mysql_latest.yaml b/docker-compose_v3_ubuntu_mysql_latest.yaml index 30f3d61bf1..b60c27bf8a 100644 --- a/docker-compose_v3_ubuntu_mysql_latest.yaml +++ b/docker-compose_v3_ubuntu_mysql_latest.yaml @@ -354,6 +354,9 @@ services: zabbix-snmptraps: image: zabbix/zabbix-snmptraps:ubuntu-trunk +# Override snmptrapd command arguments to receive SNMP traps by DNS +# It must be done with ZBX_SNMP_TRAP_USE_DNS=true environment variable +# command: /usr/sbin/snmptrapd -C -c /etc/snmp/snmptrapd.conf -Lo -A profiles: - full - all @@ -369,6 +372,8 @@ services: reservations: cpus: '0.25' memory: 128M + env_file: + - ./env_vars/.env_snmptraps networks: zbx_net_frontend: aliases: diff --git a/docker-compose_v3_ubuntu_mysql_local.yaml b/docker-compose_v3_ubuntu_mysql_local.yaml index 9a339908a6..1c8ef9e09a 100644 --- a/docker-compose_v3_ubuntu_mysql_local.yaml +++ b/docker-compose_v3_ubuntu_mysql_local.yaml @@ -442,6 +442,9 @@ services: cache_from: - ubuntu:jammy image: zabbix-snmptraps:ubuntu-local +# Override snmptrapd command arguments to receive SNMP traps by DNS +# It must be done with ZBX_SNMP_TRAP_USE_DNS=true environment variable +# command: /usr/sbin/snmptrapd -C -c /etc/snmp/snmptrapd.conf -Lo -A profiles: - full - all @@ -457,6 +460,8 @@ services: reservations: cpus: '0.25' memory: 128M + env_file: + - ./env_vars/.env_snmptraps networks: zbx_net_frontend: aliases: diff --git a/docker-compose_v3_ubuntu_pgsql_latest.yaml b/docker-compose_v3_ubuntu_pgsql_latest.yaml index 513ebd9c48..ed45f54fca 100644 --- a/docker-compose_v3_ubuntu_pgsql_latest.yaml +++ b/docker-compose_v3_ubuntu_pgsql_latest.yaml @@ -347,6 +347,9 @@ services: zabbix-snmptraps: image: zabbix/zabbix-snmptraps:ubuntu-trunk +# Override snmptrapd command arguments to receive SNMP traps by DNS +# It must be done with ZBX_SNMP_TRAP_USE_DNS=true environment variable +# command: /usr/sbin/snmptrapd -C -c /etc/snmp/snmptrapd.conf -Lo -A profiles: - full - all @@ -362,6 +365,8 @@ services: reservations: cpus: '0.25' memory: 128M + env_file: + - ./env_vars/.env_snmptraps networks: zbx_net_frontend: aliases: diff --git a/docker-compose_v3_ubuntu_pgsql_local.yaml b/docker-compose_v3_ubuntu_pgsql_local.yaml index 1193052a28..efc26b6685 100644 --- a/docker-compose_v3_ubuntu_pgsql_local.yaml +++ b/docker-compose_v3_ubuntu_pgsql_local.yaml @@ -446,6 +446,9 @@ services: cache_from: - ubuntu:jammy image: zabbix-snmptraps:ubuntu-local +# Override snmptrapd command arguments to receive SNMP traps by DNS +# It must be done with ZBX_SNMP_TRAP_USE_DNS=true environment variable +# command: /usr/sbin/snmptrapd -C -c /etc/snmp/snmptrapd.conf -Lo -A profiles: - full - all @@ -461,6 +464,8 @@ services: reservations: cpus: '0.25' memory: 128M + env_file: + - ./env_vars/.env_snmptraps networks: zbx_net_frontend: aliases: diff --git a/env_vars/.env_snmptraps b/env_vars/.env_snmptraps new file mode 100644 index 0000000000..70a705ea33 --- /dev/null +++ b/env_vars/.env_snmptraps @@ -0,0 +1,5 @@ +ZBX_SNMP_TRAP_DATE_FORMAT=+%Y%m%d.%H%M%S +ZBX_SNMP_TRAP_FORMAT=\n +# To use DNS instead of sender IP override container's command: /usr/sbin/snmptrapd -C -c /etc/snmp/snmptrapd.conf -Lo -A +# Need to remove "-n" command argument +ZBX_SNMP_TRAP_USE_DNS=false