VMmanager: Administrator guide

Sending notifications to Telegram

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:

  1. Create a Telegram bot.
  2. Connect the bot to the platfom.
  3. Add Telegram as the notification channel.

Configuration on Telegram side

  1. Open the chat with @BotFather.
  2. Send the command /newbot.
  3. Enter the bot name. E.g. Notify Me.
  4. Enter the unique bot user name. It must finish with "bot". E.g., notifyme876bot.
  5. Save the token value from the response.
  6. In order for the bot to send messages to a Telegram group:
    1. Add the bot to the Telegram group.
    2. Enter any command in the group chat. For example, /start.
  7. 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

  1. In the right menu, click the icon → Messengers section → Connect a messenger button.
  2. Insert the Bot token.
  3. Click Activate button.

  4. Select the required chats for sending notifications.
  5. Select the Messages language.
  6. Click Save button.

To change the bot connection settings, click the icon next to Messenger chats header → enter the Bot tokenSave 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.

Before adding chat, add a bot to it and send it any command. For example, /start.

To add a chat:

  1. Click Add chat button.
  2. Select the Messages language.
  3. Specify the discretionary Chat name.
  4. Select a chat from the list or Enter the chat ID.
  5. Specify the discretionary Comment for the chat.
  6. 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:

  1. Enter the Notifications center: in the right menu, click the icon → Notification settings.
  2. Click the notification name.
  3. Select channels in To the messengers' channels field.

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

You can find out the id of a supergroup using the @getmyid_bot.

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:

  1. Connect to the server with the platform via SSH.
  2. Enter the container with the messaging service: 

    Command for VMmanager 6
    docker exec -it vm_msgsender_1 bash
    Command for DCImanager 6
    docker exec -it dci_msgsender_1 bash
  3. Add to the [program:msgs_writer] section of the configuration file /etc/supervisord.conf.d/msgsender.conf parameter:

    environment=TELEGRAM_TASK_LIMIT=<number>
    Comments
    It is not recommended to set <number> value higher than 10. This may cause the bot to be blocked by Telegram.
  4. Execute the command:

    supervisorctl update
  5. Exit the docker container:

    exit

To check the simultaneous sending of messages:

  1. Connect to the server with the platform via SSH.
  2. Connect to the platform database: 

    Command for VMmanager 6
    docker exec -it mysql bash -c "mysql isp -p\$MYSQL_ROOT_PASSWORD"
    Command for DCImanager 6
    docker exec -it mysql bash -c "mysql auth -p\$MYSQL_ROOT_PASSWORD"
  3. 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"]  |
    +-------+-------------------------+--------------------------------+
  4. Exit the MySQL console:

    exit

Useful tips
Related topics: