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 in form you if the nodes that you receive from a peer is below a specified number. This is usefull to know that the path behind this node is not connected to the rest network.
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=wlan1peer on-event=\
"/system script run wlan1peer\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 have to change to the whole script the peerXYZstatus to a unique name. peerLimitLow and PeerLimitHighare set from you regarding your needs for the threshold. You change the myemail as you need. The PeerName is the BGP peer name. And finally SMTPserver is useed to resolve each time the IP address.
# BGP peer script
:global peerXYZstatus
:local PeerLimitLow 5
:local PeerLimitHigh 50
: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 PeerName "SV1XYZ"
:local SMTPserver "smtp.gmail.com"
# define Variables
:local PeersNow
:local mysubject
:local int
:local s
:foreach int in=[/routing bgp peer find name=$PeerName] do={
:set PeersNow [/routing bgp peer get $int prefix-count]}
#:log info $PeersNow
:if ([:typeof $peerMNFstatus] = "nothing") do={
:if ($PeersNow < $PeerLimitLow) do={
:set peerMNFstatus "Low"
:set mysubject ([/system identity get name]." Peer ".$PeerName." has ".$PeersNow." peers.")
/tool e-mail set address=[:resolve $SMTPserver]
:foreach s in=[:toarray $myemail] do={
/tool e-mail send to=$s subject=$mysubject}
} else={
:if ($PeersNow > $PeerLimitHigh) do={
:set peerMNFstatus "OK"}
}
} else={
:if ($PeersNow < $PeerLimitLow and $peerMNFstatus="OK") do={
:set peerMNFstatus "Low"
:set mysubject ([/system identity get name]." Peer ".$PeerName." has ".$PeersNow." peers.")
/tool e-mail set address=[:resolve $SMTPserver]
:foreach s in=[:toarray $myemail] do={
/tool e-mail send to=$s subject=$mysubject }}
:if ($PeersNow > $PeerLimitHigh and $peerMNFstatus="Low") do={
:set peerMNFstatus "OK"
:set mysubject ([/system identity get name]." Peer ".$PeerName." has ".$PeersNow." peers.")
/tool e-mail set address=[:resolve $SMTPserver]
:foreach s in=[:toarray $myemail] do={
/tool e-mail send to=$s subject=$mysubject }}
}
#:log info "end"
One improvment is to add SMS support via internal mikrotik functionality.