Skip to content

Commit

Permalink
Fixed snmptrapd persistent directory
Browse files Browse the repository at this point in the history
  • Loading branch information
dotneft committed Jan 15, 2025
1 parent a51eae9 commit ffae1d2
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 9 deletions.
6 changes: 4 additions & 2 deletions Dockerfiles/snmptraps/alpine/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ ENV TERM=xterm \
ZBX_SNMP_TRAP_USE_DNS=false \
ZABBIX_USER_HOME_DIR="/var/lib/zabbix"

ENV SNMP_PERSISTENT_DIR="${ZABBIX_USER_HOME_DIR}/snmptrapd_config"

LABEL org.opencontainers.image.authors="Alexey Pustovalov <[email protected]>" \
org.opencontainers.image.description="Zabbix SNMP traps receiver" \
org.opencontainers.image.documentation="https://www.zabbix.com/documentation/${MAJOR_VERSION}/manual/installation/containers" \
Expand Down Expand Up @@ -48,7 +50,7 @@ RUN set -eux && \
mkdir -p ${ZABBIX_USER_HOME_DIR} && \
mkdir -p ${ZABBIX_USER_HOME_DIR}/snmptraps && \
mkdir -p ${ZABBIX_USER_HOME_DIR}/mibs && \
touch /var/lib/net-snmp/snmptrapd.conf && \
mkdir -p ${SNMP_PERSISTENT_DIR} && \
chown --quiet -R zabbix:root /etc/snmp/ ${ZABBIX_USER_HOME_DIR}/ /var/tmp/ /var/run/ && \
chgrp -R 0 /etc/snmp/ ${ZABBIX_USER_HOME_DIR}/ /var/tmp/ /var/run/ && \
chmod -R g=u /etc/snmp/ ${ZABBIX_USER_HOME_DIR}/ /var/tmp/ /var/run/
Expand All @@ -57,7 +59,7 @@ EXPOSE 1162/UDP

WORKDIR ${ZABBIX_USER_HOME_DIR}/snmptraps/

VOLUME ["${ZABBIX_USER_HOME_DIR}/snmptraps"]
VOLUME ["${ZABBIX_USER_HOME_DIR}/snmptraps", "${SNMP_PERSISTENT_DIR}"]

COPY ["conf/etc/logrotate.d/zabbix_snmptraps", "/etc/logrotate.d/"]
COPY ["conf/etc/snmp/snmptrapd.conf", "/etc/snmp/"]
Expand Down
6 changes: 4 additions & 2 deletions Dockerfiles/snmptraps/centos/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ ENV TERM=xterm \
ZBX_SNMP_TRAP_USE_DNS=false \
ZABBIX_USER_HOME_DIR="/var/lib/zabbix"

ENV SNMP_PERSISTENT_DIR="${ZABBIX_USER_HOME_DIR}/snmptrapd_config"

LABEL org.opencontainers.image.authors="Alexey Pustovalov <[email protected]>" \
org.opencontainers.image.description="Zabbix SNMP traps receiver" \
org.opencontainers.image.documentation="https://www.zabbix.com/documentation/${MAJOR_VERSION}/manual/installation/containers" \
Expand Down Expand Up @@ -54,7 +56,7 @@ RUN --mount=type=tmpfs,target=/var/lib/dnf/ \
mkdir -p ${ZABBIX_USER_HOME_DIR} && \
mkdir -p ${ZABBIX_USER_HOME_DIR}/snmptraps && \
mkdir -p ${ZABBIX_USER_HOME_DIR}/mibs && \
touch /var/lib/net-snmp/snmptrapd.conf && \
mkdir -p ${SNMP_PERSISTENT_DIR} && \
chown --quiet -R zabbix:root /etc/snmp/ ${ZABBIX_USER_HOME_DIR}/ /var/tmp/ /var/run/ && \
chgrp -R 0 /etc/snmp/ ${ZABBIX_USER_HOME_DIR}/ /var/tmp/ /var/run/ && \
chmod -R g=u /etc/snmp/ ${ZABBIX_USER_HOME_DIR}/ /var/tmp/ /var/run/
Expand All @@ -63,7 +65,7 @@ EXPOSE 1162/UDP

WORKDIR ${ZABBIX_USER_HOME_DIR}/snmptraps/

VOLUME ["${ZABBIX_USER_HOME_DIR}/snmptraps"]
VOLUME ["${ZABBIX_USER_HOME_DIR}/snmptraps", "${SNMP_PERSISTENT_DIR}"]

COPY ["conf/etc/logrotate.d/zabbix_snmptraps", "/etc/logrotate.d/"]
COPY ["conf/etc/snmp/snmptrapd.conf", "/etc/snmp/"]
Expand Down
6 changes: 4 additions & 2 deletions Dockerfiles/snmptraps/ol/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ ENV TERM=xterm \
ZBX_SNMP_TRAP_USE_DNS=false \
ZABBIX_USER_HOME_DIR="/var/lib/zabbix"

ENV SNMP_PERSISTENT_DIR="${ZABBIX_USER_HOME_DIR}/snmptrapd_config"

LABEL org.opencontainers.image.authors="Alexey Pustovalov <[email protected]>" \
org.opencontainers.image.description="Zabbix SNMP traps receiver" \
org.opencontainers.image.documentation="https://www.zabbix.com/documentation/${MAJOR_VERSION}/manual/installation/containers" \
Expand Down Expand Up @@ -53,7 +55,7 @@ RUN --mount=type=tmpfs,target=/var/lib/dnf/ \
mkdir -p ${ZABBIX_USER_HOME_DIR} && \
mkdir -p ${ZABBIX_USER_HOME_DIR}/snmptraps && \
mkdir -p ${ZABBIX_USER_HOME_DIR}/mibs && \
touch /var/lib/net-snmp/snmptrapd.conf && \
mkdir -p ${SNMP_PERSISTENT_DIR} && \
chown --quiet -R zabbix:root /etc/snmp/ ${ZABBIX_USER_HOME_DIR}/ /var/tmp/ /var/run/ && \
chgrp -R 0 /etc/snmp/ ${ZABBIX_USER_HOME_DIR}/ /var/tmp/ /var/run/ && \
chmod -R g=u /etc/snmp/ ${ZABBIX_USER_HOME_DIR}/ /var/tmp/ /var/run/
Expand All @@ -62,7 +64,7 @@ EXPOSE 1162/UDP

WORKDIR ${ZABBIX_USER_HOME_DIR}/snmptraps/

VOLUME ["${ZABBIX_USER_HOME_DIR}/snmptraps"]
VOLUME ["${ZABBIX_USER_HOME_DIR}/snmptraps", "${SNMP_PERSISTENT_DIR}"]

COPY ["conf/etc/logrotate.d/zabbix_snmptraps", "/etc/logrotate.d/"]
COPY ["conf/etc/snmp/snmptrapd.conf", "/etc/snmp/"]
Expand Down
6 changes: 4 additions & 2 deletions Dockerfiles/snmptraps/rhel/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ ENV TERM=xterm \
ZBX_SNMP_TRAP_USE_DNS=false \
ZABBIX_USER_HOME_DIR="/var/lib/zabbix"

ENV SNMP_PERSISTENT_DIR="${ZABBIX_USER_HOME_DIR}/snmptrapd_config"

LABEL description="Zabbix SNMP traps receiver" \
maintainer="[email protected]" \
name="zabbix/zabbix-snmptraps-70" \
Expand Down Expand Up @@ -93,7 +95,7 @@ RUN --mount=type=tmpfs,target=/var/lib/dnf/ \
mkdir -p ${ZABBIX_USER_HOME_DIR} && \
mkdir -p ${ZABBIX_USER_HOME_DIR}/snmptraps && \
mkdir -p ${ZABBIX_USER_HOME_DIR}/mibs && \
touch /var/lib/net-snmp/snmptrapd.conf && \
mkdir -p ${SNMP_PERSISTENT_DIR} && \
chown --quiet -R zabbix:root /etc/snmp/ ${ZABBIX_USER_HOME_DIR}/ /var/tmp/ /var/run/ && \
chgrp -R 0 /etc/snmp/ ${ZABBIX_USER_HOME_DIR}/ /var/tmp/ /var/run/ && \
chmod -R g=u /etc/snmp/ ${ZABBIX_USER_HOME_DIR}/ /var/tmp/ /var/run/
Expand All @@ -102,7 +104,7 @@ EXPOSE 1162/UDP

WORKDIR ${ZABBIX_USER_HOME_DIR}/snmptraps/

VOLUME ["${ZABBIX_USER_HOME_DIR}/snmptraps"]
VOLUME ["${ZABBIX_USER_HOME_DIR}/snmptraps", "${SNMP_PERSISTENT_DIR}"]

COPY ["conf/etc/logrotate.d/zabbix_snmptraps", "/etc/logrotate.d/"]
COPY ["conf/etc/snmp/snmptrapd.conf", "/etc/snmp/"]
Expand Down
5 changes: 4 additions & 1 deletion Dockerfiles/snmptraps/ubuntu/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ ENV TERM=xterm \
ZBX_SNMP_TRAP_USE_DNS=false \
ZABBIX_USER_HOME_DIR="/var/lib/zabbix"

ENV SNMP_PERSISTENT_DIR="${ZABBIX_USER_HOME_DIR}/snmptrapd_config"

LABEL org.opencontainers.image.authors="Alexey Pustovalov <[email protected]>" \
org.opencontainers.image.description="Zabbix SNMP traps receiver" \
org.opencontainers.image.documentation="https://www.zabbix.com/documentation/${MAJOR_VERSION}/manual/installation/containers" \
Expand Down Expand Up @@ -52,6 +54,7 @@ RUN --mount=type=cache,target=/var/cache/apt/,sharing=locked \
mkdir -p ${ZABBIX_USER_HOME_DIR} && \
mkdir -p ${ZABBIX_USER_HOME_DIR}/snmptraps && \
mkdir -p ${ZABBIX_USER_HOME_DIR}/mibs && \
mkdir -p ${SNMP_PERSISTENT_DIR} && \
chown --quiet -R zabbix:root /etc/snmp/ ${ZABBIX_USER_HOME_DIR}/ /var/tmp/ /var/run/ && \
chgrp -R 0 /etc/snmp/ ${ZABBIX_USER_HOME_DIR}/ /var/tmp/ /var/run/ && \
chmod -R g=u /etc/snmp/ ${ZABBIX_USER_HOME_DIR}/ /var/tmp/ /var/run/
Expand All @@ -60,7 +63,7 @@ EXPOSE 1162/UDP

WORKDIR ${ZABBIX_USER_HOME_DIR}/snmptraps/

VOLUME ["${ZABBIX_USER_HOME_DIR}/snmptraps"]
VOLUME ["${ZABBIX_USER_HOME_DIR}/snmptraps", "${SNMP_PERSISTENT_DIR}"]

COPY ["conf/etc/logrotate.d/zabbix_snmptraps", "/etc/logrotate.d/"]
COPY ["conf/etc/snmp/snmptrapd.conf", "/etc/snmp/"]
Expand Down
1 change: 1 addition & 0 deletions compose_zabbix_components.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,7 @@ services:
read_only: true
volumes:
- snmptraps:/var/lib/zabbix/snmptraps:rwz
- ${DATA_DIRECTORY}/var/lib/zabbix/snmptrapd_config:/var/lib/zabbix/snmptrapd_config:rw
tmpfs: /tmp
deploy:
resources:
Expand Down

0 comments on commit ffae1d2

Please sign in to comment.