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
|
52
base/zabbix/3.0.3/web/Dockerfile
Normal file
52
base/zabbix/3.0.3/web/Dockerfile
Normal file
@@ -0,0 +1,52 @@
|
||||
# Usage:
|
||||
#
|
||||
# https://wiki.alpinelinux.org/wiki/Setting_up_Zabbix
|
||||
# docker build --force-rm -t zabbix-web .
|
||||
# docker run -d --name zabbix-web -h zabbix-web -p 80:80 zabbix-web
|
||||
#
|
||||
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 DB_TYPE=mysql
|
||||
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_HOST=127.0.0.1 \
|
||||
ZBX_SRV_PORT=10051 \
|
||||
ZBX_SRV_NAME= \
|
||||
DB_TYPE=${DB_TYPE}
|
||||
|
||||
RUN apk update \
|
||||
&& apk add ${APK_FLAGS_PERSISTANT} mariadb-client php5-apache2 php5-sockets php5-gd php5-gettext php5-bcmath php5-ctype php5-xmlreader php5-json php5-ldap php5-mysqli ttf-dejavu \
|
||||
&& rm -rf /var/cache/apk/*
|
||||
|
||||
RUN apk add ${APK_FLAGS_DEV} --virtual build-deps tzdata bash curl tar coreutils gettext \
|
||||
&& rm -f /etc/localtime && ln -s /usr/share/zoneinfo/UTC /etc/localtime \
|
||||
&& mkdir -p /tmp/zabbix \
|
||||
&& curl -#SL "${ZBX_SOURCES}" | tar -xz -C /tmp/zabbix --strip-components 1 \
|
||||
&& mkdir -p /usr/share/webapps/ \
|
||||
&& cp -rp /tmp/zabbix/frontends/php /usr/share/webapps/zabbix \
|
||||
&& /usr/share/webapps/zabbix/locale/make_mo.sh \
|
||||
&& rm /usr/share/webapps/zabbix/fonts/DejaVuSans.ttf \
|
||||
&& ln -s /usr/share/fonts/ttf-dejavu/DejaVuSans.ttf /usr/share/webapps/zabbix/fonts/DejaVuSans.ttf \
|
||||
&& DATE=`date +%Y-%m-%d` \
|
||||
&& sed -e "s/ZABBIX_VERSION.*'\(.*\)'/ZABBIX_VERSION', '\1 ($DATE)'/g" \
|
||||
-e "s/ZABBIX_API_VERSION.*'\(.*\)'/ZABBIX_API_VERSION', '\1 ($DATE)'/g" -i /usr/share/webapps/zabbix/include/defines.inc.php \
|
||||
&& cp /usr/share/webapps/zabbix/conf/zabbix.conf.php.example /usr/share/webapps/zabbix/conf/zabbix.conf.php \
|
||||
&& apk del ${APK_FLAGS_COMMON} --purge build-deps \
|
||||
&& rm -rf /var/cache/apk/* /tmp/zabbix/ \
|
||||
&& mkdir /run/apache2 && chown apache:apache -R /run/apache2
|
||||
|
||||
COPY docker-entrypoint.sh /
|
||||
COPY conf/apache.conf /etc/apache2/conf.d/
|
||||
COPY conf/99-zabbix.ini /etc/php5/conf.d/
|
||||
|
||||
EXPOSE 80/TCP
|
||||
CMD ["/docker-entrypoint.sh"]
|
||||
|
||||
HEALTHCHECK --interval=15s --timeout=3s --retries=3 CMD wget -U Docker-HealthCheck -Y off -O /dev/null http://localhost:80 || exit 1
|
8
base/zabbix/3.0.3/web/conf/99-zabbix.ini
Normal file
8
base/zabbix/3.0.3/web/conf/99-zabbix.ini
Normal file
@@ -0,0 +1,8 @@
|
||||
max_execution_time=300
|
||||
memory_limit=128M
|
||||
post_max_size=16M
|
||||
upload_max_filesize=2M
|
||||
max_input_time=300
|
||||
always_populate_raw_post_data=-1
|
||||
date.timezone=Asia/Shanghai
|
||||
; session.save_path=/var/lib/php5
|
45
base/zabbix/3.0.3/web/conf/apache.conf
Normal file
45
base/zabbix/3.0.3/web/conf/apache.conf
Normal file
@@ -0,0 +1,45 @@
|
||||
<VirtualHost *:80>
|
||||
DocumentRoot /usr/share/webapps/zabbix/
|
||||
ServerName zabbix
|
||||
DirectoryIndex index.php
|
||||
AddType application/x-httpd-php .php .php3 .php4 .php5 .phtml
|
||||
AddType application/x-httpd-php-source .phps
|
||||
</VirtualHost>
|
||||
|
||||
<Directory "/usr/share/webapps/zabbix">
|
||||
Options FollowSymLinks
|
||||
AllowOverride None
|
||||
Require all granted
|
||||
</Directory>
|
||||
|
||||
<Directory "/usr/share/webapps/zabbix/conf">
|
||||
Require all denied
|
||||
<files *.php>
|
||||
Order deny,allow
|
||||
Deny from all
|
||||
</files>
|
||||
</Directory>
|
||||
|
||||
<Directory "/usr/share/webapps/zabbix/app">
|
||||
Require all denied
|
||||
<files *.php>
|
||||
Order deny,allow
|
||||
Deny from all
|
||||
</files>
|
||||
</Directory>
|
||||
|
||||
<Directory "/usr/share/webapps/zabbix/include">
|
||||
Require all denied
|
||||
<files *.php>
|
||||
Order deny,allow
|
||||
Deny from all
|
||||
</files>
|
||||
</Directory>
|
||||
|
||||
<Directory "/usr/share/webapps/zabbix/local">
|
||||
Require all denied
|
||||
<files *.php>
|
||||
Order deny,allow
|
||||
Deny from all
|
||||
</files>
|
||||
</Directory>
|
15
base/zabbix/3.0.3/web/docker-entrypoint.sh
Normal file
15
base/zabbix/3.0.3/web/docker-entrypoint.sh
Normal file
@@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
|
||||
# frontend config
|
||||
sed -i "s/^\(\$DB\['TYPE'\]\).*/\1 = 'MYSQL';/" /usr/share/webapps/zabbix/conf/zabbix.conf.php
|
||||
sed -i "s/^\(\$DB\['SERVER'\]\).*/\1 = '$DATABASE_HOST';/" /usr/share/webapps/zabbix/conf/zabbix.conf.php
|
||||
sed -i "s/^\(\$DB\['PORT'\]\).*/\1 = '$DATABASE_PORT';/" /usr/share/webapps/zabbix/conf/zabbix.conf.php
|
||||
sed -i "s/^\(\$DB\['DATABASE'\]\).*/\1 = '$DATABASE_NAME';/" /usr/share/webapps/zabbix/conf/zabbix.conf.php
|
||||
sed -i "s/^\(\$DB\['USER'\]\).*/\1 = '$DATABASE_USER';/" /usr/share/webapps/zabbix/conf/zabbix.conf.php
|
||||
sed -i "s/^\(\$DB\['PASSWORD'\]\).*/\1 = '$DATABASE_PASS';/" /usr/share/webapps/zabbix/conf/zabbix.conf.php
|
||||
|
||||
sed -i "s/^\(\$ZBX_SERVER\)\s.*/\1 = '$ZBX_SRV_HOST';/" /usr/share/webapps/zabbix/conf/zabbix.conf.php
|
||||
sed -i "s/^\(\$ZBX_SERVER_PORT\)\s.*/\1 = '$ZBX_SRV_PORT';/" /usr/share/webapps/zabbix/conf/zabbix.conf.php
|
||||
sed -i "s/^\(\$ZBX_SERVER_NAME\)\s.*/\1 = '$ZBX_SRV_NAME';/" /usr/share/webapps/zabbix/conf/zabbix.conf.php
|
||||
|
||||
exec /usr/sbin/httpd -D FOREGROUND
|
Reference in New Issue
Block a user