×
Sending Power On Notification To Telegram - MikroTik Script RouterOS

Sending Power On Notification To Telegram - MikroTik Script RouterOS

MikroTik script sends a power on notification the device to Telegram. Allows you to learn about unexpected device reboots or equipment power problems, complementing the monitoring system.
When sending a message to Telegram, it will also write the event to the system log.

🔔 For the script to work, you must have a Telegram bot Token and a chat ID or a personal ID. Creating a Telegram bot and getting the required IDs is not the topic of this article.

# Func: Telegram send message
:local TGSendMessage do={
    :local tgUrl "https://api.telegram.org/bot$Token/sendMessage?chat_id=$ChatID&text=$Text&parse_mode=html";
    /tool fetch http-method=get url=$tgUrl keep-result=no;
}

# Constants
:global RebootStatus;
:local TelegramBotToken "987654321:AAFJIVTAWodBwzGX2CLne6-PK4RFNSy-8OY";
:local TelegramChatID "987654321";
:local DeviceName [/system identity get name];

:local TelegramMessageText "\F0\9F\9F\A2 $DeviceName: start after Power Off.";

# Program
:if ($RebootStatus != true)  do={
    $TGSendMessage Token=$TelegramBotToken ChatID=$TelegramChatID Text=$TelegramMessageText;
    :set RebootStatus true;
    :log info "Script CheckPowerOn send Telegram message."
}
×

Notice!!

All Quantic user are requested to use our hybrid cloud drive for you project and Data base . We had added new module of cronjob to schedule and optimise your backup .