From a97e8dd9ab41fe8f06484d578866c886f78473cd 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 a32826037..173f7312b 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 e1847f542..355f935bb 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 ac8140c08..b3f317e08 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 99290296a..f953a289c 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 aea0a853b..b3f317e08 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 2d70ac866..f3fe9ec47 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 aea0a853b..b3f317e08 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 ed01e12de..16f58ab90 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 aea0a853b..b3f317e08 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 b69ffd57c..6337876d4 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 aea0a853b..b3f317e08 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 7f375d8de..d0421fe09 100644 --- a/docker-compose_v3_alpine_mysql_latest.yaml +++ b/docker-compose_v3_alpine_mysql_latest.yaml @@ -358,6 +358,9 @@ services: zabbix-snmptraps: image: zabbix/zabbix-snmptraps:alpine-6.0-latest +# 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 @@ -373,6 +376,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 f866e5023..c8bddf4ae 100644 --- a/docker-compose_v3_alpine_mysql_local.yaml +++ b/docker-compose_v3_alpine_mysql_local.yaml @@ -444,6 +444,9 @@ services: cache_from: - alpine:3.16 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 @@ -459,6 +462,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 46047ee93..85a963db7 100644 --- a/docker-compose_v3_alpine_pgsql_latest.yaml +++ b/docker-compose_v3_alpine_pgsql_latest.yaml @@ -349,6 +349,9 @@ services: zabbix-snmptraps: image: zabbix/zabbix-snmptraps:alpine-6.0-latest +# 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 @@ -364,6 +367,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 88ddde44f..f35bbe780 100644 --- a/docker-compose_v3_alpine_pgsql_local.yaml +++ b/docker-compose_v3_alpine_pgsql_local.yaml @@ -448,6 +448,9 @@ services: cache_from: - alpine:3.16 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 @@ -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_mysql_latest.yaml b/docker-compose_v3_centos_mysql_latest.yaml index a71f642cf..07be426fb 100644 --- a/docker-compose_v3_centos_mysql_latest.yaml +++ b/docker-compose_v3_centos_mysql_latest.yaml @@ -358,6 +358,9 @@ services: zabbix-snmptraps: image: zabbix/zabbix-snmptraps:centos-6.0-latest +# 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 @@ -373,6 +376,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 cb39b19cb..e8b1f7cf3 100644 --- a/docker-compose_v3_centos_mysql_local.yaml +++ b/docker-compose_v3_centos_mysql_local.yaml @@ -444,6 +444,9 @@ services: cache_from: - quay.io/centos/centos:stream8 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 @@ -459,6 +462,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 b62158484..8a36a7b0f 100644 --- a/docker-compose_v3_centos_pgsql_latest.yaml +++ b/docker-compose_v3_centos_pgsql_latest.yaml @@ -349,6 +349,9 @@ services: zabbix-snmptraps: image: zabbix/zabbix-snmptraps:centos-6.0-latest +# 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 @@ -364,6 +367,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 aef258c00..c3c2bf152 100644 --- a/docker-compose_v3_centos_pgsql_local.yaml +++ b/docker-compose_v3_centos_pgsql_local.yaml @@ -448,6 +448,9 @@ services: cache_from: - quay.io/centos/centos:stream8 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_ol_mysql_latest.yaml b/docker-compose_v3_ol_mysql_latest.yaml index bd29b09fe..e5085ea56 100644 --- a/docker-compose_v3_ol_mysql_latest.yaml +++ b/docker-compose_v3_ol_mysql_latest.yaml @@ -358,6 +358,9 @@ services: zabbix-snmptraps: image: zabbix/zabbix-snmptraps:ol-6.0-latest +# 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 @@ -373,6 +376,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 cff34c7ee..0f9ab2944 100644 --- a/docker-compose_v3_ol_mysql_local.yaml +++ b/docker-compose_v3_ol_mysql_local.yaml @@ -444,6 +444,9 @@ services: cache_from: - oraclelinux:8-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 @@ -459,6 +462,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 aa15520e1..32e89b7b5 100644 --- a/docker-compose_v3_ol_pgsql_latest.yaml +++ b/docker-compose_v3_ol_pgsql_latest.yaml @@ -349,6 +349,9 @@ services: zabbix-snmptraps: image: zabbix/zabbix-snmptraps:ol-6.0-latest +# 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 @@ -364,6 +367,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 7fc3f4342..e29bfd852 100644 --- a/docker-compose_v3_ol_pgsql_local.yaml +++ b/docker-compose_v3_ol_pgsql_local.yaml @@ -448,6 +448,9 @@ services: cache_from: - oraclelinux:8-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_ubuntu_mysql_latest.yaml b/docker-compose_v3_ubuntu_mysql_latest.yaml index cf184392e..3919207d7 100644 --- a/docker-compose_v3_ubuntu_mysql_latest.yaml +++ b/docker-compose_v3_ubuntu_mysql_latest.yaml @@ -350,6 +350,9 @@ services: zabbix-snmptraps: image: zabbix/zabbix-snmptraps:ubuntu-6.0-latest +# 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 @@ -365,6 +368,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 4621c82a5..b0a6cf716 100644 --- a/docker-compose_v3_ubuntu_mysql_local.yaml +++ b/docker-compose_v3_ubuntu_mysql_local.yaml @@ -438,6 +438,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 @@ -453,6 +456,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 dda3183a8..685fb51e7 100644 --- a/docker-compose_v3_ubuntu_pgsql_latest.yaml +++ b/docker-compose_v3_ubuntu_pgsql_latest.yaml @@ -343,6 +343,9 @@ services: zabbix-snmptraps: image: zabbix/zabbix-snmptraps:ubuntu-6.0-latest +# 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 @@ -358,6 +361,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 fac161193..8e78550b9 100644 --- a/docker-compose_v3_ubuntu_pgsql_local.yaml +++ b/docker-compose_v3_ubuntu_pgsql_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/env_vars/.env_snmptraps b/env_vars/.env_snmptraps new file mode 100644 index 000000000..70a705ea3 --- /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