Community discussions

MikroTik App
 
karaYusuf
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 54
Joined: Wed Oct 12, 2022 11:07 am

Ping script is running but sometimes I get timeouts

Thu Feb 16, 2023 3:29 pm

Hello Guys,
I made a script, which is pinging over three different wan-interfaces. I had earlier the problem that I could not even ping the different interfaces separately. I found the solution to add vrfs like in the following picture:
vrf.PNG
After that I added different elements in the route list as in the following picture:
route_list.png
I am using the "vrf"-element in the ping tool to realize my Problem with pinging the different interfaces separately.

The following Code is the Script (gets scheduled every two seconds):
:if ([/interface print count-only where name=lte1] = 1) do={
    :global lte1Ping [([:ping 8.8.8.8 vrf=[/ip/route/get [find where gateway=[/ip/route/get [find where vrf-interface=lte1] gateway] and routing-table!=main] routing-table] count=1 as-value]->"time")];
    :global lte1Status [([:ping 8.8.8.8 vrf=[/ip/route/get [find where gateway=[/ip/route/get [find where vrf-interface=lte1] gateway] and routing-table!=main] routing-table] count=1 as-value]->"status")];
} else={
    :if ([/interface print count-only where name=lte1] = 0) do={
        /system/script/environment/remove lte1Ping;
        /system/script/environment/remove lte1Status;     
    }
}
:if ([/interface wireless print count-only  where name=[/interface wireless get [/interface wireless find where mode=station] name] running ] = 1) do={
    :global wlan1Ping [([:ping 8.8.8.8 vrf=[/ip/route/get [find where gateway=[/ip/route/get [find where vrf-interface=wlan1] gateway] and routing-table!=main] routing-table] count=1 as-value]->"time")];
    :global wlan1Status [([:ping 8.8.8.8 vrf=[/ip/route/get [find where gateway=[/ip/route/get [find where vrf-interface=wlan1] gateway] and routing-table!=main] routing-table] count=1 as-value]->"status")];
} else={
    :if ([/interface wireless print count-only  where name=[/interface wireless get [/interface wireless find where mode=station] name] running ] = 0) do={
        /system/script/environment/remove wlan1Ping;
        /system/script/environment/remove wlan1Status;
    }
}
:if ([/interface ethernet print count-only  where name=ether1 running] = 1) do={
    :global ether1Ping [([:ping 8.8.8.8 vrf=[/ip/route/get [find where gateway=[/ip/route/get [find where vrf-interface=ether1] gateway] and routing-table!=main] routing-table] count=1 as-value]->"time")];
    :global ether1Status [([:ping 8.8.8.8 vrf=[/ip/route/get [find where gateway=[/ip/route/get [find where vrf-interface=ether1] gateway] and routing-table!=main] routing-table] count=1 as-value]->"status")];
} else={
    :if ([/interface ethernet print count-only  where name=ether1 running] = 0) do={
        /system/script/environment/remove ether1Ping;
        /system/script/environment/remove ether1Status;
    }
}
Now to my problem:
Sometimes I get timeouts as in the following picture and sometimes it gives me the right output:
wrong_output.PNG
right_output.PNG
The timeouts turning up for some seconds and go away again for some minutes.
Is this a normal behaviour? Do I used the right config? If not could someone tell me how to get it right? I do not want timeout if the interfaces are working correctly.
Every help is appreciated :)
You do not have the required permissions to view the files attached to this post.
 
karaYusuf
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 54
Joined: Wed Oct 12, 2022 11:07 am

Re: Ping script is running but sometimes I get timeouts

Mon Feb 20, 2023 2:07 pm

Does no one know, what the problem could be here?
 
pe1chl
Forum Guru
Forum Guru
Posts: 10195
Joined: Mon Jun 08, 2015 12:09 pm

Re: Ping script is running but sometimes I get timeouts

Mon Feb 20, 2023 3:32 pm

When you are pinging other people's (Google's) servers, you will have to live with other people's TOS.
That is always a risk when using "ping of external server" as a method to determine if your link is up or down: it may be not your link but the other computer that is up or down (or chooses not to answer ping).
 
karaYusuf
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 54
Joined: Wed Oct 12, 2022 11:07 am

Re: Ping script is running but sometimes I get timeouts

Tue Feb 21, 2023 11:01 am

When you are pinging other people's (Google's) servers, you will have to live with other people's TOS.
That is always a risk when using "ping of external server" as a method to determine if your link is up or down: it may be not your link but the other computer that is up or down (or chooses not to answer ping).
Thank you very much for your reply. I decided to ping to 1.1.1.1 and the timeouts did not appear anymore until now.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Ping script is running but sometimes I get timeouts

Tue Feb 21, 2023 11:51 am

Thank you very much for your reply. I decided to ping to 1.1.1.1 and the timeouts did not appear anymore until now.
This will work until they blacklist you for excessive pings...

Who is online

Users browsing this forum: Bing [Bot] and 22 guests