Skip to content

Commit

Permalink
The big one update :-)
Browse files Browse the repository at this point in the history
  • Loading branch information
dotneft committed Feb 18, 2018
1 parent 3b7cc92 commit 67d50ca
Show file tree
Hide file tree
Showing 144 changed files with 16,406 additions and 15,795 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
![logo](https://www.zabbix.com/img/logo.svg)
![logo](https://assets.zabbix.com/img/logo/zabbix_logo_500x131.png)

# What is Zabbix?

Expand All @@ -15,8 +15,9 @@ This repository contains **Dockerfile** of [Zabbix](https://zabbix.com/) for [Do

### Base Docker Image

* [ubuntu](https://hub.docker.com/_/ubuntu/)
* [alpine](https://hub.docker.com/_/alpine/)
* [centos](https://hub.docker.com/_/centos/)
* [ubuntu](https://hub.docker.com/_/ubuntu/)

### Usage

Expand Down
59 changes: 41 additions & 18 deletions agent/alpine/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
FROM alpine:3.4
LABEL maintainer "Alexey Pustovalov <alexey.pustovalov@zabbix.com>"
LABEL maintainer="Alexey Pustovalov <alexey.pustovalov@zabbix.com>"

ARG BUILD_DATE
ARG VCS_REF

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"
ENV TERM=xterm

LABEL org.label-schema.name="zabbix-agent-alpine" \
org.label-schema.vendor="Zabbix LLC" \
org.label-schema.url="https://zabbix.com/" \
org.label-schema.description="Zabbix agent is deployed on a monitoring target to actively monitor local resources and applications" \
org.label-schema.vcs-ref="${VCS_REF}" \
org.label-schema.build-date="${BUILD_DATE}" \
org.label-schema.schema-version="1.0" \
org.label-schema.license="GPL 2.0"

STOPSIGNAL SIGTERM

RUN addgroup zabbix && \
adduser -S \
-D -G zabbix \
Expand All @@ -19,25 +33,31 @@ RUN addgroup zabbix && \
chown --quiet -R zabbix:root /var/lib/zabbix && \
apk update && \
apk add ${APK_FLAGS_PERSISTANT} \
iputils \
supervisor \
bash \
coreutils \
libssl1.0 && \
iputils \
libldap \
supervisor && \
rm -rf /var/cache/apk/*

ARG MAJOR_VERSION=master
ARG ZBX_VERSION=${MAJOR_VERSION}
ARG ZBX_SOURCES=svn://svn.zabbix.com/tags/${ZBX_VERSION}/
ENV ZBX_VERSION=${ZBX_VERSION} ZBX_SOURCES=${ZBX_SOURCES}

LABEL org.label-schema.usage="https://www.zabbix.com/documentation/${MAJOR_VERSION}/manual/installation/containers" \
org.label-schema.version="${ZBX_VERSION}" \
org.label-schema.vcs-url="${ZBX_SOURCES}" \
org.label-schema.docker.cmd="docker run --name zabbix-agent --link zabbix-server:zabbix-server -p 10050:10050 -d zabbix-agent:alpine-${ZBX_VERSION}"

RUN apk update && \
apk add ${APK_FLAGS_DEV} --virtual build-dependencies \
alpine-sdk \
automake \
autoconf \
automake \
openssl-dev \
subversion && \
openldap-dev \
subversion \
coreutils && \
cd /tmp/ && \
svn --quiet export ${ZBX_SOURCES} zabbix-${ZBX_VERSION} 1>/dev/null && \
cd /tmp/zabbix-${ZBX_VERSION} && \
Expand All @@ -46,35 +66,38 @@ RUN apk update && \
./bootstrap.sh 1>/dev/null && \
export CFLAGS="-fPIC -pie -Wl,-z,relro -Wl,-z,now" && \
./configure \
--datadir=/usr/lib \
--libdir=/usr/lib/zabbix \
--prefix=/usr \
--silent \
--sysconfdir=/etc/zabbix \
--libdir=/usr/lib/zabbix \
--datadir=/usr/lib \
--prefix=/usr \
--enable-agent \
--with-ldap \
--with-openssl \
--enable-ipv6 \
--with-openssl && \
--silent && \
make -j"$(nproc)" -s 1>/dev/null && \
cp src/zabbix_agent/zabbix_agentd /usr/sbin/zabbix_agentd && \
cp src/zabbix_get/zabbix_get /usr/bin/zabbix_get && \
cp src/zabbix_sender/zabbix_sender /usr/bin/zabbix_sender && \
cp conf/zabbix_agentd.conf /etc/zabbix && \
cp conf/zabbix_agentd.conf /etc/zabbix/zabbix_agentd.conf && \
chown --quiet -R zabbix:root /etc/zabbix && \
cd /tmp/ && \
rm -rf /tmp/zabbix-${ZBX_VERSION}/ && \
apk del --purge \
apk del ${APK_FLAGS_COMMON} --purge \
build-dependencies && \
rm -rf /var/cache/apk/*
rm -rf /var/cache/apk/* && \
rm -rf /root/.subversion

EXPOSE 10050/TCP

WORKDIR /var/lib/zabbix

VOLUME ["/etc/zabbix/zabbix_agentd.d", "/var/lib/zabbix/enc", "/var/lib/zabbix/modules"]

ADD conf/etc/supervisor/ /etc/supervisor/
ADD run_zabbix_component.sh /
COPY ["conf/etc/supervisor/", "/etc/supervisor/"]
COPY ["docker-entrypoint.sh", "/usr/bin/"]

ENTRYPOINT ["/bin/bash"]
ENTRYPOINT ["docker-entrypoint.sh"]

CMD ["/run_zabbix_component.sh", "agentd", "none"]
CMD ["agentd", "none"]
18 changes: 9 additions & 9 deletions agent/alpine/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
![logo](http://www.zabbix.com/ru/img/logo/zabbix_logo_500x131.png)
![logo](https://assets.zabbix.com/img/logo/zabbix_logo_500x131.png)

# What is Zabbix?

Expand All @@ -14,15 +14,15 @@ Zabbix agent is deployed on a monitoring target to actively monitor local resour

# Zabbix agent images

These are the only official Zabbix agent Docker images. They are based on latest Alpine and trusty Ubuntu images. The available versions of Zabbix agent are:
These are the only official Zabbix agent Docker images. They are based on Alpine Linux v3.4, Ubuntu 14.04 (trusty) and CentOS 7 images. The available versions of Zabbix agent are:

Zabbix server 3.0 (tags: alpine-3.0-latest, ubuntu-3.0-latest)
Zabbix server 3.0.* (tags: alpine-3.0.*, ubuntu-3.0.*)
Zabbix server 3.2 (tags: alpine-3.2-latest, ubuntu-3.2-latest)
Zabbix server 3.2.* (tags: alpine-3.2.*, ubuntu-3.2.*)
Zabbix server 3.4 (tags: alpine-3.4-latest, ubuntu-3.4-latest, alpine-latest, ubuntu-latest, latest)
Zabbix server 3.4.* (tags: alpine-3.4.*, ubuntu-3.4.*)
Zabbix server 4.0 (tags: alpine-trunk, ubuntu-trunk)
Zabbix agent 3.0 (tags: alpine-3.0-latest, ubuntu-3.0-latest, centos-3.0-latest)
Zabbix agent 3.0.* (tags: alpine-3.0.*, ubuntu-3.0.*, centos-3.0.*)
Zabbix agent 3.2 (tags: alpine-3.2-latest, ubuntu-3.2-latest, centos-3.2-latest)
Zabbix agent 3.2.* (tags: alpine-3.2.*, ubuntu-3.2.*, centos-3.2.*)
Zabbix agent 3.4 (tags: alpine-3.4-latest, ubuntu-3.4-latest, centos-3.4-latest, alpine-latest, ubuntu-latest, centos-latest, latest)
Zabbix agent 3.4.* (tags: alpine-3.4.*, ubuntu-3.4.*, centos-3.4.*)
Zabbix agent 4.0 (tags: alpine-trunk, ubuntu-trunk, centos-trunk)

Images are updated when new releases are published. The image with ``latest`` tag is based on Alpine Linux.

Expand Down
17 changes: 14 additions & 3 deletions agent/alpine/build.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,29 @@
#!/bin/bash

os=alpine
os=${PWD##*/}

version=$1
version=${version:-"latest"}

app_component=agent
cd ../
app_component=${PWD##*/}
cd $os/

if [[ ! $version =~ ^[0-9]*\.[0-9]*\.[0-9]*$ ]] && [ "$version" != "latest" ]; then
echo "Incorrect syntax of the version"
exit 1
fi

docker build -t zabbix-$app_component:$os-$version -f Dockerfile .
if [ "$version" != "latest" ]; then
VCS_REF=`svn info svn://svn.zabbix.com/tags/$version |grep "Last Changed Rev"|awk '{print $4;}'`
else
MAJOR_VERSION=`cat Dockerfile | grep "ARG MAJOR_VERSION" | cut -f2 -d"="`
MINOR_VERSION=`cat Dockerfile | grep "ARG ZBX_VERSION" | cut -f2 -d"."`

VCS_REF=$MAJOR_VERSION.$MINOR_VERSION
fi

docker build -t zabbix-$app_component:$os-$version --build-arg VCS_REF="$VCS_REF" --build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` -f Dockerfile .

#docker rm -f zabbix-$app_component
#docker run --name zabbix-$app_component -t -d --link zabbix-server:zabbix-server zabbix-$app_component:$os-$version
12 changes: 8 additions & 4 deletions agent/alpine/conf/etc/supervisor/conf.d/supervisord_zabbix.conf
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
[supervisord]
nodaemon = true

[program:zabbix-agentd]
command = /usr/sbin/zabbix_agentd --foreground -c /etc/zabbix/zabbix_agentd.conf
[program:zabbix_agentd]
command = /usr/sbin/%(program_name)s --foreground -c /etc/zabbix/%(program_name)s.conf
user = zabbix
auto_start = true
autorestart = true

startsecs=2
startretries=3
stopsignal=TERM
stopwaitsecs=2

redirect_stderr=true
stdout_logfile = /dev/stdout
stdout_logfile_maxbytes = 0
stderr_logfile = /dev/stderr
stderr_logfile_maxbytes = 0
1 change: 1 addition & 0 deletions agent/alpine/conf/etc/supervisor/supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ critical = critical
user = root
logfile_maxbytes = 0
logfile_backupcount = 0
loglevel = info

; the below section must remain in the config file for RPC
; (supervisorctl/web interface) to work, additional interfaces may be
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

set -eo pipefail

set +e

# Script trace mode
Expand Down Expand Up @@ -126,7 +128,7 @@ check_variables_mysql() {
fi

if [ ! -n "${MYSQL_USER}" ] && [ ! -n "${MYSQL_ROOT_PASSWORD}" ] && [ "${MYSQL_ALLOW_EMPTY_PASSWORD}" != "true" ]; then
echo "*** Impossible to use MySQL server because 'root' password is not defined and not empty"
echo "*** Impossible to use MySQL server because 'root' password is not defined and it is not empty"
exit 1
fi

Expand Down Expand Up @@ -216,7 +218,7 @@ check_db_connect_postgresql() {

WAIT_TIMEOUT=5

while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -l -q 2>/dev/null)" ]; do
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
sleep $WAIT_TIMEOUT
done
Expand Down Expand Up @@ -320,21 +322,10 @@ create_db_schema_mysql() {
if [ -z "${ZBX_DB_VERSION}" ]; then
echo "** Creating '${DB_SERVER_DBNAME}' schema in MySQL"

cat /usr/share/doc/zabbix-$type-mysql/schema.sql | mysql --silent --skip-column-names \
zcat /usr/share/doc/zabbix-$type-mysql/create.sql.gz | mysql --silent --skip-column-names \
-h ${DB_SERVER_HOST} -P ${DB_SERVER_PORT} \
-u ${DB_SERVER_ROOT_USER} --password="${DB_SERVER_ROOT_PASS}" \
${DB_SERVER_DBNAME} 1>/dev/null
if [ "$type" == "server" ]; then
echo "** Fill the schema with initial data"
cat /usr/share/doc/zabbix-$type-mysql/images.sql | mysql --silent --skip-column-names \
-h ${DB_SERVER_HOST} -P ${DB_SERVER_PORT} \
-u ${DB_SERVER_ROOT_USER} --password="${DB_SERVER_ROOT_PASS}" \
${DB_SERVER_DBNAME} 1>/dev/null
cat /usr/share/doc/zabbix-$type-mysql/data.sql | mysql --silent --skip-column-names \
-h ${DB_SERVER_HOST} -P ${DB_SERVER_PORT} \
-u ${DB_SERVER_ROOT_USER} --password="${DB_SERVER_ROOT_PASS}" \
${DB_SERVER_DBNAME} 1>/dev/null
fi
fi
}

Expand All @@ -356,18 +347,9 @@ create_db_schema_postgresql() {
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
fi

cat /usr/share/doc/zabbix-$type-postgresql/schema.sql | psql -q \
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
if [ "$type" == "server" ]; then
echo "** Fill the schema with initial data"
cat /usr/share/doc/zabbix-$type-postgresql/images.sql | psql -q \
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
cat /usr/share/doc/zabbix-$type-postgresql/data.sql | psql -q \
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
fi

unset PGPASSWORD
fi
Expand All @@ -378,6 +360,8 @@ prepare_web_server_apache() {
APACHE_SITES_DIR=/etc/apache2/sites-available
elif [ -d "/etc/apache2/conf.d" ]; then
APACHE_SITES_DIR=/etc/apache2/conf.d
elif [ -d "/etc/httpd/conf.d" ]; then
APACHE_SITES_DIR=/etc/httpd/conf.d
else
echo "**** Apache is not available"
exit 1
Expand All @@ -390,6 +374,7 @@ prepare_web_server_apache() {
elif [ -f "/etc/apache2/conf.d/default.conf" ]; then
echo "** Disable default site"
rm -f "/etc/apache2/conf.d/default.conf"
rm -f "/etc/httpd/conf.d/welcome.conf"
fi

echo "** Adding Zabbix virtual host (HTTP)"
Expand Down Expand Up @@ -433,6 +418,13 @@ prepare_web_server_apache() {
"/etc/apache2/apache2.conf"
fi

if [ -f "/etc/httpd/conf/httpd.conf" ]; then
sed -ri \
-e 's!^(\s*CustomLog)\s+\S+!\1 /proc/self/fd/1!g' \
-e 's!^(\s*ErrorLog)\s+\S+!\1 /proc/self/fd/2!g' \
"/etc/httpd/conf/httpd.conf"
fi

if [ -f "/etc/apache2/httpd.conf" ]; then
sed -ri \
-e 's!^(\s*CustomLog)\s+\S+!\1 /proc/self/fd/1!g' \
Expand All @@ -456,6 +448,10 @@ prepare_web_server_apache() {
if [ -f "/var/run/apache2/apache2.pid" ]; then
rm -f "/var/run/apache2/apache2.pid"
fi

if [ -f "/var/run/httpd/httpd.pid" ]; then
rm -f "/var/run/httpd/httpd.pid"
fi
}

prepare_web_server_nginx() {
Expand Down Expand Up @@ -692,6 +688,8 @@ prepare_zbx_web_config() {
PHP_CONFIG_FILE="/etc/php/7.0/apache2/conf.d/99-zabbix.ini"
elif [ -f "/etc/php/7.0/fpm/conf.d/99-zabbix.ini" ]; then
PHP_CONFIG_FILE="/etc/php/7.0/fpm/conf.d/99-zabbix.ini"
elif [ -f "/etc/php.d/99-zabbix.ini" ]; then
PHP_CONFIG_FILE="/etc/php.d/99-zabbix.ini"
fi

if [ -n "$PHP_CONFIG_FILE" ]; then
Expand Down
Loading

0 comments on commit 67d50ca

Please sign in to comment.