Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save hertzg/904feacaf3d274f0073163aafffb91c7 to your computer and use it in GitHub Desktop.
Save hertzg/904feacaf3d274f0073163aafffb91c7 to your computer and use it in GitHub Desktop.
MikroTik check ping status and send SMS
# 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