Sign inSign up

blazed/zabbix-community-docker

By blazed

•Updated over 10 years ago

Zabbix docker

Image
0

322

blazed/zabbix-community-docker 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-3.0 Deploy to Docker Cloud

Compiled Zabbix (server, proxy, agent, java gateway) 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-3.0:latest
# wait ~60 seconds for Zabbix initialization
# Zabbix web 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 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
ZS_TLSCAFile
ZS_TLSCRLFile
ZS_TLSCertFile
ZS_TLSKeyFile
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
⁠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_proxy.confZabbix proxy configuration file
logback.xmlZabbix Java gateway log configuration file

Zabbix role environment variables:

VariableDefault valueDescription
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 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-3.0: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.

⁠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-3.0 | 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" \
		zabbix/zabbix-3.0:3.0.0

Tag summary

Content type

Image

Digest

Size

235.6 MB

Last updated

over 10 years ago

docker pull blazed/zabbix-community-docker