mirror of
https://github.com/zabbix/zabbix-docker.git
synced 2024-11-26 01:34:01 +01:00
Merge pull request #59 from zabbix/master
Added Apache with PostgreSQL support image
This commit is contained in:
commit
7bcf1be0ea
@ -26,6 +26,7 @@ Please follow usage instructions of each Zabbix component image:
|
||||
* [zabbix-server-mysql](https://hub.docker.com/r/zabbix/zabbix-server-mysql/) - Zabbix server with MySQL database support
|
||||
* [zabbix-server-pgsql](https://hub.docker.com/r/zabbix/zabbix-server-pgsql/) - Zabbix server with PostgreSQL database support
|
||||
* [zabbix-web-apache-mysql](https://hub.docker.com/r/zabbix/zabbix-web-apache-mysql/) - Zabbix web interface on Apache2 web server with MySQL database support
|
||||
* [zabbix-web-apache-pgsql](https://hub.docker.com/r/zabbix/zabbix-web-apache-pgsql/) - Zabbix web interface on Apache2 web server with PostgreSQL database support
|
||||
* [zabbix-web-nginx-mysql](https://hub.docker.com/r/zabbix/zabbix-web-nginx-mysql/) - Zabbix web interface on Nginx web server with MySQL database support
|
||||
* [zabbix-web-nginx-pgsql](https://hub.docker.com/r/zabbix/zabbix-server-pgsql/) - Zabbix web interface on Nginx web server with PostgreSQL database support
|
||||
* [zabbix-proxy-sqlite3](https://hub.docker.com/r/zabbix/zabbix-proxy-sqlite3/) - Zabbix proxy with SQLite3 database support
|
||||
|
@ -123,6 +123,37 @@ services:
|
||||
com.zabbix.dbtype: "mysql"
|
||||
com.zabbix.os: "alpine"
|
||||
|
||||
zabbix-web-apache-pgsql:
|
||||
image: zabbix/zabbix-web-apache-pgsql:alpine-latest
|
||||
ports:
|
||||
- "80:80"
|
||||
- "443:443"
|
||||
links:
|
||||
- postgres-server:postgres-server
|
||||
- zabbix-server:zabbix-server
|
||||
mem_limit: 512m
|
||||
volumes:
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
- /etc/timezone:/etc/timezone:ro
|
||||
- ./zbx_env/etc/ssl/apache2:/etc/ssl/apache2:ro
|
||||
env_file:
|
||||
- .env_db_pgsql
|
||||
- .env_web
|
||||
user: root
|
||||
networks:
|
||||
zbx_net:
|
||||
aliases:
|
||||
- zabbix-web-apache-pgsql
|
||||
- zabbix-web-apache-alpine-pgsql
|
||||
- zabbix-web-apache-pgsql-alpine
|
||||
labels:
|
||||
com.zabbix.description: "Zabbix frontend on Apache web-server with PostgreSQL database support"
|
||||
com.zabbix.company: "Zabbix SIA"
|
||||
com.zabbix.component: "zabbix-frontend"
|
||||
com.zabbix.webserver: "apache2"
|
||||
com.zabbix.dbtype: "pgsql"
|
||||
com.zabbix.os: "alpine"
|
||||
|
||||
zabbix-web-nginx-pgsql:
|
||||
image: zabbix/zabbix-web-nginx-pgsql:alpine-3.2-latest
|
||||
ports:
|
||||
|
@ -126,6 +126,39 @@ services:
|
||||
com.zabbix.dbtype: "mysql"
|
||||
com.zabbix.os: "alpine"
|
||||
|
||||
|
||||
zabbix-web-apache-pgsql:
|
||||
build: ./web-apache-pgsql/alpine
|
||||
image: zabbix-web-apache-pgsql:alpine-local
|
||||
ports:
|
||||
- "80:80"
|
||||
- "443:443"
|
||||
links:
|
||||
- postgres-server:postgres-server
|
||||
- zabbix-server:zabbix-server
|
||||
mem_limit: 512m
|
||||
volumes:
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
- /etc/timezone:/etc/timezone:ro
|
||||
- ./zbx_env/etc/ssl/apache2:/etc/ssl/apache2:ro
|
||||
env_file:
|
||||
- .env_db_pgsql
|
||||
- .env_web
|
||||
user: root
|
||||
networks:
|
||||
zbx_net:
|
||||
aliases:
|
||||
- zabbix-web-apache-pgsql
|
||||
- zabbix-web-apache-alpine-pgsql
|
||||
- zabbix-web-apache-pgsql-alpine
|
||||
labels:
|
||||
com.zabbix.description: "Zabbix frontend on Apache web-server with PostgreSQL database support"
|
||||
com.zabbix.company: "Zabbix SIA"
|
||||
com.zabbix.component: "zabbix-frontend"
|
||||
com.zabbix.webserver: "apache2"
|
||||
com.zabbix.dbtype: "pgsql"
|
||||
com.zabbix.os: "alpine"
|
||||
|
||||
zabbix-web-nginx-pgsql:
|
||||
build: ./web-nginx-pgsql/alpine
|
||||
image: zabbix-web-nginx-pgsql:alpine-local
|
||||
|
@ -145,8 +145,8 @@ services:
|
||||
zbx_net:
|
||||
aliases:
|
||||
- zabbix-web-apache-mysql
|
||||
- zabbix-web-apache-alpine-mysql
|
||||
- zabbix-web-apache-mysql-alpine
|
||||
- zabbix-web-apache-ubuntu-mysql
|
||||
- zabbix-web-apache-mysql-ubuntu
|
||||
labels:
|
||||
com.zabbix.description: "Zabbix frontend on Apache web-server with MySQL database support"
|
||||
com.zabbix.company: "Zabbix SIA"
|
||||
|
@ -149,8 +149,8 @@ services:
|
||||
zbx_net:
|
||||
aliases:
|
||||
- zabbix-web-apache-mysql
|
||||
- zabbix-web-apache-alpine-mysql
|
||||
- zabbix-web-apache-mysql-alpine
|
||||
- zabbix-web-apache-ubuntu-mysql
|
||||
- zabbix-web-apache-mysql-ubuntu
|
||||
labels:
|
||||
com.zabbix.description: "Zabbix frontend on Apache web-server with MySQL database support"
|
||||
com.zabbix.company: "Zabbix SIA"
|
||||
|
@ -123,6 +123,37 @@ services:
|
||||
com.zabbix.dbtype: "mysql"
|
||||
com.zabbix.os: "ubuntu"
|
||||
|
||||
zabbix-web-apache-pgsql:
|
||||
image: zabbix/zabbix-web-apache-pgsql:ubuntu-latest
|
||||
ports:
|
||||
- "80:80"
|
||||
- "443:443"
|
||||
links:
|
||||
- postgres-server:postgres-server
|
||||
- zabbix-server:zabbix-server
|
||||
mem_limit: 512m
|
||||
volumes:
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
- /etc/timezone:/etc/timezone:ro
|
||||
- ./zbx_env/etc/ssl/apache2:/etc/ssl/apache2:ro
|
||||
env_file:
|
||||
- .env_db_pgsql
|
||||
- .env_web
|
||||
user: root
|
||||
networks:
|
||||
zbx_net:
|
||||
aliases:
|
||||
- zabbix-web-apache-pgsql
|
||||
- zabbix-web-apache-ubuntu-pgsql
|
||||
- zabbix-web-apache-pgsql-ubuntu
|
||||
labels:
|
||||
com.zabbix.description: "Zabbix frontend on Apache web-server with PostgreSQL database support"
|
||||
com.zabbix.company: "Zabbix SIA"
|
||||
com.zabbix.component: "zabbix-frontend"
|
||||
com.zabbix.webserver: "apache2"
|
||||
com.zabbix.dbtype: "pgsql"
|
||||
com.zabbix.os: "ubuntu"
|
||||
|
||||
zabbix-web-nginx-pgsql:
|
||||
image: zabbix/zabbix-web-nginx-pgsql:ubuntu-3.2-latest
|
||||
ports:
|
||||
|
@ -126,6 +126,38 @@ services:
|
||||
com.zabbix.dbtype: "mysql"
|
||||
com.zabbix.os: "ubuntu"
|
||||
|
||||
zabbix-web-apache-pgsql:
|
||||
build: ./web-apache-pgsql/ubuntu
|
||||
image: zabbix-web-apache-pgsql:ubuntu-local
|
||||
ports:
|
||||
- "80:80"
|
||||
- "443:443"
|
||||
links:
|
||||
- postgres-server:postgres-server
|
||||
- zabbix-server:zabbix-server
|
||||
mem_limit: 512m
|
||||
volumes:
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
- /etc/timezone:/etc/timezone:ro
|
||||
- ./zbx_env/etc/ssl/apache2:/etc/ssl/apache2:ro
|
||||
env_file:
|
||||
- .env_db_pgsql
|
||||
- .env_web
|
||||
user: root
|
||||
networks:
|
||||
zbx_net:
|
||||
aliases:
|
||||
- zabbix-web-apache-pgsql
|
||||
- zabbix-web-apache-ubuntu-pgsql
|
||||
- zabbix-web-apache-pgsql-ubuntu
|
||||
labels:
|
||||
com.zabbix.description: "Zabbix frontend on Apache web-server with PostgreSQL database support"
|
||||
com.zabbix.company: "Zabbix SIA"
|
||||
com.zabbix.component: "zabbix-frontend"
|
||||
com.zabbix.webserver: "apache2"
|
||||
com.zabbix.dbtype: "pgsql"
|
||||
com.zabbix.os: "ubuntu"
|
||||
|
||||
zabbix-web-nginx-pgsql:
|
||||
build: ./web-nginx-pgsql/ubuntu
|
||||
image: zabbix-web-nginx-pgsql:ubuntu-local
|
||||
|
@ -17,4 +17,4 @@ docker build -t zabbix-$app_component-$app_database:$os-$version -f Dockerfile .
|
||||
|
||||
#docker rm -f zabbix-$app_component-$app_database
|
||||
|
||||
#docker run --name zabbix-$app_component-$app_database -t -d --link postgres-server:mysql zabbix-$app_component-$app_database:$os-$version
|
||||
#docker run --name zabbix-$app_component-$app_database -t -d --link postgres-server:postgres zabbix-$app_component-$app_database:$os-$version
|
||||
|
79
web-apache-pgsql/alpine/Dockerfile
Normal file
79
web-apache-pgsql/alpine/Dockerfile
Normal file
@ -0,0 +1,79 @@
|
||||
FROM alpine:latest
|
||||
MAINTAINER Alexey Pustovalov <alexey.pustovalov@zabbix.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=postgresql
|
||||
ENV TERM=xterm
|
||||
|
||||
RUN addgroup zabbix && \
|
||||
adduser -S \
|
||||
-D -G zabbix \
|
||||
-h /var/lib/zabbix/ \
|
||||
-H \
|
||||
zabbix && \
|
||||
mkdir -p /etc/zabbix && \
|
||||
mkdir -p /etc/zabbix/web && \
|
||||
chown --quiet -R zabbix:root /etc/zabbix && \
|
||||
apk update && \
|
||||
apk add ${APK_FLAGS_PERSISTANT} \
|
||||
supervisor \
|
||||
bash \
|
||||
postgresql-client \
|
||||
apache2 \
|
||||
apache2-ssl \
|
||||
php5-apache2 \
|
||||
php5-pgsql \
|
||||
php5-ctype \
|
||||
php5-sockets \
|
||||
php5-gd \
|
||||
php5-gettext \
|
||||
php5-bcmath \
|
||||
php5-xmlreader \
|
||||
php5-ldap \
|
||||
php5-json \
|
||||
ttf-dejavu && \
|
||||
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} DB_TYPE=${DB_TYPE}
|
||||
|
||||
ADD conf/tmp/font-config /tmp/font-config
|
||||
|
||||
RUN apk add ${APK_FLAGS_DEV} --virtual build-dependencies \
|
||||
coreutils \
|
||||
gettext \
|
||||
subversion && \
|
||||
cd /usr/share/ && \
|
||||
svn --quiet export ${ZBX_SOURCES}/frontends/php/ zabbix 1>/dev/null && \
|
||||
cd /usr/share/zabbix/ && \
|
||||
patch -p3 < /tmp/font-config && \
|
||||
rm /tmp/font-config && \
|
||||
rm -f conf/zabbix.conf.php && \
|
||||
rm -rf tests && \
|
||||
rm /usr/share/zabbix/fonts/DejaVuSans.ttf && \
|
||||
./locale/make_mo.sh 2>/dev/null && \
|
||||
ln -s /usr/share/fonts/ttf-dejavu/DejaVuSans.ttf /usr/share/zabbix/fonts/graphfont.ttf && \
|
||||
apk del ${APK_FLAGS_COMMON} --purge \
|
||||
build-dependencies && \
|
||||
rm -rf /var/cache/apk/*
|
||||
|
||||
EXPOSE 80/TCP 443/TCP
|
||||
|
||||
WORKDIR /usr/share/zabbix
|
||||
|
||||
VOLUME ["/etc/ssl/apache2"]
|
||||
|
||||
ADD conf/etc/supervisor/ /etc/supervisor/
|
||||
ADD conf/etc/zabbix/apache.conf /etc/zabbix/
|
||||
ADD conf/etc/zabbix/apache_ssl.conf /etc/zabbix/
|
||||
ADD conf/etc/zabbix/web/zabbix.conf.php /etc/zabbix/web/
|
||||
ADD conf/etc/php5/conf.d/99-zabbix.ini /etc/php5/conf.d/
|
||||
ADD run_zabbix_component.sh /
|
||||
|
||||
ENTRYPOINT ["/bin/bash"]
|
||||
|
||||
CMD ["/run_zabbix_component.sh", "frontend", "postgresql", "apache"]
|
171
web-apache-pgsql/alpine/README.md
Normal file
171
web-apache-pgsql/alpine/README.md
Normal file
@ -0,0 +1,171 @@
|
||||
![logo](http://www.zabbix.com/ru/img/logo/zabbix_logo_500x131.png)
|
||||
|
||||
# What is Zabbix?
|
||||
|
||||
Zabbix is an enterprise-class open source distributed monitoring solution.
|
||||
|
||||
Zabbix is software that monitors numerous parameters of a network and the health and integrity of servers. Zabbix uses a flexible notification mechanism that allows users to configure e-mail based alerts for virtually any event. This allows a fast reaction to server problems. Zabbix offers excellent reporting and data visualisation features based on the stored data. This makes Zabbix ideal for capacity planning.
|
||||
|
||||
For more information and related downloads for Zabbix components, please visit https://hub.docker.com/u/zabbix/ and https://zabbix.com
|
||||
|
||||
# What is Zabbix web interface?
|
||||
|
||||
Zabbix web interface is a part of Zabbix software. It is used to manage resources under monitoring and view monitoring statistics.
|
||||
|
||||
# Zabbix web interface images
|
||||
|
||||
These are the only official Zabbix web interface Docker images. They are based on latest Alpine and trusty Ubuntu images. The available versions of Zabbix web interface are:
|
||||
|
||||
Zabbix web interface 3.0 (tags: alpine-3.0-latest, ubuntu-3.0-latest)
|
||||
Zabbix web interface 3.0.* (tags: alpine-3.0.*, ubuntu-3.0.*)
|
||||
Zabbix web interface 3.2 (tags: alpine-3.2-latest, ubuntu-3.2-latest, alpine-latest, ubuntu-latest, latest)
|
||||
Zabbix web interface 3.2.* (tags: alpine-3.2.*, ubuntu-3.2.*)
|
||||
Zabbix web interface 3.4 (tags: alpine-trunk, ubuntu-trunk)
|
||||
|
||||
Images are updated when new releases are published. The image with ``latest`` tag is based on Alpine Linux.
|
||||
|
||||
Zabbix web interface available in four editions:
|
||||
- Zabbix web-interface based on Apache2 web server with MySQL database support
|
||||
- Zabbix web-interface based on Apache2 web server with PostgreSQL database support
|
||||
- Zabbix web-interface based on Nginx web server with MySQL database support
|
||||
- Zabbix web-interface based on Nginx web server with PostgreSQL database support
|
||||
|
||||
The image based on Apache2 web server with PostgreSQL database support.
|
||||
|
||||
# How to use this image
|
||||
|
||||
## Start `zabbix-web-apache-pgsql`
|
||||
|
||||
Start a Zabbix web-interface container as follows:
|
||||
|
||||
docker run --name some-zabbix-web-apache-pgsql -e DB_SERVER_HOST="some-postgres-server" -e POSTGRES_USER="some-user" -e POSTGRES_PASSWORD="some-password" -e ZBX_SERVER_HOST="some-zabbix-server" -e TZ="some-timezone" -d zabbix/zabbix-web-apache-pgsql:tag
|
||||
|
||||
Where `some-zabbix-web-apache-pgsql` is the name you want to assign to your container, `some-postgres-server` is IP or DNS name of PostgreSQL server, `some-user` is user to connect to Zabbix database on PostgreSQL server, `some-password` is the password to connect to PostgreSQL server, `some-zabbix-server` is IP or DNS name of Zabbix server or proxy, `some-timezone` is PHP like timezone name and `tag` is the tag specifying the version you want. See the list above for relevant tags, or look at the [full list of tags](https://hub.docker.com/r/zabbix/zabbix-web-apache-pgsql/tags/).
|
||||
|
||||
## Linking the container to Zabbix server
|
||||
|
||||
docker run --name some-zabbix-web-apache-pgsql --link some-zabbix-server:zabbix-server -e DB_SERVER_HOST="some-postgres-server" -e POSTGRES_USER="some-user" -e POSTGRES_PASSWORD="some-password" -e ZBX_SERVER_HOST="some-zabbix-server" -e TZ="some-timezone" -d zabbix/zabbix-web-apache-pgsql:tag
|
||||
|
||||
## Linking the container to PostgreSQL database
|
||||
|
||||
docker run --name some-zabbix-web-apache-pgsql --link some-postgres-server:postgres -e DB_SERVER_HOST="some-postgres-server" -e POSTGRES_USER="some-user" -e POSTGRES_PASSWORD="some-password" -e ZBX_SERVER_HOST="some-zabbix-server" -e TZ="some-timezone" -d zabbix/zabbix-web-apache-pgsql:tag
|
||||
|
||||
## Container shell access and viewing Zabbix web interface logs
|
||||
|
||||
The `docker exec` command allows you to run commands inside a Docker container. The following command line will give you a bash shell inside your `zabbix-web-apache-pgsql` container:
|
||||
|
||||
```console
|
||||
$ docker exec -ti some-zabbix-web-apache-pgsql /bin/bash/
|
||||
```
|
||||
|
||||
The Zabbix web interface log is available through Docker's container log:
|
||||
|
||||
```console
|
||||
$ docker logs some-zabbix-web-apache-pgsql
|
||||
```
|
||||
|
||||
## Environment Variables
|
||||
|
||||
When you start the `zabbix-web-apache-pgsql` image, you can adjust the configuration of the Zabbix web interface by passing one or more environment variables on the `docker run` command line.
|
||||
|
||||
### `ZBX_SERVER_HOST`
|
||||
|
||||
This variable is IP or DNS name of Zabbix server. By default, value is `zabbix-server`.
|
||||
|
||||
### `ZBX_SERVER_PORT`
|
||||
|
||||
This variable is port Zabbix server listening on. By default, value is `10051`.
|
||||
|
||||
### `DB_SERVER_HOST`
|
||||
|
||||
This variable is IP or DNS name of PostgreSQL server. By default, value is 'postgres-server'
|
||||
|
||||
### `DB_SERVER_PORT`
|
||||
|
||||
This variable is port of PostgreSQL server. By default, value is '5432'.
|
||||
|
||||
### `POSTGRES_USER`, `POSTGRES_PASSWORD`
|
||||
|
||||
These variables are used by Zabbix web interface to connect to Zabbix database. By default, values are `zabbix`, `zabbix`.
|
||||
|
||||
### `POSTGRES_DB`
|
||||
|
||||
The variable is Zabbix database name. By default, value is `zabbix`.
|
||||
|
||||
### `TZ`
|
||||
|
||||
The variable is timezone in PHP format. Full list of supported timezones are available on [`php.net`](http://php.net/manual/en/timezones.php). By default, value is 'Europe/Riga'.
|
||||
|
||||
### `ZBX_SERVER_NAME`
|
||||
|
||||
The variable is visible Zabbix installation name in right top corner of the web interface.
|
||||
|
||||
### `ZBX_MAXEXECUTIONTIME`
|
||||
|
||||
The varable is PHP ``max_execution_time`` option. By default, value is `300`.
|
||||
|
||||
### `ZBX_MEMORYLIMIT`
|
||||
|
||||
The varable is PHP ``memory_limit`` option. By default, value is `128M`.
|
||||
|
||||
### `ZBX_POSTMAXSIZE`
|
||||
|
||||
The varable is PHP ``post_max_size`` option. By default, value is `16M`.
|
||||
|
||||
### `ZBX_UPLOADMAXFILESIZE`
|
||||
|
||||
The varable is PHP ``upload_max_filesize`` option. By default, value is `2M`.
|
||||
|
||||
### `ZBX_MAXINPUTTIME`
|
||||
|
||||
The varable is PHP ``max_input_time`` option. By default, value is `300`.
|
||||
|
||||
## Allowed volumes for the Zabbix web interface container
|
||||
|
||||
### ``/etc/ssl/apache2``
|
||||
|
||||
The volume allows to enable HTTPS for the Zabbix web interface. The volume must contains two files ``ssl.crt`` and ``ssl.key`` prepared for Apache2 SSL connections.
|
||||
|
||||
Please follow official Apache2 [documentation](https://httpd.apache.org/docs/2.4/ssl/ssl_howto.html) to get more details about how to create certificate files.
|
||||
|
||||
# The image variants
|
||||
|
||||
The `zabbix-web-apache-pgsql` images come in many flavors, each designed for a specific use case.
|
||||
|
||||
## `zabbix-web-apache-pgsql:ubuntu-<version>`
|
||||
|
||||
This is the defacto image. If you are unsure about what your needs are, you probably want to use this one. It is designed to be used both as a throw away container (mount your source code and start the container to start your app), as well as the base to build other images off of.
|
||||
|
||||
## `zabbix-web-apache-pgsql:alpine-<version>`
|
||||
|
||||
This image is based on the popular [Alpine Linux project](http://alpinelinux.org), available in [the `alpine` official image](https://hub.docker.com/_/alpine). Alpine Linux is much smaller than most distribution base images (~5MB), and thus leads to much slimmer images in general.
|
||||
|
||||
This variant is highly recommended when final image size being as small as possible is desired. The main caveat to note is that it does use [musl libc](http://www.musl-libc.org) instead of [glibc and friends](http://www.etalabs.net/compare_libcs.html), so certain software might run into issues depending on the depth of their libc requirements. However, most software doesn't have an issue with this, so this variant is usually a very safe choice. See [this Hacker News comment thread](https://news.ycombinator.com/item?id=10782897) for more discussion of the issues that might arise and some pro/con comparisons of using Alpine-based images.
|
||||
|
||||
To minimize image size, it's uncommon for additional related tools (such as `git` or `bash`) to be included in Alpine-based images. Using this image as a base, add the things you need in your own Dockerfile (see the [`alpine` image description](https://hub.docker.com/_/alpine/) for examples of how to install packages if you are unfamiliar).
|
||||
|
||||
# Supported Docker versions
|
||||
|
||||
This image is officially supported on Docker version 1.12.0.
|
||||
|
||||
Support for older versions (down to 1.6) is provided on a best-effort basis.
|
||||
|
||||
Please see [the Docker installation documentation](https://docs.docker.com/installation/) for details on how to upgrade your Docker daemon.
|
||||
|
||||
# User Feedback
|
||||
|
||||
## Documentation
|
||||
|
||||
Documentation for this image is stored in the [`web-apache-pgsql/` directory](https://github.com/zabbix/zabbix-docker/tree/3.0/web-apache-pgsql) of the [`zabbix/zabbix-docker` GitHub repo](https://github.com/zabbix/zabbix-docker/). Be sure to familiarize yourself with the [repository's `README.md` file](https://github.com/zabbix/zabbix-docker/blob/master/README.md) before attempting a pull request.
|
||||
|
||||
## Issues
|
||||
|
||||
If you have any problems with or questions about this image, please contact us through a [GitHub issue](https://github.com/zabbix/zabbix-docker/issues).
|
||||
|
||||
### Known issues
|
||||
|
||||
## Contributing
|
||||
|
||||
You are invited to contribute new features, fixes, or updates, large or small; we are always thrilled to receive pull requests, and do our best to process them as fast as we can.
|
||||
|
||||
Before you start to code, we recommend discussing your plans through a [GitHub issue](https://github.com/zabbix/zabbix-docker/issues), especially for more ambitious contributions. This gives other contributors a chance to point you in the right direction, give you feedback on your design, and help you find out if someone else is working on the same thing.
|
20
web-apache-pgsql/alpine/build.sh
Executable file
20
web-apache-pgsql/alpine/build.sh
Executable file
@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
os=alpine
|
||||
|
||||
version=$1
|
||||
version=${version:-"latest"}
|
||||
|
||||
app_component=web-apache
|
||||
app_database=postgresql
|
||||
|
||||
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 .
|
||||
|
||||
#docker rm -f zabbix-$app_component-$app_database
|
||||
|
||||
#docker run --name zabbix-$app_component-$app_database -t -d --link postgres-server:postgres --link zabbix-server:zabbix-server zabbix-$app_component-$app_database:$os-$version
|
@ -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=Europe/Riga
|
||||
; session.save_path=/var/lib/php5
|
@ -0,0 +1,12 @@
|
||||
[supervisord]
|
||||
nodaemon = true
|
||||
|
||||
[program:apache2]
|
||||
command = /usr/sbin/httpd -D FOREGROUND
|
||||
auto_start = true
|
||||
autorestart = true
|
||||
|
||||
stdout_logfile = /dev/stdout
|
||||
stdout_logfile_maxbytes = 0
|
||||
stderr_logfile = /dev/stderr
|
||||
stderr_logfile_maxbytes = 0
|
34
web-apache-pgsql/alpine/conf/etc/supervisor/supervisord.conf
Normal file
34
web-apache-pgsql/alpine/conf/etc/supervisor/supervisord.conf
Normal file
@ -0,0 +1,34 @@
|
||||
; supervisor config file
|
||||
|
||||
[unix_http_server]
|
||||
file = /var/run/supervisor.sock ; (the path to the socket file)
|
||||
chmod = 0700 ; sockef file mode (default 0700)
|
||||
username = zbx
|
||||
password = password
|
||||
|
||||
[supervisord]
|
||||
logfile = /dev/stdout ; (main log file;default $CWD/supervisord.log)
|
||||
pidfile = /var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
|
||||
childlogdir = /tmp ; ('AUTO' child log dir, default $TEMP)
|
||||
critical = critical
|
||||
user = root
|
||||
logfile_maxbytes = 0
|
||||
logfile_backupcount = 0
|
||||
|
||||
; the below section must remain in the config file for RPC
|
||||
; (supervisorctl/web interface) to work, additional interfaces may be
|
||||
; added by defining them in separate rpcinterface: sections
|
||||
[rpcinterface:supervisor]
|
||||
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
|
||||
|
||||
[supervisorctl]
|
||||
serverurl = unix:///var/run/supervisor.sock ; use a unix:// URL for a unix socket
|
||||
|
||||
; The [include] section can just contain the "files" setting. This
|
||||
; setting can list multiple files (separated by whitespace or
|
||||
; newlines). It can also contain wildcards. The filenames are
|
||||
; interpreted as relative to this file. Included files *cannot*
|
||||
; include files themselves.
|
||||
|
||||
[include]
|
||||
files = /etc/supervisor/conf.d/*.conf
|
45
web-apache-pgsql/alpine/conf/etc/zabbix/apache.conf
Normal file
45
web-apache-pgsql/alpine/conf/etc/zabbix/apache.conf
Normal file
@ -0,0 +1,45 @@
|
||||
<VirtualHost *:80>
|
||||
DocumentRoot /usr/share/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/zabbix">
|
||||
Options FollowSymLinks
|
||||
AllowOverride None
|
||||
Require all granted
|
||||
</Directory>
|
||||
|
||||
<Directory "/usr/share/zabbix/conf">
|
||||
Require all denied
|
||||
<files *.php>
|
||||
Order deny,allow
|
||||
Deny from all
|
||||
</files>
|
||||
</Directory>
|
||||
|
||||
<Directory "/usr/share/zabbix/app">
|
||||
Require all denied
|
||||
<files *.php>
|
||||
Order deny,allow
|
||||
Deny from all
|
||||
</files>
|
||||
</Directory>
|
||||
|
||||
<Directory "/usr/share/zabbix/include">
|
||||
Require all denied
|
||||
<files *.php>
|
||||
Order deny,allow
|
||||
Deny from all
|
||||
</files>
|
||||
</Directory>
|
||||
|
||||
<Directory "/usr/share/zabbix/local">
|
||||
Require all denied
|
||||
<files *.php>
|
||||
Order deny,allow
|
||||
Deny from all
|
||||
</files>
|
||||
</Directory>
|
24
web-apache-pgsql/alpine/conf/etc/zabbix/apache_ssl.conf
Normal file
24
web-apache-pgsql/alpine/conf/etc/zabbix/apache_ssl.conf
Normal file
@ -0,0 +1,24 @@
|
||||
LoadModule ssl_module modules/mod_ssl.so
|
||||
LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
|
||||
|
||||
Listen 443
|
||||
|
||||
<IfModule mod_ssl.c>
|
||||
<VirtualHost *:443>
|
||||
DocumentRoot /usr/share/zabbix/
|
||||
ServerName zabbix
|
||||
DirectoryIndex index.php
|
||||
AddType application/x-httpd-php .php .php3 .php4 .php5 .phtml
|
||||
AddType application/x-httpd-php-source .phps
|
||||
|
||||
# Enable/Disable SSL for this virtual host.
|
||||
SSLEngine on
|
||||
|
||||
SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
|
||||
SSLProtocol all -SSLv2
|
||||
|
||||
SSLCertificateFile /etc/ssl/apache2/ssl.crt
|
||||
SSLCertificateKeyFile /etc/ssl/apache2/ssl.key
|
||||
# SSLCACertificatePath /etc/ssl/apache2/chain/
|
||||
</VirtualHost>
|
||||
</IfModule>
|
20
web-apache-pgsql/alpine/conf/etc/zabbix/web/zabbix.conf.php
Normal file
20
web-apache-pgsql/alpine/conf/etc/zabbix/web/zabbix.conf.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
// Zabbix GUI configuration file.
|
||||
global $DB;
|
||||
|
||||
$DB['TYPE'] = 'POSTGRESQL';
|
||||
$DB['SERVER'] = '{DB_SERVER_HOST}';
|
||||
$DB['PORT'] = '{DB_SERVER_PORT}';
|
||||
$DB['DATABASE'] = '{DB_SERVER_DBNAME}';
|
||||
$DB['USER'] = '{DB_SERVER_USER}';
|
||||
$DB['PASSWORD'] = '{DB_SERVER_PASS}';
|
||||
|
||||
// Schema name. Used for IBM DB2 and PostgreSQL.
|
||||
$DB['SCHEMA'] = '';
|
||||
|
||||
$ZBX_SERVER = '{ZBX_SERVER_HOST}';
|
||||
$ZBX_SERVER_PORT = '{ZBX_SERVER_PORT}';
|
||||
$ZBX_SERVER_NAME = '{ZBX_SERVER_NAME}';
|
||||
|
||||
$IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG;
|
||||
?>
|
21
web-apache-pgsql/alpine/conf/tmp/font-config
Normal file
21
web-apache-pgsql/alpine/conf/tmp/font-config
Normal file
@ -0,0 +1,21 @@
|
||||
diff -Nru zabbix-2.5.0.orig/frontends/php/include/defines.inc.php zabbix-2.5.0/frontends/php/include/defines.inc.php
|
||||
--- zabbix-2.5.0.orig/frontends/php/include/defines.inc.php 2015-08-19 17:27:39.000000000 +0900
|
||||
+++ zabbix-2.5.0/frontends/php/include/defines.inc.php 2015-08-22 15:20:12.000000000 +0900
|
||||
@@ -42,7 +42,7 @@
|
||||
define('ZBX_WIDGET_ROWS', 20);
|
||||
|
||||
define('ZBX_FONTPATH', realpath('fonts')); // where to search for font (GD > 2.0.18)
|
||||
-define('ZBX_GRAPH_FONT_NAME', 'DejaVuSans'); // font file name
|
||||
+define('ZBX_GRAPH_FONT_NAME', 'graphfont'); // font file name
|
||||
define('ZBX_GRAPH_LEGEND_HEIGHT', 120); // when graph height is less then this value, some legend will not show up
|
||||
|
||||
define('ZBX_SCRIPT_TIMEOUT', 60); // in seconds
|
||||
@@ -90,7 +90,7 @@
|
||||
define('EVENTS_OPTION_ALL', 2);
|
||||
define('EVENTS_OPTION_NOT_ACK', 3);
|
||||
|
||||
-define('ZBX_FONT_NAME', 'DejaVuSans');
|
||||
+define('ZBX_FONT_NAME', 'graphfont');
|
||||
|
||||
define('ZBX_AUTH_INTERNAL', 0);
|
||||
define('ZBX_AUTH_LDAP', 1);
|
909
web-apache-pgsql/alpine/run_zabbix_component.sh
Executable file
909
web-apache-pgsql/alpine/run_zabbix_component.sh
Executable file
@ -0,0 +1,909 @@
|
||||
#!/bin/bash
|
||||
|
||||
set +e
|
||||
|
||||
# Script trace mode
|
||||
if [ "${DEBUG_MODE}" == "true" ]; then
|
||||
set -o xtrace
|
||||
fi
|
||||
|
||||
# Type of Zabbix component
|
||||
# Possible values: [server, proxy, agent, web, dev]
|
||||
zbx_type="$1"
|
||||
# Type of Zabbix database
|
||||
# Possible values: [mysql, postgresql]
|
||||
zbx_db_type="$2"
|
||||
# Type of web-server. Valid only with zbx_type = web
|
||||
# Possible values: [apache, nginx]
|
||||
zbx_opt_type="$3"
|
||||
|
||||
# Default Zabbix installation name
|
||||
# Used only by Zabbix web-interface
|
||||
ZBX_SERVER_NAME=${ZBX_SERVER_NAME:-"Zabbix docker"}
|
||||
# Default Zabbix server host
|
||||
ZBX_SERVER_HOST=${ZBX_SERVER_HOST:-"zabbix-server"}
|
||||
# Default Zabbix server port number
|
||||
ZBX_SERVER_PORT=${ZBX_SERVER_PORT:-"10051"}
|
||||
|
||||
# Default timezone for web interface
|
||||
TZ=${TZ:-"Europe/Riga"}
|
||||
|
||||
# Default directories
|
||||
# User 'zabbix' home directory
|
||||
ZABBIX_USER_HOME_DIR="/var/lib/zabbix"
|
||||
# Configuration files directory
|
||||
ZABBIX_ETC_DIR="/etc/zabbix"
|
||||
# Web interface www-root directory
|
||||
ZBX_FRONTEND_PATH="/usr/share/zabbix"
|
||||
|
||||
prepare_system() {
|
||||
local type=$1
|
||||
local web_server=$2
|
||||
|
||||
echo "** Preparing the system"
|
||||
|
||||
if [ "$type" != "dev" ]; then
|
||||
return
|
||||
fi
|
||||
}
|
||||
|
||||
update_config_var() {
|
||||
local config_path=$1
|
||||
local var_name=$2
|
||||
local var_value=$3
|
||||
local is_multiple=$4
|
||||
|
||||
if [ ! -f "$config_path" ]; then
|
||||
echo "**** Configuration file '$config_path' does not exist"
|
||||
return
|
||||
fi
|
||||
|
||||
echo -n "** Updating '$config_path' parameter \"$var_name\": '$var_value'... "
|
||||
|
||||
# Remove configuration parameter definition in case of unset parameter value
|
||||
if [ -z "$var_value" ]; then
|
||||
sed -i -e "/$var_name=/d" "$config_path"
|
||||
echo "removed"
|
||||
return
|
||||
fi
|
||||
|
||||
# Remove value from configuration parameter in case of double quoted parameter value
|
||||
if [ "$var_value" == '""' ]; then
|
||||
sed -i -e "/^$var_name=/s/=.*/=/" "$config_path"
|
||||
echo "undefined"
|
||||
return
|
||||
fi
|
||||
|
||||
# Use full path to a file for TLS related configuration parameters
|
||||
if [[ $var_name =~ ^TLS.*File$ ]]; then
|
||||
var_value=$ZABBIX_USER_HOME_DIR/enc/$var_value
|
||||
fi
|
||||
|
||||
# Escaping "/" character in parameter value
|
||||
var_value=${var_value//\//\\/}
|
||||
|
||||
if [ "$(grep -E "^$var_name=" $config_path)" ] && [ "$is_multiple" != "true" ]; then
|
||||
sed -i -e "/^$var_name=/s/=.*/=$var_value/" "$config_path"
|
||||
echo "updated"
|
||||
elif [ "$(grep -Ec "^# $var_name=" $config_path)" -gt 1 ]; then
|
||||
sed -i -e "/^[#;] $var_name=$/i\\$var_name=$var_value" "$config_path"
|
||||
echo "added first occurrence"
|
||||
else
|
||||
sed -i -e "/^[#;] $var_name=/s/.*/&\n$var_name=$var_value/" "$config_path"
|
||||
echo "added"
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
update_config_multiple_var() {
|
||||
local config_path=$1
|
||||
local var_name=$2
|
||||
local var_value=$3
|
||||
|
||||
var_value="${var_value%\"}"
|
||||
var_value="${var_value#\"}"
|
||||
|
||||
local IFS=,
|
||||
local OPT_LIST=($var_value)
|
||||
|
||||
for value in "${OPT_LIST[@]}"; do
|
||||
update_config_var $config_path $var_name $value true
|
||||
done
|
||||
}
|
||||
|
||||
# Check prerequisites for MySQL database
|
||||
check_variables_mysql() {
|
||||
local type=$1
|
||||
|
||||
DB_SERVER_HOST=${DB_SERVER_HOST:-"mysql-server"}
|
||||
DB_SERVER_PORT=${DB_SERVER_PORT:-"3306"}
|
||||
USE_DB_ROOT_USER=false
|
||||
CREATE_ZBX_DB_USER=false
|
||||
|
||||
if [ ! -n "${MYSQL_USER}" ] && [ "${MYSQL_RANDOM_ROOT_PASSWORD}" == "true" ]; then
|
||||
echo "**** Impossible to use MySQL server because of unknown Zabbix user and random 'root' password"
|
||||
exit 1
|
||||
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"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "${MYSQL_ALLOW_EMPTY_PASSWORD}" == "true" ] || [ -n "${MYSQL_ROOT_PASSWORD}" ]; then
|
||||
USE_DB_ROOT_USER=true
|
||||
DB_SERVER_ROOT_USER="root"
|
||||
DB_SERVER_ROOT_PASS=${MYSQL_ROOT_PASSWORD:-""}
|
||||
fi
|
||||
|
||||
[ -n "${MYSQL_USER}" ] || CREATE_ZBX_DB_USER=true
|
||||
|
||||
# If root password is not specified use provided credentials
|
||||
DB_SERVER_ROOT_USER=${DB_SERVER_ROOT_USER:-${MYSQL_USER}}
|
||||
[ "${MYSQL_ALLOW_EMPTY_PASSWORD}" == "true" ] || DB_SERVER_ROOT_PASS=${DB_SERVER_ROOT_PASS:-${MYSQL_PASSWORD}}
|
||||
DB_SERVER_ZBX_USER=${MYSQL_USER:-"zabbix"}
|
||||
DB_SERVER_ZBX_PASS=${MYSQL_PASSWORD:-"zabbix"}
|
||||
|
||||
if [ "$type" == "proxy" ]; then
|
||||
DB_SERVER_DBNAME=${MYSQL_DATABASE:-"zabbix_proxy"}
|
||||
else
|
||||
DB_SERVER_DBNAME=${MYSQL_DATABASE:-"zabbix"}
|
||||
fi
|
||||
}
|
||||
|
||||
# Check prerequisites for PostgreSQL database
|
||||
check_variables_postgresql() {
|
||||
local type=$1
|
||||
|
||||
DB_SERVER_HOST=${DB_SERVER_HOST:-"postgres-server"}
|
||||
DB_SERVER_PORT=${DB_SERVER_PORT:-"5432"}
|
||||
CREATE_ZBX_DB_USER=${CREATE_ZBX_DB_USER:-"false"}
|
||||
|
||||
DB_SERVER_ROOT_USER=${POSTGRES_USER:-"postgres"}
|
||||
DB_SERVER_ROOT_PASS=${POSTGRES_PASSWORD:-""}
|
||||
|
||||
DB_SERVER_ZBX_USER=${POSTGRES_USER:-"zabbix"}
|
||||
DB_SERVER_ZBX_PASS=${POSTGRES_PASSWORD:-"zabbix"}
|
||||
|
||||
if [ "$type" == "proxy" ]; then
|
||||
DB_SERVER_DBNAME=${POSTGRES_DB:-"zabbix_proxy"}
|
||||
else
|
||||
DB_SERVER_DBNAME=${POSTGRES_DB:-"zabbix"}
|
||||
fi
|
||||
}
|
||||
|
||||
check_db_connect_mysql() {
|
||||
echo "********************"
|
||||
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
||||
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
||||
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
||||
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
||||
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
||||
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
||||
fi
|
||||
echo "* DB_SERVER_ZBX_USER: ${DB_SERVER_ZBX_USER}"
|
||||
echo "* DB_SERVER_ZBX_PASS: ${DB_SERVER_ZBX_PASS}"
|
||||
echo "********************"
|
||||
|
||||
WAIT_TIMEOUT=5
|
||||
|
||||
while [ ! "$(mysqladmin ping -h ${DB_SERVER_HOST} -P ${DB_SERVER_PORT} -u ${DB_SERVER_ROOT_USER} \
|
||||
--password="${DB_SERVER_ROOT_PASS}" --silent --connect_timeout=10)" ]; do
|
||||
echo "**** MySQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
||||
sleep $WAIT_TIMEOUT
|
||||
done
|
||||
}
|
||||
|
||||
check_db_connect_postgresql() {
|
||||
echo "********************"
|
||||
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
||||
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
||||
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
||||
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
||||
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
||||
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
||||
fi
|
||||
echo "* DB_SERVER_ZBX_USER: ${DB_SERVER_ZBX_USER}"
|
||||
echo "* DB_SERVER_ZBX_PASS: ${DB_SERVER_ZBX_PASS}"
|
||||
echo "********************"
|
||||
|
||||
if [ -n "${DB_SERVER_ZBX_PASS}" ]; then
|
||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||
fi
|
||||
|
||||
WAIT_TIMEOUT=5
|
||||
|
||||
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -l -q 2>/dev/null)" ]; do
|
||||
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
||||
sleep $WAIT_TIMEOUT
|
||||
done
|
||||
|
||||
unset PGPASSWORD
|
||||
}
|
||||
|
||||
|
||||
mysql_query() {
|
||||
query=$1
|
||||
local result=""
|
||||
|
||||
result=$(mysql --silent --skip-column-names -h ${DB_SERVER_HOST} -P ${DB_SERVER_PORT} \
|
||||
-u ${DB_SERVER_ROOT_USER} --password="${DB_SERVER_ROOT_PASS}" -e "$query")
|
||||
|
||||
echo $result
|
||||
}
|
||||
|
||||
psql_query() {
|
||||
query=$1
|
||||
db=$2
|
||||
|
||||
local result=""
|
||||
|
||||
if [ -n "${DB_SERVER_ZBX_PASS}" ]; then
|
||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||
fi
|
||||
|
||||
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
||||
|
||||
unset PGPASSWORD
|
||||
|
||||
echo $result
|
||||
}
|
||||
|
||||
create_db_user_mysql() {
|
||||
[ "${CREATE_ZBX_DB_USER}" == "true" ] || return
|
||||
|
||||
echo "** Creating '${DB_SERVER_ZBX_USER}' user in MySQL database"
|
||||
|
||||
USER_EXISTS=$(mysql_query "SELECT 1 FROM mysql.user WHERE user = '${DB_SERVER_ZBX_USER}' AND host = '%'")
|
||||
|
||||
if [ -z "$USER_EXISTS" ]; then
|
||||
mysql_query "CREATE USER '${DB_SERVER_ZBX_USER}'@'%' IDENTIFIED BY '${DB_SERVER_ZBX_PASS}'" 1>/dev/null
|
||||
else
|
||||
mysql_query "SET PASSWORD FOR '${DB_SERVER_ZBX_USER}'@'%' = PASSWORD('${DB_SERVER_ZBX_PASS}');" 1>/dev/null
|
||||
fi
|
||||
|
||||
mysql_query "GRANT ALL PRIVILEGES ON $DB_SERVER_DBNAME. * TO '${DB_SERVER_ZBX_USER}'@'%'" 1>/dev/null
|
||||
}
|
||||
|
||||
create_db_user_postgresql() {
|
||||
[ "${CREATE_ZBX_DB_USER}" == "true" ] || return
|
||||
|
||||
echo "** Creating '${DB_SERVER_ZBX_USER}' user in PostgreSQL database"
|
||||
|
||||
USER_EXISTS=$(psql_query "SELECT 1 FROM pg_roles WHERE rolname='${DB_SERVER_ZBX_USER}'")
|
||||
|
||||
if [ -z "$USER_EXISTS" ]; then
|
||||
psql_query "CREATE USER ${DB_SERVER_ZBX_USER} WITH PASSWORD '${DB_SERVER_ZBX_PASS}'" 1>/dev/null
|
||||
else
|
||||
psql_query "ALTER USER ${DB_SERVER_ZBX_USER} WITH ENCRYPTED PASSWORD '${DB_SERVER_ZBX_PASS}'" 1>/dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
create_db_database_mysql() {
|
||||
DB_EXISTS=$(mysql_query "SELECT SCHEMA_NAME FROM information_schema.SCHEMATA WHERE SCHEMA_NAME='${DB_SERVER_DBNAME}'")
|
||||
|
||||
if [ -z ${DB_EXISTS} ]; then
|
||||
echo "** Database '${DB_SERVER_DBNAME}' does not exist. Creating..."
|
||||
mysql_query "CREATE DATABASE ${DB_SERVER_DBNAME} CHARACTER SET utf8 COLLATE utf8_bin" 1>/dev/null
|
||||
# better solution?
|
||||
mysql_query "GRANT ALL PRIVILEGES ON $DB_SERVER_DBNAME. * TO '${DB_SERVER_ZBX_USER}'@'%'" 1>/dev/null
|
||||
else
|
||||
echo "** Database '${DB_SERVER_DBNAME}' already exists. Please be careful with database COLLATE!"
|
||||
fi
|
||||
}
|
||||
|
||||
create_db_database_postgresql() {
|
||||
DB_EXISTS=$(psql_query "SELECT 1 AS result FROM pg_database WHERE datname='${DB_SERVER_DBNAME}'")
|
||||
|
||||
if [ -z ${DB_EXISTS} ]; then
|
||||
echo "** Database '${DB_SERVER_DBNAME}' does not exist. Creating..."
|
||||
psql_query "CREATE DATABASE ${DB_SERVER_DBNAME} WITH OWNER ${DB_SERVER_ZBX_USER} ENCODING='UTF8' LC_CTYPE='en_US.utf8' LC_COLLATE='en_US.utf8'" 1>/dev/null
|
||||
else
|
||||
echo "** Database '${DB_SERVER_DBNAME}' already exists. Please be careful with database owner!"
|
||||
fi
|
||||
}
|
||||
|
||||
create_db_schema_mysql() {
|
||||
local type=$1
|
||||
|
||||
DBVERSION_TABLE_EXISTS=$(mysql_query "SELECT 1 FROM information_schema.tables WHERE table_schema='${DB_SERVER_DBNAME}' and table_name = 'dbversion'")
|
||||
|
||||
if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then
|
||||
echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists."
|
||||
ZBX_DB_VERSION=$(mysql_query "SELECT mandatory FROM ${DB_SERVER_DBNAME}.dbversion")
|
||||
fi
|
||||
|
||||
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 \
|
||||
-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
|
||||
}
|
||||
|
||||
create_db_schema_postgresql() {
|
||||
local type=$1
|
||||
|
||||
DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid =
|
||||
c.relnamespace WHERE n.nspname = 'public' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}")
|
||||
|
||||
if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then
|
||||
echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists."
|
||||
ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM public.dbversion" "${DB_SERVER_DBNAME}")
|
||||
fi
|
||||
|
||||
if [ -z "${ZBX_DB_VERSION}" ]; then
|
||||
echo "** Creating '${DB_SERVER_DBNAME}' schema in PostgreSQL"
|
||||
|
||||
if [ -n "${DB_SERVER_ZBX_PASS}" ]; then
|
||||
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 \
|
||||
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
||||
fi
|
||||
|
||||
unset PGPASSWORD
|
||||
fi
|
||||
}
|
||||
|
||||
prepare_web_server_apache() {
|
||||
if [ -d "/etc/apache2/sites-available" ]; then
|
||||
APACHE_SITES_DIR=/etc/apache2/sites-available
|
||||
elif [ -d "/etc/apache2/conf.d" ]; then
|
||||
APACHE_SITES_DIR=/etc/apache2/conf.d
|
||||
else
|
||||
echo "**** Apache is not available"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -f "/usr/sbin/a2dissite" ]; then
|
||||
echo "** Disable default site"
|
||||
/usr/sbin/a2dissite 000-default 1>/dev/null
|
||||
rm -rf "$APACHE_SITES_DIR/*"
|
||||
elif [ -f "/etc/apache2/conf.d/default.conf" ]; then
|
||||
echo "** Disable default site"
|
||||
rm -f "/etc/apache2/conf.d/default.conf"
|
||||
fi
|
||||
|
||||
echo "** Adding Zabbix virtual host (HTTP)"
|
||||
if [ -f "$ZABBIX_ETC_DIR/apache.conf" ]; then
|
||||
ln -s "$ZABBIX_ETC_DIR/apache.conf" "$APACHE_SITES_DIR/zabbix.conf"
|
||||
if [ -f "/usr/sbin/a2dissite" ]; then
|
||||
/usr/sbin/a2ensite zabbix.conf 1>/dev/null
|
||||
fi
|
||||
else
|
||||
echo "**** Impossible to enable HTTP virtual host"
|
||||
fi
|
||||
|
||||
if [ -f "/etc/apache2/conf.d/ssl.conf" ]; then
|
||||
rm -f "/etc/apache2/conf.d/ssl.conf"
|
||||
fi
|
||||
|
||||
if [ -f "/etc/ssl/apache2/ssl.crt" ] && [ -f "/etc/ssl/apache2/ssl.key" ]; then
|
||||
echo "** Enable SSL support for Apache2"
|
||||
if [ -f "/usr/sbin/a2enmod" ]; then
|
||||
/usr/sbin/a2enmod ssl 1>/dev/null
|
||||
fi
|
||||
|
||||
echo "** Adding Zabbix virtual host (HTTPS)"
|
||||
if [ -f "$ZABBIX_ETC_DIR/apache_ssl.conf" ]; then
|
||||
ln -s "$ZABBIX_ETC_DIR/apache_ssl.conf" "$APACHE_SITES_DIR/zabbix_ssl.conf"
|
||||
if [ -f "/usr/sbin/a2dissite" ]; then
|
||||
/usr/sbin/a2ensite zabbix_ssl.conf 1>/dev/null
|
||||
fi
|
||||
else
|
||||
echo "**** Impossible to enable HTTPS virtual host"
|
||||
fi
|
||||
else
|
||||
echo "**** Impossible to enable SSL support for Apache2. Certificates are missed."
|
||||
fi
|
||||
|
||||
# Change Apache2 logging to stdout and stderr
|
||||
if [ -f "/etc/apache2/apache2.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/apache2/apache2.conf"
|
||||
fi
|
||||
|
||||
if [ -f "/etc/apache2/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/apache2/httpd.conf"
|
||||
fi
|
||||
|
||||
if [ -f "/etc/apache2/conf-available/other-vhosts-access-log.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/apache2/conf-available/other-vhosts-access-log.conf"
|
||||
fi
|
||||
|
||||
if [ -f "/etc/apache2/conf.d/mpm.conf" ]; then
|
||||
sed -ri \
|
||||
-e 's!^(\s*PidFile)\s+\S+!\1 "/var/run/httpd.pid"!g' \
|
||||
"/etc/apache2/conf.d/mpm.conf"
|
||||
fi
|
||||
|
||||
if [ -f "/var/run/apache2/apache2.pid" ]; then
|
||||
rm -f "/var/run/apache2/apache2.pid"
|
||||
fi
|
||||
}
|
||||
|
||||
prepare_web_server_nginx() {
|
||||
NGINX_CONFD_DIR="/etc/nginx/conf.d"
|
||||
NGINX_SSL_CONFIG="/etc/ssl/nginx"
|
||||
PHP_SESSIONS_DIR="/var/lib/php5"
|
||||
|
||||
echo "** Disable default vhosts"
|
||||
rm -f $NGINX_CONFD_DIR/*.conf
|
||||
|
||||
echo "** Adding Zabbix virtual host (HTTP)"
|
||||
if [ -f "$ZABBIX_ETC_DIR/nginx.conf" ]; then
|
||||
ln -s "$ZABBIX_ETC_DIR/nginx.conf" "$NGINX_CONFD_DIR"
|
||||
else
|
||||
echo "**** Impossible to enable HTTP virtual host"
|
||||
fi
|
||||
|
||||
if [ -f "$NGINX_SSL_CONFIG/ssl.crt" ] && [ -f "$NGINX_SSL_CONFIG/ssl.key" ] && [ -f "$NGINX_SSL_CONFIG/dhparam.pem" ]; then
|
||||
echo "** Enable SSL support for Nginx"
|
||||
if [ -f "$ZABBIX_ETC_DIR/nginx_ssl.conf" ]; then
|
||||
ln -s "$ZABBIX_ETC_DIR/nginx_ssl.conf" "$NGINX_CONFD_DIR"
|
||||
else
|
||||
echo "**** Impossible to enable HTTPS virtual host"
|
||||
fi
|
||||
else
|
||||
echo "**** Impossible to enable SSL support for Nginx. Certificates are missed."
|
||||
fi
|
||||
|
||||
if [ -d "/var/log/nginx/" ]; then
|
||||
ln -sf /dev/fd/2 /var/log/nginx/error.log
|
||||
fi
|
||||
|
||||
ln -sf /dev/fd/2 /var/log/php5-fpm.log
|
||||
}
|
||||
|
||||
clear_deploy() {
|
||||
local type=$1
|
||||
echo "** Cleaning the system"
|
||||
|
||||
[ "$type" != "dev" ] && return
|
||||
}
|
||||
|
||||
update_zbx_config() {
|
||||
local type=$1
|
||||
local db_type=$2
|
||||
|
||||
echo "** Preparing Zabbix $type configuration file"
|
||||
|
||||
ZBX_CONFIG=$ZABBIX_ETC_DIR/zabbix_$type.conf
|
||||
|
||||
if [ "$type" == "proxy" ]; then
|
||||
update_config_var $ZBX_CONFIG "ProxyMode" "${ZBX_PROXYMODE}"
|
||||
update_config_var $ZBX_CONFIG "Server" "${ZBX_SERVER_HOST}"
|
||||
update_config_var $ZBX_CONFIG "ServerPort" "${ZBX_SERVER_PORT}"
|
||||
update_config_var $ZBX_CONFIG "Hostname" "${ZBX_HOSTNAME:-"zabbix-proxy-"$db_type}"
|
||||
update_config_var $ZBX_CONFIG "HostnameItem" "${ZBX_HOSTNAMEITEM}"
|
||||
fi
|
||||
|
||||
if [ $type == "proxy" ] && [ "${ZBX_ADD_SERVER}" = "true" ]; then
|
||||
update_config_var $ZBX_CONFIG "ListenPort" "10061"
|
||||
else
|
||||
update_config_var $ZBX_CONFIG "ListenPort"
|
||||
fi
|
||||
update_config_var $ZBX_CONFIG "SourceIP"
|
||||
update_config_var $ZBX_CONFIG "LogType" "console"
|
||||
update_config_var $ZBX_CONFIG "LogFile"
|
||||
update_config_var $ZBX_CONFIG "LogFileSize"
|
||||
update_config_var $ZBX_CONFIG "PidFile"
|
||||
|
||||
update_config_var $ZBX_CONFIG "DebugLevel" "${ZBX_DEBUGLEVEL}"
|
||||
|
||||
if [ "$db_type" == "sqlite3" ]; then
|
||||
update_config_var $ZBX_CONFIG "DBHost"
|
||||
update_config_var $ZBX_CONFIG "DBName" "/var/lib/zabbix/zabbix_proxy_db"
|
||||
update_config_var $ZBX_CONFIG "DBUser"
|
||||
update_config_var $ZBX_CONFIG "DBPort"
|
||||
update_config_var $ZBX_CONFIG "DBPassword"
|
||||
else
|
||||
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
||||
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
||||
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
||||
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
||||
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
||||
fi
|
||||
|
||||
if [ "$type" == "proxy" ]; then
|
||||
update_config_var $ZBX_CONFIG "ProxyLocalBuffer" "${ZBX_PROXYLOCALBUFFER}"
|
||||
update_config_var $ZBX_CONFIG "ProxyOfflineBuffer" "${ZBX_PROXYOFFLINEBUFFER}"
|
||||
update_config_var $ZBX_CONFIG "HeartbeatFrequency" "${ZBX_PROXYHEARTBEATFREQUENCY}"
|
||||
update_config_var $ZBX_CONFIG "ConfigFrequency" "${ZBX_CONFIGFREQUENCY}"
|
||||
update_config_var $ZBX_CONFIG "DataSenderFrequency" "${ZBX_DATASENDERFREQUENCY}"
|
||||
fi
|
||||
|
||||
update_config_var $ZBX_CONFIG "StartPollers" "${ZBX_STARTPOLLERS}"
|
||||
update_config_var $ZBX_CONFIG "StartIPMIPollers" "${ZBX_IPMIPOLLERS}"
|
||||
update_config_var $ZBX_CONFIG "StartPollersUnreachable" "${ZBX_STARTPOLLERSUNREACHABLE}"
|
||||
update_config_var $ZBX_CONFIG "StartTrappers" "${ZBX_STARTTRAPPERS}"
|
||||
update_config_var $ZBX_CONFIG "StartPingers" "${ZBX_STARTPINGERS}"
|
||||
update_config_var $ZBX_CONFIG "StartDiscoverers" "${ZBX_STARTDISCOVERERS}"
|
||||
update_config_var $ZBX_CONFIG "StartHTTPPollers" "${ZBX_STARTHTTPPOLLERS}"
|
||||
|
||||
if [ "$type" == "server" ]; then
|
||||
update_config_var $ZBX_CONFIG "StartTimers" "${ZBX_STARTTIMERS}"
|
||||
update_config_var $ZBX_CONFIG "StartEscalators" "${ZBX_STARTESCALATORS}"
|
||||
fi
|
||||
|
||||
ZBX_JAVAGATEWAY_ENABLE=${ZBX_JAVAGATEWAY_ENABLE:-"false"}
|
||||
if [ "${ZBX_JAVAGATEWAY_ENABLE}" == "true" ]; then
|
||||
update_config_var $ZBX_CONFIG "JavaGateway" "${ZBX_JAVAGATEWAY:-"zabbix-java-gateway"}"
|
||||
update_config_var $ZBX_CONFIG "JavaGatewayPort" "${ZBX_JAVAGATEWAYPORT}"
|
||||
update_config_var $ZBX_CONFIG "StartJavaPollers" "${ZBX_STARTJAVAPOLLERS:-"5"}"
|
||||
else
|
||||
update_config_var $ZBX_CONFIG "JavaGateway"
|
||||
update_config_var $ZBX_CONFIG "JavaGatewayPort"
|
||||
update_config_var $ZBX_CONFIG "StartJavaPollers"
|
||||
fi
|
||||
|
||||
update_config_var $ZBX_CONFIG "StartVMwareCollectors" "${ZBX_STARTVMWARECOLLECTORS}"
|
||||
update_config_var $ZBX_CONFIG "VMwareFrequency" "${ZBX_VMWAREFREQUENCY}"
|
||||
update_config_var $ZBX_CONFIG "VMwarePerfFrequency" "${ZBX_VMWAREPERFFREQUENCY}"
|
||||
update_config_var $ZBX_CONFIG "VMwareCacheSize" "${ZBX_VMWARECACHESIZE}"
|
||||
update_config_var $ZBX_CONFIG "VMwareTimeout" "${ZBX_VMWARETIMEOUT}"
|
||||
|
||||
ZBX_ENABLE_SNMP_TRAPS=${ZBX_ENABLE_SNMP_TRAPS:-"false"}
|
||||
if [ "${ZBX_ENABLE_SNMP_TRAPS}" == "true" ]; then
|
||||
update_config_var $ZBX_CONFIG "SNMPTrapperFile" "${ZABBIX_USER_HOME_DIR}/snmptraps/snmptraps.log"
|
||||
update_config_var $ZBX_CONFIG "StartSNMPTrapper" "1"
|
||||
else
|
||||
update_config_var $ZBX_CONFIG "SNMPTrapperFile"
|
||||
update_config_var $ZBX_CONFIG "StartSNMPTrapper"
|
||||
fi
|
||||
|
||||
update_config_var $ZBX_CONFIG "HousekeepingFrequency" "${ZBX_HOUSEKEEPINGFREQUENCY}"
|
||||
if [ "$type" == "server" ]; then
|
||||
update_config_var $ZBX_CONFIG "MaxHousekeeperDelete" "${ZBX_MAXHOUSEKEEPERDELETE}"
|
||||
update_config_var $ZBX_CONFIG "SenderFrequency" "${ZBX_SENDERFREQUENCY}"
|
||||
fi
|
||||
|
||||
update_config_var $ZBX_CONFIG "CacheSize" "${ZBX_CACHESIZE}"
|
||||
|
||||
if [ "$type" == "server" ]; then
|
||||
update_config_var $ZBX_CONFIG "CacheUpdateFrequency" "${ZBX_CACHEUPDATEFREQUENCY}"
|
||||
fi
|
||||
|
||||
update_config_var $ZBX_CONFIG "StartDBSyncers" "${ZBX_STARTDBSYNCERS}"
|
||||
update_config_var $ZBX_CONFIG "HistoryCacheSize" "${ZBX_HISTORYCACHESIZE}"
|
||||
update_config_var $ZBX_CONFIG "HistoryIndexCacheSize" "${ZBX_HISTORYINDEXCACHESIZE}"
|
||||
|
||||
if [ "$type" == "server" ]; then
|
||||
update_config_var $ZBX_CONFIG "TrendCacheSize" "${ZBX_TRENDCACHESIZE}"
|
||||
update_config_var $ZBX_CONFIG "ValueCacheSize" "${ZBX_VALUECACHESIZE}"
|
||||
fi
|
||||
|
||||
update_config_var $ZBX_CONFIG "Timeout" "${ZBX_TIMEOUT}"
|
||||
update_config_var $ZBX_CONFIG "TrapperTimeout" "${ZBX_TRAPPERIMEOUT}"
|
||||
update_config_var $ZBX_CONFIG "UnreachablePeriod" "${ZBX_UNREACHABLEPERIOD}"
|
||||
update_config_var $ZBX_CONFIG "UnavailableDelay" "${ZBX_UNAVAILABLEDELAY}"
|
||||
update_config_var $ZBX_CONFIG "UnreachableDelay" "${ZBX_UNREACHABLEDELAY}"
|
||||
|
||||
update_config_var $ZBX_CONFIG "AlertScriptsPath" "/usr/lib/zabbix/alertscripts"
|
||||
update_config_var $ZBX_CONFIG "ExternalScripts" "/usr/lib/zabbix/externalscripts"
|
||||
|
||||
# Possible few fping locations
|
||||
if [ -f "/usr/bin/fping" ]; then
|
||||
update_config_var $ZBX_CONFIG "FpingLocation" "/usr/bin/fping"
|
||||
else
|
||||
update_config_var $ZBX_CONFIG "FpingLocation" "/usr/sbin/fping"
|
||||
fi
|
||||
if [ -f "/usr/bin/fping6" ]; then
|
||||
update_config_var $ZBX_CONFIG "Fping6Location" "/usr/bin/fping6"
|
||||
else
|
||||
update_config_var $ZBX_CONFIG "Fping6Location" "/usr/sbin/fping6"
|
||||
fi
|
||||
|
||||
update_config_var $ZBX_CONFIG "SSHKeyLocation" "$ZABBIX_USER_HOME_DIR/ssh_keys"
|
||||
update_config_var $ZBX_CONFIG "LogSlowQueries" "${ZBX_LOGSLOWQUERIES}"
|
||||
|
||||
if [ "$type" == "server" ]; then
|
||||
update_config_var $ZBX_CONFIG "StartProxyPollers" "${ZBX_STARTPROXYPOLLERS}"
|
||||
update_config_var $ZBX_CONFIG "ProxyConfigFrequency" "${ZBX_PROXYCONFIGFREQUENCY}"
|
||||
update_config_var $ZBX_CONFIG "ProxyDataFrequency" "${ZBX_PROXYDATAFREQUENCY}"
|
||||
fi
|
||||
|
||||
update_config_var $ZBX_CONFIG "SSLCertLocation" "$ZABBIX_USER_HOME_DIR/ssl/certs/"
|
||||
update_config_var $ZBX_CONFIG "SSLKeyLocation" "$ZABBIX_USER_HOME_DIR/ssl/keys/"
|
||||
update_config_var $ZBX_CONFIG "SSLCALocation" "$ZABBIX_USER_HOME_DIR/ssl/ssl_ca/"
|
||||
update_config_var $ZBX_CONFIG "LoadModulePath" "$ZABBIX_USER_HOME_DIR/modules/"
|
||||
update_config_multiple_var $ZBX_CONFIG "LoadModule" "${ZBX_LOADMODULE}"
|
||||
|
||||
if [ "$type" == "proxy" ]; then
|
||||
update_config_var $ZBX_CONFIG "TLSConnect" "${ZBX_TLSCONNECT}"
|
||||
update_config_var $ZBX_CONFIG "TLSAccept" "${ZBX_TLSACCEPT}"
|
||||
fi
|
||||
update_config_var $ZBX_CONFIG "TLSCAFile" "${ZBX_TLSCAFILE}"
|
||||
update_config_var $ZBX_CONFIG "TLSCRLFile" "${ZBX_TLSCRLFILE}"
|
||||
|
||||
if [ "$type" == "proxy" ]; then
|
||||
update_config_var $ZBX_CONFIG "TLSServerCertIssuer" "${ZBX_TLSSERVERCERTISSUER}"
|
||||
update_config_var $ZBX_CONFIG "TLSServerCertSubject" "${ZBX_TLSSERVERCERTSUBJECT}"
|
||||
fi
|
||||
|
||||
update_config_var $ZBX_CONFIG "TLSCertFile" "${ZBX_TLSCERTFILE}"
|
||||
update_config_var $ZBX_CONFIG "TLSKeyFile" "${ZBX_TLSKEYFILE}"
|
||||
|
||||
if [ "$type" == "proxy" ]; then
|
||||
update_config_var $ZBX_CONFIG "TLSPSKIdentity" "${ZBX_TLSPSKIDENTITY}"
|
||||
update_config_var $ZBX_CONFIG "TLSPSKFile" "${ZBX_TLSPSKFILE}"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
prepare_zbx_web_config() {
|
||||
local db_type=$1
|
||||
local server_name=""
|
||||
|
||||
echo "** Preparing Zabbix frontend configuration file"
|
||||
|
||||
ZBX_WEB_CONFIG="$ZABBIX_ETC_DIR/web/zabbix.conf.php"
|
||||
|
||||
if [ -f "/usr/share/zabbix/conf/zabbix.conf.php" ]; then
|
||||
rm -f "/usr/share/zabbix/conf/zabbix.conf.php"
|
||||
fi
|
||||
|
||||
ln -s "$ZBX_WEB_CONFIG" "/usr/share/zabbix/conf/zabbix.conf.php"
|
||||
|
||||
# Different places of PHP configuration file
|
||||
if [ -f "/etc/php5/conf.d/99-zabbix.ini" ]; then
|
||||
PHP_CONFIG_FILE="/etc/php5/conf.d/99-zabbix.ini"
|
||||
elif [ -f "/etc/php5/fpm/conf.d/99-zabbix.ini" ]; then
|
||||
PHP_CONFIG_FILE="/etc/php5/fpm/conf.d/99-zabbix.ini"
|
||||
elif [ -f "/etc/php5/apache2/conf.d/99-zabbix.ini" ]; then
|
||||
PHP_CONFIG_FILE="/etc/php5/apache2/conf.d/99-zabbix.ini"
|
||||
elif [ -f "/etc/php/7.0/apache2/conf.d/99-zabbix.ini" ]; then
|
||||
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"
|
||||
fi
|
||||
|
||||
if [ -n "$PHP_CONFIG_FILE" ]; then
|
||||
update_config_var "$PHP_CONFIG_FILE" "max_execution_time" "${ZBX_MAXEXECUTIONTIME:-"600"}"
|
||||
update_config_var "$PHP_CONFIG_FILE" "memory_limit" "${ZBX_MEMORYLIMIT:-"128M"}"
|
||||
update_config_var "$PHP_CONFIG_FILE" "post_max_size" "${ZBX_POSTMAXSIZE:-"16M"}"
|
||||
update_config_var "$PHP_CONFIG_FILE" "upload_max_filesize" "${ZBX_UPLOADMAXFILESIZE:-"2M"}"
|
||||
update_config_var "$PHP_CONFIG_FILE" "max_input_time" "${ZBX_MAXINPUTTIME:-"300"}"
|
||||
update_config_var "$PHP_CONFIG_FILE" "date.timezone" "${TZ}"
|
||||
else
|
||||
echo "**** Zabbix related PHP configuration file not found"
|
||||
fi
|
||||
|
||||
# Escaping "/" character in parameter value
|
||||
server_name=${ZBX_SERVER_NAME//\//\\/}
|
||||
|
||||
sed -i \
|
||||
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
||||
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
||||
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
||||
-e "s/{DB_SERVER_USER}/${DB_SERVER_ZBX_USER}/g" \
|
||||
-e "s/{DB_SERVER_PASS}/${DB_SERVER_ZBX_PASS}/g" \
|
||||
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
||||
-e "s/{ZBX_SERVER_PORT}/${ZBX_SERVER_PORT}/g" \
|
||||
-e "s/{ZBX_SERVER_NAME}/$server_name/g" \
|
||||
"$ZBX_WEB_CONFIG"
|
||||
|
||||
[ "$db_type" = "postgresql" ] && sed -i "s/MYSQL/POSTGRESQL/g" "$ZBX_WEB_CONFIG"
|
||||
}
|
||||
|
||||
prepare_zbx_agent_config() {
|
||||
echo "** Preparing Zabbix agent configuration file"
|
||||
|
||||
ZBX_AGENT_CONFIG=$ZABBIX_ETC_DIR/zabbix_agentd.conf
|
||||
|
||||
ZBX_PASSIVESERVERS=${ZBX_PASSIVESERVERS:-""}
|
||||
ZBX_ACTIVESERVERS=${ZBX_ACTIVESERVERS:-""}
|
||||
|
||||
[ -n "$ZBX_PASSIVESERVERS" ] && ZBX_PASSIVESERVERS=","$ZBX_PASSIVESERVERS
|
||||
|
||||
ZBX_PASSIVESERVERS=$ZBX_SERVER_HOST$ZBX_PASSIVESERVERS
|
||||
|
||||
[ -n "$ZBX_ACTIVESERVERS" ] && ZBX_ACTIVESERVERS=","$ZBX_ACTIVESERVERS
|
||||
|
||||
ZBX_ACTIVESERVERS=$ZBX_SERVER_HOST":"$ZBX_SERVER_PORT$ZBX_ACTIVESERVERS
|
||||
|
||||
update_config_var $ZBX_AGENT_CONFIG "PidFile"
|
||||
update_config_var $ZBX_AGENT_CONFIG "LogType" "console"
|
||||
update_config_var $ZBX_AGENT_CONFIG "LogFile"
|
||||
update_config_var $ZBX_AGENT_CONFIG "LogFileSize"
|
||||
update_config_var $ZBX_AGENT_CONFIG "DebugLevel" "${ZBX_DEBUGLEVEL}"
|
||||
update_config_var $ZBX_AGENT_CONFIG "SourceIP"
|
||||
update_config_var $ZBX_AGENT_CONFIG "EnableRemoteCommands" "${ZBX_ENABLEREMOTECOMMANDS}"
|
||||
update_config_var $ZBX_AGENT_CONFIG "LogRemoteCommands" "${ZBX_LOGREMOTECOMMANDS}"
|
||||
|
||||
ZBX_PASSIVE_ALLOW=${ZBX_PASSIVE_ALLOW:-"true"}
|
||||
if [ "$ZBX_PASSIVE_ALLOW" == "true" ]; then
|
||||
echo "** Using '$ZBX_PASSIVESERVERS' servers for passive checks"
|
||||
update_config_var $ZBX_AGENT_CONFIG "Server" "${ZBX_PASSIVESERVERS}"
|
||||
else
|
||||
update_config_var $ZBX_AGENT_CONFIG "Server"
|
||||
fi
|
||||
|
||||
update_config_var $ZBX_AGENT_CONFIG "ListenPort"
|
||||
update_config_var $ZBX_AGENT_CONFIG "ListenIP"
|
||||
update_config_var $ZBX_AGENT_CONFIG "StartAgents" "${ZBX_STARTAGENTS}"
|
||||
|
||||
ZBX_ACTIVE_ALLOW=${ZBX_ACTIVE_ALLOW:-"true"}
|
||||
if [ "$ZBX_ACTIVE_ALLOW" == "true" ]; then
|
||||
echo "** Using '$ZBX_ACTIVESERVERS' servers for active checks"
|
||||
update_config_var $ZBX_AGENT_CONFIG "ServerActive" "${ZBX_ACTIVESERVERS}"
|
||||
else
|
||||
update_config_var $ZBX_AGENT_CONFIG "ServerActive"
|
||||
fi
|
||||
|
||||
update_config_var $ZBX_AGENT_CONFIG "Hostname" "${ZBX_HOSTNAME}"
|
||||
update_config_var $ZBX_AGENT_CONFIG "HostnameItem" "${ZBX_HOSTNAMEITEM}"
|
||||
update_config_var $ZBX_AGENT_CONFIG "HostMetadata" "${ZBX_METADATA}"
|
||||
update_config_var $ZBX_AGENT_CONFIG "HostMetadataItem" "${ZBX_METADATAITEM}"
|
||||
update_config_var $ZBX_AGENT_CONFIG "RefreshActiveChecks" "${ZBX_REFRESHACTIVECHECKS}"
|
||||
update_config_var $ZBX_AGENT_CONFIG "BufferSend" "${ZBX_BUFFERSEND}"
|
||||
update_config_var $ZBX_AGENT_CONFIG "BufferSize" "${ZBX_BUFFERSIZE}"
|
||||
update_config_var $ZBX_AGENT_CONFIG "MaxLinesPerSecond" "${ZBX_MAXLINESPERSECOND}"
|
||||
# update_config_multiple_var $ZBX_AGENT_CONFIG "Alias" ${ZBX_ALIAS}
|
||||
update_config_var $ZBX_AGENT_CONFIG "Timeout" "${ZBX_TIMEOUT}"
|
||||
update_config_var $ZBX_AGENT_CONFIG "Include" "/etc/zabbix/zabbix_agentd.d/"
|
||||
update_config_var $ZBX_AGENT_CONFIG "UnsafeUserParameters" "${ZBX_UNSAFEUSERPARAMETERS}"
|
||||
update_config_var $ZBX_AGENT_CONFIG "LoadModulePath" "$ZABBIX_USER_HOME_DIR/modules/"
|
||||
update_config_multiple_var $ZBX_AGENT_CONFIG "LoadModule" "${ZBX_LOADMODULE}"
|
||||
update_config_var $ZBX_AGENT_CONFIG "TLSConnect" "${ZBX_TLSCONNECT}"
|
||||
update_config_var $ZBX_AGENT_CONFIG "TLSAccept" "${ZBX_TLSACCEPT}"
|
||||
update_config_var $ZBX_AGENT_CONFIG "TLSCAFile" "${ZBX_TLSCAFILE}"
|
||||
update_config_var $ZBX_AGENT_CONFIG "TLSCRLFile" "${ZBX_TLSCRLFILE}"
|
||||
update_config_var $ZBX_AGENT_CONFIG "TLSServerCertIssuer" "${ZBX_TLSSERVERCERTISSUER}"
|
||||
update_config_var $ZBX_AGENT_CONFIG "TLSServerCertSubject" "${ZBX_TLSSERVERCERTSUBJECT}"
|
||||
update_config_var $ZBX_AGENT_CONFIG "TLSCertFile" "${ZBX_TLSCERTFILE}"
|
||||
update_config_var $ZBX_AGENT_CONFIG "TLSKeyFile" "${ZBX_TLSKEYFILE}"
|
||||
update_config_var $ZBX_AGENT_CONFIG "TLSPSKIdentity" "${ZBX_TLSPSKIDENTITY}"
|
||||
update_config_var $ZBX_AGENT_CONFIG "TLSPSKFile" "${ZBX_TLSPSKFILE}"
|
||||
}
|
||||
|
||||
prepare_java_gateway_config() {
|
||||
echo "** Preparing Zabbix Java Gateway log configuration file"
|
||||
|
||||
ZBX_GATEWAY_CONFIG=$ZABBIX_ETC_DIR/zabbix_java_gateway_logback.xml
|
||||
|
||||
if [ -n "${ZBX_DEBUGLEVEL}" ]; then
|
||||
echo "Updating $ZBX_GATEWAY_CONFIG 'DebugLevel' parameter: '${ZBX_DEBUGLEVEL}'... updated"
|
||||
if [ -f "$ZBX_GATEWAY_CONFIG" ]; then
|
||||
sed -i -e "/^.*<root level=/s/=.*/=\"${ZBX_DEBUGLEVEL}\">/" "$ZBX_GATEWAY_CONFIG"
|
||||
else
|
||||
echo "**** Zabbix Java Gateway log configuration file '$ZBX_GATEWAY_CONFIG' not found"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
prepare_agent() {
|
||||
echo "** Preparing Zabbix agent"
|
||||
prepare_zbx_agent_config
|
||||
}
|
||||
|
||||
prepare_server() {
|
||||
local db_type=$1
|
||||
|
||||
echo "** Preparing Zabbix server"
|
||||
|
||||
check_variables_$db_type "server"
|
||||
check_db_connect_$db_type
|
||||
create_db_user_$db_type
|
||||
create_db_database_$db_type
|
||||
create_db_schema_$db_type "server"
|
||||
|
||||
update_zbx_config "server" "$db_type"
|
||||
}
|
||||
|
||||
prepare_proxy() {
|
||||
local db_type=$1
|
||||
|
||||
echo "Preparing Zabbix proxy"
|
||||
|
||||
if [ "$db_type" != "sqlite3" ]; then
|
||||
check_variables_$db_type "proxy"
|
||||
check_db_connect_$db_type
|
||||
create_db_user_$db_type
|
||||
create_db_database_$db_type
|
||||
create_db_schema_$db_type "proxy"
|
||||
fi
|
||||
|
||||
update_zbx_config "proxy" $db_type
|
||||
}
|
||||
|
||||
prepare_web() {
|
||||
local web_server=$1
|
||||
local db_type=$2
|
||||
|
||||
echo "** Preparing Zabbix web-interface"
|
||||
|
||||
check_variables_$db_type
|
||||
check_db_connect_$db_type
|
||||
prepare_web_server_$web_server
|
||||
prepare_zbx_web_config $db_type
|
||||
}
|
||||
|
||||
prepare_java_gateway() {
|
||||
echo "** Preparing Zabbix Java Gateway"
|
||||
|
||||
prepare_java_gateway_config
|
||||
}
|
||||
|
||||
#################################################
|
||||
|
||||
if [ ! -n "$zbx_type" ]; then
|
||||
echo "**** Type of Zabbix component is not specified"
|
||||
exit 1
|
||||
elif [ "$zbx_type" == "dev" ]; then
|
||||
echo "** Deploying Zabbix installation from SVN"
|
||||
else
|
||||
if [ ! -n "$zbx_db_type" ]; then
|
||||
echo "**** Database type of Zabbix $zbx_type is not specified"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -n "$zbx_db_type" ]; then
|
||||
if [ -n "$zbx_opt_type" ]; then
|
||||
echo "** Deploying Zabbix $zbx_type ($zbx_opt_type) with $zbx_db_type database"
|
||||
else
|
||||
echo "** Deploying Zabbix $zbx_type with $zbx_db_type database"
|
||||
fi
|
||||
else
|
||||
echo "** Deploying Zabbix $zbx_type"
|
||||
fi
|
||||
fi
|
||||
|
||||
prepare_system "$zbx_type" "$zbx_opt_type"
|
||||
|
||||
[ "$zbx_type" == "server" ] && prepare_server $zbx_db_type
|
||||
[ "${ZBX_ADD_SERVER}" == "true" ] && prepare_server ${ZBX_MAIN_DB}
|
||||
|
||||
[ "$zbx_type" == "proxy" ] && prepare_proxy $zbx_db_type
|
||||
[ "${ZBX_ADD_PROXY}" == "true" ] && prepare_proxy ${ZBX_PROXY_DB}
|
||||
|
||||
[ "$zbx_type" == "frontend" ] && prepare_web $zbx_opt_type $zbx_db_type
|
||||
[ "${ZBX_ADD_WEB}" == "true" ] && prepare_web ${ZBX_WEB_SERVER} ${ZBX_MAIN_DB}
|
||||
|
||||
[ "$zbx_type" == "agentd" ] && prepare_agent
|
||||
[ "${ZBX_ADD_AGENT}" == "true" ] && prepare_agent
|
||||
|
||||
[ "$zbx_type" == "java-gateway" ] && prepare_java_gateway
|
||||
[ "${ZBX_ADD_JAVA_GATEWAY}" == "true" ] && prepare_java_gateway
|
||||
|
||||
clear_deploy "$zbx_type"
|
||||
|
||||
echo "########################################################"
|
||||
|
||||
echo "** Executing supervisord"
|
||||
exec /usr/bin/supervisord -c /etc/supervisor/supervisord.conf
|
||||
|
||||
#################################################
|
99
web-apache-pgsql/ubuntu/Dockerfile
Normal file
99
web-apache-pgsql/ubuntu/Dockerfile
Normal file
@ -0,0 +1,99 @@
|
||||
FROM ubuntu:trusty
|
||||
MAINTAINER Alexey Pustovalov <alexey.pustovalov@zabbix.com>
|
||||
|
||||
ARG APT_FLAGS_COMMON="-qq -y"
|
||||
ARG APT_FLAGS_PERSISTANT="${APT_FLAGS_COMMON} --no-install-recommends"
|
||||
ARG APT_FLAGS_DEV="${APT_FLAGS_COMMON} --no-install-recommends"
|
||||
ARG DB_TYPE=postgresql
|
||||
ENV LANG=en_US.UTF-8 LANGUAGE=en_US:en LC_ALL=en_US.UTF-8 DEBIAN_FRONTEND=noninteractive TERM=xterm
|
||||
|
||||
RUN DISTRIB_CODENAME=$(/bin/bash -c 'source /etc/lsb-release && echo $DISTRIB_CODENAME') && \
|
||||
locale-gen $LC_ALL && \
|
||||
echo "#!/bin/sh\nexit 0" > /usr/sbin/policy-rc.d && \
|
||||
echo "deb http://us.archive.ubuntu.com/ubuntu/ $DISTRIB_CODENAME multiverse" >> /etc/apt/sources.list && \
|
||||
addgroup --system --quiet zabbix && \
|
||||
adduser --quiet \
|
||||
--system --disabled-login \
|
||||
--ingroup zabbix \
|
||||
--home /var/lib/zabbix/ \
|
||||
--no-create-home \
|
||||
zabbix && \
|
||||
mkdir -p /etc/zabbix && \
|
||||
mkdir -p /etc/zabbix/web && \
|
||||
chown --quiet -R zabbix:root /etc/zabbix && \
|
||||
apt-get ${APT_FLAGS_COMMON} update && \
|
||||
apt-get ${APT_FLAGS_PERSISTANT} install \
|
||||
supervisor \
|
||||
postgresql-client \
|
||||
apache2 \
|
||||
libapache2-mod-php5 \
|
||||
php5-pgsql \
|
||||
php5-gd \
|
||||
php5-json \
|
||||
php5-ldap \
|
||||
ttf-dejavu-core 1>/dev/null && \
|
||||
apt-get ${APT_FLAGS_COMMON} autoremove && \
|
||||
apt-get ${APT_FLAGS_COMMON} clean && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
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} DB_TYPE=${DB_TYPE}
|
||||
|
||||
ADD conf/tmp/font-config /tmp/font-config
|
||||
|
||||
RUN apt-get ${APT_FLAGS_COMMON} update && \
|
||||
apt-get ${APT_FLAGS_DEV} install \
|
||||
subversion \
|
||||
patch \
|
||||
gettext 1>/dev/null && \
|
||||
mkdir -p /var/lib/locales/supported.d/ && \
|
||||
echo "en_US.UTF-8 UTF-8" > /var/lib/locales/supported.d/local && \
|
||||
echo "ru_RU.UTF-8 UTF-8" >> /var/lib/locales/supported.d/local && \
|
||||
echo "ja_JP.UTF-8 UTF-8" >> /var/lib/locales/supported.d/local && \
|
||||
echo "cs_CZ.UTF-8 UTF-8" >> /var/lib/locales/supported.d/local && \
|
||||
echo "ko_KR.UTF-8 UTF-8" >> /var/lib/locales/supported.d/local && \
|
||||
echo "it_IT.UTF-8 UTF-8" >> /var/lib/locales/supported.d/local && \
|
||||
echo "pt_BR.UTF-8 UTF-8" >> /var/lib/locales/supported.d/local && \
|
||||
echo "sk_SK.UTF-8 UTF-8" >> /var/lib/locales/supported.d/local && \
|
||||
echo "uk_UA.UTF-8 UTF-8" >> /var/lib/locales/supported.d/local && \
|
||||
echo "fr_FR.UTF-8 UTF-8" >> /var/lib/locales/supported.d/local && \
|
||||
echo "pl_PL.UTF-8 UTF-8" >> /var/lib/locales/supported.d/local && \
|
||||
echo "zh_CN.UTF-8 UTF-8" >> /var/lib/locales/supported.d/local && \
|
||||
dpkg-reconfigure locales 1>/dev/null && \
|
||||
cd /usr/share/ && \
|
||||
svn --quiet export ${ZBX_SOURCES}/frontends/php/ zabbix 1>/dev/null && \
|
||||
cd /usr/share/zabbix/ && \
|
||||
patch -p3 < /tmp/font-config && \
|
||||
rm /tmp/font-config && \
|
||||
rm -f conf/zabbix.conf.php && \
|
||||
rm -rf tests && \
|
||||
rm /usr/share/zabbix/fonts/DejaVuSans.ttf && \
|
||||
./locale/make_mo.sh 2>/dev/null && \
|
||||
update-alternatives --install /usr/share/zabbix/fonts/graphfont.ttf \
|
||||
zabbix-frontend-font /usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf 10 && \
|
||||
apt-get ${APT_FLAGS_COMMON} purge \
|
||||
subversion \
|
||||
patch \
|
||||
gettext 1>/dev/null && \
|
||||
apt-get ${APT_FLAGS_COMMON} autoremove && \
|
||||
apt-get ${APT_FLAGS_COMMON} clean && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
EXPOSE 80/TCP 443/TCP
|
||||
|
||||
WORKDIR /usr/share/zabbix
|
||||
|
||||
VOLUME ["/etc/ssl/apache2"]
|
||||
|
||||
ADD conf/etc/supervisor/ /etc/supervisor/
|
||||
ADD conf/etc/zabbix/apache.conf /etc/zabbix/
|
||||
ADD conf/etc/zabbix/apache_ssl.conf /etc/zabbix/
|
||||
ADD conf/etc/zabbix/web/zabbix.conf.php /etc/zabbix/web/
|
||||
ADD conf/etc/php5/apache2/conf.d/99-zabbix.ini /etc/php5/apache2/conf.d/
|
||||
ADD run_zabbix_component.sh /
|
||||
|
||||
ENTRYPOINT ["/bin/bash"]
|
||||
|
||||
CMD ["/run_zabbix_component.sh", "frontend", "postgresql", "apache"]
|
170
web-apache-pgsql/ubuntu/README.md
Normal file
170
web-apache-pgsql/ubuntu/README.md
Normal file
@ -0,0 +1,170 @@
|
||||
![logo](http://www.zabbix.com/ru/img/logo/zabbix_logo_500x131.png)
|
||||
|
||||
# What is Zabbix?
|
||||
|
||||
Zabbix is an enterprise-class open source distributed monitoring solution.
|
||||
|
||||
Zabbix is software that monitors numerous parameters of a network and the health and integrity of servers. Zabbix uses a flexible notification mechanism that allows users to configure e-mail based alerts for virtually any event. This allows a fast reaction to server problems. Zabbix offers excellent reporting and data visualisation features based on the stored data. This makes Zabbix ideal for capacity planning.
|
||||
|
||||
For more information and related downloads for Zabbix components, please visit https://hub.docker.com/u/zabbix/ and https://zabbix.com
|
||||
|
||||
# What is Zabbix web interface?
|
||||
|
||||
Zabbix web interface is a part of Zabbix software. It is used to manage resources under monitoring and view monitoring statistics.
|
||||
|
||||
# Zabbix web interface images
|
||||
|
||||
These are the only official Zabbix web interface Docker images. They are based on latest Alpine and trusty Ubuntu images. The available versions of Zabbix web interface are:
|
||||
|
||||
Zabbix web interface 3.0 (tags: alpine-3.0-latest, ubuntu-3.0-latest)
|
||||
Zabbix web interface 3.0.* (tags: alpine-3.0.*, ubuntu-3.0.*)
|
||||
Zabbix web interface 3.2 (tags: alpine-3.2-latest, ubuntu-3.2-latest, alpine-latest, ubuntu-latest, latest)
|
||||
Zabbix web interface 3.2.* (tags: alpine-3.2.*, ubuntu-3.2.*)
|
||||
Zabbix web interface 3.4 (tags: alpine-trunk, ubuntu-trunk)
|
||||
|
||||
Images are updated when new releases are published. The image with ``latest`` tag is based on Alpine Linux.
|
||||
|
||||
Zabbix web interface available in three editions:
|
||||
- Zabbix web-interface based on Apache2 web server with MySQL database support
|
||||
- Zabbix web-interface based on Nginx web server with MySQL database support
|
||||
- Zabbix web-interface based on Nginx web server with PostgreSQL database support
|
||||
|
||||
The image based on Apache2 web server with MySQL database support.
|
||||
|
||||
# How to use this image
|
||||
|
||||
## Start `zabbix-web-apache-mysql`
|
||||
|
||||
Start a Zabbix web-interface container as follows:
|
||||
|
||||
docker run --name some-zabbix-web-apache-mysql -e DB_SERVER_HOST="some-mysql-server" -e MYSQL_USER="some-user" -e MYSQL_PASSWORD="some-password" -e ZBX_SERVER_HOST="some-zabbix-server" -e TZ="some-timezone" -d zabbix/zabbix-web-apache-mysql:tag
|
||||
|
||||
Where `some-zabbix-web-apache-mysql` is the name you want to assign to your container, `some-mysql-server` is IP or DNS name of MySQL server, `some-user` is user to connect to Zabbix database on MySQL server, `some-password` is the password to connect to MySQL server, `some-zabbix-server` is IP or DNS name of Zabbix server or proxy, `some-timezone` is PHP like timezone name and `tag` is the tag specifying the version you want. See the list above for relevant tags, or look at the [full list of tags](https://hub.docker.com/r/zabbix/zabbix-web-apache-mysql/tags/).
|
||||
|
||||
## Linking the container to Zabbix server
|
||||
|
||||
docker run --name some-zabbix-web-apache-mysql --link some-zabbix-server:zabbix-server -e DB_SERVER_HOST="some-mysql-server" -e MYSQL_USER="some-user" -e MYSQL_PASSWORD="some-password" -e ZBX_SERVER_HOST="some-zabbix-server" -e TZ="some-timezone" -d zabbix/zabbix-web-apache-mysql:tag
|
||||
|
||||
## Linking the container to MySQL database
|
||||
|
||||
docker run --name some-zabbix-web-apache-mysql --link some-mysql-server:mysql -e DB_SERVER_HOST="some-mysql-server" -e MYSQL_USER="some-user" -e MYSQL_PASSWORD="some-password" -e ZBX_SERVER_HOST="some-zabbix-server" -e TZ="some-timezone" -d zabbix/zabbix-web-apache-mysql:tag
|
||||
|
||||
## Container shell access and viewing Zabbix web interface logs
|
||||
|
||||
The `docker exec` command allows you to run commands inside a Docker container. The following command line will give you a bash shell inside your `zabbix-web-apache-mysql` container:
|
||||
|
||||
```console
|
||||
$ docker exec -ti some-zabbix-web-apache-mysql /bin/bash/
|
||||
```
|
||||
|
||||
The Zabbix web interface log is available through Docker's container log:
|
||||
|
||||
```console
|
||||
$ docker logs some-zabbix-web-apache-mysql
|
||||
```
|
||||
|
||||
## Environment Variables
|
||||
|
||||
When you start the `zabbix-web-apache-mysql` image, you can adjust the configuration of the Zabbix web interface by passing one or more environment variables on the `docker run` command line.
|
||||
|
||||
### `ZBX_SERVER_HOST`
|
||||
|
||||
This variable is IP or DNS name of Zabbix server. By default, value is `zabbix-server`.
|
||||
|
||||
### `ZBX_SERVER_PORT`
|
||||
|
||||
This variable is port Zabbix server listening on. By default, value is `10051`.
|
||||
|
||||
### `DB_SERVER_HOST`
|
||||
|
||||
This variable is IP or DNS name of MySQL server. By default, value is 'mysql-server'
|
||||
|
||||
### `DB_SERVER_PORT`
|
||||
|
||||
This variable is port of MySQL server. By default, value is '3306'.
|
||||
|
||||
### `MYSQL_USER`, `MYSQL_PASSWORD`
|
||||
|
||||
These variables are used by Zabbix web interface to connect to Zabbix database. By default, values are `zabbix`, `zabbix`.
|
||||
|
||||
### `MYSQL_DATABASE`
|
||||
|
||||
The variable is Zabbix database name. By default, value is `zabbix`.
|
||||
|
||||
### `TZ`
|
||||
|
||||
The variable is timezone in PHP format. Full list of supported timezones are available on [`php.net`](http://php.net/manual/en/timezones.php). By default, value is 'Europe/Riga'.
|
||||
|
||||
### `ZBX_SERVER_NAME`
|
||||
|
||||
The variable is visible Zabbix installation name in right top corner of the web interface.
|
||||
|
||||
### `ZBX_MAXEXECUTIONTIME`
|
||||
|
||||
The varable is PHP ``max_execution_time`` option. By default, value is `300`.
|
||||
|
||||
### `ZBX_MEMORYLIMIT`
|
||||
|
||||
The varable is PHP ``memory_limit`` option. By default, value is `128M`.
|
||||
|
||||
### `ZBX_POSTMAXSIZE`
|
||||
|
||||
The varable is PHP ``post_max_size`` option. By default, value is `16M`.
|
||||
|
||||
### `ZBX_UPLOADMAXFILESIZE`
|
||||
|
||||
The varable is PHP ``upload_max_filesize`` option. By default, value is `2M`.
|
||||
|
||||
### `ZBX_MAXINPUTTIME`
|
||||
|
||||
The varable is PHP ``max_input_time`` option. By default, value is `300`.
|
||||
|
||||
## Allowed volumes for the Zabbix web interface container
|
||||
|
||||
### ``/etc/ssl/apache2``
|
||||
|
||||
The volume allows to enable HTTPS for the Zabbix web interface. The volume must contains two files ``ssl.crt`` and ``ssl.key`` prepared for Apache2 SSL connections.
|
||||
|
||||
Please follow official Apache2 [documentation](https://httpd.apache.org/docs/2.4/ssl/ssl_howto.html) to get more details about how to create certificate files.
|
||||
|
||||
# The image variants
|
||||
|
||||
The `zabbix-web-apache-mysql` images come in many flavors, each designed for a specific use case.
|
||||
|
||||
## `zabbix-web-apache-mysql:ubuntu-<version>`
|
||||
|
||||
This is the defacto image. If you are unsure about what your needs are, you probably want to use this one. It is designed to be used both as a throw away container (mount your source code and start the container to start your app), as well as the base to build other images off of.
|
||||
|
||||
## `zabbix-web-apache-mysql:alpine-<version>`
|
||||
|
||||
This image is based on the popular [Alpine Linux project](http://alpinelinux.org), available in [the `alpine` official image](https://hub.docker.com/_/alpine). Alpine Linux is much smaller than most distribution base images (~5MB), and thus leads to much slimmer images in general.
|
||||
|
||||
This variant is highly recommended when final image size being as small as possible is desired. The main caveat to note is that it does use [musl libc](http://www.musl-libc.org) instead of [glibc and friends](http://www.etalabs.net/compare_libcs.html), so certain software might run into issues depending on the depth of their libc requirements. However, most software doesn't have an issue with this, so this variant is usually a very safe choice. See [this Hacker News comment thread](https://news.ycombinator.com/item?id=10782897) for more discussion of the issues that might arise and some pro/con comparisons of using Alpine-based images.
|
||||
|
||||
To minimize image size, it's uncommon for additional related tools (such as `git` or `bash`) to be included in Alpine-based images. Using this image as a base, add the things you need in your own Dockerfile (see the [`alpine` image description](https://hub.docker.com/_/alpine/) for examples of how to install packages if you are unfamiliar).
|
||||
|
||||
# Supported Docker versions
|
||||
|
||||
This image is officially supported on Docker version 1.12.0.
|
||||
|
||||
Support for older versions (down to 1.6) is provided on a best-effort basis.
|
||||
|
||||
Please see [the Docker installation documentation](https://docs.docker.com/installation/) for details on how to upgrade your Docker daemon.
|
||||
|
||||
# User Feedback
|
||||
|
||||
## Documentation
|
||||
|
||||
Documentation for this image is stored in the [`web-apache-mysql/` directory](https://github.com/zabbix/zabbix-docker/tree/3.0/web-apache-mysql) of the [`zabbix/zabbix-docker` GitHub repo](https://github.com/zabbix/zabbix-docker/). Be sure to familiarize yourself with the [repository's `README.md` file](https://github.com/zabbix/zabbix-docker/blob/master/README.md) before attempting a pull request.
|
||||
|
||||
## Issues
|
||||
|
||||
If you have any problems with or questions about this image, please contact us through a [GitHub issue](https://github.com/zabbix/zabbix-docker/issues).
|
||||
|
||||
### Known issues
|
||||
|
||||
## Contributing
|
||||
|
||||
You are invited to contribute new features, fixes, or updates, large or small; we are always thrilled to receive pull requests, and do our best to process them as fast as we can.
|
||||
|
||||
Before you start to code, we recommend discussing your plans through a [GitHub issue](https://github.com/zabbix/zabbix-docker/issues), especially for more ambitious contributions. This gives other contributors a chance to point you in the right direction, give you feedback on your design, and help you find out if someone else is working on the same thing.
|
20
web-apache-pgsql/ubuntu/build.sh
Executable file
20
web-apache-pgsql/ubuntu/build.sh
Executable file
@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
os=ubuntu
|
||||
|
||||
version=$1
|
||||
version=${version:-"latest"}
|
||||
|
||||
app_component=web-apache
|
||||
app_database=postgresql
|
||||
|
||||
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 .
|
||||
|
||||
#docker rm -f zabbix-$app_component-$app_database
|
||||
|
||||
#docker run --name zabbix-$app_component-$app_database -t -d --link postgres-server:postgres --link zabbix-server:zabbix-server zabbix-$app_component-$app_database:$os-$version
|
@ -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_date=-1
|
||||
; date.timezone=Europe/Riga
|
||||
session.save_path=/var/lib/php5
|
@ -0,0 +1,12 @@
|
||||
[supervisord]
|
||||
nodaemon = true
|
||||
|
||||
[program:apache2]
|
||||
command = /bin/bash -c "source /etc/apache2/envvars && /usr/sbin/apache2ctl -D FOREGROUND"
|
||||
auto_start = true
|
||||
autorestart = true
|
||||
|
||||
stdout_logfile = /dev/stdout
|
||||
stdout_logfile_maxbytes = 0
|
||||
stderr_logfile = /dev/stderr
|
||||
stderr_logfile_maxbytes = 0
|
34
web-apache-pgsql/ubuntu/conf/etc/supervisor/supervisord.conf
Normal file
34
web-apache-pgsql/ubuntu/conf/etc/supervisor/supervisord.conf
Normal file
@ -0,0 +1,34 @@
|
||||
; supervisor config file
|
||||
|
||||
[unix_http_server]
|
||||
file = /var/run/supervisor.sock ; (the path to the socket file)
|
||||
chmod = 0700 ; sockef file mode (default 0700)
|
||||
username = zbx
|
||||
password = password
|
||||
|
||||
[supervisord]
|
||||
logfile = /dev/stdout ; (main log file;default $CWD/supervisord.log)
|
||||
pidfile = /var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
|
||||
childlogdir = /tmp ; ('AUTO' child log dir, default $TEMP)
|
||||
critical = critical
|
||||
user = root
|
||||
logfile_maxbytes = 0
|
||||
logfile_backupcount = 0
|
||||
|
||||
; the below section must remain in the config file for RPC
|
||||
; (supervisorctl/web interface) to work, additional interfaces may be
|
||||
; added by defining them in separate rpcinterface: sections
|
||||
[rpcinterface:supervisor]
|
||||
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
|
||||
|
||||
[supervisorctl]
|
||||
serverurl = unix:///var/run/supervisor.sock ; use a unix:// URL for a unix socket
|
||||
|
||||
; The [include] section can just contain the "files" setting. This
|
||||
; setting can list multiple files (separated by whitespace or
|
||||
; newlines). It can also contain wildcards. The filenames are
|
||||
; interpreted as relative to this file. Included files *cannot*
|
||||
; include files themselves.
|
||||
|
||||
[include]
|
||||
files = /etc/supervisor/conf.d/*.conf
|
50
web-apache-pgsql/ubuntu/conf/etc/zabbix/apache.conf
Normal file
50
web-apache-pgsql/ubuntu/conf/etc/zabbix/apache.conf
Normal file
@ -0,0 +1,50 @@
|
||||
<VirtualHost *:80>
|
||||
DocumentRoot /usr/share/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/zabbix">
|
||||
Options FollowSymLinks
|
||||
AllowOverride None
|
||||
Order allow,deny
|
||||
Allow from all
|
||||
</Directory>
|
||||
|
||||
<Directory "/usr/share/zabbix/conf">
|
||||
Order deny,allow
|
||||
Deny from all
|
||||
<files *.php>
|
||||
Order deny,allow
|
||||
Deny from all
|
||||
</files>
|
||||
</Directory>
|
||||
|
||||
<Directory "/usr/share/zabbix/app">
|
||||
Order deny,allow
|
||||
Deny from all
|
||||
<files *.php>
|
||||
Order deny,allow
|
||||
Deny from all
|
||||
</files>
|
||||
</Directory>
|
||||
|
||||
<Directory "/usr/share/zabbix/include">
|
||||
Order deny,allow
|
||||
Deny from all
|
||||
<files *.php>
|
||||
Order deny,allow
|
||||
Deny from all
|
||||
</files>
|
||||
</Directory>
|
||||
|
||||
<Directory "/usr/share/zabbix/local">
|
||||
Order deny,allow
|
||||
Deny from all
|
||||
<files *.php>
|
||||
Order deny,allow
|
||||
Deny from all
|
||||
</files>
|
||||
</Directory>
|
19
web-apache-pgsql/ubuntu/conf/etc/zabbix/apache_ssl.conf
Normal file
19
web-apache-pgsql/ubuntu/conf/etc/zabbix/apache_ssl.conf
Normal file
@ -0,0 +1,19 @@
|
||||
<IfModule mod_ssl.c>
|
||||
<VirtualHost *:443>
|
||||
DocumentRoot /usr/share/zabbix/
|
||||
ServerName zabbix
|
||||
DirectoryIndex index.php
|
||||
AddType application/x-httpd-php .php .php3 .php4 .php5 .phtml
|
||||
AddType application/x-httpd-php-source .phps
|
||||
|
||||
# Enable/Disable SSL for this virtual host.
|
||||
SSLEngine on
|
||||
|
||||
SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
|
||||
SSLProtocol all -SSLv2
|
||||
|
||||
SSLCertificateFile /etc/ssl/apache2/ssl.crt
|
||||
SSLCertificateKeyFile /etc/ssl/apache2/ssl.key
|
||||
# SSLCACertificatePath /etc/ssl/apache2/chain/
|
||||
</VirtualHost>
|
||||
</IfModule>
|
20
web-apache-pgsql/ubuntu/conf/etc/zabbix/web/zabbix.conf.php
Normal file
20
web-apache-pgsql/ubuntu/conf/etc/zabbix/web/zabbix.conf.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
// Zabbix GUI configuration file.
|
||||
global $DB;
|
||||
|
||||
$DB['TYPE'] = 'POSTGRESQL';
|
||||
$DB['SERVER'] = '{DB_SERVER_HOST}';
|
||||
$DB['PORT'] = '{DB_SERVER_PORT}';
|
||||
$DB['DATABASE'] = '{DB_SERVER_DBNAME}';
|
||||
$DB['USER'] = '{DB_SERVER_USER}';
|
||||
$DB['PASSWORD'] = '{DB_SERVER_PASS}';
|
||||
|
||||
// Schema name. Used for IBM DB2 and PostgreSQL.
|
||||
$DB['SCHEMA'] = '';
|
||||
|
||||
$ZBX_SERVER = '{ZBX_SERVER_HOST}';
|
||||
$ZBX_SERVER_PORT = '{ZBX_SERVER_PORT}';
|
||||
$ZBX_SERVER_NAME = '{ZBX_SERVER_NAME}';
|
||||
|
||||
$IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG;
|
||||
?>
|
21
web-apache-pgsql/ubuntu/conf/tmp/font-config
Normal file
21
web-apache-pgsql/ubuntu/conf/tmp/font-config
Normal file
@ -0,0 +1,21 @@
|
||||
diff -Nru zabbix-2.5.0.orig/frontends/php/include/defines.inc.php zabbix-2.5.0/frontends/php/include/defines.inc.php
|
||||
--- zabbix-2.5.0.orig/frontends/php/include/defines.inc.php 2015-08-19 17:27:39.000000000 +0900
|
||||
+++ zabbix-2.5.0/frontends/php/include/defines.inc.php 2015-08-22 15:20:12.000000000 +0900
|
||||
@@ -42,7 +42,7 @@
|
||||
define('ZBX_WIDGET_ROWS', 20);
|
||||
|
||||
define('ZBX_FONTPATH', realpath('fonts')); // where to search for font (GD > 2.0.18)
|
||||
-define('ZBX_GRAPH_FONT_NAME', 'DejaVuSans'); // font file name
|
||||
+define('ZBX_GRAPH_FONT_NAME', 'graphfont'); // font file name
|
||||
define('ZBX_GRAPH_LEGEND_HEIGHT', 120); // when graph height is less then this value, some legend will not show up
|
||||
|
||||
define('ZBX_SCRIPT_TIMEOUT', 60); // in seconds
|
||||
@@ -90,7 +90,7 @@
|
||||
define('EVENTS_OPTION_ALL', 2);
|
||||
define('EVENTS_OPTION_NOT_ACK', 3);
|
||||
|
||||
-define('ZBX_FONT_NAME', 'DejaVuSans');
|
||||
+define('ZBX_FONT_NAME', 'graphfont');
|
||||
|
||||
define('ZBX_AUTH_INTERNAL', 0);
|
||||
define('ZBX_AUTH_LDAP', 1);
|
909
web-apache-pgsql/ubuntu/run_zabbix_component.sh
Executable file
909
web-apache-pgsql/ubuntu/run_zabbix_component.sh
Executable file
@ -0,0 +1,909 @@
|
||||
#!/bin/bash
|
||||
|
||||
set +e
|
||||
|
||||
# Script trace mode
|
||||
if [ "${DEBUG_MODE}" == "true" ]; then
|
||||
set -o xtrace
|
||||
fi
|
||||
|
||||
# Type of Zabbix component
|
||||
# Possible values: [server, proxy, agent, web, dev]
|
||||
zbx_type="$1"
|
||||
# Type of Zabbix database
|
||||
# Possible values: [mysql, postgresql]
|
||||
zbx_db_type="$2"
|
||||
# Type of web-server. Valid only with zbx_type = web
|
||||
# Possible values: [apache, nginx]
|
||||
zbx_opt_type="$3"
|
||||
|
||||
# Default Zabbix installation name
|
||||
# Used only by Zabbix web-interface
|
||||
ZBX_SERVER_NAME=${ZBX_SERVER_NAME:-"Zabbix docker"}
|
||||
# Default Zabbix server host
|
||||
ZBX_SERVER_HOST=${ZBX_SERVER_HOST:-"zabbix-server"}
|
||||
# Default Zabbix server port number
|
||||
ZBX_SERVER_PORT=${ZBX_SERVER_PORT:-"10051"}
|
||||
|
||||
# Default timezone for web interface
|
||||
TZ=${TZ:-"Europe/Riga"}
|
||||
|
||||
# Default directories
|
||||
# User 'zabbix' home directory
|
||||
ZABBIX_USER_HOME_DIR="/var/lib/zabbix"
|
||||
# Configuration files directory
|
||||
ZABBIX_ETC_DIR="/etc/zabbix"
|
||||
# Web interface www-root directory
|
||||
ZBX_FRONTEND_PATH="/usr/share/zabbix"
|
||||
|
||||
prepare_system() {
|
||||
local type=$1
|
||||
local web_server=$2
|
||||
|
||||
echo "** Preparing the system"
|
||||
|
||||
if [ "$type" != "dev" ]; then
|
||||
return
|
||||
fi
|
||||
}
|
||||
|
||||
update_config_var() {
|
||||
local config_path=$1
|
||||
local var_name=$2
|
||||
local var_value=$3
|
||||
local is_multiple=$4
|
||||
|
||||
if [ ! -f "$config_path" ]; then
|
||||
echo "**** Configuration file '$config_path' does not exist"
|
||||
return
|
||||
fi
|
||||
|
||||
echo -n "** Updating '$config_path' parameter \"$var_name\": '$var_value'... "
|
||||
|
||||
# Remove configuration parameter definition in case of unset parameter value
|
||||
if [ -z "$var_value" ]; then
|
||||
sed -i -e "/$var_name=/d" "$config_path"
|
||||
echo "removed"
|
||||
return
|
||||
fi
|
||||
|
||||
# Remove value from configuration parameter in case of double quoted parameter value
|
||||
if [ "$var_value" == '""' ]; then
|
||||
sed -i -e "/^$var_name=/s/=.*/=/" "$config_path"
|
||||
echo "undefined"
|
||||
return
|
||||
fi
|
||||
|
||||
# Use full path to a file for TLS related configuration parameters
|
||||
if [[ $var_name =~ ^TLS.*File$ ]]; then
|
||||
var_value=$ZABBIX_USER_HOME_DIR/enc/$var_value
|
||||
fi
|
||||
|
||||
# Escaping "/" character in parameter value
|
||||
var_value=${var_value//\//\\/}
|
||||
|
||||
if [ "$(grep -E "^$var_name=" $config_path)" ] && [ "$is_multiple" != "true" ]; then
|
||||
sed -i -e "/^$var_name=/s/=.*/=$var_value/" "$config_path"
|
||||
echo "updated"
|
||||
elif [ "$(grep -Ec "^# $var_name=" $config_path)" -gt 1 ]; then
|
||||
sed -i -e "/^[#;] $var_name=$/i\\$var_name=$var_value" "$config_path"
|
||||
echo "added first occurrence"
|
||||
else
|
||||
sed -i -e "/^[#;] $var_name=/s/.*/&\n$var_name=$var_value/" "$config_path"
|
||||
echo "added"
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
update_config_multiple_var() {
|
||||
local config_path=$1
|
||||
local var_name=$2
|
||||
local var_value=$3
|
||||
|
||||
var_value="${var_value%\"}"
|
||||
var_value="${var_value#\"}"
|
||||
|
||||
local IFS=,
|
||||
local OPT_LIST=($var_value)
|
||||
|
||||
for value in "${OPT_LIST[@]}"; do
|
||||
update_config_var $config_path $var_name $value true
|
||||
done
|
||||
}
|
||||
|
||||
# Check prerequisites for MySQL database
|
||||
check_variables_mysql() {
|
||||
local type=$1
|
||||
|
||||
DB_SERVER_HOST=${DB_SERVER_HOST:-"mysql-server"}
|
||||
DB_SERVER_PORT=${DB_SERVER_PORT:-"3306"}
|
||||
USE_DB_ROOT_USER=false
|
||||
CREATE_ZBX_DB_USER=false
|
||||
|
||||
if [ ! -n "${MYSQL_USER}" ] && [ "${MYSQL_RANDOM_ROOT_PASSWORD}" == "true" ]; then
|
||||
echo "**** Impossible to use MySQL server because of unknown Zabbix user and random 'root' password"
|
||||
exit 1
|
||||
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"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "${MYSQL_ALLOW_EMPTY_PASSWORD}" == "true" ] || [ -n "${MYSQL_ROOT_PASSWORD}" ]; then
|
||||
USE_DB_ROOT_USER=true
|
||||
DB_SERVER_ROOT_USER="root"
|
||||
DB_SERVER_ROOT_PASS=${MYSQL_ROOT_PASSWORD:-""}
|
||||
fi
|
||||
|
||||
[ -n "${MYSQL_USER}" ] || CREATE_ZBX_DB_USER=true
|
||||
|
||||
# If root password is not specified use provided credentials
|
||||
DB_SERVER_ROOT_USER=${DB_SERVER_ROOT_USER:-${MYSQL_USER}}
|
||||
[ "${MYSQL_ALLOW_EMPTY_PASSWORD}" == "true" ] || DB_SERVER_ROOT_PASS=${DB_SERVER_ROOT_PASS:-${MYSQL_PASSWORD}}
|
||||
DB_SERVER_ZBX_USER=${MYSQL_USER:-"zabbix"}
|
||||
DB_SERVER_ZBX_PASS=${MYSQL_PASSWORD:-"zabbix"}
|
||||
|
||||
if [ "$type" == "proxy" ]; then
|
||||
DB_SERVER_DBNAME=${MYSQL_DATABASE:-"zabbix_proxy"}
|
||||
else
|
||||
DB_SERVER_DBNAME=${MYSQL_DATABASE:-"zabbix"}
|
||||
fi
|
||||
}
|
||||
|
||||
# Check prerequisites for PostgreSQL database
|
||||
check_variables_postgresql() {
|
||||
local type=$1
|
||||
|
||||
DB_SERVER_HOST=${DB_SERVER_HOST:-"postgres-server"}
|
||||
DB_SERVER_PORT=${DB_SERVER_PORT:-"5432"}
|
||||
CREATE_ZBX_DB_USER=${CREATE_ZBX_DB_USER:-"false"}
|
||||
|
||||
DB_SERVER_ROOT_USER=${POSTGRES_USER:-"postgres"}
|
||||
DB_SERVER_ROOT_PASS=${POSTGRES_PASSWORD:-""}
|
||||
|
||||
DB_SERVER_ZBX_USER=${POSTGRES_USER:-"zabbix"}
|
||||
DB_SERVER_ZBX_PASS=${POSTGRES_PASSWORD:-"zabbix"}
|
||||
|
||||
if [ "$type" == "proxy" ]; then
|
||||
DB_SERVER_DBNAME=${POSTGRES_DB:-"zabbix_proxy"}
|
||||
else
|
||||
DB_SERVER_DBNAME=${POSTGRES_DB:-"zabbix"}
|
||||
fi
|
||||
}
|
||||
|
||||
check_db_connect_mysql() {
|
||||
echo "********************"
|
||||
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
||||
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
||||
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
||||
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
||||
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
||||
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
||||
fi
|
||||
echo "* DB_SERVER_ZBX_USER: ${DB_SERVER_ZBX_USER}"
|
||||
echo "* DB_SERVER_ZBX_PASS: ${DB_SERVER_ZBX_PASS}"
|
||||
echo "********************"
|
||||
|
||||
WAIT_TIMEOUT=5
|
||||
|
||||
while [ ! "$(mysqladmin ping -h ${DB_SERVER_HOST} -P ${DB_SERVER_PORT} -u ${DB_SERVER_ROOT_USER} \
|
||||
--password="${DB_SERVER_ROOT_PASS}" --silent --connect_timeout=10)" ]; do
|
||||
echo "**** MySQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
||||
sleep $WAIT_TIMEOUT
|
||||
done
|
||||
}
|
||||
|
||||
check_db_connect_postgresql() {
|
||||
echo "********************"
|
||||
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
||||
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
||||
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
||||
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
||||
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
||||
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
||||
fi
|
||||
echo "* DB_SERVER_ZBX_USER: ${DB_SERVER_ZBX_USER}"
|
||||
echo "* DB_SERVER_ZBX_PASS: ${DB_SERVER_ZBX_PASS}"
|
||||
echo "********************"
|
||||
|
||||
if [ -n "${DB_SERVER_ZBX_PASS}" ]; then
|
||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||
fi
|
||||
|
||||
WAIT_TIMEOUT=5
|
||||
|
||||
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -l -q 2>/dev/null)" ]; do
|
||||
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
||||
sleep $WAIT_TIMEOUT
|
||||
done
|
||||
|
||||
unset PGPASSWORD
|
||||
}
|
||||
|
||||
|
||||
mysql_query() {
|
||||
query=$1
|
||||
local result=""
|
||||
|
||||
result=$(mysql --silent --skip-column-names -h ${DB_SERVER_HOST} -P ${DB_SERVER_PORT} \
|
||||
-u ${DB_SERVER_ROOT_USER} --password="${DB_SERVER_ROOT_PASS}" -e "$query")
|
||||
|
||||
echo $result
|
||||
}
|
||||
|
||||
psql_query() {
|
||||
query=$1
|
||||
db=$2
|
||||
|
||||
local result=""
|
||||
|
||||
if [ -n "${DB_SERVER_ZBX_PASS}" ]; then
|
||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||
fi
|
||||
|
||||
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
||||
|
||||
unset PGPASSWORD
|
||||
|
||||
echo $result
|
||||
}
|
||||
|
||||
create_db_user_mysql() {
|
||||
[ "${CREATE_ZBX_DB_USER}" == "true" ] || return
|
||||
|
||||
echo "** Creating '${DB_SERVER_ZBX_USER}' user in MySQL database"
|
||||
|
||||
USER_EXISTS=$(mysql_query "SELECT 1 FROM mysql.user WHERE user = '${DB_SERVER_ZBX_USER}' AND host = '%'")
|
||||
|
||||
if [ -z "$USER_EXISTS" ]; then
|
||||
mysql_query "CREATE USER '${DB_SERVER_ZBX_USER}'@'%' IDENTIFIED BY '${DB_SERVER_ZBX_PASS}'" 1>/dev/null
|
||||
else
|
||||
mysql_query "SET PASSWORD FOR '${DB_SERVER_ZBX_USER}'@'%' = PASSWORD('${DB_SERVER_ZBX_PASS}');" 1>/dev/null
|
||||
fi
|
||||
|
||||
mysql_query "GRANT ALL PRIVILEGES ON $DB_SERVER_DBNAME. * TO '${DB_SERVER_ZBX_USER}'@'%'" 1>/dev/null
|
||||
}
|
||||
|
||||
create_db_user_postgresql() {
|
||||
[ "${CREATE_ZBX_DB_USER}" == "true" ] || return
|
||||
|
||||
echo "** Creating '${DB_SERVER_ZBX_USER}' user in PostgreSQL database"
|
||||
|
||||
USER_EXISTS=$(psql_query "SELECT 1 FROM pg_roles WHERE rolname='${DB_SERVER_ZBX_USER}'")
|
||||
|
||||
if [ -z "$USER_EXISTS" ]; then
|
||||
psql_query "CREATE USER ${DB_SERVER_ZBX_USER} WITH PASSWORD '${DB_SERVER_ZBX_PASS}'" 1>/dev/null
|
||||
else
|
||||
psql_query "ALTER USER ${DB_SERVER_ZBX_USER} WITH ENCRYPTED PASSWORD '${DB_SERVER_ZBX_PASS}'" 1>/dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
create_db_database_mysql() {
|
||||
DB_EXISTS=$(mysql_query "SELECT SCHEMA_NAME FROM information_schema.SCHEMATA WHERE SCHEMA_NAME='${DB_SERVER_DBNAME}'")
|
||||
|
||||
if [ -z ${DB_EXISTS} ]; then
|
||||
echo "** Database '${DB_SERVER_DBNAME}' does not exist. Creating..."
|
||||
mysql_query "CREATE DATABASE ${DB_SERVER_DBNAME} CHARACTER SET utf8 COLLATE utf8_bin" 1>/dev/null
|
||||
# better solution?
|
||||
mysql_query "GRANT ALL PRIVILEGES ON $DB_SERVER_DBNAME. * TO '${DB_SERVER_ZBX_USER}'@'%'" 1>/dev/null
|
||||
else
|
||||
echo "** Database '${DB_SERVER_DBNAME}' already exists. Please be careful with database COLLATE!"
|
||||
fi
|
||||
}
|
||||
|
||||
create_db_database_postgresql() {
|
||||
DB_EXISTS=$(psql_query "SELECT 1 AS result FROM pg_database WHERE datname='${DB_SERVER_DBNAME}'")
|
||||
|
||||
if [ -z ${DB_EXISTS} ]; then
|
||||
echo "** Database '${DB_SERVER_DBNAME}' does not exist. Creating..."
|
||||
psql_query "CREATE DATABASE ${DB_SERVER_DBNAME} WITH OWNER ${DB_SERVER_ZBX_USER} ENCODING='UTF8' LC_CTYPE='en_US.utf8' LC_COLLATE='en_US.utf8'" 1>/dev/null
|
||||
else
|
||||
echo "** Database '${DB_SERVER_DBNAME}' already exists. Please be careful with database owner!"
|
||||
fi
|
||||
}
|
||||
|
||||
create_db_schema_mysql() {
|
||||
local type=$1
|
||||
|
||||
DBVERSION_TABLE_EXISTS=$(mysql_query "SELECT 1 FROM information_schema.tables WHERE table_schema='${DB_SERVER_DBNAME}' and table_name = 'dbversion'")
|
||||
|
||||
if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then
|
||||
echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists."
|
||||
ZBX_DB_VERSION=$(mysql_query "SELECT mandatory FROM ${DB_SERVER_DBNAME}.dbversion")
|
||||
fi
|
||||
|
||||
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 \
|
||||
-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
|
||||
}
|
||||
|
||||
create_db_schema_postgresql() {
|
||||
local type=$1
|
||||
|
||||
DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid =
|
||||
c.relnamespace WHERE n.nspname = 'public' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}")
|
||||
|
||||
if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then
|
||||
echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists."
|
||||
ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM public.dbversion" "${DB_SERVER_DBNAME}")
|
||||
fi
|
||||
|
||||
if [ -z "${ZBX_DB_VERSION}" ]; then
|
||||
echo "** Creating '${DB_SERVER_DBNAME}' schema in PostgreSQL"
|
||||
|
||||
if [ -n "${DB_SERVER_ZBX_PASS}" ]; then
|
||||
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 \
|
||||
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
||||
fi
|
||||
|
||||
unset PGPASSWORD
|
||||
fi
|
||||
}
|
||||
|
||||
prepare_web_server_apache() {
|
||||
if [ -d "/etc/apache2/sites-available" ]; then
|
||||
APACHE_SITES_DIR=/etc/apache2/sites-available
|
||||
elif [ -d "/etc/apache2/conf.d" ]; then
|
||||
APACHE_SITES_DIR=/etc/apache2/conf.d
|
||||
else
|
||||
echo "**** Apache is not available"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -f "/usr/sbin/a2dissite" ]; then
|
||||
echo "** Disable default site"
|
||||
/usr/sbin/a2dissite 000-default 1>/dev/null
|
||||
rm -rf "$APACHE_SITES_DIR/*"
|
||||
elif [ -f "/etc/apache2/conf.d/default.conf" ]; then
|
||||
echo "** Disable default site"
|
||||
rm -f "/etc/apache2/conf.d/default.conf"
|
||||
fi
|
||||
|
||||
echo "** Adding Zabbix virtual host (HTTP)"
|
||||
if [ -f "$ZABBIX_ETC_DIR/apache.conf" ]; then
|
||||
ln -s "$ZABBIX_ETC_DIR/apache.conf" "$APACHE_SITES_DIR/zabbix.conf"
|
||||
if [ -f "/usr/sbin/a2dissite" ]; then
|
||||
/usr/sbin/a2ensite zabbix.conf 1>/dev/null
|
||||
fi
|
||||
else
|
||||
echo "**** Impossible to enable HTTP virtual host"
|
||||
fi
|
||||
|
||||
if [ -f "/etc/apache2/conf.d/ssl.conf" ]; then
|
||||
rm -f "/etc/apache2/conf.d/ssl.conf"
|
||||
fi
|
||||
|
||||
if [ -f "/etc/ssl/apache2/ssl.crt" ] && [ -f "/etc/ssl/apache2/ssl.key" ]; then
|
||||
echo "** Enable SSL support for Apache2"
|
||||
if [ -f "/usr/sbin/a2enmod" ]; then
|
||||
/usr/sbin/a2enmod ssl 1>/dev/null
|
||||
fi
|
||||
|
||||
echo "** Adding Zabbix virtual host (HTTPS)"
|
||||
if [ -f "$ZABBIX_ETC_DIR/apache_ssl.conf" ]; then
|
||||
ln -s "$ZABBIX_ETC_DIR/apache_ssl.conf" "$APACHE_SITES_DIR/zabbix_ssl.conf"
|
||||
if [ -f "/usr/sbin/a2dissite" ]; then
|
||||
/usr/sbin/a2ensite zabbix_ssl.conf 1>/dev/null
|
||||
fi
|
||||
else
|
||||
echo "**** Impossible to enable HTTPS virtual host"
|
||||
fi
|
||||
else
|
||||
echo "**** Impossible to enable SSL support for Apache2. Certificates are missed."
|
||||
fi
|
||||
|
||||
# Change Apache2 logging to stdout and stderr
|
||||
if [ -f "/etc/apache2/apache2.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/apache2/apache2.conf"
|
||||
fi
|
||||
|
||||
if [ -f "/etc/apache2/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/apache2/httpd.conf"
|
||||
fi
|
||||
|
||||
if [ -f "/etc/apache2/conf-available/other-vhosts-access-log.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/apache2/conf-available/other-vhosts-access-log.conf"
|
||||
fi
|
||||
|
||||
if [ -f "/etc/apache2/conf.d/mpm.conf" ]; then
|
||||
sed -ri \
|
||||
-e 's!^(\s*PidFile)\s+\S+!\1 "/var/run/httpd.pid"!g' \
|
||||
"/etc/apache2/conf.d/mpm.conf"
|
||||
fi
|
||||
|
||||
if [ -f "/var/run/apache2/apache2.pid" ]; then
|
||||
rm -f "/var/run/apache2/apache2.pid"
|
||||
fi
|
||||
}
|
||||
|
||||
prepare_web_server_nginx() {
|
||||
NGINX_CONFD_DIR="/etc/nginx/conf.d"
|
||||
NGINX_SSL_CONFIG="/etc/ssl/nginx"
|
||||
PHP_SESSIONS_DIR="/var/lib/php5"
|
||||
|
||||
echo "** Disable default vhosts"
|
||||
rm -f $NGINX_CONFD_DIR/*.conf
|
||||
|
||||
echo "** Adding Zabbix virtual host (HTTP)"
|
||||
if [ -f "$ZABBIX_ETC_DIR/nginx.conf" ]; then
|
||||
ln -s "$ZABBIX_ETC_DIR/nginx.conf" "$NGINX_CONFD_DIR"
|
||||
else
|
||||
echo "**** Impossible to enable HTTP virtual host"
|
||||
fi
|
||||
|
||||
if [ -f "$NGINX_SSL_CONFIG/ssl.crt" ] && [ -f "$NGINX_SSL_CONFIG/ssl.key" ] && [ -f "$NGINX_SSL_CONFIG/dhparam.pem" ]; then
|
||||
echo "** Enable SSL support for Nginx"
|
||||
if [ -f "$ZABBIX_ETC_DIR/nginx_ssl.conf" ]; then
|
||||
ln -s "$ZABBIX_ETC_DIR/nginx_ssl.conf" "$NGINX_CONFD_DIR"
|
||||
else
|
||||
echo "**** Impossible to enable HTTPS virtual host"
|
||||
fi
|
||||
else
|
||||
echo "**** Impossible to enable SSL support for Nginx. Certificates are missed."
|
||||
fi
|
||||
|
||||
if [ -d "/var/log/nginx/" ]; then
|
||||
ln -sf /dev/fd/2 /var/log/nginx/error.log
|
||||
fi
|
||||
|
||||
ln -sf /dev/fd/2 /var/log/php5-fpm.log
|
||||
}
|
||||
|
||||
clear_deploy() {
|
||||
local type=$1
|
||||
echo "** Cleaning the system"
|
||||
|
||||
[ "$type" != "dev" ] && return
|
||||
}
|
||||
|
||||
update_zbx_config() {
|
||||
local type=$1
|
||||
local db_type=$2
|
||||
|
||||
echo "** Preparing Zabbix $type configuration file"
|
||||
|
||||
ZBX_CONFIG=$ZABBIX_ETC_DIR/zabbix_$type.conf
|
||||
|
||||
if [ "$type" == "proxy" ]; then
|
||||
update_config_var $ZBX_CONFIG "ProxyMode" "${ZBX_PROXYMODE}"
|
||||
update_config_var $ZBX_CONFIG "Server" "${ZBX_SERVER_HOST}"
|
||||
update_config_var $ZBX_CONFIG "ServerPort" "${ZBX_SERVER_PORT}"
|
||||
update_config_var $ZBX_CONFIG "Hostname" "${ZBX_HOSTNAME:-"zabbix-proxy-"$db_type}"
|
||||
update_config_var $ZBX_CONFIG "HostnameItem" "${ZBX_HOSTNAMEITEM}"
|
||||
fi
|
||||
|
||||
if [ $type == "proxy" ] && [ "${ZBX_ADD_SERVER}" = "true" ]; then
|
||||
update_config_var $ZBX_CONFIG "ListenPort" "10061"
|
||||
else
|
||||
update_config_var $ZBX_CONFIG "ListenPort"
|
||||
fi
|
||||
update_config_var $ZBX_CONFIG "SourceIP"
|
||||
update_config_var $ZBX_CONFIG "LogType" "console"
|
||||
update_config_var $ZBX_CONFIG "LogFile"
|
||||
update_config_var $ZBX_CONFIG "LogFileSize"
|
||||
update_config_var $ZBX_CONFIG "PidFile"
|
||||
|
||||
update_config_var $ZBX_CONFIG "DebugLevel" "${ZBX_DEBUGLEVEL}"
|
||||
|
||||
if [ "$db_type" == "sqlite3" ]; then
|
||||
update_config_var $ZBX_CONFIG "DBHost"
|
||||
update_config_var $ZBX_CONFIG "DBName" "/var/lib/zabbix/zabbix_proxy_db"
|
||||
update_config_var $ZBX_CONFIG "DBUser"
|
||||
update_config_var $ZBX_CONFIG "DBPort"
|
||||
update_config_var $ZBX_CONFIG "DBPassword"
|
||||
else
|
||||
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
||||
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
||||
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
||||
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
||||
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
||||
fi
|
||||
|
||||
if [ "$type" == "proxy" ]; then
|
||||
update_config_var $ZBX_CONFIG "ProxyLocalBuffer" "${ZBX_PROXYLOCALBUFFER}"
|
||||
update_config_var $ZBX_CONFIG "ProxyOfflineBuffer" "${ZBX_PROXYOFFLINEBUFFER}"
|
||||
update_config_var $ZBX_CONFIG "HeartbeatFrequency" "${ZBX_PROXYHEARTBEATFREQUENCY}"
|
||||
update_config_var $ZBX_CONFIG "ConfigFrequency" "${ZBX_CONFIGFREQUENCY}"
|
||||
update_config_var $ZBX_CONFIG "DataSenderFrequency" "${ZBX_DATASENDERFREQUENCY}"
|
||||
fi
|
||||
|
||||
update_config_var $ZBX_CONFIG "StartPollers" "${ZBX_STARTPOLLERS}"
|
||||
update_config_var $ZBX_CONFIG "StartIPMIPollers" "${ZBX_IPMIPOLLERS}"
|
||||
update_config_var $ZBX_CONFIG "StartPollersUnreachable" "${ZBX_STARTPOLLERSUNREACHABLE}"
|
||||
update_config_var $ZBX_CONFIG "StartTrappers" "${ZBX_STARTTRAPPERS}"
|
||||
update_config_var $ZBX_CONFIG "StartPingers" "${ZBX_STARTPINGERS}"
|
||||
update_config_var $ZBX_CONFIG "StartDiscoverers" "${ZBX_STARTDISCOVERERS}"
|
||||
update_config_var $ZBX_CONFIG "StartHTTPPollers" "${ZBX_STARTHTTPPOLLERS}"
|
||||
|
||||
if [ "$type" == "server" ]; then
|
||||
update_config_var $ZBX_CONFIG "StartTimers" "${ZBX_STARTTIMERS}"
|
||||
update_config_var $ZBX_CONFIG "StartEscalators" "${ZBX_STARTESCALATORS}"
|
||||
fi
|
||||
|
||||
ZBX_JAVAGATEWAY_ENABLE=${ZBX_JAVAGATEWAY_ENABLE:-"false"}
|
||||
if [ "${ZBX_JAVAGATEWAY_ENABLE}" == "true" ]; then
|
||||
update_config_var $ZBX_CONFIG "JavaGateway" "${ZBX_JAVAGATEWAY:-"zabbix-java-gateway"}"
|
||||
update_config_var $ZBX_CONFIG "JavaGatewayPort" "${ZBX_JAVAGATEWAYPORT}"
|
||||
update_config_var $ZBX_CONFIG "StartJavaPollers" "${ZBX_STARTJAVAPOLLERS:-"5"}"
|
||||
else
|
||||
update_config_var $ZBX_CONFIG "JavaGateway"
|
||||
update_config_var $ZBX_CONFIG "JavaGatewayPort"
|
||||
update_config_var $ZBX_CONFIG "StartJavaPollers"
|
||||
fi
|
||||
|
||||
update_config_var $ZBX_CONFIG "StartVMwareCollectors" "${ZBX_STARTVMWARECOLLECTORS}"
|
||||
update_config_var $ZBX_CONFIG "VMwareFrequency" "${ZBX_VMWAREFREQUENCY}"
|
||||
update_config_var $ZBX_CONFIG "VMwarePerfFrequency" "${ZBX_VMWAREPERFFREQUENCY}"
|
||||
update_config_var $ZBX_CONFIG "VMwareCacheSize" "${ZBX_VMWARECACHESIZE}"
|
||||
update_config_var $ZBX_CONFIG "VMwareTimeout" "${ZBX_VMWARETIMEOUT}"
|
||||
|
||||
ZBX_ENABLE_SNMP_TRAPS=${ZBX_ENABLE_SNMP_TRAPS:-"false"}
|
||||
if [ "${ZBX_ENABLE_SNMP_TRAPS}" == "true" ]; then
|
||||
update_config_var $ZBX_CONFIG "SNMPTrapperFile" "${ZABBIX_USER_HOME_DIR}/snmptraps/snmptraps.log"
|
||||
update_config_var $ZBX_CONFIG "StartSNMPTrapper" "1"
|
||||
else
|
||||
update_config_var $ZBX_CONFIG "SNMPTrapperFile"
|
||||
update_config_var $ZBX_CONFIG "StartSNMPTrapper"
|
||||
fi
|
||||
|
||||
update_config_var $ZBX_CONFIG "HousekeepingFrequency" "${ZBX_HOUSEKEEPINGFREQUENCY}"
|
||||
if [ "$type" == "server" ]; then
|
||||
update_config_var $ZBX_CONFIG "MaxHousekeeperDelete" "${ZBX_MAXHOUSEKEEPERDELETE}"
|
||||
update_config_var $ZBX_CONFIG "SenderFrequency" "${ZBX_SENDERFREQUENCY}"
|
||||
fi
|
||||
|
||||
update_config_var $ZBX_CONFIG "CacheSize" "${ZBX_CACHESIZE}"
|
||||
|
||||
if [ "$type" == "server" ]; then
|
||||
update_config_var $ZBX_CONFIG "CacheUpdateFrequency" "${ZBX_CACHEUPDATEFREQUENCY}"
|
||||
fi
|
||||
|
||||
update_config_var $ZBX_CONFIG "StartDBSyncers" "${ZBX_STARTDBSYNCERS}"
|
||||
update_config_var $ZBX_CONFIG "HistoryCacheSize" "${ZBX_HISTORYCACHESIZE}"
|
||||
update_config_var $ZBX_CONFIG "HistoryIndexCacheSize" "${ZBX_HISTORYINDEXCACHESIZE}"
|
||||
|
||||
if [ "$type" == "server" ]; then
|
||||
update_config_var $ZBX_CONFIG "TrendCacheSize" "${ZBX_TRENDCACHESIZE}"
|
||||
update_config_var $ZBX_CONFIG "ValueCacheSize" "${ZBX_VALUECACHESIZE}"
|
||||
fi
|
||||
|
||||
update_config_var $ZBX_CONFIG "Timeout" "${ZBX_TIMEOUT}"
|
||||
update_config_var $ZBX_CONFIG "TrapperTimeout" "${ZBX_TRAPPERIMEOUT}"
|
||||
update_config_var $ZBX_CONFIG "UnreachablePeriod" "${ZBX_UNREACHABLEPERIOD}"
|
||||
update_config_var $ZBX_CONFIG "UnavailableDelay" "${ZBX_UNAVAILABLEDELAY}"
|
||||
update_config_var $ZBX_CONFIG "UnreachableDelay" "${ZBX_UNREACHABLEDELAY}"
|
||||
|
||||
update_config_var $ZBX_CONFIG "AlertScriptsPath" "/usr/lib/zabbix/alertscripts"
|
||||
update_config_var $ZBX_CONFIG "ExternalScripts" "/usr/lib/zabbix/externalscripts"
|
||||
|
||||
# Possible few fping locations
|
||||
if [ -f "/usr/bin/fping" ]; then
|
||||
update_config_var $ZBX_CONFIG "FpingLocation" "/usr/bin/fping"
|
||||
else
|
||||
update_config_var $ZBX_CONFIG "FpingLocation" "/usr/sbin/fping"
|
||||
fi
|
||||
if [ -f "/usr/bin/fping6" ]; then
|
||||
update_config_var $ZBX_CONFIG "Fping6Location" "/usr/bin/fping6"
|
||||
else
|
||||
update_config_var $ZBX_CONFIG "Fping6Location" "/usr/sbin/fping6"
|
||||
fi
|
||||
|
||||
update_config_var $ZBX_CONFIG "SSHKeyLocation" "$ZABBIX_USER_HOME_DIR/ssh_keys"
|
||||
update_config_var $ZBX_CONFIG "LogSlowQueries" "${ZBX_LOGSLOWQUERIES}"
|
||||
|
||||
if [ "$type" == "server" ]; then
|
||||
update_config_var $ZBX_CONFIG "StartProxyPollers" "${ZBX_STARTPROXYPOLLERS}"
|
||||
update_config_var $ZBX_CONFIG "ProxyConfigFrequency" "${ZBX_PROXYCONFIGFREQUENCY}"
|
||||
update_config_var $ZBX_CONFIG "ProxyDataFrequency" "${ZBX_PROXYDATAFREQUENCY}"
|
||||
fi
|
||||
|
||||
update_config_var $ZBX_CONFIG "SSLCertLocation" "$ZABBIX_USER_HOME_DIR/ssl/certs/"
|
||||
update_config_var $ZBX_CONFIG "SSLKeyLocation" "$ZABBIX_USER_HOME_DIR/ssl/keys/"
|
||||
update_config_var $ZBX_CONFIG "SSLCALocation" "$ZABBIX_USER_HOME_DIR/ssl/ssl_ca/"
|
||||
update_config_var $ZBX_CONFIG "LoadModulePath" "$ZABBIX_USER_HOME_DIR/modules/"
|
||||
update_config_multiple_var $ZBX_CONFIG "LoadModule" "${ZBX_LOADMODULE}"
|
||||
|
||||
if [ "$type" == "proxy" ]; then
|
||||
update_config_var $ZBX_CONFIG "TLSConnect" "${ZBX_TLSCONNECT}"
|
||||
update_config_var $ZBX_CONFIG "TLSAccept" "${ZBX_TLSACCEPT}"
|
||||
fi
|
||||
update_config_var $ZBX_CONFIG "TLSCAFile" "${ZBX_TLSCAFILE}"
|
||||
update_config_var $ZBX_CONFIG "TLSCRLFile" "${ZBX_TLSCRLFILE}"
|
||||
|
||||
if [ "$type" == "proxy" ]; then
|
||||
update_config_var $ZBX_CONFIG "TLSServerCertIssuer" "${ZBX_TLSSERVERCERTISSUER}"
|
||||
update_config_var $ZBX_CONFIG "TLSServerCertSubject" "${ZBX_TLSSERVERCERTSUBJECT}"
|
||||
fi
|
||||
|
||||
update_config_var $ZBX_CONFIG "TLSCertFile" "${ZBX_TLSCERTFILE}"
|
||||
update_config_var $ZBX_CONFIG "TLSKeyFile" "${ZBX_TLSKEYFILE}"
|
||||
|
||||
if [ "$type" == "proxy" ]; then
|
||||
update_config_var $ZBX_CONFIG "TLSPSKIdentity" "${ZBX_TLSPSKIDENTITY}"
|
||||
update_config_var $ZBX_CONFIG "TLSPSKFile" "${ZBX_TLSPSKFILE}"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
prepare_zbx_web_config() {
|
||||
local db_type=$1
|
||||
local server_name=""
|
||||
|
||||
echo "** Preparing Zabbix frontend configuration file"
|
||||
|
||||
ZBX_WEB_CONFIG="$ZABBIX_ETC_DIR/web/zabbix.conf.php"
|
||||
|
||||
if [ -f "/usr/share/zabbix/conf/zabbix.conf.php" ]; then
|
||||
rm -f "/usr/share/zabbix/conf/zabbix.conf.php"
|
||||
fi
|
||||
|
||||
ln -s "$ZBX_WEB_CONFIG" "/usr/share/zabbix/conf/zabbix.conf.php"
|
||||
|
||||
# Different places of PHP configuration file
|
||||
if [ -f "/etc/php5/conf.d/99-zabbix.ini" ]; then
|
||||
PHP_CONFIG_FILE="/etc/php5/conf.d/99-zabbix.ini"
|
||||
elif [ -f "/etc/php5/fpm/conf.d/99-zabbix.ini" ]; then
|
||||
PHP_CONFIG_FILE="/etc/php5/fpm/conf.d/99-zabbix.ini"
|
||||
elif [ -f "/etc/php5/apache2/conf.d/99-zabbix.ini" ]; then
|
||||
PHP_CONFIG_FILE="/etc/php5/apache2/conf.d/99-zabbix.ini"
|
||||
elif [ -f "/etc/php/7.0/apache2/conf.d/99-zabbix.ini" ]; then
|
||||
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"
|
||||
fi
|
||||
|
||||
if [ -n "$PHP_CONFIG_FILE" ]; then
|
||||
update_config_var "$PHP_CONFIG_FILE" "max_execution_time" "${ZBX_MAXEXECUTIONTIME:-"600"}"
|
||||
update_config_var "$PHP_CONFIG_FILE" "memory_limit" "${ZBX_MEMORYLIMIT:-"128M"}"
|
||||
update_config_var "$PHP_CONFIG_FILE" "post_max_size" "${ZBX_POSTMAXSIZE:-"16M"}"
|
||||
update_config_var "$PHP_CONFIG_FILE" "upload_max_filesize" "${ZBX_UPLOADMAXFILESIZE:-"2M"}"
|
||||
update_config_var "$PHP_CONFIG_FILE" "max_input_time" "${ZBX_MAXINPUTTIME:-"300"}"
|
||||
update_config_var "$PHP_CONFIG_FILE" "date.timezone" "${TZ}"
|
||||
else
|
||||
echo "**** Zabbix related PHP configuration file not found"
|
||||
fi
|
||||
|
||||
# Escaping "/" character in parameter value
|
||||
server_name=${ZBX_SERVER_NAME//\//\\/}
|
||||
|
||||
sed -i \
|
||||
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
||||
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
||||
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
||||
-e "s/{DB_SERVER_USER}/${DB_SERVER_ZBX_USER}/g" \
|
||||
-e "s/{DB_SERVER_PASS}/${DB_SERVER_ZBX_PASS}/g" \
|
||||
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
||||
-e "s/{ZBX_SERVER_PORT}/${ZBX_SERVER_PORT}/g" \
|
||||
-e "s/{ZBX_SERVER_NAME}/$server_name/g" \
|
||||
"$ZBX_WEB_CONFIG"
|
||||
|
||||
[ "$db_type" = "postgresql" ] && sed -i "s/MYSQL/POSTGRESQL/g" "$ZBX_WEB_CONFIG"
|
||||
}
|
||||
|
||||
prepare_zbx_agent_config() {
|
||||
echo "** Preparing Zabbix agent configuration file"
|
||||
|
||||
ZBX_AGENT_CONFIG=$ZABBIX_ETC_DIR/zabbix_agentd.conf
|
||||
|
||||
ZBX_PASSIVESERVERS=${ZBX_PASSIVESERVERS:-""}
|
||||
ZBX_ACTIVESERVERS=${ZBX_ACTIVESERVERS:-""}
|
||||
|
||||
[ -n "$ZBX_PASSIVESERVERS" ] && ZBX_PASSIVESERVERS=","$ZBX_PASSIVESERVERS
|
||||
|
||||
ZBX_PASSIVESERVERS=$ZBX_SERVER_HOST$ZBX_PASSIVESERVERS
|
||||
|
||||
[ -n "$ZBX_ACTIVESERVERS" ] && ZBX_ACTIVESERVERS=","$ZBX_ACTIVESERVERS
|
||||
|
||||
ZBX_ACTIVESERVERS=$ZBX_SERVER_HOST":"$ZBX_SERVER_PORT$ZBX_ACTIVESERVERS
|
||||
|
||||
update_config_var $ZBX_AGENT_CONFIG "PidFile"
|
||||
update_config_var $ZBX_AGENT_CONFIG "LogType" "console"
|
||||
update_config_var $ZBX_AGENT_CONFIG "LogFile"
|
||||
update_config_var $ZBX_AGENT_CONFIG "LogFileSize"
|
||||
update_config_var $ZBX_AGENT_CONFIG "DebugLevel" "${ZBX_DEBUGLEVEL}"
|
||||
update_config_var $ZBX_AGENT_CONFIG "SourceIP"
|
||||
update_config_var $ZBX_AGENT_CONFIG "EnableRemoteCommands" "${ZBX_ENABLEREMOTECOMMANDS}"
|
||||
update_config_var $ZBX_AGENT_CONFIG "LogRemoteCommands" "${ZBX_LOGREMOTECOMMANDS}"
|
||||
|
||||
ZBX_PASSIVE_ALLOW=${ZBX_PASSIVE_ALLOW:-"true"}
|
||||
if [ "$ZBX_PASSIVE_ALLOW" == "true" ]; then
|
||||
echo "** Using '$ZBX_PASSIVESERVERS' servers for passive checks"
|
||||
update_config_var $ZBX_AGENT_CONFIG "Server" "${ZBX_PASSIVESERVERS}"
|
||||
else
|
||||
update_config_var $ZBX_AGENT_CONFIG "Server"
|
||||
fi
|
||||
|
||||
update_config_var $ZBX_AGENT_CONFIG "ListenPort"
|
||||
update_config_var $ZBX_AGENT_CONFIG "ListenIP"
|
||||
update_config_var $ZBX_AGENT_CONFIG "StartAgents" "${ZBX_STARTAGENTS}"
|
||||
|
||||
ZBX_ACTIVE_ALLOW=${ZBX_ACTIVE_ALLOW:-"true"}
|
||||
if [ "$ZBX_ACTIVE_ALLOW" == "true" ]; then
|
||||
echo "** Using '$ZBX_ACTIVESERVERS' servers for active checks"
|
||||
update_config_var $ZBX_AGENT_CONFIG "ServerActive" "${ZBX_ACTIVESERVERS}"
|
||||
else
|
||||
update_config_var $ZBX_AGENT_CONFIG "ServerActive"
|
||||
fi
|
||||
|
||||
update_config_var $ZBX_AGENT_CONFIG "Hostname" "${ZBX_HOSTNAME}"
|
||||
update_config_var $ZBX_AGENT_CONFIG "HostnameItem" "${ZBX_HOSTNAMEITEM}"
|
||||
update_config_var $ZBX_AGENT_CONFIG "HostMetadata" "${ZBX_METADATA}"
|
||||
update_config_var $ZBX_AGENT_CONFIG "HostMetadataItem" "${ZBX_METADATAITEM}"
|
||||
update_config_var $ZBX_AGENT_CONFIG "RefreshActiveChecks" "${ZBX_REFRESHACTIVECHECKS}"
|
||||
update_config_var $ZBX_AGENT_CONFIG "BufferSend" "${ZBX_BUFFERSEND}"
|
||||
update_config_var $ZBX_AGENT_CONFIG "BufferSize" "${ZBX_BUFFERSIZE}"
|
||||
update_config_var $ZBX_AGENT_CONFIG "MaxLinesPerSecond" "${ZBX_MAXLINESPERSECOND}"
|
||||
# update_config_multiple_var $ZBX_AGENT_CONFIG "Alias" ${ZBX_ALIAS}
|
||||
update_config_var $ZBX_AGENT_CONFIG "Timeout" "${ZBX_TIMEOUT}"
|
||||
update_config_var $ZBX_AGENT_CONFIG "Include" "/etc/zabbix/zabbix_agentd.d/"
|
||||
update_config_var $ZBX_AGENT_CONFIG "UnsafeUserParameters" "${ZBX_UNSAFEUSERPARAMETERS}"
|
||||
update_config_var $ZBX_AGENT_CONFIG "LoadModulePath" "$ZABBIX_USER_HOME_DIR/modules/"
|
||||
update_config_multiple_var $ZBX_AGENT_CONFIG "LoadModule" "${ZBX_LOADMODULE}"
|
||||
update_config_var $ZBX_AGENT_CONFIG "TLSConnect" "${ZBX_TLSCONNECT}"
|
||||
update_config_var $ZBX_AGENT_CONFIG "TLSAccept" "${ZBX_TLSACCEPT}"
|
||||
update_config_var $ZBX_AGENT_CONFIG "TLSCAFile" "${ZBX_TLSCAFILE}"
|
||||
update_config_var $ZBX_AGENT_CONFIG "TLSCRLFile" "${ZBX_TLSCRLFILE}"
|
||||
update_config_var $ZBX_AGENT_CONFIG "TLSServerCertIssuer" "${ZBX_TLSSERVERCERTISSUER}"
|
||||
update_config_var $ZBX_AGENT_CONFIG "TLSServerCertSubject" "${ZBX_TLSSERVERCERTSUBJECT}"
|
||||
update_config_var $ZBX_AGENT_CONFIG "TLSCertFile" "${ZBX_TLSCERTFILE}"
|
||||
update_config_var $ZBX_AGENT_CONFIG "TLSKeyFile" "${ZBX_TLSKEYFILE}"
|
||||
update_config_var $ZBX_AGENT_CONFIG "TLSPSKIdentity" "${ZBX_TLSPSKIDENTITY}"
|
||||
update_config_var $ZBX_AGENT_CONFIG "TLSPSKFile" "${ZBX_TLSPSKFILE}"
|
||||
}
|
||||
|
||||
prepare_java_gateway_config() {
|
||||
echo "** Preparing Zabbix Java Gateway log configuration file"
|
||||
|
||||
ZBX_GATEWAY_CONFIG=$ZABBIX_ETC_DIR/zabbix_java_gateway_logback.xml
|
||||
|
||||
if [ -n "${ZBX_DEBUGLEVEL}" ]; then
|
||||
echo "Updating $ZBX_GATEWAY_CONFIG 'DebugLevel' parameter: '${ZBX_DEBUGLEVEL}'... updated"
|
||||
if [ -f "$ZBX_GATEWAY_CONFIG" ]; then
|
||||
sed -i -e "/^.*<root level=/s/=.*/=\"${ZBX_DEBUGLEVEL}\">/" "$ZBX_GATEWAY_CONFIG"
|
||||
else
|
||||
echo "**** Zabbix Java Gateway log configuration file '$ZBX_GATEWAY_CONFIG' not found"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
prepare_agent() {
|
||||
echo "** Preparing Zabbix agent"
|
||||
prepare_zbx_agent_config
|
||||
}
|
||||
|
||||
prepare_server() {
|
||||
local db_type=$1
|
||||
|
||||
echo "** Preparing Zabbix server"
|
||||
|
||||
check_variables_$db_type "server"
|
||||
check_db_connect_$db_type
|
||||
create_db_user_$db_type
|
||||
create_db_database_$db_type
|
||||
create_db_schema_$db_type "server"
|
||||
|
||||
update_zbx_config "server" "$db_type"
|
||||
}
|
||||
|
||||
prepare_proxy() {
|
||||
local db_type=$1
|
||||
|
||||
echo "Preparing Zabbix proxy"
|
||||
|
||||
if [ "$db_type" != "sqlite3" ]; then
|
||||
check_variables_$db_type "proxy"
|
||||
check_db_connect_$db_type
|
||||
create_db_user_$db_type
|
||||
create_db_database_$db_type
|
||||
create_db_schema_$db_type "proxy"
|
||||
fi
|
||||
|
||||
update_zbx_config "proxy" $db_type
|
||||
}
|
||||
|
||||
prepare_web() {
|
||||
local web_server=$1
|
||||
local db_type=$2
|
||||
|
||||
echo "** Preparing Zabbix web-interface"
|
||||
|
||||
check_variables_$db_type
|
||||
check_db_connect_$db_type
|
||||
prepare_web_server_$web_server
|
||||
prepare_zbx_web_config $db_type
|
||||
}
|
||||
|
||||
prepare_java_gateway() {
|
||||
echo "** Preparing Zabbix Java Gateway"
|
||||
|
||||
prepare_java_gateway_config
|
||||
}
|
||||
|
||||
#################################################
|
||||
|
||||
if [ ! -n "$zbx_type" ]; then
|
||||
echo "**** Type of Zabbix component is not specified"
|
||||
exit 1
|
||||
elif [ "$zbx_type" == "dev" ]; then
|
||||
echo "** Deploying Zabbix installation from SVN"
|
||||
else
|
||||
if [ ! -n "$zbx_db_type" ]; then
|
||||
echo "**** Database type of Zabbix $zbx_type is not specified"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -n "$zbx_db_type" ]; then
|
||||
if [ -n "$zbx_opt_type" ]; then
|
||||
echo "** Deploying Zabbix $zbx_type ($zbx_opt_type) with $zbx_db_type database"
|
||||
else
|
||||
echo "** Deploying Zabbix $zbx_type with $zbx_db_type database"
|
||||
fi
|
||||
else
|
||||
echo "** Deploying Zabbix $zbx_type"
|
||||
fi
|
||||
fi
|
||||
|
||||
prepare_system "$zbx_type" "$zbx_opt_type"
|
||||
|
||||
[ "$zbx_type" == "server" ] && prepare_server $zbx_db_type
|
||||
[ "${ZBX_ADD_SERVER}" == "true" ] && prepare_server ${ZBX_MAIN_DB}
|
||||
|
||||
[ "$zbx_type" == "proxy" ] && prepare_proxy $zbx_db_type
|
||||
[ "${ZBX_ADD_PROXY}" == "true" ] && prepare_proxy ${ZBX_PROXY_DB}
|
||||
|
||||
[ "$zbx_type" == "frontend" ] && prepare_web $zbx_opt_type $zbx_db_type
|
||||
[ "${ZBX_ADD_WEB}" == "true" ] && prepare_web ${ZBX_WEB_SERVER} ${ZBX_MAIN_DB}
|
||||
|
||||
[ "$zbx_type" == "agentd" ] && prepare_agent
|
||||
[ "${ZBX_ADD_AGENT}" == "true" ] && prepare_agent
|
||||
|
||||
[ "$zbx_type" == "java-gateway" ] && prepare_java_gateway
|
||||
[ "${ZBX_ADD_JAVA_GATEWAY}" == "true" ] && prepare_java_gateway
|
||||
|
||||
clear_deploy "$zbx_type"
|
||||
|
||||
echo "########################################################"
|
||||
|
||||
echo "** Executing supervisord"
|
||||
exec /usr/bin/supervisord -c /etc/supervisor/supervisord.conf
|
||||
|
||||
#################################################
|
Loading…
Reference in New Issue
Block a user