Hello everyone!
I have a problem with my ISP. Sometimes my router lost connection to my ISP and establish connection later. I want to create log file about these periods. Is this possible, maybe netwatch, but do not know how to create file automaticly, save the file on hard drive (router memory) to download later and how much resourses does it take? My router is RB 2011 UiAS-RM
I hope someone can help me,thank you
I am checking VPN tunnels with
:local TargetServer192 "192.168.1.17"
:local komunikat ""
:local i 0
:local Missed192 0
:local VPNChanged
:global VPNUp
#:log info ("CHECK_VPN: >> <<")
:if ([:typeof $VPNUp] = "nothing") do={:set VPNUp false}
{
:for i from=1 to=4 do={
# :log info ("CHECK_VPN: ping $TargetServer192")
if ([/ping $TargetServer192 count=1 interval=1s]=0) do={:set Missed192 ($Missed192 + 1)}
};
# Max 2 missed from 4 means that VPN works, 4 missed means that VPN is down
# :log info ("CHECK_VPN: Missed192 $Missed192")
:set VPNChanged (($VPNUp and ($Missed192=4)) or (!$VPNUp and ($Missed192<3)))
# :log info ("CHECK_VPN: $VPNChanged $VPNUp and $Missed192")
:set VPNUp ($Missed192<3)
# :log info ("CHECK_VPN: $VPNChanged $VPNUp and $Missed192")
:if ($VPNChanged) do={
:set komunikat "VPN: $[/system identity get name], $[/system clock get time], $[/system clock get date], $[/ip address get [find interface=ETH1-WAN] address] - "
:if ( $VPNUp ) do={
:set komunikat ($komunikat . "UP")
} else={
:set komunikat ($komunikat . "DOWN")
}
:log info $komunikat
/tool e-mail send to=youremailhere subject=$komunikat;
} else={
# :log info ("CHECK_VPN: VPNChanged $VPNChanged")
}
}
Info about up/down is logged to log and send to my e-mail.
Remeber to configure Tools/E-mail to use “/tool e-mail send” form.
This code should be saved as script in System/Script and the the name of this script should be used as action in sheduled event in System/Sheduler.
If you want to append “komunikat” to afile the look here: http://forum.mikrotik.com/t/print-in-file-on-specific-interfval-help/60558/1
BartoszP:
I am checking VPN tunnels with
:local TargetServer192 "192.168.1.17"
:local komunikat ""
:local i 0
:local Missed192 0
:local VPNChanged
:global VPNUp
#:log info ("CHECK_VPN: >> <<")
:if ([:typeof $VPNUp] = "nothing") do={:set VPNUp false}
{
:for i from=1 to=4 do={
# :log info ("CHECK_VPN: ping $TargetServer192")
if ([/ping $TargetServer192 count=1 interval=1s]=0) do={:set Missed192 ($Missed192 + 1)}
};
# Max 2 missed from 4 means that VPN works, 4 missed means that VPN is down
# :log info ("CHECK_VPN: Missed192 $Missed192")
:set VPNChanged (($VPNUp and ($Missed192=4)) or (!$VPNUp and ($Missed192<3)))
# :log info ("CHECK_VPN: $VPNChanged $VPNUp and $Missed192")
:set VPNUp ($Missed192<3)
# :log info ("CHECK_VPN: $VPNChanged $VPNUp and $Missed192")
:if ($VPNChanged) do={
:set komunikat "VPN: $[/system identity get name], $[/system clock get time], $[/system clock get date], $[/ip address get [find interface=ETH1-WAN] address] - "
:if ( $VPNUp ) do={
:set komunikat ($komunikat . "UP")
} else={
:set komunikat ($komunikat . "DOWN")
}
:log info $komunikat
/tool e-mail send to=youremailhere subject=$komunikat;
} else={
# :log info ("CHECK_VPN: VPNChanged $VPNChanged")
}
}
Info about up/down is logged to log and send to my e-mail.
Remeber to configure Tools/E-mail to use “/tool e-mail send” form.
This code should be saved as script in System/Script and the the name of this script should be used as action in sheduled event in System/Sheduler.
If you want to append “komunikat” to afile the look here: http://forum.mikrotik.com/t/print-in-file-on-specific-interfval-help/60558/1
Hello BartoszP,
i’m new to RouterOS; i’m trying your script and it’s very well done.
Is there anyway to make it loop through all the IPSEC vpn we have, customizing every mail?
Like a for loop i mean.
Thanks in advance!