Skip to content
Snippets Groups Projects
Commit 37f6971e authored by void's avatar void
Browse files

icinga matrix notification

parent 3f79d671
No related branches found
No related tags found
No related merge requests found
...@@ -190,6 +190,8 @@ ...@@ -190,6 +190,8 @@
domain: icinga.warpzone.ms, domain: icinga.warpzone.ms,
api_port: 5665, api_port: 5665,
mysql_port: 33306, mysql_port: 33306,
matrix_notification_domain: "matrix.warpzone.ms",
matrix_notification_room: "!iYefxbySFEfFQfUGEK:matrix.warpzone.ms"
} }
- { - {
role: webserver/docker_hackmd, tags: hackmd, role: webserver/docker_hackmd, tags: hackmd,
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
- { path: "{{ basedir }}/icinga_api_pass", length: 8 } - { path: "{{ basedir }}/icinga_api_pass", length: 8 }
- { path: "{{ basedir }}/mysql_admin_pass", length: 12 } - { path: "{{ basedir }}/mysql_admin_pass", length: 12 }
- { path: "{{ basedir }}/mysql_user_pass", length: 12 } - { path: "{{ basedir }}/mysql_user_pass", length: 12 }
- { path: "{{ basedir }}/matrix_notification_access_token", length: -1 }
- name: pakete installieren - name: pakete installieren
......
...@@ -48,3 +48,9 @@ RUN cd /opt/ \ ...@@ -48,3 +48,9 @@ RUN cd /opt/ \
&& git clone https://github.com/elberfeld/check_metric_value.git \ && git clone https://github.com/elberfeld/check_metric_value.git \
&& cd /opt/check_metric_value/ \ && cd /opt/check_metric_value/ \
&& git checkout b94d3c3e78497a05e3b4520d33421f37e4d77985 && git checkout b94d3c3e78497a05e3b4520d33421f37e4d77985
# icinga2-matrix_notification - commit from 15.04.2012
RUN cd /opt/ \
&& git clone https://github.com/linuxmail/icinga2-matrix_notification \
&& cd /opt/icinga2-matrix_notification/ \
&& git checkout 99d2174a3b00e9a88648fe58bcd975368f69837d
/**
* Check MQTT values
*/
object CheckCommand "check_mqtt" { object CheckCommand "check_mqtt" {
import "plugin-check-command" import "plugin-check-command"
...@@ -33,6 +37,10 @@ object CheckCommand "check_mqtt" { ...@@ -33,6 +37,10 @@ object CheckCommand "check_mqtt" {
} }
} }
/**
* Check for Mail Blacklisting
*/
object CheckCommand "check_mail_blacklist" { object CheckCommand "check_mail_blacklist" {
import "plugin-check-command" import "plugin-check-command"
...@@ -45,6 +53,9 @@ object CheckCommand "check_mail_blacklist" { ...@@ -45,6 +53,9 @@ object CheckCommand "check_mail_blacklist" {
} }
} }
/**
* Check for Prometheus values
*/
object CheckCommand "check_metric_value" { object CheckCommand "check_metric_value" {
import "plugin-check-command" import "plugin-check-command"
...@@ -62,4 +73,138 @@ object CheckCommand "check_metric_value" { ...@@ -62,4 +73,138 @@ object CheckCommand "check_metric_value" {
"-w" = "$metric_warn$" "-w" = "$metric_warn$"
"-c" = "$metric_crit$" "-c" = "$metric_crit$"
} }
} }
\ No newline at end of file
/**
* Matrix Notification
*/
object NotificationCommand "matrix-host-notification" {
import "plugin-notification-command"
command = [ "/opt/icinga2-matrix_notification/scripts/matrix-host-notification.sh" ]
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 = [ "/opt/icinga2-matrix_notification/scripts/matrix-service-notification.sh" ]
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$"
}
// https://github.com/linuxmail/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"
vars.notification_matrix_server = "https://{{ matrix_notification_domain }}"
vars.notification_matrix_room_id = "{{ matrix_notification_room }}"
vars.notification_matrix_token = "{{ matrix_notification_access_token }}"
# Assign to all hosts
assign where host.address
}
apply Notification "Matrix service problems" to Service {
import "matrix-service-notification"
vars.notification_matrix_server = "https://{{ matrix_notification_domain }}"
vars.notification_matrix_room_id = "{{ matrix_notification_room }}"
vars.notification_matrix_token = "{{ matrix_notification_access_token }}"
# Assign to all services
assign where service.name
}
...@@ -81,3 +81,38 @@ template Notification "mail-service-notification" { ...@@ -81,3 +81,38 @@ template Notification "mail-service-notification" {
period = "24x7" period = "24x7"
} }
/**
* 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://{{ domain }}/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://{{ domain }}/icingaweb2"
notification_logtosyslog = false
}
// interval = 0s
period = "24x7"
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment