Sign inSign up

maksim77/zabbix

By maksim77

Updated over 10 years ago

Fork zabbix

Image
0

2.1K

maksim77/zabbix repository overview

Zabbix Community Dockerfiles

Zabbix Github repo is intended as a source for Zabbix Docker registry. Please use these community Zabbix Docker images, if you want to build/ship your own Zabbix Docker image.

zabbix-2.4 Deploy to Docker Cloud

Zabbix 2.4 is not supported - please use 3.0 version - http://www.zabbix.com/life_cycle_and_release_policy.php

Compiled zabbix with almost all features (MySQL support, Java, SNMP, Curl, IPMI, IPv6, Jabber, fping) and Zabbix web UI based on CentOS 7, Supervisor, Nginx, PHP. Image requires external MySQL/MariaDB database (you can run MySQL/MariaDB also as Docker container).

Standard Dockerized Zabbix deployement
# 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" \
    zabbix/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" \
    zabbix/zabbix-2.4
# wait ~60 seconds for Zabbix initialization
# Zabbix web UI will be available on the port 80, Zabbix server on the port 10051

# Backup of Zabbix configuration data only
docker exec \
    -ti zabbix-db \
    /zabbix-backup/zabbix-mariadb-dump -u zabbix -p my_password -o /backups

# Full DB backup of Zabbix
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"
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. Easiest way to do that is to use another docker image. For this purpose you can use [zabbix/zabbix-db-mariadb] (https://registry.hub.docker.com/u/zabbix/zabbix-db-mariadb) image as database.

For more information about zabbix/zabbix-db-mariadb see [README of zabbix-db-mariadb] (https://github.com/zabbix/zabbix-community-docker/tree/master/Dockerfile/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" \
	zabbix/zabbix-db-mariadb

Remember to use the same credentials when deploying zabbix image.

Environmental variables

You can use environmental variables to config Zabbix server and Zabbix web UI (PHP). Available variables:

VariableDefault value
PHP_date_timezoneUTC
PHP_max_execution_time300
PHP_max_input_time300
PHP_memory_limit128M
PHP_error_reportingE_ALL
ZS_ListenPort10051
ZS_SourceIP
ZS_LogFile/tmp/zabbix_server.log
ZS_LogFileSize10
ZS_DebugLevel3
ZS_PidFile/var/run/zabbix_server.pid
ZS_DBHostzabbix.db
ZS_DBNamezabbix
ZS_DBSchema
ZS_DBUserzabbix
ZS_DBPasswordzabbix
ZS_DBSocket/tmp/mysql.sock
ZS_DBPort3306
ZS_StartPollers5
ZS_StartPollersUnreachable1
ZS_StartTrappers5
ZS_StartPingers1
ZS_StartDiscoverers1
ZS_StartHTTPPollers1
ZS_StartTimers1
ZS_JavaGateway127.0.0.1
ZS_JavaGatewayPort10052
ZS_StartJavaPollers0
ZS_StartVMwareCollectors0
ZS_VMwareFrequency60
ZS_VMwarePerfFrequency60
ZS_VMwareCacheSize8M
ZS_VMwareTimeout10
ZS_SNMPTrapperFile/tmp/zabbix_traps.tmp
ZS_StartSNMPTrapper0
ZS_ListenIP0.0.0.0
ZS_HousekeepingFrequency1
ZS_MaxHousekeeperDelete500
ZS_SenderFrequency30
ZS_CacheSize8M
ZS_CacheUpdateFrequency60
ZS_StartDBSyncers4
ZS_HistoryCacheSize8M
ZS_TrendCacheSize4M
ZS_HistoryTextCacheSize16M
ZS_ValueCacheSize8M
ZS_Timeout3
ZS_TrapperTimeout300
ZS_UnreachablePeriod45
ZS_UnavailableDelay60
ZS_UnreachableDelay15
ZS_AlertScriptsPath/usr/local/share/zabbix/alertscripts
ZS_ExternalScripts/usr/local/share/zabbix/externalscripts
ZS_FpingLocation/usr/sbin/fping
ZS_Fping6Location/usr/sbin/fping6
ZS_SSHKeyLocation
ZS_LogSlowQueries0
ZS_TmpDir/tmp
ZS_StartProxyPollers1
ZS_ProxyConfigFrequency3600
ZS_ProxyDataFrequency1
ZS_AllowRoot0
ZS_Userzabbix
ZS_Include
ZS_SSLCertLocation/usr/local/share/zabbix/ssl/certs
ZS_SSLKeyLocation/usr/local/share/zabbix/ssl/keys
ZS_SSLCALocation
ZS_LoadModulePath/usr/lib/zabbix/modules
ZS_LoadModule
ZW_ZBX_SERVERlocalhost
ZW_ZBX_SERVER_PORT10051
ZW_ZBX_SERVER_NAMEZabbix Server
Configuration from volume

Full config files can be also used. Environment configs will be overriden 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 role environment variables:

VariableDefault valueDescription
ZS_enabledtrueZabbix Server enablement, DB operations will be enabled as well
ZA_enabledtrueZabbix Agent enablement, DB operations will be enabled as well
ZW_enabledtrueZabbix Web UI enablement, DB operations will be enabled as well
SNMPTRAP_enabledfalseSNMP trap process (port 162) enablement

All Zabbix components are enabled by default except SNMP traps proccessing. However users want to run dedicated Zabbix component per container. Typical use case is Zabbix web UI. Thanks to role environemnt 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 environmental 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" \
	zabbix/zabbix-2.4
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

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 zabbix/zabbix-2.4 | tr -s ' ' | tail -n+2 | awk -F " ago " '{print $2}'

Run specific Zabbix version, e.g. 2.4.4 - just specify 2.4.4 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" \
		zabbix/zabbix-2.4:2.4.4

Tag summary

Content type

Image

Digest

Size

217.8 MB

Last updated

over 10 years ago

docker pull maksim77/zabbix:3