Merge pull request #199 from zabbix/master

Master
This commit is contained in:
Alexey Pustovalov
2018-02-18 23:13:22 +02:00
committed by GitHub
268 changed files with 32763 additions and 15824 deletions

View File

@ -0,0 +1 @@
build.sh

View File

@ -1,43 +1,58 @@
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"
ARG DB_TYPE=sqlite3
ENV TERM=xterm
ENV MIBDIRS=/usr/share/snmp/mibs:/var/lib/zabbix/mibs MIBS=+ALL
ENV TERM=xterm MIBDIRS=/usr/share/snmp/mibs:/var/lib/zabbix/mibs MIBS=+ALL
LABEL org.label-schema.name="zabbix-proxy-${DB_TYPE}-alpine" \
org.label-schema.vendor="Zabbix LLC" \
org.label-schema.url="https://zabbix.com/" \
org.label-schema.description="Zabbix proxy with SQLite3 database support" \
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 \
-h /var/lib/zabbix/ \
zabbix && \
mkdir -p /etc/zabbix/ && \
mkdir -p /etc/zabbix && \
mkdir -p /var/lib/zabbix && \
mkdir -p /var/lib/zabbix/enc && \
mkdir -p /usr/lib/zabbix/externalscripts && \
mkdir -p /var/lib/zabbix/mibs && \
mkdir -p /var/lib/zabbix/modules && \
mkdir -p /var/lib/zabbix/snmptraps && \
mkdir -p /var/lib/zabbix/ssh_keys && \
mkdir -p /var/lib/zabbix/ssl && \
mkdir -p /var/lib/zabbix/ssl/certs && \
mkdir -p /var/lib/zabbix/ssl/keys && \
mkdir -p /var/lib/zabbix/ssl/ssl_ca && \
chown --quiet -R zabbix:root /var/lib/zabbix && \
mkdir -p /usr/lib/zabbix/externalscripts && \
apk update && \
apk add ${APK_FLAGS_PERSISTANT} \
iputils \
supervisor \
bash \
sqlite-libs \
fping \
libxml2 \
unixodbc \
net-snmp-agent-libs \
libldap \
iputils \
libcurl \
libldap \
libssh2 \
libxml2 \
net-snmp-agent-libs \
openipmi-libs \
libssh2 && \
sqlite-libs \
supervisor \
unixodbc && \
rm -rf /var/cache/apk/*
ARG MAJOR_VERSION=3.2
@ -45,20 +60,25 @@ ARG ZBX_VERSION=${MAJOR_VERSION}.10
ARG ZBX_SOURCES=svn://svn.zabbix.com/tags/${ZBX_VERSION}/
ENV ZBX_VERSION=${ZBX_VERSION} ZBX_SOURCES=${ZBX_SOURCES} DB_TYPE=${DB_TYPE}
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-proxy-${DB_TYPE} --link zabbix-server:zabbix-server -p 10051:10051 -d zabbix-proxy-${DB_TYPE}:alpine-${ZBX_VERSION}"
RUN apk add ${APK_FLAGS_DEV} --virtual build-dependencies \
alpine-sdk \
coreutils \
automake \
autoconf \
sqlite-dev \
libxml2-dev \
unixodbc-dev \
net-snmp-dev \
automake \
coreutils \
curl-dev \
libssh2-dev \
libxml2-dev \
net-snmp-dev \
openipmi-dev \
openldap-dev \
curl-dev \
subversion && \
sqlite-dev \
subversion \
unixodbc-dev && \
cd /tmp/ && \
svn --quiet export ${ZBX_SOURCES} zabbix-${ZBX_VERSION} 1>/dev/null && \
cd /tmp/zabbix-${ZBX_VERSION} && \
@ -67,25 +87,23 @@ RUN apk add ${APK_FLAGS_DEV} --virtual build-dependencies \
./bootstrap.sh 1>/dev/null && \
export CFLAGS="-fPIC -pie -Wl,-z,relro -Wl,-z,now" && \
./configure \
--prefix=/usr \
--silent \
--sysconfdir=/etc/zabbix \
--libdir=/usr/lib/zabbix \
--datadir=/usr/lib \
--enable-proxy \
--libdir=/usr/lib/zabbix \
--sysconfdir=/etc/zabbix \
--prefix=/usr \
--enable-agent \
--enable-ipv6 \
# Does not support stable iksemel library
# --with-jabber \
--enable-proxy \
--with-${DB_TYPE} \
--with-ldap \
--with-libcurl \
--with-libxml2 \
--with-net-snmp \
--with-openipmi \
--with-ssh2 \
--with-libcurl \
--with-unixodbc \
--with-libxml2 \
--with-openssl \
--with-${DB_TYPE} && \
--with-ssh2 \
--with-unixodbc \
--enable-ipv6 \
--silent && \
make -j"$(nproc)" -s dbschema 1>/dev/null && \
make -j"$(nproc)" -s 1>/dev/null && \
cp src/zabbix_proxy/zabbix_proxy /usr/sbin/zabbix_proxy && \
@ -97,18 +115,19 @@ RUN apk add ${APK_FLAGS_DEV} --virtual build-dependencies \
rm -rf /tmp/zabbix-${ZBX_VERSION}/ && \
apk del ${APK_FLAGS_COMMON} --purge \
build-dependencies && \
rm -rf /var/cache/apk/*
rm -rf /var/cache/apk/* && \
rm -rf /root/.subversion
EXPOSE 10051/TCP 162/UDP
EXPOSE 10051/TCP
WORKDIR /var/lib/zabbix
VOLUME ["/usr/lib/zabbix/externalscripts", "/var/lib/zabbix/enc", "/var/lib/zabbix/modules", "/var/lib/zabbix/ssh_keys"]
VOLUME ["/var/lib/zabbix/ssl/certs", "/var/lib/zabbix/ssl/keys", "/var/lib/zabbix/ssl/ssl_ca", "/var/lib/zabbix/snmptraps", "/var/lib/zabbix/mibs"]
VOLUME ["/usr/lib/zabbix/externalscripts", "/var/lib/zabbix/enc", "/var/lib/zabbix/modules", "/var/lib/zabbix/snmptraps"]
VOLUME ["/var/lib/zabbix/ssh_keys", "/var/lib/zabbix/ssl/certs", "/var/lib/zabbix/ssl/keys", "/var/lib/zabbix/ssl/ssl_ca"]
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", "proxy", "sqlite3"]
CMD ["proxy", "sqlite3"]

View File

@ -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?
@ -14,15 +14,15 @@ Zabbix proxy is a process that may collect monitoring data from one or more moni
# Zabbix proxy images
These are the only official Zabbix proxy Docker images. They are based on latest Alpine and trusty Ubuntu images. The available versions of Zabbix proxy are:
These are the only official Zabbix proxy Docker images. They are based on Alpine Linux v3.4, Ubuntu 14.04 (trusty) and CentOS 7 images. The available versions of Zabbix proxy 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 proxy 3.0 (tags: alpine-3.0-latest, ubuntu-3.0-latest, centos-3.0-latest)
Zabbix proxy 3.0.* (tags: alpine-3.0.*, ubuntu-3.0.*, centos-3.0.*)
Zabbix proxy 3.2 (tags: alpine-3.2-latest, ubuntu-3.2-latest, centos-3.2-latest)
Zabbix proxy 3.2.* (tags: alpine-3.2.*, ubuntu-3.2.*, centos-3.2.*)
Zabbix proxy 3.4 (tags: alpine-3.4-latest, ubuntu-3.4-latest, centos-3.4-latest, alpine-latest, ubuntu-latest, centos-latest, latest)
Zabbix proxy 3.4.* (tags: alpine-3.4.*, ubuntu-3.4.*, centos-3.4.*)
Zabbix proxy 4.0 (tags: alpine-trunk, ubuntu-trunk)
Images are updated when new releases are published. The image with ``latest`` tag is based on Alpine Linux.

View File

@ -1,20 +1,25 @@
#!/bin/bash
os=alpine
os=${PWD##*/}
version=$1
version=${version:-"latest"}
app_component=proxy
app_database=sqlite3
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-$app_database:$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;}'`
fi
#docker rm -f zabbix-$app_component-$app_database
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 run --name zabbix-$app_component-$app_database -t -d --link zabbix-server:zabbix-server zabbix-$app_component-$app_database:$os-$version
#docker rm -f zabbix-$app_component
#docker run --name zabbix-$app_component -t -d --link zabbix-server:zabbix-server zabbix-$app_component:$os-$version

View File

@ -1,13 +1,18 @@
[supervisord]
nodaemon = true
[program:zabbix-proxy]
command = /usr/sbin/zabbix_proxy --foreground -c /etc/zabbix/zabbix_proxy.conf
[program:zabbix_proxy]
command = /usr/sbin/%(program_name)s --foreground -c /etc/zabbix/zabbix_proxy.conf
user = zabbix
auto_start = true
autorestart = true
startsecs=5
startretries=3
stopsignal=INT
stopwaitsecs=5
redirect_stderr=true
stdout_logfile = /dev/stdout
stdout_logfile_maxbytes = 0
stderr_logfile = /dev/stderr
stderr_logfile_maxbytes = 0

View File

@ -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

View File

@ -1,5 +1,7 @@
#!/bin/bash
set -eo pipefail
set +e
# Script trace mode
@ -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
@ -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
@ -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
}
@ -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 \
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
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 \
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
fi
unset PGPASSWORD
fi
@ -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
@ -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)"
@ -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' \
@ -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() {
@ -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