Print
Category: Software
Hits: 4646

 In local Athens Wireless Metropolitan Network we run backbone connections with 5.6 GHz links.

We use BGP as routing protocol as it can support about 1000 backbone nodes that exist.

Each node has a AS assigned. The script sends an Email to alert you about the failure of one link.

It also alerts you if the RSSI drops below a limit. If you send an Email to an SMS gateway you can receive

an SMS also. It also disable the BGP peer of this link to avoid filling

log with entries.

 In order to work correctly you have to setup the email account. 

/tool e-mail

set address=74.125.136.108 from="<Mikrotik QTH>" last-status=succeeded \

    password=xxxxxx port=587 start-tls=yes user=This email address is being protected from spambots. You need JavaScript enabled to view it.

The address in the 6.7 which I use does not resolved to IP so I use the IP address.

I think in newest MT versions it can be resolved.

You need also a scheduled task.

/system scheduler

add interval=10m name=wlan1status on-event=\

    "/system script run wlan1status\r\

    \n" policy=\

    ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive,api \

    start-date=apr/05/2015 start-time=04:38:40

You must replace the string wlan1status and wlan1RSSI with another string if used more than once in the whole script.

In interfacename you write your wireless interface. in myemail you write your Email list.

The RSSIlevel is the threshold that alerting is occured. In SMTPserver you put the SMTP server that you use.

As 67 is not resolve names SMTP server is resolved each time that you have to send Email.

And peername is te BGP that you use.

# monitor WLAN1 status

:global wlan1status

:global wlan1RSSI

:local interfacename "wlan1"

:local myemail "This email address is being protected from spambots. You need JavaScript enabled to view it.,This email address is being protected from spambots. You need JavaScript enabled to view it.,This email address is being protected from spambots. You need JavaScript enabled to view it."

:local RSSIlevel -75

:local SMTPserver "smtp.gmail.com"

:local peername "SV1XYZ"

 

# Local variables

:local int

:local mysubject

:local RSSIs "-1dB"

:local RSSI

:local statusnow "down"

:local s

 

:foreach int in=[/interface wireless registration-table find interface=$interfacename] do={

    :set statusnow "up"

    :set RSSIs [/interface wireless registration-table get $int signal-strength]}

 

:set RSSI [:tonum [:pick $RSSIs 0 [:find $RSSIs "d" 0]]]

 

#:log info $RSSI

#:log info $statusnow

 

:if ([:typeof $wlan1status] = "nothing") do={

     :set wlan1status $statusnow

  } else={:if ($wlan1status != $statusnow) do={

              :set mysubject ($interfacename." on ".[/system identity get name]." is ".$statusnow)

             /tool e-mail set address=[:resolve $SMTPserver]

             :foreach s in=[:toarray $myemail] do={

                  /tool e-mail send to=$s subject=$mysubject}

             :log info $mysubject

             :set wlan1status $statusnow

             :foreach int in=[/routing bgp peer find name=$peername] do={

                 :if ($statusnow = "up") do={

                      /routing bgp peer enable $int

                 } else={

                      /routing bgp peer disable $int

                 }

             }

         } 

 }

:if ($statusnow="up") do={

  :if ([:typeof $wlan1RSSI] = "nothing") do={

      :if ( $RSSI<$RSSIlevel) do={

          :set wlan1RSSI "BAD"

          :set mysubject ($interfacename." on ".[/system identity get name]." RSSI is ".$RSSI." (".$RSSIlevel.")")

          /tool e-mail set address=[:resolve $SMTPserver]

          :foreach s in=[:toarray $myemail] do={

              /tool e-mail send to=$s subject=$mysubject}

          :log info $mysubject

          :foreach int in=[/routing bgp peer find name=$peername] do={ /routing bgp peer disable $int }

      } else={

           :set wlan1RSSI "OK"

           :foreach int in=[/routing bgp peer find name=$peername] do={ /routing bgp peer enable $int }

      }

  } else={:if ( $RSSI<$RSSIlevel and $wlan1RSSI="OK") do={

                 :set wlan1RSSI "BAD"

                 :set mysubject ($interfacename." on ".[/system identity get name]." RSSI is ".$RSSI." (".$RSSIlevel.")")

                 /tool e-mail set address=[:resolve $SMTPserver]

                 :foreach s in=[:toarray $myemail] do={

                       /tool e-mail send to=$s subject=$mysubject}

                 :log info $mysubject

                 :foreach int in=[/routing bgp peer find name=$peername] do={ /routing bgp peer disable $int }

                 }

              :if ( !($RSSI<$RSSIlevel) and $wlan1RSSI="BAD") do={

                 :set wlan1RSSI "OK"

                 :set mysubject ($interfacename." on ".[/system identity get name]." RSSI is ".$RSSI." (".$RSSIlevel.")")

                 /tool e-mail set address=[:resolve $SMTPserver]

                 :foreach s in=[:toarray $myemail] do={

                        /tool e-mail send to=$s subject=$mysubject}

                 :log info $mysubject

                 :foreach int in=[/routing bgp peer find name=$peername] do={ /routing bgp peer enable $int }

               }

  }

}

#:log info "end"

 

Improvments are to add SMS support via embeded functionality and RSSI level has two levels, one for ON and one for OFF to avoid flapping.