You can use the Telegram messenger to receive status notifications for your infrastructure. The platform uses a Telegram bot to send notifications.
A bot is an application that can send messages to a general chat or directly to a Telegram user. The platform interacts with bots via the Telegram API. A unique bot token is used for authorization. When setting up notifications, you will be able to select the chats to which the bot will send messages.
To configure sending notifications to Telegram:
- Create a Telegram bot.
- Connect the bot to the platfom.
- Add Telegram as the notification channel.
Configuration on Telegram side
- Open the chat with @BotFather.
- Send the command /newbot.
- Enter the bot name. E.g. Notify Me.
- Enter the unique bot user name. It must finish with "bot". E.g., notifyme876bot.
- Save the token value from the response.
- In order for the bot to send messages to a Telegram group:
- Add the bot to the Telegram group.
- Enter any command in the group chat. For example, /start.
- In order for the bot to send messages to a Telegram user, the user must open the chat with the bot and click Start.
Example of creating a bot
Configuration on VMmanager side
Connecting the bot
- In the right menu, click the icon → Messengers section → Connect a messenger button.
- Insert the Bot token.
- Click Activate button.
- Select the required chats for sending notifications.
- Select the Messages language.
- Click Save button.
To change the bot connection settings, click the icon next to Messenger chats header → enter the Bot token → Save button.
To delete the bot connection settings, click the icon next to Messenger chats header → Delete the bot button.
Managing chats
To manage the chats to which the bot sends messages, in the right menu, click the icon → Messengers section. Channels may include groups and individual Telegram users.
To add a chat:
- Click Add chat button.
- Select the Messages language.
- Specify the discretionary Chat name.
- Select a chat from the list or Enter the chat ID.
- Specify the discretionary Comment for the chat.
- Click Add button.
To change the chat settings, click the icon in the chat line.
To enable or disable notifications to the channel, click the switch in the chat line.
To delete the chat, click the icon in the chat line.
Notification settings
To use Telegram as the notification channel:
- Enter the Notifications center: in the right menu, click the icon → Notification settings.
- Click the notification name.
- Select channels in To the messengers' channels field.
- Click Save button.
Features of handling Telegram supergroups
In some cases, Telegram may change the status of your group to supergroup. For example, if the group has become public or has more than 200 members. When the group status changes, its id will change and notifications will not be sent. To resume sending notifications, specify the new id in the chat settings.
If a supergroup uses multiple threads, notifications will only be sent to the main chat.
Configuring simultaneous notifications
By default, the platfom sends no more than five notifications to Telegram at a time. To change this setting:
- Connect to the server with the platform via SSH.
-
Enter the container with the messaging service:
Command for VMmanager 6docker exec -it vm_msgsender_1 bash
Command for DCImanager 6docker exec -it dci_msgsender_1 bash
-
Add to the [program:msgs_writer] section of the configuration file /etc/supervisord.conf.d/msgsender.conf parameter:
environment=TELEGRAM_TASK_LIMIT=<number>
CommentsIt is not recommended to set <number> value higher than 10. This may cause the bot to be blocked by Telegram. -
Execute the command:
supervisorctl update
-
Exit the docker container:
exit
To check the simultaneous sending of messages:
- Connect to the server with the platform via SSH.
-
Connect to the platform database:
Command for VMmanager 6docker exec -it mysql bash -c "mysql isp -p\$MYSQL_ROOT_PASSWORD"
Command for DCImanager 6docker exec -it mysql bash -c "mysql auth -p\$MYSQL_ROOT_PASSWORD"
-
Perform the request:
SELECT id, name, lock_tag from taskmgr_task WHERE name = 'msgsender_telegram_send' ORDER BY id desc LIMIT 10;
The number in the lock_tag column shows the number of the message in the queue.
Example answer+-------+-------------------------+--------------------------------+ | id | name | lock_tag | +-------+-------------------------+--------------------------------+ | 11493 | msgsender_telegram_send | ["msgsender_telegram_send.6"] | | 11492 | msgsender_telegram_send | ["msgsender_telegram_send.5"] | | 11485 | msgsender_telegram_send | ["msgsender_telegram_send.4"] | | 11484 | msgsender_telegram_send | ["msgsender_telegram_send.3"] | | 11483 | msgsender_telegram_send | ["msgsender_telegram_send.2"] | | 11482 | msgsender_telegram_send | ["msgsender_telegram_send.1"] | | 11481 | msgsender_telegram_send | ["msgsender_telegram_send.7"] | | 11480 | msgsender_telegram_send | ["msgsender_telegram_send.10"] | | 11479 | msgsender_telegram_send | ["msgsender_telegram_send.9"] | | 11478 | msgsender_telegram_send | ["msgsender_telegram_send.8"] | +-------+-------------------------+--------------------------------+
-
Exit the MySQL console:
exit