Managing a MikroTik router can be challenging, especially when you need to keep an eye on dozens of PPPoE customers, traffic patterns, and system health around the clock. In this guide, I’ll show you how to build a Telegram bot that monitors your MikroTik router automatically — sending real-time alerts when customers go offline, CPU spikes, or traffic thresholds are exceeded.
Why Telegram for Network Monitoring?
Telegram is one of the most reliable messaging platforms for bot automation. Unlike email or SMS, Telegram bots deliver messages instantly, support rich formatting, and cost nothing to operate. If you’re already using MikroTik for your ISP or enterprise network, a Telegram monitoring bot is one of the fastest ways to get real-time visibility without expensive commercial monitoring software.
What You’ll Need
- A MikroTik router running RouterOS 6.x or 7.x
- The MikroTik API service enabled (port 8728 or custom)
- A Telegram bot token from @BotFather
- A server to run the monitoring script (Linux with Python 3.8+)
- Basic understanding of PPPoE and router administration
Step 1: Enable the MikroTik API
Before anything else, you need to enable the RouterOS API on your MikroTik router. Log in via Winbox or SSH, then navigate to IP > Services and enable the api service. We recommend using a dedicated port and restricting access to specific IP addresses for security.
Create a read-only API user:
/user
add name=monitoring_bot group=read password=YourSecurePassword address=YOUR_SERVER_IP
This user can read all router data but cannot make changes — a best practice for monitoring accounts.
Step 2: Create Your Telegram Bot
Open Telegram and search for @BotFather. Send the command /newbot and follow the prompts to create your bot. Copy the API token — you’ll need it to send messages and register commands.
Once your bot is created, register its commands so users get a neat menu when they type /. Commands like /status, /pppoe, /interfaces, and /alerts make the bot intuitive to use.
Step 3: The Monitoring Script
The monitoring script connects to your MikroTik via the RouterOS API and exposes data through a Telegram bot. Here’s what the system monitors:
- System Status — CPU load, RAM usage, router uptime
- PPPoE Users — Online/offline status, IP address, session duration, traffic usage
- Interface Traffic — RX/TX bytes on main interfaces (ISP uplink, PON links, LAN)
- Hotspot Users — Active sessions and uptime
The script uses the librouteros Python library for API communication, and python-telegram-bot for the Telegram interface. On first run, it saves the current state of active PPPoE sessions. Every subsequent poll compares the new state against the saved one to detect customers who went offline or came back online.
Step 4: Real-Time PPPoE Alerts
The bot runs a background check every 60 seconds. When a PPPoE customer disconnects, you get an instant Telegram alert:
🔴 PPPoE DOWN!
jtk-bowo
jtk-dea
jtk-ilham
When they reconnect:
🟢 PPPoE UP!
jtk-bowo
You can also set CPU and RAM thresholds — if either exceeds 80%, the bot sends a warning. This is useful for catching router overload before it affects customers.
Monitoring PPPoE Customers in Detail
Each PPPoE user entry shows:
- Status — Green dot for online, red for offline, gray for disabled accounts
- IP Address — Assigned PPPoE IP from the address pool
- Uptime — How long the current session has been active
- Traffic — Total RX (download) and TX (upload) bytes
- Profile — The bandwidth package the customer subscribed to
Sample Output from /pppoe Command
Here’s what the bot returns when you send /pppoe:
📶 PPPoE Users (60 total)
🟢 Online: 33 | 🔴 Offline: 27
🟢 jtk-yafet
📍 192.164.100.38 | ⏱ 1w5d16h47m
📥 2.15 GB | 📤 18.32 GB | 📦 25 Mbps
🟢 kmk-salsa
📍 192.100.99.102 | ⏱ 1w5d16h39m
📥 1.87 GB | 📤 12.45 GB | 📦 12 Mbps 150
🔴 kmk-atika
📍 - | ⏱ -
📥 - | 📤 - | 📦 8 Mbps 110
The offline users are sorted to the bottom so you can immediately see who’s disconnected.
Security Considerations
Never use an admin-level API account for monitoring. Create a dedicated read-only user as shown above. If possible, restrict the API user to only accept connections from your monitoring server’s IP address using the address= parameter in the user configuration.
Also keep your Telegram bot token secure — treat it like a password. If it ever leaks, revoke it immediately via @BotFather and generate a new one.
Conclusion
A Telegram monitoring bot for MikroTik is one of the most practical automation projects for network administrators. It gives you instant visibility into PPPoE customer status, system health, and traffic patterns — all from a phone or desktop without needing to log into the router.
The setup takes about 30 minutes, and the ongoing maintenance is minimal. Once it’s running, you’ll catch outages before customers call to report them.