Sending notifications to Telegram
You can use the Telegram messenger to receive status notifications for virtual machines and cluster nodes. VMmanager uses a Telegram bot to send notifications.
To configure sending notifications to Telegram:
- Create a Telegram bot.
- Connect the bot to VMmanager.
- 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. VMmanager Notifier
- Enter the bot user name. It must finish with “bot”. E.g., vmnotifybot.
- Save the token value from the response.
Add the bot to the Telegram group for notifications.
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
- Enter
→ Messengers → Connect a messenger.
- 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 settings, click icon → enter the Bot token → Save button.
To delete a connected bot, click icon → Delete the bot → Delete button.
Example of deleting a bot
Managing channels
In → Messengers section you can manage channels to which the bot will send notifications. Channels may include groups and individual Telegram users.
To add a channel:
- Click Add channel button.
- Select the Messages language.
- Specify the discretionary Channel name.
- Select the channel from the list or Enter the chat ID.
- Specify the discretionary Comment for the channel.
- Click Add button.
Click icon to edit the channel settings.
Click icon to enable/disable notifications to the channel.
Click icon to delete the channel.
Messengers section of the interface
Adding a channel to notification
To use Telegram as the notification channel:
- Enter the Notifications center:
→ Notification settings.
- Click the notification name.
- Select channels in To the messengers' channels field.
- Click Save button.
Read more about managing notifications in Notifications.
Adding a notification channel
Configuring simultaneous notifications
By default, VMmanager sends no more than five notifications to Telegram at a time. To change this setting:
- Connect to the server with VMmanager via SSH.
Go to the vm_msgsender_1 docker container:
docker exec -it vm_msgsender_1 bash
BASHAdd to the [program:msgs_writer] section of the configuration file /etc/supervisord.conf.d/msgsender.conf parameter:
environment=TELEGRAM_TASK_LIMIT=<number>
CODEComments<number> — number of notifications to be sent simultaneously
It 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
BASHExit the docker container:
exit
BASH
To check the simultaneous sending of messages:
- Connect to the server with VMmanager via SSH.
Connect to the platform database:
docker exec -it mysql bash -c "mysql isp -p\$MYSQL_ROOT_PASSWORD"
BASHPerform the request:
SELECT id, name, lock_tag from taskmgr_task WHERE name = 'msgsender_telegram_send' ORDER BY id desc LIMIT 10;
SQLThe 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"] | +-------+-------------------------+--------------------------------+
CODEExit the MySQL console:
exit
BASH
Useful tips
Related topics: