Added parse int functionality for severity to make sure it's always a integer value to send to zabify server
parent
56098bbfcc
commit
99fc9545fb
|
@ -46,7 +46,7 @@
|
|||
"value": "{ALERT.SUBJECT}"
|
||||
}
|
||||
],
|
||||
"script": "try {\n Zabbix.log(4, '[ Zabify ] Starting to send push notification');\n\n var params = JSON.parse(value);\n var payload = {\n \"token\": params.send_to.split(\"===\")[1],\n \"rsaKey\": params.send_to.split(\"===\")[0],\n \"notification\": {\n \"data\": {\n \"host_id\": params.host_id,\n \"event_id\": params.event_id,\n \"severity\": params.severity\n },\n \"message\": { \n \"title\": params.title,\n \"message\": params.message,\n }\n }\n };\n\n Zabbix.log(4, '[ Zabify ] Sending request');\n var request = new HttpRequest();\n request.addHeader('Content-Type: application/json');\n request.setProxy(params.proxy);\n\n var data = JSON.stringify(payload);\n var endpoint = params.protocol + \"://\" + params.fully_qualified_name + \":\" + params.port + \"/send\";\n var response = request.post(endpoint, data);\n if (response === null) {\n throw 'Unknown error. Check debug log for more information.';\n }\n Zabbix.log(4, '[ Zabify ] Received response with status code ' + request.getStatus() + '\\n' + response);\n\n if (request.getStatus() != 200) {\n var parsedResponse;\n try {\n parsedResponse = JSON.parse(response);\n }\n catch (error) {\n Zabbix.log(4, '[ Zabify ] Failed to parse response');\n throw 'Unknown error. Check debug log for more information.';\n }\n\n throw parsedResponse;\n }\n\n Zabbix.log(4, '[ Zabify ] Finished to send push notification without errors');\n return 'OK';\n}\ncatch (error) {\n Zabbix.log(4, '[ Zabify ] Failed to send push notification: ' + error);\n throw 'Zabbix app notification failed: ' + error;\n}",
|
||||
"script": "try {\n Zabbix.log(4, '[ Zabify ] Starting to send push notification');\n\n var params = JSON.parse(value);\n var payload = {\n \"token\": params.send_to.split(\"===\")[1],\n \"rsaKey\": params.send_to.split(\"===\")[0],\n \"notification\": {\n \"data\": {\n \"host_id\": params.host_id,\n \"event_id\": params.event_id,\n \"severity\": parseInt(params.severity)\n },\n \"message\": { \n \"title\": params.title,\n \"message\": params.message,\n }\n }\n };\n\n Zabbix.log(4, '[ Zabify ] Sending request');\n var request = new HttpRequest();\n request.addHeader('Content-Type: application/json');\n request.setProxy(params.proxy);\n\n var data = JSON.stringify(payload);\n var endpoint = params.protocol + \"://\" + params.fully_qualified_name + \":\" + params.port + \"/send\";\n var response = request.post(endpoint, data);\n if (response === null) {\n throw 'Unknown error. Check debug log for more information.';\n }\n Zabbix.log(4, '[ Zabify ] Received response with status code ' + request.getStatus() + '\\n' + response);\n\n if (request.getStatus() != 200) {\n var parsedResponse;\n try {\n parsedResponse = JSON.parse(response);\n }\n catch (error) {\n Zabbix.log(4, '[ Zabify ] Failed to parse response');\n throw 'Unknown error. Check debug log for more information.';\n }\n\n throw parsedResponse;\n }\n\n Zabbix.log(4, '[ Zabify ] Finished to send push notification without errors');\n return 'OK';\n}\ncatch (error) {\n Zabbix.log(4, '[ Zabify ] Failed to send push notification: ' + error);\n throw 'Zabbix app notification failed: ' + error;\n}",
|
||||
"description": "Please refer to the Zabify integration documentation on https://www.zabify.de/plugin for more information.",
|
||||
"message_templates": [
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue