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 65dba7679..c22d7bdbe 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=" " + ZBX_SNMP_TRAP_DATE_FORMAT=+%Y%m%d.%H%M%S ZBX_SNMP_TRAP_FORMAT=" " \ + 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 15c1aa6fa..b46c9ebf5 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:-" "} +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 5489f45a7..7d776a601 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=" " + ZBX_SNMP_TRAP_DATE_FORMAT=+%Y%m%d.%H%M%S ZBX_SNMP_TRAP_FORMAT=" " \ + 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 051c6f02d..b46c9ebf5 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:-" "} +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 2b3506abb..631251cdd 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=" " + ZBX_SNMP_TRAP_DATE_FORMAT=+%Y%m%d.%H%M%S ZBX_SNMP_TRAP_FORMAT=" " \ + 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 200485048..290b8dab5 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=" " + ZBX_SNMP_TRAP_DATE_FORMAT=+%Y%m%d.%H%M%S ZBX_SNMP_TRAP_FORMAT=" " \ + 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 690ccc272..bd14cb6d8 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/snmp/mibs/ietf:/var/lib/snmp/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=" " + ZBX_SNMP_TRAP_DATE_FORMAT=+%Y%m%d.%H%M%S ZBX_SNMP_TRAP_FORMAT=" " \ + 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 051c6f02d..b46c9ebf5 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:-" "} +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 6ef1bcae9..bee8e70d4 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-5.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 16020401a..5c57e981c 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.14 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 ebf3fdab6..2b9404a5d 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-5.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 ab7201c94..c4406c058 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.14 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 538f930b9..be3c07d78 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-5.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 8a613d022..fbd4de1e0 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 50a1b486d..a228b8cdc 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-5.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 be5b8e24b..f3055e7ee 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 4d4a63a89..c14e2debf 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-5.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 0c1f0b589..255dd8727 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 1da1dcb05..65455b240 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-5.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 540cec1a8..89b04a116 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 a5a668d9a..14b6bde8f 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-5.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 dd344af1e..800b4269c 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:focal 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 15d1abc58..68d93d608 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-5.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 c9d501e4b..79a92e509 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:focal 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