{"id":20541172,"url":"https://github.com/netways/icinga2-notification-telegram","last_synced_at":"2026-02-02T11:21:02.075Z","repository":{"id":148513470,"uuid":"119360870","full_name":"NETWAYS/icinga2-notification-telegram","owner":"NETWAYS","description":"Send Icinga 2 notifications via Telegram","archived":false,"fork":false,"pushed_at":"2023-12-06T09:57:54.000Z","size":285,"stargazers_count":15,"open_issues_count":0,"forks_count":9,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-03-27T22:11:50.209Z","etag":null,"topics":["icinga","notifications","plugin","telegram"],"latest_commit_sha":null,"homepage":"https://netways.de/","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NETWAYS.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,"governance":null}},"created_at":"2018-01-29T09:25:07.000Z","updated_at":"2025-03-02T16:51:08.000Z","dependencies_parsed_at":"2023-05-20T09:00:09.337Z","dependency_job_id":null,"html_url":"https://github.com/NETWAYS/icinga2-notification-telegram","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/NETWAYS%2Ficinga2-notification-telegram","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NETWAYS%2Ficinga2-notification-telegram/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NETWAYS%2Ficinga2-notification-telegram/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NETWAYS%2Ficinga2-notification-telegram/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NETWAYS","download_url":"https://codeload.github.com/NETWAYS/icinga2-notification-telegram/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248848275,"owners_count":21171339,"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":["icinga","notifications","plugin","telegram"],"created_at":"2024-11-16T01:19:53.834Z","updated_at":"2026-02-02T11:20:57.039Z","avatar_url":"https://github.com/NETWAYS.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Notification by Telegram\nSend Icinga 2 notifications via Telegram.\n\n## Preparing\n\n### Create your Bot\n\n\u003cimg src=\"img/Telegram.png\" width=\"25%\" align=\"right\"\u003e\n\nYou need a bot to begin:\n\nFollow the [official Telegram guide](https://core.telegram.org/bots) and do not forget to grab your bot `API TOKEN` (referred to here as `BOT_TOKEN`) afterwards\n\n### Get your chat_id(s)\n\nYou can notify a specific TG user account or throw a message to a TG group.\n\nIn order to do so you need to know the corresponding (hidden) ID also called `chat_id` (`-q TELEGRAM_CHATID`).\n\nIf you want to notify a **group/channel**:\n\n1. Add your bot to that group/channel\n1. Send with your favorite client a simple mention msg to your bot (e.g. `hi @mybot`)\n1. Catch updates for your bot:\n`curl https://api.telegram.org/bot\u003cBOT_TOKEN\u003e/getUpdates`\n1. Review the output, an example below:\n   \u003e \"message\":{\"message_id\":91, \"from\":{\"id\":123456789, \"is_bot\":false,\"first_name\":\"foo\",\"username\":\"foobar\",\"language_code\":\"de\"}, \"chat\":{\"id\":-987654321, \"title\":\"\u003cGROUPNAME\u003e\",\"type\":\"group\",\"all_members_are_administrators\":true},\"date\":1563547428,\"group_chat_created\":true}}]}`\n\n    There are 2 important parts here:\n     - a) `\"from\":{\"id\":123456789` which is the unique user/chat_id of the user who sends a message to your bot (required to send to a notify to that person directly)\n     - b) `\"chat\":{\"id\":-987654321` which is the unique group/channel id of the group where the message has been sent\n\nIf you do not want to notify a group i.e. just **a direct user notification**:\n\n1. Do the same as above, just at step 1 make a direct message to your bot instead\n1. As you have done a direct message you will only get a \"from\" id which is all you need here\n\n## Examples\n\n### Testing a notification\n\nSending a test notification – replace the token, botname and chat id obviously.\n\n```\nsudo -u nagios ./alert-by-telegram.sh -4 127.0.0.1 \\\n-a service \\\n-d\"$(date +%F-%T)\" \\\n-e serviceshort \\\n-l myhostalias \\\n-o testing-telegram-notifiy \\\n-p $BOT_NAME\u003e \\\n-q $GROUP_CHAT_ID \\\n-r $BOT_TOKEN \\\n-c mycomment \\\n-b mycommentauthor \\\n-i https://myicingaserver/icingaweb2 \\\n-n myhostdisplayname \\\n-s CRITICAL \\\n-t PROBLEM \\\n-u fullservicename\n```\n\n### Icinga2 objects\n#### Example host objects\n\u003cdetails\u003e\n   \u003csummary\u003eExample host template\u003c/summary\u003e\n\n```ini\ntemplate Host \"Generic Host Template\" {\n  check_command = \"hostalive\"\n  max_check_attempts = \"3\"\n  check_interval = 1m\n  retry_interval = 1m\n  check_timeout = 30s\n  enable_notifications = true\n  enable_active_checks = true\n  enable_passive_checks = true\n  enable_event_handler = true\n  enable_flapping = true\n  enable_perfdata = true\n  volatile = false\n  vars.notification_type = \"Telegram\"\n}\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n   \u003csummary\u003eExample host object\u003c/summary\u003e\n\n```ini\nobject Host \"icinga2-master\" {\n    import \"Generic Host Template\"\n    address = \"127.0.0.1\"\n}\n\n```\n\u003c/details\u003e\n\n#### Example user templates\n\u003cdetails\u003e\n   \u003csummary\u003eGeneric user template\u003c/summary\u003e\n\n```ini\ntemplate User \"Generic User Template\" {\n    enable_notifications = true\n}\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n   \u003csummary\u003eUser \"telegram_bot\"\u003c/summary\u003e\n\n```ini\nobject User \"telegram_bot\" {\n    import \"Generic User Template\"\n\n    display_name = \"Bot via Telegram\"\n    email = \"you@yourdomain.tld\"\n    states = [ Critical, Down, OK, Unknown, Up, Warning ]\n    types = [ Custom, Problem, Recovery ]\n}\n```\n\u003c/details\u003e\n\n#### Example command definitions\n\u003cdetails\u003e\n   \u003csummary\u003eNotification Command: Hosts by Telegram\u003c/summary\u003e\n\n```ini\nobject NotificationCommand \"Notify Host By Telegram\" {\n    import \"plugin-notification-command\"\n    command = [ \"/etc/icinga2/scripts/alert-by-telegram.sh\" ]\n    arguments += {\n        \"-4\" = {\n            required = true\n            value = \"$address$\"\n        }\n        \"-6\" = \"$address6$\"\n        \"-a\" = \"host\"\n        \"-b\" = \"$notification.author$\"\n        \"-c\" = \"$notification.comment$\"\n        \"-d\" = {\n            required = true\n            value = \"$icinga.long_date_time$\"\n        }\n        \"-i\" = \"$icingaweb2url$\"\n        \"-l\" = {\n            required = true\n            value = \"$host.name$\"\n        }\n        \"-n\" = \"$host.display_name$\"\n        \"-o\" = {\n            required = true\n            value = \"$host.output$\"\n        }\n        \"-p\" = {\n            required = true\n            value = \"$telegram_bot$\"\n        }\n        \"-q\" = {\n            required = true\n            value = \"$telegram_chatid$\"\n        }\n        \"-r\" = {\n            required = true\n            value = \"$telegram_bottoken$\"\n        }\n        \"-s\" = {\n            required = true\n            value = \"$host.state$\"\n        }\n        \"-t\" = {\n            required = true\n            value = \"$notification.type$\"\n        }\n        \"-v\" = \"$telegram_notification_logtosyslog$\"\n    }\n}\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n   \u003csummary\u003eNotification Command: Services by Telegram\u003c/summary\u003e\n\n```ini\nobject NotificationCommand \"Notify Service By Telegram\" {\n    import \"plugin-notification-command\"\n    command = [ \"/etc/icinga2/scripts/alert-by-telegram.sh\" ]\n    arguments += {\n        \"-4\" = {\n            required = true\n            value = \"$address$\"\n        }\n        \"-6\" = \"$address6$\"\n        \"-a\" = \"service\"\n        \"-b\" = \"$notification.author$\"\n        \"-c\" = \"$notification.comment$\"\n        \"-d\" = {\n            required = true\n            value = \"$icinga.long_date_time$\"\n        }\n        \"-e\" = {\n            required = true\n            value = \"$service.name$\"\n        }\n        \"-i\" = \"$icingaweb2url$\"\n        \"-l\" = {\n            required = true\n            value = \"$host.name$\"\n        }\n        \"-n\" = \"$host.display_name$\"\n        \"-o\" = {\n            required = true\n            value = \"$service.output$\"\n        }\n        \"-p\" = {\n            required = true\n            value = \"$telegram_bot$\"\n        }\n        \"-q\" = {\n            required = true\n            value = \"$telegram_chatid$\"\n        }\n        \"-r\" = {\n            required = true\n            value = \"$telegram_bottoken$\"\n        }\n        \"-s\" = {\n            required = true\n            value = \"$service.state$\"\n        }\n        \"-t\" = {\n            required = true\n            value = \"$notification.type$\"\n        }\n        \"-u\" = {\n            required = true\n            value = \"$service.display_name$\"\n        }\n        \"-v\" = \"$telegram_notification_logtosyslog$\"\n    }\n}\n```\n\u003c/details\u003e\n\n#### Example notification objects\n\u003c!-- NOTIFICATION TEMPLATE TELEGRAM GENERIC --\u003e\n\u003cdetails\u003e\n   \u003csummary\u003eNotification Template: Telegram Generic\u003c/summary\u003e\n\n```ini\ntemplate Notification \"Template: Telegram (Generic)\" {\n    vars.telegram_bot = \"\u003cYOUR_TELEGRAM_BOT_NAME\u003e\"\n    vars.telegram_bottoken = \"\u003cYOUR_TELEGRAM_BOT_TOKEN\u003e\"\n    vars.telegram_chatid = \"\u003cYOUR_TELEGRAM_CHAT_ID\u003e\"\n    vars.telegram_notification_logtosyslog = true\n}\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n   \u003csummary\u003eNotification Template: Host Notifications\u003c/summary\u003e\n\n```ini\ntemplate Notification \"Template: Host Notifications via Telegram\" {\n    import \"Template: Telegram (Generic)\"\n\n    command = \"Notify Host By Telegram\"\n    interval = 1h\n}\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n   \u003csummary\u003eNotification Template: Service Notifications\u003c/summary\u003e\n\n```ini\ntemplate Notification \"Template: Service Notifications via Telegram\" {\n    import \"Template: Telegram (Generic)\"\n\n    command = \"Notify Service By Telegram\"\n    interval = 4h\n}\n```\n\u003c/details\u003e\n\n#### Example notification apply rules\n\u003cdetails\u003e\n   \u003csummary\u003eApply rule for host notifications\u003c/summary\u003e\n\n```ini\n   apply Notification \"Host Alert via @telegram_bot\" to Host {\n    import \"Template: Host Notifications via Telegram\"\n\n    interval = 1h\n    assign where host.vars.notification_type == \"Telegram\"\n    states = [ Down, Up ]\n    types = [ Custom, Problem, Recovery ]\n    users = [ \"telegram_bot\" ]\n}\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n   \u003csummary\u003eApply rule for service notifications\u003c/summary\u003e\n\n```ini\napply Notification \"Service Alerts via @telegram_bot\" to Service {\n  import \"Template: Service Notifications via Telegram\"\n\n  interval = 12h\n  assign where host.vars.notification_type == \"Telegram\"\n  users = [ \"telegram_bot\" ]\n}\n```\n\u003c/details\u003e\n\n#### Example Director screenshot\n\u003cdetails\u003e\n   \u003csummary\u003eNotifications by Telegram via Icinga Director\u003c/summary\u003e\n\n![Icinga Director Config](img/Telegram_Notification_in_Icinga_Director.jpg)\n\u003c/details\u003e\n\n#### Related Director Baskets\n* [Just the Commands](contrib/Director-Basket_Telegram_Commands.json)\n* [Commands and Notification Templates with fields](contrib/Director-Basket_Telegram_Notifications.json)\n  (requires Director v1.8.0 or a master newer than [80f9ea2](https://github.com/Icinga/icingaweb2-module-director/commit/80f9ea2))\n\n## License\n\nCopyright (C) 2018 Marianne M. Spiller \u003cgithub@spiller.me\u003e\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program.  If not, see \u003chttp://www.gnu.org/licenses/\u003e.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetways%2Ficinga2-notification-telegram","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnetways%2Ficinga2-notification-telegram","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetways%2Ficinga2-notification-telegram/lists"}