first commit
Some checks failed
Vulhub Format Check and Lint / format-check (push) Has been cancelled
Vulhub Format Check and Lint / markdown-check (push) Has been cancelled
Vulhub Docker Image CI / longtime-images-test (push) Has been cancelled
Vulhub Docker Image CI / images-test (push) Has been cancelled
Some checks failed
Vulhub Format Check and Lint / format-check (push) Has been cancelled
Vulhub Format Check and Lint / markdown-check (push) Has been cancelled
Vulhub Docker Image CI / longtime-images-test (push) Has been cancelled
Vulhub Docker Image CI / images-test (push) Has been cancelled
This commit is contained in:
84
base/zabbix/3.0.3/server/Dockerfile
Normal file
84
base/zabbix/3.0.3/server/Dockerfile
Normal file
@@ -0,0 +1,84 @@
|
||||
# Usage:
|
||||
#
|
||||
# docker build --force-rm -t zabbix-server .
|
||||
# docker run -d --name zabbix-server -h zabbix-server -p 10051:10051 zabbix-server
|
||||
#
|
||||
#
|
||||
FROM alpine:3.4
|
||||
LABEL maintainer="phithon <root@leavesongs.com>"
|
||||
|
||||
ARG APK_FLAGS_COMMON="-q"
|
||||
ARG APK_FLAGS_PERSISTANT="${APK_FLAGS_COMMON} --clean-protected --no-cache"
|
||||
ARG APK_FLAGS_DEV="${APK_FLAGS_COMMON} --no-cache"
|
||||
ARG ZBX_SOURCES="http://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/3.0.3/zabbix-3.0.3.tar.gz/download"
|
||||
|
||||
ENV LANG=en_US.UTF-8 \
|
||||
TERM=xterm \
|
||||
ZBX_SOURCES=${ZBX_SOURCES} \
|
||||
ZBX_SRV_PORT=10051 \
|
||||
ZBX_SRV_HOST=127.0.0.1,172.17.0.1 \
|
||||
ZBX_SRV_HOST_ACT= \
|
||||
ZBX_AGT_NUM=3 \
|
||||
ZBX_AGT_PORT=10050 \
|
||||
MIBDIRS=/var/lib/zabbix/mibs \
|
||||
MIBS=+ALL \
|
||||
DB_TYPE=mysql
|
||||
|
||||
RUN apk update \
|
||||
&& apk add ${APK_FLAGS_PERSISTANT} bash mariadb-client-libs \
|
||||
mariadb-client fping libxml2 unixodbc net-snmp-agent-libs libldap libcurl openipmi-libs libssh2 \
|
||||
&& addgroup zabbix \
|
||||
&& adduser -S -D -G zabbix -h /var/lib/zabbix/ zabbix \
|
||||
&& mkdir -p /etc/zabbix/zabbix_agentd.conf.d /etc/zabbix/zabbix_server.conf.d /var/log/zabbix /var/run/zabbix/ /var/lib/zabbix/enc /var/lib/zabbix/modules /var/lib/zabbix/externalscripts /var/lib/zabbix/alertscripts /var/lib/zabbix/mibs /var/lib/zabbix/snmptraps /var/lib/zabbix/ssh_keys /var/lib/zabbix/ssl/certs /var/lib/zabbix/ssl/keys /var/lib/zabbix/ssl/ssl_ca \
|
||||
&& chown -R zabbix:root /var/lib/zabbix /var/run/zabbix /var/log/zabbix \
|
||||
&& rm -rf /var/cache/apk/*
|
||||
|
||||
RUN apk add ${APK_FLAGS_DEV} --virtual build-deps tzdata alpine-sdk coreutils automake autoconf mysql-dev libxml2-dev unixodbc-dev net-snmp-dev libssh2-dev openipmi-dev openldap-dev curl-dev openssl-dev \
|
||||
&& rm -f /etc/localtime && ln -s /usr/share/zoneinfo/UTC /etc/localtime \
|
||||
&& cd /tmp/ \
|
||||
&& mkdir -p /tmp/zabbix \
|
||||
&& curl -#SL "${ZBX_SOURCES}" | tar -xz -C /tmp/zabbix --strip-components 1 \
|
||||
&& cd /tmp/zabbix \
|
||||
&& ./configure --prefix=/usr --silent --sysconfdir=/etc/zabbix --libdir=/usr/lib/zabbix \
|
||||
--enable-server \
|
||||
--enable-agent \
|
||||
# --enable-static \
|
||||
# --enable-ipv6 \
|
||||
--with-ldap \
|
||||
--with-net-snmp \
|
||||
--with-openipmi \
|
||||
--with-ssh2 \
|
||||
--with-libcurl \
|
||||
--with-unixodbc \
|
||||
--with-libxml2 \
|
||||
--with-openssl \
|
||||
--with-${DB_TYPE} \
|
||||
&& make -j"$(nproc)" -s 1>/dev/null \
|
||||
&& cp src/zabbix_get/zabbix_get /usr/sbin/ \
|
||||
&& cp src/zabbix_server/zabbix_server /usr/sbin/ \
|
||||
&& cp conf/zabbix_server.conf /etc/zabbix/ \
|
||||
&& cp src/zabbix_agent/zabbix_agentd /usr/sbin/ \
|
||||
&& cp conf/zabbix_agentd.conf /etc/zabbix/ \
|
||||
&& cp /usr/share/snmp/mibs/* ${MIBDIRS}/ \
|
||||
&& chown -R zabbix:root /etc/zabbix /var/lib/zabbix/ \
|
||||
&& sed -e "s/.*\(PidFile=\).*/\1\/var\/run\/zabbix\/zabbix_server.pid/g" \
|
||||
-e "s/^\(LogFile=\).*/\1\/var\/log\/zabbix\/zabbix_server.log/g" \
|
||||
-e "s/^#\(FpingLocation=.*\)/\1/g" \
|
||||
-e "s/^# \(LoadModulePath=\)$/\1\/usr\/lib\/zabbix\/modules/g" \
|
||||
-e "s/^# \(Include=\)$/\1\/etc\/zabbix\/zabbix_server.conf.d\/*\.conf/g" -i /etc/zabbix/zabbix_server.conf \
|
||||
&& sed -e "s/.*\(PidFile=\).*/\1\/var\/run\/zabbix\/zabbix_agentd.pid/g" \
|
||||
-e "s/^\(LogFile=\).*/\1\/var\/log\/zabbix\/zabbix_agentd.log/g" \
|
||||
-e "s/^# \(LoadModulePath=\)$/\1\/usr\/lib\/zabbix\/modules/g" \
|
||||
-e "s/^# \(Include=\)$/\1\/etc\/zabbix\/zabbix_agentd.conf.d\/*\.conf/g" -i /etc/zabbix/zabbix_agentd.conf \
|
||||
&& chmod 4770 /usr/sbin/fping \
|
||||
&& chmod ug+s /usr/sbin/fping \
|
||||
&& chown root:zabbix /usr/sbin/fping \
|
||||
&& apk del ${APK_FLAGS_COMMON} --purge build-deps \
|
||||
&& rm -rf /var/cache/apk/* /tmp/zabbix/
|
||||
|
||||
COPY docker-entrypoint.sh /
|
||||
|
||||
EXPOSE 10051/TCP 162/UDP
|
||||
ENTRYPOINT ["/docker-entrypoint.sh"]
|
||||
|
||||
HEALTHCHECK --interval=15s --timeout=3s --retries=3 CMD nc -vz localhost 10051 || exit 1
|
34
base/zabbix/3.0.3/server/docker-entrypoint.sh
Normal file
34
base/zabbix/3.0.3/server/docker-entrypoint.sh
Normal file
@@ -0,0 +1,34 @@
|
||||
#!/bin/sh
|
||||
|
||||
__stop() {
|
||||
echo "> SIGTERM signal received, try to gracefully shutdown all services..."
|
||||
echo "> Stopping: Agent"
|
||||
kill $(cat /var/run/zabbix/zabbix_agentd.pid)
|
||||
tail -n50 /var/log/zabbix/zabbix_agentd.log
|
||||
echo "> Stopping: Server"
|
||||
kill $(cat /var/run/zabbix/zabbix_server.pid)
|
||||
tail -n50 /var/log/zabbix/zabbix_server.log
|
||||
}
|
||||
|
||||
trap "__stop; exit 0" SIGTERM SIGINT
|
||||
|
||||
if [ "$1" == "server" ]; then
|
||||
sed -e "s/.*\(ListenPort=\).*/\1$ZBX_SRV_PORT/g" \
|
||||
-e "s/.*\(DBHost=\).*/\1$DATABASE_HOST/g" \
|
||||
-e "s/^\(DBName=\).*/\1$DATABASE_NAME/g" \
|
||||
-e "s/.*\(DBPort=\).*/\1$DATABASE_PORT/g" \
|
||||
-e "s/^\(DBUser=\).*/\1$DATABASE_USER/g" \
|
||||
-e "s/.*\(DBPassword=\).*/\1$DATABASE_PASS/g" -i /etc/zabbix/zabbix_server.conf
|
||||
echo "> Running zabbix server..."
|
||||
exec su zabbix -s "/bin/bash" -c "/usr/sbin/zabbix_server --foreground -c /etc/zabbix/zabbix_server.conf"
|
||||
elif [ "$1" == "agent" ]; then
|
||||
sed -e "s/^\(Server=\).*/\1$ZBX_SRV_HOST/g" \
|
||||
-e "s/^\(ServerActive=\).*/\1$ZBX_SRV_HOST_ACT/g" \
|
||||
-e "s/.*\(StartAgents=\).*/\1$ZBX_AGT_NUM/g" \
|
||||
-e "s/.*\(ListenPort=\).*/\1$ZBX_AGT_PORT/g" \
|
||||
-e "s/^\(Hostname=\).*/\1`hostname`/g" -i /etc/zabbix/zabbix_agentd.conf
|
||||
echo "> Running zabbix server..."
|
||||
exec su zabbix -s "/bin/bash" -c "/usr/sbin/zabbix_agentd --foreground -c /etc/zabbix/zabbix_agentd.conf"
|
||||
else
|
||||
exec "$@"
|
||||
fi
|
Reference in New Issue
Block a user