Mikrotik Monitoring Alert to Telegram

To set up network monitoring with MikroTik's Netwatch feature and Telegram notifications, you need to create a Telegram bot, configure Netwatch on your MikroTik router to use the bot, and then set up actions for when a monitored host goes up or down. This will allow you to receive alerts in Telegram when a device on your network becomes unreachable or returns online. 

Here's a step-by-step guide:

1. Create a Telegram Bot:

Start a chat with @BotFather on Telegram.

Send the /newbot command to create a new bot.

Choose a name and username for your bot.

Save the provided API token, as you'll need it later. 

2. Get the Chat ID for Your Telegram Group/Channel (Optional):

If you want to send alerts to a group or channel, you'll need its chat ID.

Add your bot to the group/channel.

Send a message to the group/channel.

Use the following URL to get the chat ID: https://api.telegram.org/bot<YourBOTToken>/getUpdates (replace <YourBOTToken> with your bot's token).

Look for the "chat": field in the JSON response, and copy the id value. 

3. Configure Netwatch on MikroTik:

Open Winbox and connect to your MikroTik router. 

Go to System > Netwatch. 

Click the "+" button to add a new Netwatch entry. 

General Tab:

Host: Enter the IP address or hostname of the device you want to monitor. 

Interval: Set the interval for checking the host (e.g., 1 minute). 

Timeout: Set the timeout for the ping (e.g., 500ms). 

Down Timeout: Set the timeout for marking the host as down (e.g., 2 seconds). 

Up Script (Optional):

Enter a script to execute when the host comes back up.

/tool fetch url="https://api.telegram.org/bot<YourBOTToken>/sendMessage?chat_id=<Your Chat ID>&text=<Your Text>" keep-result=no;

 

Down Script:

Enter a script to execute when the host goes down. 

/tool fetch url="https://api.telegram.org/bot<YourBOTToken>/sendMessage?chat_id=<Your Chat ID>&text=<Your Text>" keep-result=no;

Mikrotik Monitoring Alert to Telegram Mikrotik Monitoring Alert to Telegram Reviewed by RIO IT on 17:47 Rating: 5
Powered by Blogger.