Zabbix Integration¶
To fully understand the integration process, it is necessary to understand the following terms:
- Item - defines what data or metric Zabbix should collect (e.g. CPU usage, text objects, numeric objects).
- Trigger - logical condition, that evaluates item values and determines if some action should be taken based on this values (e.g. if code value is greater than 400).
- Alert - defines action, which will be taken, when trigger detects defined value (e.g. send an email, send an SMS).
To integrate Cluster Manager, to send messages to the Zabbix server, we need to execute 6 configuration operations in it’s frontend:
- Create a Zabbix trapper item – define item, which will store the cluster manager messages. Example message object:
- Create dependent items for the Zabbix trapper created in step 1 – define subobjects of the cluster manager message. Each message consists of three variables: source (where does the message come from), message (actual message), code (message code).
- Create a trigger, based on the message code – trigger, when message code indicates an error.
- Configure SMTP – configure SMTP server, for sending emails if error occurs.
- Configure user’s email address – for the logged in user, define theirs email address.
- Create a trigger action (alert) – when trigger created in step 3 indicates an error, then send an email to chosen user(s).
Create Zabbix trapper item¶
- Click Monitoring in the navigation bar.
- Click Hosts in the monitoring navigation.
- Click on your Zabbix server.
- From the Zabbix server menu, choose Items.

- Click Create item button in the top right corner.

- Set Name (for example
Cluster Manager Message). - Set Type to be Zabbix trapper.
- Set Key (for example
clusterManagerMsg.json). - Set Type of information to Text.
- Click Add button at the bottom of the form.

Create dependent items¶
The following steps, should be executed for code, message and source fields.
- Click Create item button in the top right corner (as in step 5 of Create Zabbix trapper item).
- Set Name (for example
Cluster Manager Message Code). - Set Type to be Dependent item.
- Set Key (for example
clusterManagerMsg.code). - Set Type of information to Numeric (unsigned) for code and Text for message and source.
- Set Master item to
clusterManagerMsg.json(select correct Zabbix trapper). - Click on Preprocessing tab.

- Click Add.
- Add code/message/source field with JSONPath step (for example
$.code). - Click Add button at the bottom of the form.

Create trigger¶
Problems Severity by Message Codes¶
| Severity | Codes |
|---|---|
| Information | 100-399 |
| Warning | 508, 522, 523, 524, 525, 526, 527, 528, 529, 530, 531, 532, 533, 534, 535, 605, 609 |
| Average | 502, 503, 505, 506, 509, 608, 610 |
| High | 400, 401, 402, 403, 404, 405, 406, 501, 507, 510, 511, 512, 513, 515, 517, 519, 520, 604, 606 |
| Disaster | 500, 514, 516, 518, 521, 600, 601, 602, 603, 607, 611 |
Expressions by Severity¶
Information¶
(jsonpath(last(/Zabbix server/clusterManagerMsg.json),"$.code")>=100) and (jsonpath(last(/Zabbix server/clusterManagerMsg.json),"$.code")<=399)
Warning¶
((jsonpath(last(/Zabbix server/clusterManagerMsg.json),"$.code")
= 508) or
(jsonpath(last(/Zabbix server/clusterManagerMsg.json),"$.code")
= 522) or
(jsonpath(last(/Zabbix server/clusterManagerMsg.json),"$.code")
= 523) or
(jsonpath(last(/Zabbix server/clusterManagerMsg.json),"$.code")
= 524) or
(jsonpath(last(/Zabbix server/clusterManagerMsg.json),"$.code")
= 525) or
(jsonpath(last(/Zabbix server/clusterManagerMsg.json),"$.code")
= 526) or
(jsonpath(last(/Zabbix server/clusterManagerMsg.json),"$.code")
= 527) or
(jsonpath(last(/Zabbix server/clusterManagerMsg.json),"$.code")
= 528) or
(jsonpath(last(/Zabbix server/clusterManagerMsg.json),"$.code")
= 529) or
(jsonpath(last(/Zabbix server/clusterManagerMsg.json),"$.code")
= 530) or
(jsonpath(last(/Zabbix server/clusterManagerMsg.json),"$.code")
= 531) or
(jsonpath(last(/Zabbix server/clusterManagerMsg.json),"$.code")
= 532) or
(jsonpath(last(/Zabbix server/clusterManagerMsg.json),"$.code")
= 533) or
(jsonpath(last(/Zabbix server/clusterManagerMsg.json),"$.code")
= 534) or
(jsonpath(last(/Zabbix server/clusterManagerMsg.json),"$.code")
= 535) or
(jsonpath(last(/Zabbix server/clusterManagerMsg.json),"$.code")
= 605) or
(jsonpath(last(/Zabbix server/clusterManagerMsg.json),"$.code")
= 609))
Average¶
((jsonpath(last(/Zabbix server/clusterManagerMsg.json),"$.code")
= 502) or
(jsonpath(last(/Zabbix server/clusterManagerMsg.json),"$.code")
= 503) or
(jsonpath(last(/Zabbix server/clusterManagerMsg.json),"$.code")
= 505) or
(jsonpath(last(/Zabbix server/clusterManagerMsg.json),"$.code")
= 506) or
(jsonpath(last(/Zabbix server/clusterManagerMsg.json),"$.code")
= 509) or
(jsonpath(last(/Zabbix server/clusterManagerMsg.json),"$.code")
= 608) or
(jsonpath(last(/Zabbix server/clusterManagerMsg.json),"$.code")
= 610))
High¶
((jsonpath(last(/Zabbix server/clusterManagerMsg.json),"$.code")
= 400) or
(jsonpath(last(/Zabbix server/clusterManagerMsg.json),"$.code")
= 401) or
(jsonpath(last(/Zabbix server/clusterManagerMsg.json),"$.code")
= 402) or
(jsonpath(last(/Zabbix server/clusterManagerMsg.json),"$.code")
= 403) or
(jsonpath(last(/Zabbix server/clusterManagerMsg.json),"$.code")
= 404) or
(jsonpath(last(/Zabbix server/clusterManagerMsg.json),"$.code")
= 405) or
(jsonpath(last(/Zabbix server/clusterManagerMsg.json),"$.code")
= 406) or
(jsonpath(last(/Zabbix server/clusterManagerMsg.json),"$.code")
= 501) or
(jsonpath(last(/Zabbix server/clusterManagerMsg.json),"$.code")
= 507) or
(jsonpath(last(/Zabbix server/clusterManagerMsg.json),"$.code")
= 510) or
(jsonpath(last(/Zabbix server/clusterManagerMsg.json),"$.code")
= 511) or
(jsonpath(last(/Zabbix server/clusterManagerMsg.json),"$.code")
= 512) or
(jsonpath(last(/Zabbix server/clusterManagerMsg.json),"$.code")
= 513) or
(jsonpath(last(/Zabbix server/clusterManagerMsg.json),"$.code")
= 515) or
(jsonpath(last(/Zabbix server/clusterManagerMsg.json),"$.code")
= 517) or
(jsonpath(last(/Zabbix server/clusterManagerMsg.json),"$.code")
= 519) or
(jsonpath(last(/Zabbix server/clusterManagerMsg.json),"$.code")
= 520) or
(jsonpath(last(/Zabbix server/clusterManagerMsg.json),"$.code")
= 604) or
(jsonpath(last(/Zabbix server/clusterManagerMsg.json),"$.code")
= 606))
Disaster¶
((jsonpath(last(/Zabbix server/clusterManagerMsg.json),"$.code")
= 500) or
(jsonpath(last(/Zabbix server/clusterManagerMsg.json),"$.code")
= 514) or
(jsonpath(last(/Zabbix server/clusterManagerMsg.json),"$.code")
= 516) or
(jsonpath(last(/Zabbix server/clusterManagerMsg.json),"$.code")
= 518) or
(jsonpath(last(/Zabbix server/clusterManagerMsg.json),"$.code")
= 521) or
(jsonpath(last(/Zabbix server/clusterManagerMsg.json),"$.code")
= 600) or
(jsonpath(last(/Zabbix server/clusterManagerMsg.json),"$.code")
= 601) or
(jsonpath(last(/Zabbix server/clusterManagerMsg.json),"$.code")
= 602) or
(jsonpath(last(/Zabbix server/clusterManagerMsg.json),"$.code")
= 603) or
(jsonpath(last(/Zabbix server/clusterManagerMsg.json),"$.code")
= 607) or
(jsonpath(last(/Zabbix server/clusterManagerMsg.json),"$.code")
= 611))
Create trigger¶
- Click Monitoring in the navigation bar.
- Click Hosts in the monitoring navigation.
- Click on your Zabbix server.
- From the Zabbix server menu, choose Triggers.

- Click Create trigger button in the top right corner.

- Set Name (for example
Cluster Message Information) - Set proper Severity based on the severities table.
- Set PROBLEM event generation mode to Multiple.
- In the Expression text field, paste correct expression based on the trigger severity.
- Click Add at the bottom of the form.

Configure SMTP¶
- Click Alerts in the navigation bar.
- Click Media types in the alerts navigation.
- Click on Email media type.
- Configure SMTP server.
- Check the Enabled box.
- Click Update button.

Configure user’s email address¶
- Click User settings at the bottom of the navigation bar.
- Click Profile in the user settings navigation.
- Click on Media tab.
- Click Add.

- Add email to Send to section.
- Click Add at the bottom of the form.

Create trigger action (alert)¶
- Click Alerts in the navigation bar.
- Click Actions in the alerts navigation.
- Click Trigger actions in the actions navigation.
- Click Create action button in the top right corner.

- Set Name (for example
Send Alert for Cluster Manager Error Code). - Click Add in the Conditions section.

- Set Type to Trigger.
- Click Select on Triggers and choose the trigger created in previous steps.
- Click Add.

- Click Operations tab and the Add button in Operations section.
- Choose users and/or user groups.
- Enable Custom Message.
- Set Subject (for example
Cluster Manager Error). - Set Message, with the following content as part of the message, to receive a JSON object of the message:
{ITEM.LASTVALUE}. - Click Add.
- Click Add.

Send message to Zabbix¶
Send message via zabbix_sender¶
zabbix_sender is a command-line utility, a binary file used to send data to a Zabbix server, that comes with Zabbix.
To send a message via zabbix_sender use the following schema:
zabbix_sender \
-z 127.0.0.1 \
-s "Zabbix server" \
-k clusterManagerMsg.json \
-o '{"source": "127.0.0.1", "message": "Hello, Zabbix!", "code": 200}'
Where:
zabbix_senderis the executable command,-z 127.0.0.1specifies the target Zabbix server’s IP address,-s "Zabbix server"specifies the monitored host name in Zabbix,-k clusterManagerMsg.jsonis the item (Zabbix trapper) key,-o '{"source": "127.0.0.1", "message": "Hello, Zabbix!", "code": 200}'is a JSON-formatted message.
Send message via API¶
Generate API Token¶
- Click Users in the navigation bar.
- Click API tokens in the users navigation.
- Click Create API token button.

- Set Name.
- Either disable the expiration date or remember to update the token, when expired.
- Click Add.
- Copy the API Token.

Get Host ID¶
Before executing the next step – getting the item ID, we need to get the host’s ID. To do so, execute the following cURL command and replace:
$auth_token– actual API token (from previous step),$zabbix_ip– actual Zabbix server IP.
curl -X POST -H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "host.get",
"params": {
"output": ["hostid", "name"],
"search": {
"name": "Zabbix server"
}
},
"auth": "$auth_token",
"id": 1
}' \
http://$zabbix_ip/zabbix/api_jsonrpc.php | jq -r '.result[0].hostid'
Get Item ID¶
Before actually sending a message, we need to get the Zabbix trappers item ID. To do so, execute the following cURL command and replace:
$auth_token– actual API token (from previous step),$host_id– host ID (from previous step),$zabbix_ip– actual Zabbix server IP.
curl -X POST -H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "item.get",
"params": {
"output": "extend",
"hostids": "$host_id",
"search": {
"key_": "clusterManagerMsg"
}
},
"auth": "$auth_token",
"id": 1
}' \
http://$zabbix_ip/zabbix/api_jsonrpc.php | jq -r '.result[0].itemid'
Send Message¶
To send a message to the Zabbix server, execute the following cURL command and replace:
$auth_token– actual API token (from previous step),$item_id– item ID (from previous step),$zabbix_ip– actual Zabbix server IP.
curl -X POST -H "Content-Type: application/json" -d '{
"jsonrpc": "2.0",
"method": "history.push",
"params": {
"itemid": "$item_id",
"value": "{\"source\": \"127.0.0.1-Primary-Cluster-Manager\", \"message\": \"Hello, Zabbix!\", \"code\": 200}"
},
"auth": "$auth_token",
"id": 1
}' http://$zabbix_ip/zabbix/api_jsonrpc.php
Cluster Manager Message Scripts¶
Cluster Manager message scripts (both standard and error), should contain the following content, where:
$auth_token– API token,$item_id– item ID,$zabbix_ip– actual Zabbix server IP.$cluster_manager_ip– ip of the Cluster Manager.
#!/bin/bash
set -e -o errexit
curl -X POST \
--header "Content-Type: application/json"
--data ‘{
"jsonrpc": "2.0",
"method": "history.push",
"params": {
"itemid": "$item_id",
"value": "{\"source\": \"$cluster_manager_ip-Primary-Cluster-Manager\", \"message\": \"${message}\", \"code\": ${code}}"
},
"auth": "$auth_token",
"id": 1
}’ http://$zabbix_ip/zabbix/api_jsonrpc.php
Messages Dashboard¶
Dashboard¶
In the Dashboard screen, problems are displayed in the Current problems section. They are categorized by severity (corresponding colors are visible in the Problems by severity section).

Latest values¶

- Click Monitoring in the navigation bar.
- Click Latest data in the monitoring navigation.
- Select your host in the Hosts section.
- Click the Apply button.

- Click the Cluster Manager Message item.
- Click 500 latest values from the menu.
