Ethernet Port Rate Reporter - Useful Script for Telegram

Hey All,This is a simple script u can schedule it every while of time to detect your Ethernet port rate status

And to report u the situation of it by your Telegram Group

Look also at http://forum.mikrotik.com/t/basic-notifications-system-with-telegram/122485/1

1- To Detect if there is 10Mbps Ethernet Rate

#Edit Here Only Identify Telegram Values
:local server ([/system identity get name])
:local botid "XXXXXXXX"
:local chatid "-XXXXXXX"

#Start Monitoring of All Ethernet Ports
/interface ethernet monitor [find] once do={

:if ($"rate" = "10Mbps") do={
/tool fetch "https://api.telegram.org/$botid/sendmessage?chat_id=$chatid&text=$server%0APort $name Rate is $rate" keep-result=no;};
}

Now if u have a 1Gpbs Ethernet u wish to keep monitoring it,Use this method

#Edit Here to Identify Telegram Values
:local server ([/system identity get name])
:local botid "XXXXXXXX"
:local chatid "-XXXXXXX"

#Start Monitoring of All Ethernet Ports
#Edit The X to the desired Ethernet port Name
/interface ethernet monitor [find name=X] once do={

:if ($"rate" != "1Gbps") do={
/tool fetch "https://api.telegram.org/$botid/sendmessage?chat_id=$chatid&text=$server%0APort $name Rate is $rate" keep-result=no;};
}

I wish it could help u :slight_smile:

Many thanks for this guy who guide me to the right way to complete it https://forum.mikrotik.com/memberlist.php?mode=viewprofile&u=97351
Ahmed Mouselly
Regards.

Thanks a lot Katem.

It helped me out to do my script, the truth is that I don’t know what I’'m doing, but this is how I made it work.

#Start Monitoring of All Ethernet Ports
#Edit The X to the desired Ethernet port Name

/interface ethernet monitor etherX once do={

:if ($"rate" != "1Gbps") do={

/tool e-mail send to=example@example.com from=routername@example.com port=587 server=smtp-relay.gmail.com start-tls=yes subject="WAN PORT 100Mbps" body="WAN port went down to 100Mbps at your router"};
}

I don’t have telegram, so i’m using my smtp relay in google apps to send emails from my routers.