install zabbix
https://crashlaker.github.io/2021/01/26/zabbix_docker-compose.html
target machine
https://www.zabbix.com/download
rpm -Uvh https://repo.zabbix.com/zabbix/6.0/rhel/8/x86_64/zabbix-release-6.0-1.el8.noarch.rpm
# edit /var/log/zabbix/zabbix_agentd.log
# ServerActive zabbix
# Hostname zabbix-demo
systemctl restart zabbix-agent
ssh -nplut
tcp LISTEN 0 128 0.0.0.0:10050 0.0.0.0:* users:(("zabbix_agentd",pid=1667,fd=4),("zabbix_agentd",pid=1666,fd=4),("zabbix_agentd",pid=1665,fd=4),("zabbix_agentd",pid=1664,fd=4),("zabbix_agentd",pid=1663,fd=4),("zabbix_agentd",pid=1662,fd=4))
Create host trigger
Create trigger action
Assign media to User
Create media type webhook
try {
var params = JSON.parse(value),
request = new HttpRequest(),
data,
response,
severities = [
{name: 'not_classified', color: '#97AAB3'},
{name: 'information', color: '#7499FF'},
{name: 'warning', color: '#FFC859'},
{name: 'average', color: '#FFA059'},
{name: 'high', color: '#E97659'},
{name: 'disaster', color: '#E45959'},
{name: 'resolved', color: '#009900'},
{name: 'default', color: '#000000'}
],
priority;
data = JSON.stringify(params);
Zabbix.log(4, '[ Pushover Webhook ] Sending request: ' + params.endpoint + '\n' + data);
request.addHeader('Content-Type: application/json');
response = request.post(params.endpoint, data);
Zabbix.log(4, '[ Pushover Webhook ] Received response with status code ' + request.getStatus() + '\n' + response);
if (response !== null) {
try {
response = JSON.parse(response);
}
catch (error) {
Zabbix.log(4, '[ Pushover Webhook ] Failed to parse response received from Pushover');
response = null;
}
}
if (request.getStatus() != 200 || response === null || typeof response !== 'object' || response.status !== 1) {
if (response !== null && typeof response === 'object' && typeof response.errors === 'object'
&& typeof response.errors[0] === 'string') {
throw response.errors[0];
}
else {
throw 'Unknown error. Check debug log for more information.';
}
}
return 'OK';
}
catch (error) {
Zabbix.log(4, '[ Pushover Webhook ] Pushover notification failed: ' + error);
throw 'Pushover notification failed: ' + error;
}
Payload example
problem
{
"endpoint": "http://10.7.0.57:9000/",
"alert_message": "Problem started at 02:10:31 on 2022.03.29\r\nProblem name: server unavailable\r\nHost: zabbix-demo\r\nSeverity: High\r\nOperational data: Up (1)\r\nOriginal problem ID: 92\r\n",
"alert_subject": "Problem: server unavailable",
"event_recovery_value": "{EVENT.RECOVERY.VALUE}",
"event_source": "0",
"event_update_status": "0",
"event_value": "1",
"event_nseverity": "4",
"event_severity": "High",
"event_ack_status": "No",
"event_name": "server unavailable",
"event_recovery_status": "{EVENT.RECOVERY.STATUS}",
"event_status": "PROBLEM"
}
resolved
{
"endpoint": "http://10.7.0.57:9000/",
"alert_message": "Problem has been resolved at 02:11:21 on 2022.03.29\r\nProblem name: server unavailable\r\nProblem duration: 50s\r\nHost: zabbix-demo\r\nSeverity: High\r\nOriginal problem ID: 92\r\n",
"alert_subject": "Resolved in 50s: server unavailable",
"event_recovery_value": "0",
"event_source": "0",
"event_update_status": "0",
"event_value": "0",
"event_nseverity": "4",
"event_severity": "High",
"event_ack_status": "No",
"event_name": "server unavailable",
"event_recovery_status": "RESOLVED",
"event_status": "RESOLVED"
}
- EVENT.UPDATE.STATUS
- 0 - Webhook was called because of problem/recovery event
- 1 - Update operation
- EVENT.VALUE
- 1 - Problem
- 0 - Recovering
- EVENT.NSEVERITY
- 0 - Not classified
- 1 - Information
- 2 - Warning
- 3 - Average
- 4 - High
- 5 - Disaster