Icinga2 Notification to Telegram through Director
Prerequisite
- Telegram BOT Token code and Chat ID created. If you haven't created these, please consult here
- Notification Users are created in Icinga Director
Create new command on Icinga2
We have created custom bash codes to translate Icinga notifications to Telegram. Download them into the scripts directory.
cd /etc/icinga2/scripts wget https://raw.githubusercontent.com/LEARN-LK/Tutorials/master/Scripts/ICINGA2/icinga2-telegram-host.sh wget https://raw.githubusercontent.com/LEARN-LK/Tutorials/master/Scripts/ICINGA2/icinga2-telegram-service.sh chmod +x icinga2-telegram-host.sh chmod +x icinga2-telegram-service.sh
Then log into Icinga Director and create two commands as follows.
- Host Alarm to Telegram
Add following Arguments as well.
- Service Alarm to Telegram
Add following Arguments as well.
Create Custom Variables
Above scripts uses two custom variables called tokencode and chat_id, these are Telegram User specific data and we have to define them on Iciga Director before applying it on Notifications.
Go to Icinga Director --> Data Field Categories
Add a Data Category as below.
Then go to Icinga Director --> Define Data Fields
Create two new Data Fields as follows:
- Token Code
- Chat ID
Telegram Notification Templates
Create following templates with the given data.
- Telegram Host Notification Template
- Include custom fields we created earlier. Goto the Fields tab of the template and enter chat_id and tockencode as mandatory fields
- Telegram Service Notification Template
- Goto the Fields tab of the template and enter
chat_id
andtockencode
as mandatory fields based on previous guidelines.
Create Notifications to Telegram
In this setup, we shall create two notifications setups for Hosts and Services respectively. When assigning notifications we should select a user rather than a user group to avoid multiple duplicates of notifications.
- Telegram-Host-Notification
- Telegram-Service-Notification
- Finally, Deploy the changes you did.
Attachments (14)
- HostAlarm-Telegram.png (76.3 KB ) - added by 4 years ago.
- HAT-Args.png (73.4 KB ) - added by 4 years ago.
- ServiceAlarm-Telegram.png (63.3 KB ) - added by 4 years ago.
- SAT-Args.png (88.7 KB ) - added by 4 years ago.
- DataCat1.png (151.3 KB ) - added by 4 years ago.
- DataCat2.png (52.1 KB ) - added by 4 years ago.
- TokenCode.png (62.6 KB ) - added by 4 years ago.
- ChatId.png (55.3 KB ) - added by 4 years ago.
- THT.png (112.3 KB ) - added by 4 years ago.
- Field_chatId.png (94.6 KB ) - added by 4 years ago.
- Field_tokencode.png (108.7 KB ) - added by 4 years ago.
- TST.png (114.0 KB ) - added by 4 years ago.
- TSN.png (148.4 KB ) - added by 4 years ago.
- THS.png (141.8 KB ) - added by 4 years ago.
Download all attachments as: .zip