-
Notifications
You must be signed in to change notification settings - Fork 0
/
export_znt_autoreg_mediatypes.yaml
127 lines (116 loc) · 4.88 KB
/
export_znt_autoreg_mediatypes.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
zabbix_export:
version: '6.4'
media_types:
- name: 'ZNT Autoregistration'
type: WEBHOOK
parameters:
- name: actionid_tag
value: 'true'
- name: action_id
value: '{ACTION.ID}'
- name: body
value: '{ALERT.MESSAGE}'
- name: bot
value: '@znt_test_test_bot'
- name: bot_group
- name: eventid_tag
value: 'true'
- name: event_id
value: '{EVENT.ID}'
- name: header
value: '{ALERT.SUBJECT}'
- name: send_to
value: '{ALERT.SENDTO}'
- name: znt_host
value: 192.168.1.118
- name: znt_port
value: '8081'
- name: znt_proto
value: http
script: |
var znt = {
sendmessage: function () {
var fields = {
send_to: params.send_to,
bot: params.bot,
bot_group: params.bot_group,
media_type: params.media_type,
title: params.graph_title,
message: params.message,
header: params.header,
body: params.body,
hostname: params.hostname,
itemid: params.item_id,
hostid: params.host_id,
triggerid: params.trigger_id,
triggerurl: params.trigger_url,
eventtags: params.event_tags,
eventid: params.event_id,
actionid: params.action_id,
graphs: params.graphs,
hostlinks: params.host_links,
graphlinks: params.graph_links,
acklinks: params.ack_links,
eventlinks: params.event_links,
triggerlinks: params.trigger_links,
eventtag: params.event_tag,
eventidtag: params.eventid_tag,
itemidtag: params.itemid_tag,
triggeridtag: params.triggerid_tag,
actionidtag: params.actionid_tag,
hostidtag: params.hostid_tag,
zntsettingstag: params.zntsettings_tag,
zntmentions: params.zntmentions,
graphs_period: params.graphs_period,
},
data,
response,
request = new HttpRequest(),
url = params.znt_proto + '://' + params.znt_host + ':' + params.znt_port + '/api/latest/zbx_autoreg/tg/sendMessage';
Zabbix.log(4, '[ZNT Webhook] url: ' + url);
request.addHeader('Content-Type: application/json');
request.addHeader('User-Agent: Zabbix');
data = JSON.stringify(fields);
Zabbix.log(4, '[ZNT Webhook] params: ' + data);
response = request.post(url, data);
Zabbix.log(4, '[ZNT Webhook] HTTP code: ' + request.getStatus());
Zabbix.log(4, '[ZNT Webhook] HTTP description: ' + response.description);
try {
response = JSON.parse(response);
}
catch (error) {
response = null;
}
if (request.getStatus() !== 200) {
if (typeof response.description === 'string') {
throw response.description;
}
else {
throw 'Unknown error. Check debug log for more information.';
}
}
}
};
try {
var params = JSON.parse(value);
znt.sendmessage();
return 'OK';
}
catch (error) {
Zabbix.log(4, '[ZNT Webhook] notification failed: ' + error);
throw 'Sending failed: ' + error + '.';
}
timeout: 10s
description: |
ZNT Autoregistration
Используется для нотификации при авторегистрации хостов
→ Autoregistration notifications and commands
https://github.com/xxsokolov/znt
message_templates:
- event_source: AUTOREGISTRATION
operation_mode: PROBLEM
subject: '{Autoregistration} Autoregistration - {HOST.HOST}'
message: |
Host name: {HOST.HOST}
Host IP: {HOST.IP}
Agent port: {HOST.PORT}