push icinga2 notifications to rocket.chat
!!! work in progress, but looks fancy enough at the moment !!!
copy both notification scripts to /etc/icinga2/scripts or any other folder which is accessible by icinga2 user
{
"arguments": {
"(no key)": {
"command_id": "220",
"skip_key": true,
"value": "icinga2.localdomain.local",
"order": "1"
},
"(no key.2)": {
"command_id": "220",
"skip_key": true,
"value": "https:\/\/rocketchat.localdomain.local\/hooks\/deiquie5oabeiphazohph5Ae\/ooph0roo3foi6ceefie7ahthee3IejecheDe",
"order": "2"
},
"(no key.3)": {
"command_id": "220",
"skip_key": true,
"value": "$notification.type$",
"order": "3"
},
"(no key.4)": {
"command_id": "220",
"skip_key": true,
"value": "$host.name$",
"order": "4"
},
"(no key.5)": {
"command_id": "220",
"skip_key": true,
"value": "$host.state$",
"order": "5"
},
"(no key.6)": {
"command_id": "220",
"skip_key": true,
"value": "$host.display_name$",
"order": "6"
},
"(no key.7)": {
"command_id": "220",
"skip_key": true,
"value": "$notification.author$",
"order": "7"
},
"(no key.8)": {
"command_id": "220",
"skip_key": true,
"value": "$notification.comment$",
"order": "8"
},
"(no key.9)": {
"command_id": "220",
"skip_key": true,
"value": "$host.output$",
"order": "9"
}
},
"command": "\/etc\/icinga2\/scripts\/rocketchat-host-notification.sh",
"disabled": false,
"imports": [],
"methods_execute": "PluginNotification",
"object_name": "notification-rocketchat-host",
"object_type": "object",
"timeout": null,
"vars": {},
"zone": null
}
{
"arguments": {
"(no key)": {
"command_id": "221",
"skip_key": true,
"value": "icinga2.localdomain.local",
"order": "1"
},
"(no key.10)": {
"command_id": "221",
"skip_key": true,
"value": "$notification.comment$",
"order": "10"
},
"(no key.2)": {
"command_id": "221",
"skip_key": true,
"value": "https:\/\/rocketchat.localdomain.local\/hooks\/deiquie5oabeiphazohph5Ae\/ooph0roo3foi6ceefie7ahthee3IejecheDe",
"order": "2"
},
"(no key.3)": {
"command_id": "221",
"skip_key": true,
"value": "$notification.type$",
"order": "3"
},
"(no key.4)": {
"command_id": "221",
"skip_key": true,
"value": "$host.name$",
"order": "4"
},
"(no key.5)": {
"command_id": "221",
"skip_key": true,
"value": "$host.display_name$",
"order": "5"
},
"(no key.6)": {
"command_id": "221",
"skip_key": true,
"value": "$service.display_name$",
"order": "6"
},
"(no key.7)": {
"command_id": "221",
"skip_key": true,
"value": "$service.state$",
"order": "7"
},
"(no key.8)": {
"command_id": "221",
"skip_key": true,
"value": "$service.output$",
"order": "8"
},
"(no key.9)": {
"command_id": "221",
"skip_key": true,
"value": "$notification.author$",
"order": "9"
}
},
"command": "\/etc\/icinga2\/scripts\/rocketchat-service-notification.sh",
"disabled": false,
"imports": [],
"methods_execute": "PluginNotification",
"object_name": "notification-rocketchat-service",
"object_type": "object",
"timeout": null,
"vars": {},
"zone": null
}
template Notification "host-by-rocketchat" {
command = "notification-rocketchat-host"
interval = 0s
}
template Notification "service-by-rocketchat" {
command = "notification-rocketchat-service"
interval = 0s
users = [ "rocket.chat" ]
}
apply Notification "Host (DOWN) -> Rocket.Chat" to Host {
import "host-by-rocketchat"
period = "24x7"
assign where match("*", host.name)
users = [ "rocket.chat" ]
}
apply Notification "Service (Problem) -> Rocket.Chat" to Service {
import "service-by-rocketchat"
period = "24x7"
assign where match("*", host.name)
users = [ "rocket.chat" ]
}