All Projects → filipnet → checkmk-telegram-notify

filipnet / checkmk-telegram-notify

Licence: BSD-3-Clause License
Get alerted by Check_MK via Telegram bash script

Programming Languages

shell
77523 projects

Projects that are alternatives of or similar to checkmk-telegram-notify

Bot Api Base
Clear and simple Telegram bot API
Stars: ✭ 122 (+335.71%)
Mutual labels:  telegram, telegram-bot, telegram-bot-api
Telegram Bot Sdk
🤖 Telegram Bot API PHP SDK. Lets you build Telegram Bots easily! Supports Laravel out of the box.
Stars: ✭ 2,212 (+7800%)
Mutual labels:  telegram, telegram-bot, telegram-bot-api
Botserver
http://telegram.org Bot API Webhooks Framework, for Rubyists
Stars: ✭ 125 (+346.43%)
Mutual labels:  telegram, telegram-bot, telegram-bot-api
Integram
Integrate Telegram into your workflow – Trello, Gitlab, Bitbucket and other bots
Stars: ✭ 1,365 (+4775%)
Mutual labels:  telegram, telegram-bot, telegram-bot-api
Telegrammer
Telegram Bot - written with Swift 5.2 / NIO, supports Linux, macOS
Stars: ✭ 248 (+785.71%)
Mutual labels:  telegram, telegram-bot, telegram-bot-api
Vk To Telegram Bot
Bot for auto-reposting posts from VK to Telegram channel
Stars: ✭ 103 (+267.86%)
Mutual labels:  telegram, telegram-bot, telegram-bot-api
Teledart
A Dart library interfacing with the latest Telegram Bot API.
Stars: ✭ 142 (+407.14%)
Mutual labels:  telegram, telegram-bot, telegram-bot-api
Telebot
The easy way to write Telegram bots in Node.js
Stars: ✭ 1,096 (+3814.29%)
Mutual labels:  telegram, telegram-bot, telegram-bot-api
Python Telegram
Python client for the Telegram's tdlib
Stars: ✭ 246 (+778.57%)
Mutual labels:  telegram, telegram-bot, telegram-bot-api
Rastreiobot
Telegram Bot @RastreioBot
Stars: ✭ 196 (+600%)
Mutual labels:  telegram, telegram-bot, telegram-bot-api
Telebot.nim
Async client for Telegram Bot API in pure Nim [Bot API 5.1]
Stars: ✭ 93 (+232.14%)
Mutual labels:  telegram, telegram-bot, telegram-bot-api
Telegram Bot Github
Allows to you receive GitHub notifications right in the Telegram
Stars: ✭ 103 (+267.86%)
Mutual labels:  notifications, telegram, telegram-bot
Libtelegram
Fast, efficient, header-only C++ Telegram bot API library using polling or FastCGI
Stars: ✭ 88 (+214.29%)
Mutual labels:  telegram, telegram-bot, telegram-bot-api
Zanzara
Asynchronous PHP Telegram Bot Framework built on top of ReactPHP
Stars: ✭ 107 (+282.14%)
Mutual labels:  telegram, telegram-bot, telegram-bot-api
Telegram Spring Boot Starter
Telegram Bot API Spring Boot Starter
Stars: ✭ 79 (+182.14%)
Mutual labels:  telegram, telegram-bot, telegram-bot-api
Telegram.bot
.NET Client for Telegram Bot API
Stars: ✭ 1,964 (+6914.29%)
Mutual labels:  telegram, telegram-bot, telegram-bot-api
Bot Telegram
Exemplo de como criar um BOT para o melhor app de mensagens do mundo: Telegram.
Stars: ✭ 53 (+89.29%)
Mutual labels:  telegram, telegram-bot, telegram-bot-api
University News Notifier
📚 University news notifier
Stars: ✭ 56 (+100%)
Mutual labels:  telegram, telegram-bot, telegram-bot-api
Java Telegram Bot Tutorial
Java Telegram Bot Tutorial. Feel free to submit issue if you found a mistake.
Stars: ✭ 165 (+489.29%)
Mutual labels:  telegram, telegram-bot, telegram-bot-api
Zabbix In Telegram
Zabbix Notifications with graphs in Telegram
Stars: ✭ 710 (+2435.71%)
Mutual labels:  notifications, telegram, telegram-bot

Check_MK Telegram notification

Telegram notification example

Telegram has long been one of my real-time communication media. It is obvious to output monitoring messages for server and network components as alarm messages. There are several scripts for this on the internet, but most of them are written in Python, many of them have problems with Python3 and its libraries. Instead of spending hours and hours with Python, I decided to use a scripting language I know and write a Linux Bash script for it.

COMPATIBILITY

  • Check_MK RAW version 1.6.0_p18
  • Check_MK RAW version 2.0.0_p8
  • Should also work with other versions of Check_MK

EXAMPLE

Notifications are usually sent via a Telegram group. Here is an example of how a Telegram notification is structured.

Telegram notification example

REQUIREMENTS

In order for Check_MK to send alerts (notifications) to the Telegram Messenger, we need

  • a Telegram bot
  • a username for the bot
  • an API token
  • a Telegram Chat- or Group-ID

There are a lot of good instructions for this on the Internet, so this is not part of this documentation.

INSTALLATION

Change to your Check_MK site user

su - mysite

Change to the notification directory

cd ~/local/share/check_mk/notifications/

Download the Telegram notify script from Git repository

git clone https://github.com/filipnet/checkmk-telegram-notify.git .

Give the script execution permissions

chmod +x check_mk_telegram-notify.sh

CHECK_MK CONFIGURATION

CHECK_MK VERSION 2.0.0 AND ABOVE

Now you can create your own alarm rules in Check_MK.

Setup → Events → Notifications

First create a clone of your existing mail notification rule

Create clone

  • Change the description (e.g. Notify all contacts of a host/service via Telegram)
  • The notification method is "Push Notification (by Telegram)"
  • Select option "Call with the following parameters:"
  • As the first parameter we set the Telegram token ID (without bot-prefix)
  • The second parameter is the Telegram Chat-ID or Telegram Group-ID

Adjust settings

CHECK_MK VERSION 1.6.0

Now you can create your own alarm rules in Check_MK.

WATO → Notifications → New Rule → Notification Method → Push Notification (using Telegram)

First create a clone of your existing mail notification rule

Create clone

  • Change the description (e.g. Notify all contacts of a host/service via Telegram)
  • The notification method is "Push Notification (by Telegram)"
  • Select option "Call with the following parameters:"
  • As the first parameter we set the Telegram token ID (without bot-prefix)
  • The second parameter is the Telegram Chat-ID or Telegram Group-ID

Adjust settings

If everything was ok, you will see your new Notification Rule afterwards

Final result

ACTIVATE CHANGES

To activate it you have to press "1 Change" and "Activate affected"

Activate changes and commit

Since Check_MK 2.0.0 it is calles "Active on selected sites"

Active on selected sites

To ensure that the parameters are also transferred in the event of an alert, it is strongly recommended that the Check_MK instance is restarted.

su - mysite
omd stop
omd start

PRIVACY ANONYMIZATION / MASQUERADING

The 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.

The activation of the privacy settings is realized directly in the Notification Rules in Check_MK by NOTIFY_PARAMETER_3, here the value "privacy" has to be entered:

Enable privacy settings

There 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.

The adjustment is done exclusively in the following two lines of the script.

# Adjust the output to your privacy needs here (Details in the readme.md)
NOTIFY_HOST_ADDRESS_4="${sec1}.${sec2}.2.${sec4}"
NOTIFY_HOST_ADDRESS_6="${sec1}:${sec2}:${sec3}:${sec4}:ffff:ffff:ffff:${sec8}"

Explanation for the example configuration above:

  • 192.168.143.104 --> 192.168.2.104
  • 2001:db8:85a3:8d3:1319:8a2e:370:7348 --> 2001:db8:85a3:8d3:ffff:ffff:ffff:7348

PAGER ADDRESS (CHAT-ID) INSTEAD OF TELEGRAM GROUP-ID

A different approach is to use the 'Pager address' field in Check_MK's user properties. This gets exported as $NOTIFY_CONTACTPAGER variable to the script and as such all that's needed is:

if [ -z ${NOTIFY_CONTACTPAGER} ]; then
        echo "No pager address provided to be used as Chat-ID. Exiting" >&2
        exit 2
else
        CHAT_ID="${NOTIFY_CONTACTPAGER}"
fi

TROUBLESHOOTING

For more details and troubleshooting with parameters please check:

CONTRIBUTIONS

  • Thank you for the excellent code optimization contributions and additional information ThomasKaiser.
  • Best regards to Jonathan Barratt in Bangkok and many thanks for adding emojies to the module.

LICENSE

checkmk-telegram-notify and all individual scripts are under the BSD 3-Clause license unless explicitly noted otherwise. Please refer to the LICENSE

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].