Add adapted Icinga2 configuration files
This commit is contained in:
parent
99b9a3639f
commit
d976feef80
3 changed files with 196 additions and 0 deletions
131
cfg/command.cfg
Normal file
131
cfg/command.cfg
Normal file
|
@ -0,0 +1,131 @@
|
||||||
|
// https://git.dittberner.info/jan/icinga2-matrix-notification
|
||||||
|
|
||||||
|
object NotificationCommand "matrix-host-notification" {
|
||||||
|
import "plugin-notification-command"
|
||||||
|
command = [ SysconfDir + "/icinga2/scripts/matrix-host-notification" ]
|
||||||
|
arguments += {
|
||||||
|
"-4" = "$notification_address$"
|
||||||
|
"-6" = "$notification_address6$"
|
||||||
|
"-b" = "$notification_author$"
|
||||||
|
"-c" = "$notification_comment$"
|
||||||
|
"-d" = {
|
||||||
|
required = true
|
||||||
|
value = "$notification_date$"
|
||||||
|
}
|
||||||
|
"-i" = "$notification_icingaweb2url$"
|
||||||
|
"-l" = {
|
||||||
|
required = true
|
||||||
|
value = "$notification_hostname$"
|
||||||
|
}
|
||||||
|
"-m" = {
|
||||||
|
required = true
|
||||||
|
value = "$notification_matrix_room_id$"
|
||||||
|
}
|
||||||
|
"-n" = {
|
||||||
|
required = true
|
||||||
|
value = "$notification_hostdisplayname$"
|
||||||
|
}
|
||||||
|
"-o" = {
|
||||||
|
required = true
|
||||||
|
value = "$notification_hostoutput$"
|
||||||
|
}
|
||||||
|
"-s" = {
|
||||||
|
required = true
|
||||||
|
value = "$notification_hoststate$"
|
||||||
|
}
|
||||||
|
"-t" = {
|
||||||
|
required = true
|
||||||
|
value = "$notification_type$"
|
||||||
|
}
|
||||||
|
"-x" = {
|
||||||
|
required = true
|
||||||
|
value = "$notification_matrix_server$"
|
||||||
|
}
|
||||||
|
"-y" = {
|
||||||
|
required = true
|
||||||
|
value = "$notification_matrix_token$"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
vars.notification_address = "$address$"
|
||||||
|
vars.notification_address6 = "$address6$"
|
||||||
|
vars.notification_author = "$notification.author$"
|
||||||
|
vars.notification_comment = "$notification.comment$"
|
||||||
|
vars.notification_date = "$icinga.long_date_time$"
|
||||||
|
vars.notification_hostdisplayname = "$host.display_name$"
|
||||||
|
vars.notification_hostname = "$host.name$"
|
||||||
|
vars.notification_hostoutput = "$host.output$"
|
||||||
|
vars.notification_hoststate = "$host.state$"
|
||||||
|
vars.notification_type = "$notification.type$"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
object NotificationCommand "matrix-service-notification" {
|
||||||
|
import "plugin-notification-command"
|
||||||
|
command = [ SysconfDir + "/icinga2/scripts/matrix-service-notification" ]
|
||||||
|
arguments += {
|
||||||
|
"-4" = {
|
||||||
|
required = true
|
||||||
|
value = "$notification_address$"
|
||||||
|
}
|
||||||
|
"-6" = "$notification_address6$"
|
||||||
|
"-b" = "$notification_author$"
|
||||||
|
"-c" = "$notification_comment$"
|
||||||
|
"-d" = {
|
||||||
|
required = true
|
||||||
|
value = "$notification_date$"
|
||||||
|
}
|
||||||
|
"-e" = {
|
||||||
|
required = true
|
||||||
|
value = "$notification_servicename$"
|
||||||
|
}
|
||||||
|
"-i" = "$notification_icingaweb2url$"
|
||||||
|
"-l" = {
|
||||||
|
required = true
|
||||||
|
value = "$notification_hostname$"
|
||||||
|
}
|
||||||
|
"-m" = {
|
||||||
|
required = true
|
||||||
|
value = "$notification_matrix_room_id$"
|
||||||
|
}
|
||||||
|
"-n" = {
|
||||||
|
required = true
|
||||||
|
value = "$notification_hostdisplayname$"
|
||||||
|
}
|
||||||
|
"-o" = {
|
||||||
|
required = true
|
||||||
|
value = "$notification_serviceoutput$"
|
||||||
|
}
|
||||||
|
"-s" = {
|
||||||
|
required = true
|
||||||
|
value = "$notification_servicestate$"
|
||||||
|
}
|
||||||
|
"-t" = {
|
||||||
|
required = true
|
||||||
|
value = "$notification_type$"
|
||||||
|
}
|
||||||
|
"-u" = {
|
||||||
|
required = true
|
||||||
|
value = "$notification_servicedisplayname$"
|
||||||
|
}
|
||||||
|
"-x" = {
|
||||||
|
required = true
|
||||||
|
value = "$notification_matrix_server$"
|
||||||
|
}
|
||||||
|
"-y" = {
|
||||||
|
required = true
|
||||||
|
value = "$notification_matrix_token$"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
vars.notification_address = "$address$"
|
||||||
|
vars.notification_address6 = "$address6$"
|
||||||
|
vars.notification_author = "$notification.author$"
|
||||||
|
vars.notification_comment = "$notification.comment$"
|
||||||
|
vars.notification_date = "$icinga.long_date_time$"
|
||||||
|
vars.notification_hostdisplayname = "$host.display_name$"
|
||||||
|
vars.notification_hostname = "$host.name$"
|
||||||
|
vars.notification_servicedisplayname = "$service.display_name$"
|
||||||
|
vars.notification_serviceoutput = "$service.output$"
|
||||||
|
vars.notification_servicestate = "$service.state$"
|
||||||
|
vars.notification_type = "$notification.type$"
|
||||||
|
vars.notification_servicename = "$service.name$"
|
||||||
|
}
|
29
cfg/services.cfg
Normal file
29
cfg/services.cfg
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
// https://git.dittberner.info/jan/icinga2-matrix-notification
|
||||||
|
/**
|
||||||
|
* Example Matrix.org apply rules.
|
||||||
|
* The "!<id>:matrix.org" needs to be replaced with the room ID
|
||||||
|
* for example "!SDFfskjfdszhdaslasdkjhdasd:matrix.org".
|
||||||
|
* Also a Matrix access token is required too.
|
||||||
|
*/
|
||||||
|
|
||||||
|
apply Notification "Matrix host problems" to Host {
|
||||||
|
import "matrix-host-notification"
|
||||||
|
|
||||||
|
user_groups = host.vars.notification.matrix.groups
|
||||||
|
users = host.vars.notification.matrix.users
|
||||||
|
vars.notification_matrix_server = "https://matrix.org"
|
||||||
|
vars.notification_matrix_room_id = "!<id>:matrix.org"
|
||||||
|
// vars.notification_matrix_token = "<access_token>"
|
||||||
|
assign where host.vars.notification.matrix
|
||||||
|
}
|
||||||
|
|
||||||
|
apply Notification "Matrix service problems" to Service {
|
||||||
|
import "matrix-service-notification"
|
||||||
|
|
||||||
|
user_groups = host.vars.notification.matrix.groups
|
||||||
|
users = host.vars.notification.matrix.users
|
||||||
|
vars.notification_matrix_server = "https://matrix.org"
|
||||||
|
vars.notification_matrix_room_id = "!<id>:matrix.org"
|
||||||
|
// vars.notification_matrix_token = "<access_token>"
|
||||||
|
assign where host.vars.notification.matrix
|
||||||
|
}
|
36
cfg/templates.cfg
Normal file
36
cfg/templates.cfg
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
// https://git.dittberner.info/jan/icinga2-matrix-notification
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides default settings for Matrix.org service notifications.
|
||||||
|
*/
|
||||||
|
|
||||||
|
template Notification "matrix-host-notification" {
|
||||||
|
command = "matrix-host-notification"
|
||||||
|
|
||||||
|
states = [ Up, Down ]
|
||||||
|
types = [ Problem, Acknowledgement, Recovery, Custom,
|
||||||
|
FlappingStart, FlappingEnd,
|
||||||
|
DowntimeStart, DowntimeEnd, DowntimeRemoved ]
|
||||||
|
vars += {
|
||||||
|
// notification_icingaweb2url = "https://www.example.com/icingaweb2"
|
||||||
|
notification_logtosyslog = false
|
||||||
|
}
|
||||||
|
// interval = 0s
|
||||||
|
period = "24x7"
|
||||||
|
}
|
||||||
|
|
||||||
|
template Notification "matrix-service-notification" {
|
||||||
|
command = "matrix-service-notification"
|
||||||
|
|
||||||
|
states = [ OK, Warning, Critical, Unknown ]
|
||||||
|
types = [ Problem, Acknowledgement, Recovery, Custom,
|
||||||
|
FlappingStart, FlappingEnd,
|
||||||
|
DowntimeStart, DowntimeEnd, DowntimeRemoved ]
|
||||||
|
|
||||||
|
vars += {
|
||||||
|
// notification_icingaweb2url = "https://www.example.com/icingaweb2"
|
||||||
|
notification_logtosyslog = false
|
||||||
|
}
|
||||||
|
// interval = 0s
|
||||||
|
period = "24x7"
|
||||||
|
}
|
Loading…
Reference in a new issue