zabbix使用Lark接收告警通知
zabbix使用Lark接收告警通知
通过webhook推送告警通知的脚本:
try {
var params = JSON.parse(value),
request = new HttpRequest(),
message = params.Subject + '\n' + params.Message;
request.addHeader('Content-Type: application/json');
var response = request.post(params.URL, JSON.stringify({"msg_type": "text", "content": {"text": message}}));
try {
response = JSON.parse(response);
} catch (error) {
response = null;
}
if (request.getStatus() !== 200 || response.StatusCode !== 0) {
if (typeof response.msg === 'string') {
throw response.msg;
} else {
throw 'Unknown error. Check debug log for more information.';
}
}
return "ok"
} catch (error) {
throw 'Sending failed: ' + error + '.';
}

浙公网安备 33010602011771号