Skip to content
Scripting and automation

Scripting and automation

Scripts, scheduler, Netwatch and alerts via Telegram and email: a router that works on its own and tells you.

Image generated locally with ComfyUI from randomly selected elements. How the images are created

Illustrazione per Netwatch su MikroTik: avvisami su Telegram quando un apparato cade
Dojo

Netwatch on MikroTik: alert me on Telegram when a device goes down

Netwatch is RouterOS's sentry: it knocks on an address and, when it stops answering or comes back, it runs a script. We use it to watch a camera and the internet line, with the alerts on Telegram, and we go over the thresholds and the behavior after a reboot that the manuals don't mention.

5 min read
Illustrazione per Collegare MikroTik a Telegram: gli avvisi del router sul telefonoDojo

Connect MikroTik to Telegram: router alerts on your phone

A router that messages you on Telegram when something happens is worth more than ten graphs you look at the next day. In seven steps we create the bot, find the chat_id, and write a reusable telegram script, which the other Dojo howtos then use to send alerts: Netwatch, reboots, rogue DHCP.

Illustrazione per Inviare email da MikroTik con Gmail: SMTP e password per le appDojo
Howto · System

Send email from MikroTik with Gmail: SMTP and app passwords

A MikroTik can send email (alerts, backups, reports) using a Gmail account as the SMTP server: smtp.gmail.com, port 587, STARTTLS. The password, though, isn't the account one: you need an app password, a 16-character password generated by Google, valid only for sending and revocable at any time. In RouterOS 7 the configuration lives in /tool e-mail.

Illustrazione per Scan wireless su un MikroTik remoto senza perdere il risultatoDojo
Howto · WiFi

Wireless scan on a remote MikroTik without losing the result

A frequency scan stops the radio for a few seconds: if you reach the remote router through that very wireless link, you lose the connection and the result. The fix is to run the scan in the background on the router itself, with the result saved to a file you read when the link comes back up. In RouterOS 7 you do it with :execute and the file= parameter, which works with both the wifi package and wireless.

Illustrazione per DHCP server MikroTik: eseguire uno script a ogni leaseDojo
Howto · DHCP

MikroTik DHCP server: run a script on every lease

The RouterOS DHCP server can run a script every time it hands out or frees an address: that's the lease-script. Inside the script you already have variables like $leaseBound, $leaseActIP and $leaseActMAC, which let you log new devices, send an email alert, or add the client to an address list with an expiry.