Wednesday, May 7, 2025

Mikrotik Monitoring Alert to Telegram



You can set up MikroTik to send monitoring alerts to Telegram using scripts and API calls. Here’s a general approach:

  1. Create a Telegram Bot
    • Use BotFather on Telegram to create a bot and get the API token.
    • Note down your bot’s token and chat ID.
  2. Write a MikroTik Script
    • Use MikroTik’s scripting feature to send alerts when specific events occur.
    • Example script:
:local BotID "YOUR_BOT_TOKEN"
:local CHID "YOUR_CHAT_ID"
:local message "Alert: Something happened on MikroTik!"
/tool fetch url="https://api.telegram.org/bot$BotID/sendMessage?chat_id=$CHID&text=$message" keep-result=no

    • Replace YOUR_BOT_TOKEN and YOUR_CHAT_ID with actual values.
  1. Set Up Netwatch or Log Monitoring

  • Use /tool netwatch to monitor network status and trigger alerts.
  • Use /log monitoring to send alerts for specific events like failed login attempts or interface down.
You can find more details and example scripts here and here. Let me know if you need help customizing it!

SCRIPT:
:log info "send message to your phone"
/tool fetch url="https://api.telegram.org/bot<TOKEN>/sendMessage?chat_id=<CHAT_ID>&text=YourMessage"



No comments:

Post a Comment