:global currentIP;
:local newIP [/ip address get [find interface="ethert1"] address];
:if ($newIP != $currentIP) do={
:local newIP [/ip address get [find interface="ethert1"] address];
/tool e-mail send to="xxxxx@hotmail.com" subject=([/system identity
get name]) body=" This is your new IP: $newIP" start-tls=yes;
:set currentIP $newIP;
}
This script tests the for change of IP, not if interface is running or not that Op requested.Code: Select all:global currentIP; ...
:global ifstatus
:if ([/interface ethernet get ether1 running]=true) do={
:put "running"
:if ($ifstatus="down") do={
:put "changed to up"
}
:set $ifstatus "up"
} else={
:put "not running"
:if ($ifstatus="up") do={
:put "changed to down"
}
:set $ifstatus "down"
}
Where did you put the email, to send it to me it doesn't work for me, put your script please.Nice!
(PS sent you an email)
You can send email directly to user when they have added email to their profile.
This script tests the for change of IP, not if interface is running or not that Op requested.Code: Select all:global currentIP; ...
This will test status of interface ether1. If status changes, it will run the line :put "change to xxxx", that can be change to email a message.
Code: Select all:global ifstatus :if ([/interface ethernet get ether1 running]=true) do={ :put "running" :if ($ifstatus="down") do={ :put "changed to up" } :set $ifstatus "up" } else={ :put "not running" :if ($ifstatus="up") do={ :put "changed to down" } :set $ifstatus "down" }
Replace with some like these two linesit will run the line :put "change to xxxx", that can be change to email a message.
/tool e-mail send to=youremail@gmail.com subject="Host is D own" from=youremail@gmail.com port=587 start-tls=yes user=youremail@gmail.com password=123456 body="IF Down"
/tool e-mail send to=youremail@gmail.com subject="Host is D own" from=youremail@gmail.com port=587 start-tls=yes user=youremail@gmail.com password=123456 body="IF UP"
Hi Jotne,This script tests the for change of IP, not if interface is running or not that Op requested.Code: Select all:global currentIP; ...
This will test status of interface ether1. If status changes, it will run the line :put "change to xxxx", that can be change to email a message.
Code: Select all:global ifstatus :if ([/interface ethernet get ether1 running]=true) do={ :put "running" :if ($ifstatus="down") do={ :put "changed to up" } :set $ifstatus "up" } else={ :put "not running" :if ($ifstatus="up") do={ :put "changed to down" } :set $ifstatus "down" }
Hi Jotne,This script tests the for change of IP, not if interface is running or not that Op requested.Code: Select all:global currentIP; ...
This will test status of interface ether1. If status changes, it will run the line :put "change to xxxx", that can be change to email a message.
Code: Select all:global ifstatus :if ([/interface ethernet get ether1 running]=true) do={ :put "running" :if ($ifstatus="down") do={ :put "changed to up" } :set $ifstatus "up" } else={ :put "not running" :if ($ifstatus="up") do={ :put "changed to down" } :set $ifstatus "down" }
Thank You so much for your Help!!!
Script Worked for me....
But the emails are exchanging bodily bits since then.....geez now everyone will think we are lovers LOL.
Share your script please.Hello,
We are trying to code a script which will check/monitor the Interface Running status and when ever the interface status is change from Running-->not running or vice versa then it will send an Email Alert to Admin.
Can anyone Help us???
Just let the router do it internally - instead of a script...
/system logging
add action=emailalert disabled=no prefix="" topics=info,interface
Then change your email alert settings:
/system logging action
remove [find name="emailalert"]
add email-to=noc@youremaildomain.com name=emailalert target=email
I just pasted the commands and it doesn't create any rules, my email is enkas012016@gmai.comThe built in syslog functions will put into the log when an interface goes up and down. YOu just need to add a syslog event to email that to you. We use it all the time - every time an interface goes up and down it will email our NOC. No script needed. Try it. Paste in those commands with a valid working email relay and you should get emails.
Solution is simple and Easy rather then Scripting....The built in syslog functions will put into the log when an interface goes up and down. YOu just need to add a syslog event to email that to you. We use it all the time - every time an interface goes up and down it will email our NOC. No script needed. Try it. Paste in those commands with a valid working email relay and you should get emails.
When my DHCP clients update... A script in the DHCP client updates my recursive gateways.Sure but my script has a different purpose.
I use recursive routing and whenever the gateway changes on my ISP, the gatewayIPs, in my IP routes do not get updated.
This script addresses that.
:if ($bound=1) do={
:local iface $interface
:local gw [ /ip dhcp-client get [ find interface=$"iface" ] gateway ]
/ip route set [ find comment="PrimaryRecursive" gateway!=$gw ] gateway=$gw
/ip route set [ find comment="SecondaryRecursive" gateway!=$gw ] gateway=$gw
/tool e-mail send to="myaddress@email.com" subject=([/system identity
get name]) body=" This is your new gateway IP: $newIgw";
}
My TOOLS EMAIL Setting.
/tool e-mail
set address=ISP_email_server_IP from=myaddress@email.com port=465 start-tls=\
tls-only user=myaddress@email.com
I tried this and nothing happened. I went into system logging and tried to do it manually but there is no email option.Just let the router do it internally - instead of a script...
/system logging
add action=emailalert disabled=no prefix="" topics=info,interface
Then change your email alert settings:
/system logging action
remove [find name="emailalert"]
add email-to=noc@youremaildomain.com name=emailalert target=email
Great idea! thanks.The built in syslog functions will put into the log when an interface goes up and down. YOu just need to add a syslog event to email that to you. We use it all the time - every time an interface goes up and down it will email our NOC. No script needed. Try it. Paste in those commands with a valid working email relay and you should get emails.
/system logging action
add email-start-tls=yes email-to=myemail@gmail.com name=sendinterface target=email
/system logging
add action=sendinterface topics=interface
This does work, but for the love of god i can't make mikrotik send any information about the board thus i don't know what is it good for. There is a field "from" : Name or email address that will be shown as receiver.Just let the router do it internally - instead of a script...
/system logging
add action=emailalert disabled=no prefix="" topics=info,interface
Then change your email alert settings:
/system logging action
remove [find name="emailalert"]
add email-to=noc@youremaildomain.com name=emailalert target=email