Dude v6 - SMS notifications
Requirements
1. Mikrotik ROS with installed Dude server
2. Access to SMS gateway
Setup instruction
1. Create new Notification in Dude:
Name: SMS-Notification-Gateway
Type: execute on server
Command:
Code: Select all
# Variables
:local notificationtext "Service [Probe.Name] on [Device.Name] is now [Service.Status]"
:local url "http://192.168.1.1/cgi-bin/sendsms"
:local username user
:local password password
:local from dude
#
#
# Firstname Lastname
:local to "+xxxxxxxxxxx"
#
/tool fetch output=none url="$url\?username=$username&password=$password&to=$to&from=$from&text=$notificationtext" keep-result=no
2. Now you can use it: ----
We got one issue with this type of notification:
1. We can't sent SMS with the text containing spaces.
In ROS, before 6.41rc37 fetch tool failed on 202 HTTP response code. For more information please see the following post: tool fetch - 2xx HTTP response codes.
As a result our final command for two recipients is the following:
Code: Select all
# Send SMS notification using SMS Center
#
{
#
# Encode notification text
#
:local notificationtext "Service [Probe.Name] on [Device.Name] is now [Service.Status]"
:local notificationtextEncoded
:for i from=0 to=([:len $notificationtext] - 1) do={
:local char [:pick $notificationtext $i]
:if ($char = " ") do={
:set $char "%20"
}
:set notificationtextEncoded ($notificationtextEncoded . $char)
}
:put $notificationtextEncoded
#
# Send SMS
#
:local url http://192.168.1.1:8080/cgi-bin/sendsms
:local username user
:local password password
:local from dude
#
# Firstname Lastname
:local to "+xxxxxxxxxxx"
/tool fetch output=none url="$url\?username=$username&password=$password&to=$to&from=$from&text=$notificationtextEncoded" keep-result=no
#
# Firstname2 Lastname2
:local to "+yyyyyyyyyyy"
/tool fetch output=none url="$url\?username=$username&password=$password&to=$to&from=$from&text=$notificationtextEncoded" keep-result=no
#
}
Related Wiki articles
Manual:Tools/Fetch
Related forum topics
Replace characters in string (url encode)
A function for url encoding
Hope this will help someone.