Sign inSign up

monitoringartist/zabbix-xxl

By monitoringartist

Updated over 8 years ago

Zabbix 3.x - server, web, proxy, java gateway, snmpd with additional XXL community extensions

Image
71

1M+

monitoringartist/zabbix-xxl repository overview

Zabbix XXL

Zabbix XXL is a standard Zabbix prepared for Docker world. You must install Zabbix package (rpm, deb, ...) in the old world. Similarly, you need to pull Zabbix Docker image in the Docker world. This Docker image contains standard Zabbix + additional XXL (community) extensions. Routine tasks such as import of Zabbix DB are automated, so it's prepared for easy deployment.

If you like or use this project, please provide feedback to author - Star it ★.

Overview of Monitoring Artist (dockerized) monitoring ecosystem:

zabbix-xxl (Zabbix 3.0/3.2) Deploy to Docker Cloud

Compiled Zabbix (server, proxy, agent, java gateway, snmpd daemon) with almost all features (MySQL support, Java, SNMP, Curl, Ipmi, SSH, fping) and Zabbix web UI based on CentOS 7, Supervisor, Nginx, PHP. Image requires external MySQL/MariDB database (you can run MySQL/MariaDB as a Docker container). Integated XXL extensions: Searcher, Grapher, Zapix, template auto import, API command/script execution (some extensions must be explicitly enabled - see env variables section).

Zabbix XXL Zabbix searcher Zabbix XXL Zapix Zabbix XXL Grapher Zabbix XXL Update Checker

Standard Dockerized Zabbix deployment
# create /var/lib/mysql as persistent volume storage
docker run -d -v /var/lib/mysql --name zabbix-db-storage busybox:latest

# start DB for Zabbix - default 1GB innodb_buffer_pool_size is used
docker run \
    -d \
    --name zabbix-db \
    -v /backups:/backups \
    -v /etc/localtime:/etc/localtime:ro \
    --volumes-from zabbix-db-storage \
    --env="MARIADB_USER=zabbix" \
    --env="MARIADB_PASS=my_password" \
    monitoringartist/zabbix-db-mariadb

# start Zabbix linked to started DB
docker run \
    -d \
    --name zabbix \
    -p 80:80 \
    -p 10051:10051 \
    -v /etc/localtime:/etc/localtime:ro \
    --link zabbix-db:zabbix.db \
    --env="ZS_DBHost=zabbix.db" \
    --env="ZS_DBUser=zabbix" \
    --env="ZS_DBPassword=my_password" \
    monitoringartist/zabbix-xxl:latest
# wait ~60 seconds for Zabbix initialization
# Zabbix web will be available on the port 80, Zabbix server on the port 10051

Examples of admin tasks:

# Backup of DB Zabbix - configuration data only, no item history/trends
docker exec \
    -ti zabbix-db \
    /zabbix-backup/zabbix-mariadb-dump -u zabbix -p my_password -o /backups

# Full backup of Zabbix DB
docker exec \
    -ti zabbix-db \
    bash -c "\
    mysqldump -u zabbix -pmy_password zabbix | \
    bzip2 -cq9 > /backups/zabbix_db_dump_$(date +%Y-%m-%d-%H.%M.%S).sql.bz2"

# Restore Zabbix DB
# remove zabbix server container
docker rm -f zabbix
# restore data from dump (all current data will be dropped!!!)
docker exec -i zabbix-db sh -c 'bunzip2 -dc /backups/zabbix_db_dump_2016-05-25-02.57.46.sql.bz2 | mysql -uzabbix -p --password=my_password zabbix'
# run zabbix server again
docker run ...
Up and Running with Docker Compose
docker-compose up -d
Zabbix database as Docker container

To be able to connect to database we would need one to be running first. The easiest way to do that is to use another docker image. For this purpose you can use zabbix/zabbix-db-mariadb image as database.

For more information about monitoringartist/zabbix-db-mariadb see README of zabbix-db-mariadb.

Example:

docker run \
	-d \
	--name zabbix-db \
	-p 3306:3306 \
	-v /etc/localtime:/etc/localtime:ro \
	--env="MARIADB_USER=zabbix" \
	--env="MARIADB_PASS=my_password" \
	monitoringartist/zabbix-db-mariadb

Remember to use the same credentials when deploying zabbix image.

Environment variables

Environment variables for Zabbix server/proxy are not hardcoded. Just add correct variable prefix (ZS_ for Zabbix server,ZP_ for Zabbix Proxy) and setting name with value. For example if you need to set StartPollers=1000 for Zabbix server => use variable ZS_StartPollers=1000. If you don't specify environment variable for some setting, then default Zabbix value or Docker image variable value is used. See lists below for predefined Docker image variables.

Available variables related to XXL features:

VariableDefault value in the containerDescription
XXL_searchertrueenable/disable Zabbix searcher project
XXL_zapixfalseenable/disable Zapix project
XXL_grapherfalseenable/disable Grapher project
XXL_apitrueenable/disable auto import of templates (.xml), API curl commands (.curl) or API scripts (.sh) located in path /etc/zabbix/api/<custom_folder>
XXL_apiuserAdminusername used for API commands
XXL_apipasszabbixpassword used for API commands
XXL_analyticstrueenable/disable collecting of statistics via Google Analytics
XXL_updatecheckertrueenable/disable check of latest available Docker image

Use environment variables to config Zabbix and Zabbix web UI (PHP). Default container variables or default Zabbix are used:

VariableDefault value in the container
PHP_date_timezoneUTC
PHP_max_execution_time300
PHP_max_input_time300
PHP_memory_limit128M
PHP_error_reportingE_ALL
ZS_LogTypeconsole
ZS_PidFile/var/run/zabbix_server.pid
ZS_Userzabbix
ZS_DBHostzabbix.db
ZS_DBNamezabbix
ZS_DBUserzabbix
ZS_DBPasswordzabbix
ZS_DBPort3306
ZS_PidFile/tmp/zabbix_server.pid
ZS_AlertScriptsPath/usr/local/share/zabbix/alertscripts
ZS_ExternalScripts/usr/local/share/zabbix/externalscripts
ZS_SSLCertLocation/usr/local/share/zabbix/ssl/certs
ZS_SSLKeyLocation/usr/local/share/zabbix/ssl/keys
ZS_LoadModulePath/usr/lib/zabbix/modules
ZW_ZBX_SERVERlocalhost
ZW_ZBX_SERVER_PORT10051
ZW_ZBX_SERVER_NAMEZabbix Server
ZJ_LISTEN_IP0.0.0.0
ZJ_LISTEN_PORT10052
ZJ_PID_FILE/tmp/zabbix_java.pid
ZJ_START_POLLERS5
ZJ_TIMEOUT3
ZJ_LogLevelerror
ZJ_TCP_TIMEOUT3000
ZP_LogTypeconsole
ZP_DBHostzabbixproxy.db
ZP_DBNamezabbix
ZP_DBUserzabbix
ZP_DBPasswordzabbix
ZP_DBPort3306
ZP_Userzabbix

You can add more variables, just add correct variable prefix (ZS_ for Zabbix Server, ZP_ for Zabbix Proxy) and set your custom value. Use numeric suffix (_<NUM>) for multiple config parameters. Example:

ZS_LoadModule_1=module1.so
ZS_LoadModule_2=module2.so

Note: Japanese users might want to set env. variable ZBX_GRAPH_FONT_NAME=ipagp to support japanese font in graphs.

Configuration from volume

Full config files can be also used. Environment configs will be overridden by values from config files in this case. You need only to add /etc/custom-config/ volume:

-v /host/custom-config/:/etc/custom-config/

Available files:

FileDescription
php-zabbix.iniPHP configuration file
zabbix_server.confZabbix server configuration file
zabbix_proxy.confZabbix proxy configuration file
logback.xmlZabbix Java gateway log configuration file

Zabbix role environment variables:

VariableDefault value in the containerDescription
ZS_enabledtrueZabbix Server start
ZA_enabledtrueZabbix Agent start
ZW_enabledtrueZabbix Web UI start
ZP_enabledfalseZabbix Proxy start
ZJ_enabledfalseZabbix Java Gateway start
SNMPTRAP_enabledfalseSNMP trap process (port 162) start

All Zabbix server components are enabled by default except SNMP traps processing. However, users want to run dedicated Zabbix component per container. Typical use case is Zabbix web UI. Thanks to role environment variables are users able to execute many web UI containers, which helps to scale Zabbix as a service.

Zabbix deployment

Now when we have Zabbix database running we can deploy Zabbix image with appropriate environment variables set.

Example:

docker run \
	-d \
	--name zabbix \
	-p 80:80 \
	-p 10051:10051 \
	-v /etc/localtime:/etc/localtime:ro \
	--link zabbix-db:zabbix.db \
	--env="ZS_DBHost=zabbix.db" \
	--env="ZS_DBUser=zabbix" \
	--env="ZS_DBPassword=my_password" \
	monitoringartist/zabbix-xxl:latest
Access to Zabbix web interface

To log in into Zabbix web interface for the first time use credentials Admin:zabbix.

Access web interface under http://docker_host_ip

HTTPS web interface

Set up nginx - customize default.conf and then use volume to mount custom nginx configuration (for example -v /etc/https-zabbix-nginx.conf:/etc/nginx/hosts.d/default.conf) + mount also certificates used in your custom nginx conf file.

XXL API features

If env variable XXL_api is true (default value), then bootstrap script will try to find recursively any .xml, .api, .sh in /etc/zabbix/api. For example mount folder with your XML templates and script will try to import all your templates:

-v /myhosttemplatefolder/:/etc/zabbix/api/mytemplates
  • XML files: All *.xml file are processed as Zabbix XML template and script tries to import them by using Zabbix API. Default additional imported templates are basic Docker templates.

  • Api files: All *.api files are processed as data commands for Zabbix API. Standard curl command is used for execution. Request id <ID> and auth token <AUTH_TOKEN> are replaced automatically. Defaul API command is used to enable Zabbix server host:

{"jsonrpc":"2.0","method":"host.update","id":<ID>,"auth":"<AUTH_TOKEN>","params":{"hostid":"10084","status":0}}
  • Sh files: All *.sh* files are processed as scripts and they are intended for user custom API scripting. Env variables XXL_apiuser, XXL_apipass should be used for API authentication.

Docker troubleshooting

Use docker command to see if all required containers are up and running:

$ docker ps

Check logs of Zabbix container:

$ docker logs zabbix

Sometimes you might just want to review how things are deployed inside a running container, you can do this by executing a bash shell through docker's exec command:

docker exec -ti zabbix /bin/bash

History of an image and size of layers:

docker history --no-trunc=true monitoringartist/zabbix-xxl | tr -s ' ' | tail -n+2 | awk -F " ago " '{print $2}'

Run specific Zabbix version, e.g. 3.0.0 - just specify 3.0.0 tag for image:

	docker run \
		-d \
		--name zabbix \
		-p 80:80 \
		-p 10051:10051 \
		-v /etc/localtime:/etc/localtime:ro \
		--link zabbix-db:zabbix.db \
		--env="ZS_DBHost=zabbix.db" \
		--env="ZS_DBUser=zabbix" \
		--env="ZS_DBPassword=my_password" \
		monitoringartist/zabbix-xxl:3.0.0

Author

Devops Monitoring Expert, who loves monitoring systems, which start with letter Z. Those are Zabbix and Zenoss.

Professional devops / monitoring services:

Monitoring Artist

Tag summary

Content type

Image

Digest

Size

260.5 MB

Last updated

over 8 years ago

docker pull monitoringartist/zabbix-xxl