Last active
March 1, 2024 13:03
-
-
Save sitchi/c2f8bdf262b806078eecd2123a1d4534 to your computer and use it in GitHub Desktop.
MikroTik check ping status and send SMS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# RouterOS script for pinging a list of addresses (sending SMS from UBILL API https://ubill.ge) | |
# Example | |
# Insert script: System > Scheduler > + Name=ubill-ping; interval=00:01:00; | |
# insert IP for monitoring: IP > Firewall > Address Lists > + Name=ubill-ping; Address=1.1.1.1; Comment=Router-Tbilisi; | |
:local ip; | |
:local disabled; | |
:local com; | |
/ip firewall address-list | |
:foreach i in=[find (list=ubill-ping)] do={ | |
:set ip [get $i address]; | |
:set disabled [get $i disabled]; | |
:set com [get $i comment]; | |
# status disabled | |
:if ([/ping $ip interval=1 count=2] = 0) do={ | |
/ip firewall address-list set disabled=yes numbers=$i; | |
:if ($disabled = false) do={ | |
/tool fetch "https://api.ubill.dev/v1/sms/send?key=xxxxxxxx&brandID=2&numbers=99559219####&text=device down: name: $com ip: $ip"; | |
} | |
} | |
# status enabled | |
:if ([/ping $ip interval=1 count=2] > 0) do={ | |
/ip firewall address-list set disabled=no numbers=$i; | |
:if ($disabled = true) do={ | |
/tool fetch "https://api.ubill.dev/v1/sms/send?key=xxxxxxxx&brandID=2&numbers=99559219####&text=device up: name: $com ip: $ip"; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment