Community discussions

MikroTik App
 
djshaunvt
just joined
Topic Author
Posts: 10
Joined: Fri May 29, 2020 8:34 am

Script To Nofify Of Route Change Via Email

Tue Mar 12, 2024 7:06 am

Hi all.

I wonder if anyone can help a total newbie with regards to scripting. I have the following script which monitors preconfigured static routes on the router and checks the comment with regards to the route and emails me when the route by that name becomes disabled. This works perfect but I want to include the other route names in this script to email with regards to that specific static route beging disabled with the custom corresponsing email notification.

Many thanks


So what i want to do is to add more lines for example:

[:ip route get value-name=active [:ip route find comment="SiteB via Metro-E"]]
:if ( "$status" != "$prevstatus" ) do={
:log warn "Primary Route To SiteB via Metro E Status Changed From \"$prevstatus\" -> \"$status\" (true=up, false=down, nothing=unintialized)";
:tool e-mail send to=it@companyname.com subject="Primary Route To SiteB via Metro E Status Changed" body=( [ :system clock get date ] . " " . [ :system clock get time ] . " Metro E Gateway To SiteB Changed Status From \"$prevstatus\" -> \"$status\" (true=up, false=down, nothing=unintialized)" )


Origianl Script Below:

{
:global prevstatus;
:global status [:ip route get value-name=active [:ip route find comment="Kenilworth via Metro-E"]]
:if ( "$status" != "$prevstatus" ) do={
:log warn "Primary Route To Kenilworth via Metro E Status Changed From \"$prevstatus\" -> \"$status\" (true=up, false=down, nothing=unintialized)";
:tool e-mail send to=it@companyname.com subject="Primary Route To Kenilworth via Metro E Status Changed" body=( [ :system clock get date ] . " " . [ :system clock get time ] . " Metro E Gateway To Kenilworth Changed Status From \"$prevstatus\" -> \"$status\" (true=up, false=down, nothing=unintialized)" )
:tool e-mail send to=it@companyname.com subject="Primary Route To Kenilworth via Metro E Status Changed" body=( [ :system clock get date ] . " " . [ :system clock get time ] . " Metro E Gateway To Kenilworth Changed Status From \"$prevstatus\" -> \"$status\" (true=up, false=down, nothing=unintialized)" )
}
:global prevstatus $status
}

Who is online

Users browsing this forum: No registered users and 11 guests