{"id":23592602,"url":"https://github.com/filipnet/checkmk-telegram-notify","last_synced_at":"2025-10-14T21:30:54.303Z","repository":{"id":47190814,"uuid":"311097091","full_name":"filipnet/checkmk-telegram-notify","owner":"filipnet","description":"Get alerted by Check_MK via Telegram bash script","archived":false,"fork":false,"pushed_at":"2025-05-11T06:58:42.000Z","size":1554,"stargazers_count":61,"open_issues_count":0,"forks_count":30,"subscribers_count":10,"default_branch":"main","last_synced_at":"2025-05-20T07:06:44.701Z","etag":null,"topics":["alert","bash","bash-script","checkmk","checkmk-extension","monitoring","monitoring-plugins","nagios","notifications","telegram","telegram-bot","telegram-bot-api"],"latest_commit_sha":null,"homepage":"https://www.filipnet.de/checkmk-telegram-notify","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/filipnet.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-11-08T15:48:02.000Z","updated_at":"2025-05-13T15:00:55.000Z","dependencies_parsed_at":"2024-07-30T17:59:54.994Z","dependency_job_id":"2a604447-16f6-4601-8260-e30f0bc4ce56","html_url":"https://github.com/filipnet/checkmk-telegram-notify","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/filipnet/checkmk-telegram-notify","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/filipnet%2Fcheckmk-telegram-notify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/filipnet%2Fcheckmk-telegram-notify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/filipnet%2Fcheckmk-telegram-notify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/filipnet%2Fcheckmk-telegram-notify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/filipnet","download_url":"https://codeload.github.com/filipnet/checkmk-telegram-notify/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/filipnet%2Fcheckmk-telegram-notify/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279021373,"owners_count":26087022,"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","status":"online","status_checked_at":"2025-10-14T02:00:06.444Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["alert","bash","bash-script","checkmk","checkmk-extension","monitoring","monitoring-plugins","nagios","notifications","telegram","telegram-bot","telegram-bot-api"],"created_at":"2024-12-27T08:14:54.343Z","updated_at":"2025-10-14T21:30:54.297Z","avatar_url":"https://github.com/filipnet.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Telegram Plugin](https://img.shields.io/badge/Telegram-Plugin-blue)\n![Checkmk Compatible](https://img.shields.io/badge/Check__MK-Compatible-brightgreen)\n\n# Checkmk Telegram Notify\n\n\u003cimg src=\"images/logo-checkmk-telegram-notify.png\" alt=\"Checkmk Telegram Notify Logo\" width=\"300\" align=\"right\" hspace=\"30\" vspace=\"20\"/\u003e\n\n\u003c!-- TOC --\u003e\n\n- [Checkmk Telegram Notify](#checkmk-telegram-notify)\n  - [Compatibility](#compatibility)\n  - [Example](#example)\n  - [Requirements](#requirements)\n  - [Installation](#installation)\n  - [Update existing installation](#update-existing-installation)\n  - [Checkmk configuration](#checkmk-configuration)\n    - [Acivate changes](#acivate-changes)\n    - [Test notifications](#test-notifications)\n  - [Optional features](#optional-features)\n    - [Use of Telegram topics / threads](#use-of-telegram-topics--threads)\n    - [Privacy anonymization / masquerading](#privacy-anonymization--masquerading)\n    - [Custom User Attributes](#custom-user-attributes)\n    - [Custom Macro](#custom-macro)\n    - [Telegram Chat-ID instead of Group-ID](#telegram-chat-id-instead-of-group-id)\n  - [Help \u0026 Troubleshooting Guide](#help--troubleshooting-guide)\n  - [Contributions](#contributions)\n  - [License](#license)\n\n\u003c!-- /TOC --\u003e\n\n## Compatibility\n\nUnderstanding compatibility ensures that the plugin works seamlessly with your specific Checkmk version and environment.\n\n- Checkmk RAW version 1.6.0p18\n- Checkmk RAW version 2.4.0p4 for RedHat/CentOS/AlmaLinux/RockyLinux 8 and 9\n- Should also work with other versions of Checkmk\n\n## Example\n\nNotifications are usually sent via a Telegram group. Here is an example of how a Telegram notification is structured.\n\n\u003cimg src=\"images/telegram_notification_example.png\" alt=\"Telegram notification example\" width=\"100%\"/\u003e\n\n## Requirements\n\nTo enable Checkmk to send notifications via Telegram, you need:\n\n- a Telegram bot\n- a username for the bot\n- an API token\n- a Telegram Chat- or Group-ID\n\nFor detailed instructions on creating a Telegram bot, refer to the [official Telegram Bot documentation](https://core.telegram.org/bots#6-botfather).\n\n## Installation\n\nSwitch to the Checkmk site user to ensure proper permissions for the following commands\n\n```\nsu - mysite\n```\n\nNavigate to the notification directory where custom notification scripts are stored\n\n```\ncd ~/local/share/Checkmk/notifications/\n```\n\nDownload the Telegram notify script from the Git repository (a new subfolder will be created to store the notification script and its related files, which are essential for the setup process)\n\n```\n`git clone https://github.com/filipnet/checkmk-telegram-notify.git`\n```\n\nGive the script execution permissions to ensure the script is executable and can be run by the system\n\n```\nchmod +x checkmk-telegram-notify/check_mk_telegram-notify.sh\nls -l checkmk-telegram-notify/check_mk_telegram-notify.sh\n```\n\nCreate a symbolic link to enable the plugin and integrate the notification script into the Checkmk system. This ensures the script is recognized and executed for Telegram notifications. Verify the symlink using `ls -l` to confirm it points to the correct script.\n\n```\nln -s checkmk-telegram-notify/check_mk_telegram-notify.sh check_mk_telegram-notify.sh\n```\n\n## Update existing installation\n\nTo update an existing installation of the Checkmk Telegram notification script, follow these steps to ensure you have the latest features and fixes.\n\n```\nsu - mysite\ncd ~/local/share/check_mk/notifications/checkmk-telegram-notify\ngit pull\n```\n\n## Checkmk configuration\n\nNow you can create your own alarm rules in Checkmk, which are configurations that define how and when notifications are sent based on specific conditions or events in your monitoring setup.\n\nTo navigate to this path in the Checkmk interface, go to the main menu, select \"Setup,\" then \"Events,\" and finally \"Notifications.\"\n\n`Setup → Events → Notifications`\n\nFirst create a clone of your existing mail notification rule\n\n\u003cimg src=\"images/global_notification_rules_create_clone_v2.png\" alt=\"Create clone\" width=\"100%\"/\u003e\n\n- Change the description (e.g. Notify all contacts of a host/service via Telegram)\n- The notification method is \"Push Notification (by Telegram)\"\n- Select option \"Call with the following parameters:\"\n- As the first parameter we set the Telegram token ID (without bot-prefix), e.g., `123456789:ABCDEF1234567890abcdef1234567890`\n- The second parameter is the Telegram Chat-ID or Telegram Group-ID e.g., `-1001234567890`\n\n\u003cimg src=\"images/create_new_notification_rule_for_telegram_v2.png\" alt=\"Adjust settings\" width=\"100%\"/\u003e\n\nReferring to #6 and #15 at this point the note that initially only one field is displayed, further fields are only displayed after the first field has been filled.\n\nFor configuration in Checkmk Legacy versions (1.x), please refer to [LEGACY_CONFIGURATION.md](LEGACY_CONFIGURATION.md).\n\n### Acivate changes\n\nTo activate it you have to press \"Active on selected sites\"\n\n\u003cimg src=\"images/activate_on_selected_sites.png\" alt=\"Active on selected sites\" width=\"200\"/\u003e\n\nRestarting the Checkmk instance ensures that all configuration changes, including notification rules and script parameters, are fully applied and operational. This step helps avoid potential issues where changes might not take effect until the system is restarted.\n\n```\nsu - mysite\nomd stop\nomd start\n```\n\n### Test notifications\n\nYou can verify if your notification rules are applied correctly by performing a notification check. Navigate to `Setup \u003e Events \u003e Notifications \u003e Configuration` and use the `Test Notifications` button. This allows you to simulate and confirm the behavior of your notification rules.\n\n\u003cimg src=\"images/notification_configuration_test.png\" alt=\"Test Notifications\" width=\"60%\"/\u003e\n\n## Optional features\n\n### Use of Telegram topics / threads\n\nTelegram topics (also referred to as threads) are a feature available in Telegram groups that allow you to organize discussions into separate threads. This is particularly useful for managing notifications in large groups, as it helps keep conversations focused and organized.\n\nTo send notifications to a specific topic within a Telegram group, append the `Thread-ID` to the `Group-ID`, separated by a colon. For example: `Group-ID:Thread-ID`.\n\n\u003cimg src=\"images/notification_rule_use_topic.png\" alt=\"Use of topic\" width=\"60%\"/\u003e\n\nTo find the `Thread-ID`, use the `getUpdates` method of the Telegram Bot API:\n\n```\nhttps://api.telegram.org/bot\u003cYOUR_BOT_TOKEN\u003e/getUpdates\n```\n\nIn the JSON response, look for the `message_thread_id` field. This field contains the ID of the thread. Example output:\n\n```\n... \"date\":1743786667, \"message_thread_id\":281234, \"forum_topic_created\": ...\n```\n\nBy combining the `Group-ID` and `Thread-ID`, you can ensure that notifications are sent directly to the desired topic within the group.\n\n### Privacy anonymization / masquerading\n\nThe current version of this script allows you to optionally enable IP anonymization. This gives you the option to comply with your own privacy policy or the recommendations of data protection authorities in certain countries if they prohibit the transmission of the full IP address. This masks IPv4 and IPv6 IP addresses before they are transmitted in a message to the Telegram service.\n\nThe activation of the privacy settings is realized directly in the Notification Rules in Checkmk by NOTIFY_PARAMETER_3, here the value \"privacy\" has to be entered:\n\n\u003cimg src=\"images/notification_rule_modify_privacy.png\" alt=\"Enable privacy settings\" width=\"100%\"/\u003e\n\nThere are certainly different requirements for privacy and masquerading of IP addresses. In the script, the IPv4 IP address is split into the 4 octets, the IPv6 address into the 8 columns. This allows to control **very individually** which parts of the addresses are sent via Telegram and which are not. Both, placeholders and manipulations are basically possible here.\n\nThe adjustment is done exclusively in the following two lines of the script (Details in the readme.md).\n\n```\nNOTIFY_HOST_ADDRESS_4=\"${sec1}.${sec2}.2.${sec4}\"\nNOTIFY_HOST_ADDRESS_6=\"${sec1}:${sec2}:${sec3}:${sec4}:ffff:ffff:ffff:${sec8}\"\n```\n\nExplanation for the example configuration above:\n\n- 192.168.**143**.104 --\u003e 192.168.**2**.104\n- 2001:db8:85a3:8d3:**1319**:**8a2e**:**370**:7348 --\u003e 2001:db8:85a3:8d3:**ffff**:**ffff**:**ffff**:7348\n\n### Custom User Attributes\n\nYou can add a custom user attribute and use it in your script. This feature is particularly useful for tailoring notifications to individual users or groups, allowing you to specify unique identifiers like Telegram Chat-IDs directly in user profiles. It ensures that notifications are sent to the correct recipients without requiring manual adjustments in the script.\n\n- Go to: `Setup \u003e Users \u003e Custom User Attributes`\n\n\u003cimg src=\"images/custom_user_attributes_menu.png\" alt=\"Custom user attribute menu link\" width=\"30%\"/\u003e\n\n- Create a custom attribute named `TELEGRAMCHAT` by click to `Add attribute`\n- Do NOT change the name, as it is required for compatibility with the notification script and Checkmk's configuration.\n- You can change the title and help text\n- Make sure you activate the option `Make this variable available in notifications`\n\n\u003cimg src=\"images/custom_user_attributes_creation.png\" alt=\"Custom user attribute creation\" width=\"100%\"/\u003e\n\n- Edit your user and enter your Group/Chat-ID\n\n\u003cimg src=\"images/user_add_chat_id.png\" alt=\"Custom macro for notification\" width=\"100%\"/\u003e\n\n### Custom Macro\n\n- Go to: `Setup \u003e Events \u003e Notifications\u003e`\n\n\u003cimg src=\"images/notification_configuration.png\" alt=\"Notification configuraton menu\" width=\"20%\"/\u003e\n\n- Edit your notifcation. Add a custom macro.\n\nThis pattern ensures that only valid Telegram Chat-IDs are used in the notification setup by accepting numbers with or without an optional minus sign and requiring a minimum of 5 digits.:\nRegex : `^-?\\d{5,}$`\n\n- Breakdown:\n\n```\n^: Start of the string.\n-?: An optional minus sign.\n\\d{5,}: Five or more consecutive digits.\n$: End of the string.\n```\n\n- The macro ensures that only users with a valid Chat-ID receive notifications.\n- It validates the format of the Chat-ID, requiring a numeric value with at least 5 digits (the expected format for Telegram Chat-IDs).\n- Users without a valid Chat-ID will not receive notifications.\n- This behavior effectively acts as a whitelist, including only users with properly configured Chat-IDs matching the regex pattern.\n\n### Telegram Chat-ID instead of Group-ID\n\nA different approach is to use the 'Pager address' field in Checkmk's user properties. This method simplifies configuration by directly linking user properties to the notification script, avoiding the need for additional custom attributes. The 'Pager address' gets exported as $NOTIFY_CONTACTPAGER variable to the script and as such all that's needed is:\n\n```\nif [ -z ${NOTIFY_CONTACTPAGER} ]; then\n        echo \"No pager address provided to be used as Chat-ID. Exiting\" \u003e\u00262\n        exit 2\nelse\n        CHAT_ID=\"${NOTIFY_CONTACTPAGER}\"\nfi\n```\n\n\u003cimg src=\"images/notification_custom_macro.png\" alt=\"Custom macro for notification\" width=\"100%\"/\u003e\n\n## Help \u0026 Troubleshooting Guide\n\nYou can find further information and assistance in the [HELP.md](HELP.md)\n\n## Contributions\n\n- Thank you for the excellent code optimization contributions and additional information [ThomasKaiser](https://github.com/ThomasKaiser).\n- Best regards to [Jonathan Barratt](https://github.com/reduxionist) in Bangkok and many thanks for adding emojies to the module.\n- Many thanks to [progamernoob](https://github.com/progamernoob) for the contributions and enhancements to custom user attributes and macros.\n- Big thanks to [Sebastian Hayer-Lutz](https://github.com/Elompenta) for the idea with the symlinks and thereby supporting several plugins, as well as the timeout optimization.\n- Great Work [Christian Hesse](https://github.com/eworm-de) for implementing the solution to send notifications to specific topics within a Telegram group.\n\n## License\n\ncheckmk-telegram-notify and all individual scripts are under the BSD 3-Clause license unless explicitly noted otherwise. See the [LICENSE](LICENSE) file for more details\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffilipnet%2Fcheckmk-telegram-notify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffilipnet%2Fcheckmk-telegram-notify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffilipnet%2Fcheckmk-telegram-notify/lists"}