{"id":13783665,"url":"https://github.com/linuxmail/icinga2-matrix_notification","last_synced_at":"2025-05-11T19:31:20.271Z","repository":{"id":52890079,"uuid":"128812879","full_name":"linuxmail/icinga2-matrix_notification","owner":"linuxmail","description":"Icinga2 notification to Matrix.org chat rooms","archived":false,"fork":false,"pushed_at":"2021-04-15T01:23:29.000Z","size":145,"stargazers_count":6,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-17T20:47:43.638Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/linuxmail.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-04-09T17:58:15.000Z","updated_at":"2024-06-10T20:03:31.000Z","dependencies_parsed_at":"2022-08-23T13:30:51.399Z","dependency_job_id":null,"html_url":"https://github.com/linuxmail/icinga2-matrix_notification","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linuxmail%2Ficinga2-matrix_notification","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linuxmail%2Ficinga2-matrix_notification/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linuxmail%2Ficinga2-matrix_notification/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linuxmail%2Ficinga2-matrix_notification/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/linuxmail","download_url":"https://codeload.github.com/linuxmail/icinga2-matrix_notification/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253621042,"owners_count":21937468,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T19:00:27.987Z","updated_at":"2025-05-11T19:31:19.912Z","avatar_url":"https://github.com/linuxmail.png","language":"Shell","funding_links":[],"categories":["Other softwares plugins"],"sub_categories":["Icinga2"],"readme":"# icinga2-matrix_notification\nSent Icinga2 notifications to Matrix.org or own Matrix homeserver chatroom\n\n* https://matrix.org\n\u003e An open network for secure, decentralized communication.\n\nThe scripts itself are just a bad clone from the original mail notifications, which are from https://github.com/sysadmama if I remember correctly. The \"only\" difference is -- that instead of creating a mail -- we use curl to submit the notification into a room.\n\n![example-screenshot](https://raw.githubusercontent.com/linuxmail/icinga2-matrix_notification/master/example-screenshot.png)\n\nTo send notifications from Icinga2 into a room, the following conditions are required:\n* A matrix compatible server, e.g [matrix-synapse](https://github.com/matrix-org/synapse) or use https://matrix.org\n* An access token to get access to the Matrix server\n* A Matrix room ID\n* Access to the room (invite) as the Matrix user, which sends the notifications.\n\nThere exists several ways for creating a Matrix user, but an easy way is to create a new user (for example \"monitoring\" via login in [Riot web](https://riot.im/app/)); get the access token and invite the new Matrix user into the room, which may was created for the monitoring. A good approach is to have several rooms, for example devops, sysops, web, dba .... and use the apply rule to assign the correct room with the $notification_matrix_room_id$ .\n\nThe following configuration examples should work in most cases :-)\n\n## commands.cfg\n\n * **Host Matrix NotificationCommand**\n\n```\nobject NotificationCommand \"Host Alarm by Matrix\" {\n    import \"plugin-notification-command\"\n    command = [ SysconfDir + \"/icinga2/scripts/matrix-host-notification.sh\" ]\n    arguments += {\n        \"-4\" = \"$notification_address$\"\n        \"-6\" = \"$notification_address6$\"\n        \"-b\" = \"$notification_author$\"\n        \"-c\" = \"$notification_comment$\"\n        \"-d\" = {\n            required = true\n            value = \"$notification_date$\"\n        }\n        \"-i\" = \"$notification_icingaweb2url$\"\n        \"-l\" = {\n            required = true\n            value = \"$notification_hostname$\"\n        }\n        \"-m\" = {\n            required = true\n            value = \"$notification_matrix_room_id$\"\n        }\n        \"-n\" = {\n            required = true\n            value = \"$notification_hostdisplayname$\"\n        }\n        \"-o\" = {\n            required = true\n            value = \"$notification_hostoutput$\"\n        }\n        \"-s\" = {\n            required = true\n            value = \"$notification_hoststate$\"\n        }\n        \"-t\" = {\n            required = true\n            value = \"$notification_type$\"\n        }\n        \"-x\" = {\n            required = true\n            value = \"$notification_matrix_server$\"\n        }\n        \"-y\" = {\n            required = true\n            value = \"$notification_matrix_token$\"\n        }\n    }\n    vars.notification_address = \"$address$\"\n    vars.notification_address6 = \"$address6$\"\n    vars.notification_author = \"$notification.author$\"\n    vars.notification_comment = \"$notification.comment$\"\n    vars.notification_date = \"$icinga.long_date_time$\"\n    vars.notification_hostdisplayname = \"$host.display_name$\"\n    vars.notification_hostname = \"$host.name$\"\n    vars.notification_hostoutput = \"$host.output$\"\n    vars.notification_hoststate = \"$host.state$\"\n    vars.notification_type = \"$notification.type$\"\n}\n```\n * **Service Matrix NotificationCommand**\n\n```\nobject NotificationCommand \"Service Alarm by Matrix\" {\n    import \"plugin-notification-command\"\n    command = [ SysconfDir + \"/icinga2/scripts/matrix-service-notification.sh\" ]\n    arguments += {\n        \"-4\" = {\n            required = true\n            value = \"$notification_address$\"\n        }\n        \"-6\" = \"$notification_address6$\"\n        \"-b\" = \"$notification_author$\"\n        \"-c\" = \"$notification_comment$\"\n        \"-d\" = {\n            required = true\n            value = \"$notification_date$\"\n        }\n        \"-e\" = {\n            required = true\n            value = \"$notification_servicename$\"\n        }\n        \"-i\" = \"$notification_icingaweb2url$\"\n        \"-l\" = {\n            required = true\n            value = \"$notification_hostname$\"\n        }\n        \"-m\" = {\n            required = true\n            value = \"$notification_matrix_room_id$\"\n        }\n        \"-n\" = {\n            required = true\n            value = \"$notification_hostdisplayname$\"\n        }\n        \"-o\" = {\n            required = true\n            value = \"$notification_serviceoutput$\"\n        }\n        \"-s\" = {\n            required = true\n            value = \"$notification_servicestate$\"\n        }\n        \"-t\" = {\n            required = true\n            value = \"$notification_type$\"\n        }\n        \"-u\" = {\n            required = true\n            value = \"$notification_servicedisplayname$\"\n        }\n        \"-x\" = {\n            required = true\n            value = \"$notification_matrix_server$\"\n        }\n        \"-y\" = {\n            required = true\n            value = \"$notification_matrix_token$\"\n        }\n    }\n    vars.notification_address = \"$address$\"\n    vars.notification_address6 = \"$address6$\"\n    vars.notification_author = \"$notification.author$\"\n    vars.notification_comment = \"$notification.comment$\"\n    vars.notification_date = \"$icinga.long_date_time$\"\n    vars.notification_hostdisplayname = \"$host.display_name$\"\n    vars.notification_hostname = \"$host.name$\"\n    vars.notification_servicedisplayname = \"$service.display_name$\"\n    vars.notification_serviceoutput = \"$service.output$\"\n    vars.notification_servicestate = \"$service.state$\"\n    vars.notification_type = \"$notification.type$\"\n```\n\n## services.cfg\n\n```\n/**\n * Example Matrix.org apply rules.\n * The \"!\u003cid\u003e:matrix.org\" needs to be replaced with the room ID\n * for example \"!SDFfskjfdszhdaslasdkjhdasd:matrix.org\".\n * Also a Matrix access token is required too.\n */\n\napply Notification \"Matrix host problems\" to Host {\n    import \"matrix-host-notification\"\n\n    user_groups = host.vars.notification.matrix.groups\n    users = host.vars.notification.matrix.users\n    vars.notification_matrix_server = \"https://matrix.org\"\n    vars.notification_matrix_room_id = \"!\u003cid\u003e:matrix.org\"\n   // vars.notification_matrix_token = \"\u003caccess_token\u003e\"\n    assign where host.vars.notification.matrix\n}\n\napply Notification \"Matrix service problems\" to Service {\n    import \"matrix-service-notification\"\n\n    user_groups = host.vars.notification.matrix.groups\n    users = host.vars.notification.matrix.users\n    vars.notification_matrix_server = \"https://matrix.org\"\n    vars.notification_matrix_room_id = \"!\u003cid\u003e:matrix.org\"\n   // vars.notification_matrix_token = \"\u003caccess_token\u003e\"\n    assign where host.vars.notification.matrix\n}\n```\n\n## templates.cfg\n\n```\n/**\n * Provides default settings for Matrix.org service notifications.\n */\n\ntemplate Notification \"matrix-host-notification\" {\n  command = \"matrix-host-notification\"\n\n  states = [ Up, Down ]\n  types = [ Problem, Acknowledgement, Recovery, Custom,\n            FlappingStart, FlappingEnd,\n            DowntimeStart, DowntimeEnd, DowntimeRemoved ]\n  vars += {\n    // notification_icingaweb2url = \"https://www.example.com/icingaweb2\"\n    notification_logtosyslog = false\n  }\n    // interval = 0s\n    period = \"24x7\"\n}\n\ntemplate Notification \"matrix-service-notification\" {\n  command = \"matrix-service-notification\"\n\n  states = [ OK, Warning, Critical, Unknown ]\n  types = [ Problem, Acknowledgement, Recovery, Custom,\n            FlappingStart, FlappingEnd,\n            DowntimeStart, DowntimeEnd, DowntimeRemoved ]\n\n  vars += {\n    // notification_icingaweb2url = \"https://www.example.com/icingaweb2\"\n    notification_logtosyslog = false\n  }\n    // interval = 0s\n    period = \"24x7\"\n}\n```\n\nJust put the both scripts into the /etc/icinga2/scripts/ folder, make them 0755 executable and try it out.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinuxmail%2Ficinga2-matrix_notification","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flinuxmail%2Ficinga2-matrix_notification","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinuxmail%2Ficinga2-matrix_notification/lists"}