init
This commit is contained in:
27
zabbix-agent2/Dockerfile
Normal file
27
zabbix-agent2/Dockerfile
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
ARG BUILD_ARCH
|
||||||
|
ARG BUILD_VERSION
|
||||||
|
ARG BUILD_BASE_IMAGE=zabbix/zabbix-agent2:alpine-trunk
|
||||||
|
|
||||||
|
FROM ${BUILD_BASE_IMAGE} as builder
|
||||||
|
|
||||||
|
FROM alpine
|
||||||
|
|
||||||
|
LABEL maintainer "sinav"
|
||||||
|
|
||||||
|
ENV LANG C.UTF-8
|
||||||
|
|
||||||
|
# Install requirements for add-on
|
||||||
|
RUN apk add --no-cache jq zabbix-agent2 && \
|
||||||
|
addgroup -g 1003 docker && \
|
||||||
|
addgroup zabbix docker && \
|
||||||
|
mkdir -p /etc/zabbix/zabbix_agent2.d/plugins.d
|
||||||
|
|
||||||
|
# Copy zabbix-agent2 plugins
|
||||||
|
COPY --from=builder ["/usr/sbin/zabbix-agent2-plugin", "/usr/sbin/zabbix-agent2-plugin"]
|
||||||
|
RUN echo -e "\nPlugins.PostgreSQL.System.Path=/usr/sbin/zabbix-agent2-plugin/zabbix-agent2-plugin-mongodb\nPlugins.PostgreSQL.System.Path=/usr/sbin/zabbix-agent2-plugin/zabbix-agent2-plugin-postgresql\n" >> /etc/zabbix/zabbix_agent2.conf
|
||||||
|
|
||||||
|
# Copy data for add-on
|
||||||
|
COPY run.sh /
|
||||||
|
RUN chmod a+x /run.sh
|
||||||
|
|
||||||
|
CMD [ "/run.sh" ]
|
||||||
32
zabbix-agent2/config.yaml
Normal file
32
zabbix-agent2/config.yaml
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
---
|
||||||
|
name: zabbix-agent2
|
||||||
|
version: '7.0'
|
||||||
|
slug: zabbix-agent2
|
||||||
|
description: Zabbix agent 2
|
||||||
|
url: https://gitea.sinav-lab.com/sinav/haos-addons
|
||||||
|
arch:
|
||||||
|
- armhf
|
||||||
|
- armv7
|
||||||
|
- aarch64
|
||||||
|
- amd64
|
||||||
|
- i386
|
||||||
|
startup: system
|
||||||
|
boot: auto
|
||||||
|
full_access: true
|
||||||
|
host_ipc: true
|
||||||
|
host_pid: true
|
||||||
|
host_network: true
|
||||||
|
docker_api: true
|
||||||
|
advanced: true
|
||||||
|
ports:
|
||||||
|
10050/tcp: 10050
|
||||||
|
options:
|
||||||
|
server: zabbix-server.local
|
||||||
|
serveractive: zabbix-server.local
|
||||||
|
hostname: homeassistant
|
||||||
|
schema:
|
||||||
|
server: str
|
||||||
|
serveractive: str
|
||||||
|
hostname: str
|
||||||
|
tlspskidentity: str?
|
||||||
|
tlspsksecret: str?
|
||||||
BIN
zabbix-agent2/icon.png
Normal file
BIN
zabbix-agent2/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.9 KiB |
BIN
zabbix-agent2/logo.png
Normal file
BIN
zabbix-agent2/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
31
zabbix-agent2/run.sh
Normal file
31
zabbix-agent2/run.sh
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
#!/usr/bin/env ash
|
||||||
|
# shellcheck shell=dash
|
||||||
|
|
||||||
|
# Extract config data
|
||||||
|
CONFIG_PATH=/data/options.json
|
||||||
|
ZABBIX_SERVER=$(jq --raw-output ".server" "${CONFIG_PATH}")
|
||||||
|
ZABBIX_SERVER_ACTIVE=$(jq --raw-output ".serveractive" "${CONFIG_PATH}")
|
||||||
|
ZABBIX_HOSTNAME=$(jq --raw-output ".hostname" "${CONFIG_PATH}")
|
||||||
|
ZABBIX_TLSPSK_IDENTITY=$(jq --raw-output ".tlspskidentity" "${CONFIG_PATH}")
|
||||||
|
ZABBIX_TLSPSK_SECRET=$(jq --raw-output ".tlspsksecret" "${CONFIG_PATH}")
|
||||||
|
|
||||||
|
# Update zabbix-agent config
|
||||||
|
ZABBIX_CONFIG_FILE=/etc/zabbix/zabbix_agent2.conf
|
||||||
|
sed -i 's@^\(Server\)=.*@\1='"${ZABBIX_SERVER}"'@' "${ZABBIX_CONFIG_FILE}"
|
||||||
|
sed -i 's@^\(ServerActive\)=.*@\1='"${ZABBIX_SERVER_ACTIVE}"'@' "${ZABBIX_CONFIG_FILE}"
|
||||||
|
sed -i 's@^#\?\s\?\(Hostname\)=.*@\1='"${ZABBIX_HOSTNAME}"'@' "${ZABBIX_CONFIG_FILE}"
|
||||||
|
|
||||||
|
# Add TLS PSK config if variables are used
|
||||||
|
if [ "${ZABBIX_TLSPSK_IDENTITY}" != "null" ] && [ "${ZABBIX_TLSPSK_SECRET}" != "null" ]; then
|
||||||
|
ZABBIX_TLSPSK_SECRET_FILE=/etc/zabbix/tls_secret
|
||||||
|
echo "${ZABBIX_TLSPSK_SECRET}" > "${ZABBIX_TLSPSK_SECRET_FILE}"
|
||||||
|
sed -i 's@^#\?\s\?\(TLSConnect\)=.*@\1='"psk"'@' "${ZABBIX_CONFIG_FILE}"
|
||||||
|
sed -i 's@^#\?\s\?\(TLSAccept\)=.*@\1='"psk"'@' "${ZABBIX_CONFIG_FILE}"
|
||||||
|
sed -i 's@^#\?\s\?\(TLSPSKIdentity\)=.*@\1='"${ZABBIX_TLSPSK_IDENTITY}"'@' "${ZABBIX_CONFIG_FILE}"
|
||||||
|
sed -i 's@^#\?\s\?\(TLSPSKFile\)=.*@\1='"${ZABBIX_TLSPSK_SECRET_FILE}"'@' "${ZABBIX_CONFIG_FILE}"
|
||||||
|
fi
|
||||||
|
unset ZABBIX_TLSPSK_IDENTITY
|
||||||
|
unset ZABBIX_TLSPSK_SECRET
|
||||||
|
|
||||||
|
# Run zabbix-agent2 in foreground
|
||||||
|
exec su zabbix -s /bin/ash -c "zabbix_agent2 -f"
|
||||||
Reference in New Issue
Block a user