Find the Exponential Software extensions you want
| UNIX name | Owner | Status |
|---|---|---|
| platformsh-zabbix-template | 7x | stable |
| Version | Compatible with |
|---|---|
| N/A | N/A |
Platform.sh provides basic capabilities to for the monitoring via Health notifications. But in some advanced cases, you might need to monitor some specific metrics of a specific app service. And Zabbix is a perfect tool for doing it.
This solution lets you install Zabbix on top of any existing Platform.sh PHP project.
Also, it provides a Platform.sh Zabbix template, which allows monitoring of the following services:
Usage examples:
Add zabbix sources and utility scripts from this repo to your project sources:
git clone [email protected]:contextualcode/platformsh-zabbix-template.git ~/platformsh-zabbix-template
cp -R ~/platformsh-zabbix-template/zabbix /
mysqldb:
...
configuration:
schemas:
...
- zabbix
endpoints:
...
zabbix:
default_schema: zabbix
privileges:
zabbix: admin
relationships:
...
# Zabbix relationships
database_zabbix: mysqldb:zabbix
Enable required PHP extensions in .platform.app.yaml:
runtime:
extensions:
...
- ctype
- xmlreader
- xmlwriter
- gettext
Add the install script for Platform.sh CLI to build hook in .platform.app.yaml:
hooks:
build: |
...
curl -sS https://platform.sh/cli/installer | php
Add the zabbix install scripts to the build and deploy hooks in .platform.app.yaml:
hooks:
build: |
...
/app/zabbix/scripts/install-libevent.sh
/app/zabbix/scripts/install-zabbix.sh
/app/zabbix/scripts/install-composer-ui.sh
deploy: |
...
/app/zabbix/scripts/update-configs.sh
/app/zabbix/scripts/install-db.sh
/app/zabbix/scripts/start-zabbix.sh
Add a zabbix/configs mount in .platform.app.yaml:
mounts:
...
zabbix/configs:
source: local
source_path: zabbix-configs
Update the PHP configuration in .platform.app.yaml:
variables:
php:
max_input_time: 300
Add a zabbix web location in .platform.app.yaml (please make sure it is the first one in the locations list):
web:
locations:
/zabbix:
root: zabbix/src/zabbix/ui
passthru: true
scripts: true
index: [index.php]
...
If Varnish is used on your project, please make sure all requests to the Zabbix UI bypass it and are served directly by PHP. Please update .platform/routes.yaml in order to achieve this:
https://{default}/zabbix/:
type: upstream
upstream: app:http
cache:
enabled: false
ssi:
enabled: false
Add PHP dependencies in .platform.app.yaml:
dependencies:
php:
...
wizaplace/php-fpm-status-cli: "^1.0"
gordalina/cachetool: "^5.0"
For each Platform.sh service which needs to be monitored by Zabbix add status_<service> relationship in .platform.app.yaml. It should point to the existing service endpoints:
relationships:
...
status_database: mysqldb:user
status_solr: solrsearch:collection1
status_redis: rediscache:redis
cp -R ~/platformsh-zabbix-template/varnish-stats /
platform variable:create \
--project= \
--level=project \
--environment=master \
--name="PLATFORMSH_CLI_TOKEN" \
--value="" \
--visible-build=false \
--sensitive=true \
--json=false \
--prefix=env \
--visible-runtime=true \
--enabled=true \
--inheritable=true
Deploy all the changes:
git add zabbix .platform.app.yaml .platform/routes.yaml .platform/services.yaml varnish-stats/.platform.app.yaml
git commit -m "Installed Zabbix"
git push platform master
To check all the collected metrics open "Monitoring" -> "Latest data" from the left navigation. And you will see:
And for each of the metrics you can access the historical data by clicking on "Graph":
Besides allowing for monitoring Zabbix provides capabilities to send out notifications and alerts when a metric matches specific conditions.
Some additional configuration is required, in order to use Zabbix alerts and notifications:
Now media types are set, and the notifications are enabled. And we are ready to setup the first notification.
Let's set up a notification for the case when there is less than 500MB of free persistent storage space:
After the trigger is added, each time when there is less than 500MB of available storage the notification will be sent out to the Admin user. To test it out, you can ssh to your project and generate a big test file in one of your mounts:
platform ssh -A app
dd if=/dev/zero of=/app/zabbix/configs/output.dat bs=512M count=1