Home

Awesome

Zabbix-Server (CentOS-7 + Supervisor)

CircleCI Build Status GitHub Open Issues GitHub Stars GitHub Forks
Stars on Docker Hub Pulls on Docker Hub
Docker Layers

Deploy to Docker Cloud

Docker Image with Zabbix Server using CentOS-7 and Supervisor. Image is using external datbase.
This image is using offcial zabbix-server-2.4 Docker Image as base image.

Installed Plugins

Email Notifications with authorisation
Slack Notifications
Nginx Status /nginx_status
PHP-FPM Status /fpm_status

Database deployment

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 we will use our million12/mariadb image as our database.

**For more information about million12/MariaDB see our documentation. **

Example:

docker run \
	-d \
	--name zabbix-db \
	-p 3306:3306 \
	--env="MARIADB_USER=username" \
	--env="MARIADB_PASS=my_password" \
	million12/mariadb

Remember to use the same credentials when deploying zabbix-server image.

Environmental Variable

IYou can use environmental variables to config Zabbix server and 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

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-Server Deployment

Now when we have our database running we can deploy zabbix-server image with appropriate environmental variables set.

Example:

docker run \
	-d \
	--name zabbix \
	-p 80:80 \
	-p 10051:10051 \
	--link zabbix-db:zabbix.db \
	--env="ZS_DBHost=zabbix.db" \
	--env="ZS_DBUser=zabbix" \
	--env="ZS_DBPassword=my_password" \
	million12/zabbix-server

With email settings and Slack integration and custom timezone:

docker run \
	-d \
	--name zabbix \
	-p 80:80 \
	-p 10051:10051 \
	--link zabbix-db:zabbix.db \
	--env="ZS_DBHost=zabbix.db" \
	--env="ZS_DBUser=zabbix" \
	--env="ZS_DBPassword=my_password" \
	--env="ZABBIX_ADMIN_EMAIL=default@domain.com" \
	--env="ZABBIX_SMTP_SERVER=default.smtp.server.com" \
	--env="ZABBIX_SMTP_USER=default.smtp.username" \
	--env="ZABBIX_SMTP_PASS=default.smtp.password" \
	--env="SLACK_WEBHOOK=https://hooks.slack.com/services/QQ3PTH/B67THC0D3/ABCDGabcDEF124" \
	million12/zabbix-server

With MySQL/MariaDB linked container:

docker run \
	-d \
	--name zabbix \
	-p 80:80 \
	-p 10051:10051 \
	--link some-mariadb:db \
	million12/zabbix-server

Access Zabbix-Server 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 Follow the on screen instructions.

Zabbix Push Notifications

Zabbix notification script is located in /usr/local/share/zabbix/alertscripts
Please follow Zabbkit manual to configure notifications.

Email Notifications (Server settings)

Using environmental variables on docker run you can edit default email server settings. Valuse would be added on into /usr/local/share/zabbix/alertscripts/zabbix_sendmail.sh.
Environmental variables are:
ZABBIX_ADMIN_EMAIL=default@domain.com
ZABBIX_SMTP_SERVER=default.smtp.server.com
ZABBIX_SMTP_USER=default.smtp.username
ZABBIX_SMTP_PASS=default.smtp.password

Configuration: Go into Administration/Media types and add new type using script as Type. Script name should be zabbix_sendmail.sh

Media type

Next go to Configuration/Actions and create new action. Select recovery message.

Actions1

Next select tab Operations and click New to add new action. In Send to User groups add Zabbix Adminstrator or any user group you like. In Send only to select Name of your previously created Media type name.

Actions2

Next go to Administration/Users and select your user. Go to Media tab and add new Media. In Type select your Media type you have created in first step. Add your email addess and enjoy receiving emails.

User-Media

Slack Integration

This docker image comes with Slack integrations script. You need to provide your WebHook generated in yo your Slack account. it should look like https://hooks.slack.com/services/QQ3PTH/B67THC0D3/ABCDGabcDEF124

Note: this Slack Integration script is based on one originally developed by ericoc/zabbix-slack-alertscript. For deatiled installation please see ericoc instructions.

Nginx Status Template

Nginx stats script is located in /usr/local/share/zabbix/externalscripts/.
It's latest version of vicendominguez/nginx-zabbix-template official Zabbix communty repo.
Gathering data is done by getNginxInfo.py which is already installed in this image. User need to install template to be able to use this feature.
Go to Configuration/Templates and select Import and import file located in this repo in templates-files directory called zbx_nginx_template.xml

Nginx1

Nginx2

More details in official documentation here.

PHP-FPM Status Template

PHP-FPM Status template assumes that your Nginx server is configured to serve stats under /fpm_status url and port 80. If you you want to use custom port please edit necessary files.

Example of nginx.conf file:

location /fpm_status {
access_log off;
allow 127.0.0.1;
deny all;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass php-upstream;
}  

Installation:
Go to Configuration/Templates and select Import and import file located in this repo in templates-files directory called zabbix-php-fpm-template.xml

Screenshots:
PHP-FPM

Docker troubleshooting

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

$ docker ps

Check logs of Zabbix server 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 million12/zabbix-server | tr -s ' ' | tail -n+2 | awk -F " ago " '{print $2}'

Author

Author: Przemyslaw Ozgo (linux@ozgo.info)


Sponsored by Typostrap.io - the new prototyping tool for building highly-interactive prototypes of your website or web app. Built on top of TYPO3 Neos CMS and Zurb Foundation framework.