Community discussions

MikroTik App
 
iwankaro1
just joined
Topic Author
Posts: 1
Joined: Mon Sep 18, 2017 5:10 pm

a script for monitoring packet loss for ping 10 times

Mon Sep 18, 2017 5:16 pm

guys.. need some in help here
can u please teach me to make a script "if" "do" "then" for monitoring packet loss on ping for 10 times, when packet loss reach for 90% then the script will "do" disable interface and "then" enable another interface.
 
gustavomam
Trainer
Trainer
Posts: 287
Joined: Tue Jul 23, 2013 6:29 pm
Location: Spain
Contact:

Re: a script for monitoring packet loss for ping 10 times

Wed Sep 20, 2017 10:13 pm

Hi.

Try this script.
:local ipPing ("8.8.8.8")
:local pingip
:set pingip [/ping $ipPing count=10]
:if ($pingip = 1) do={
	:log info ("90% lost")
    /interface ethernet disable ether1
} else={
    /interface ethernet enable ether1
}
 
darkprocess
Member Candidate
Member Candidate
Posts: 249
Joined: Fri Mar 20, 2015 1:16 pm

Re: a script for monitoring packet loss for ping 10 times

Wed Sep 20, 2017 11:52 pm

Why you don't use netwatch?
 
gustavomam
Trainer
Trainer
Posts: 287
Joined: Tue Jul 23, 2013 6:29 pm
Location: Spain
Contact:

Re: a script for monitoring packet loss for ping 10 times

Sat Sep 23, 2017 1:08 pm

You can use netwatch too.
But @iwankaro1 is asking for 90% lost. Netwatch is binary ping (works or not wokrs) you can't fine setup % of lost.
 
gustavomam
Trainer
Trainer
Posts: 287
Joined: Tue Jul 23, 2013 6:29 pm
Location: Spain
Contact:

Re: a script for monitoring packet loss for ping 10 times

Sat Sep 23, 2017 1:09 pm

You can use netwatch too.
But @iwankaro1 is asking for 90% lost. Netwatch is binary ping (works or not wokrs) you can't fine setup % of lost.
 
JaviGL93
just joined
Posts: 12
Joined: Thu Mar 03, 2022 7:13 pm

Re: a script for monitoring packet loss for ping 10 times

Fri Mar 11, 2022 12:49 am

Hi.

Try this script.
:local ipPing ("8.8.8.8")
:local pingip
:set pingip [/ping $ipPing count=10]
:if ($pingip = 1) do={
	:log info ("90% lost")
    /interface ethernet disable ether1
} else={
    /interface ethernet enable ether1
}
Thank you sir, exactly what i was looking for. Netwatch is just not good enough
 
JaviGL93
just joined
Posts: 12
Joined: Thu Mar 03, 2022 7:13 pm

Re: a script for monitoring packet loss for ping 10 times

Fri Mar 11, 2022 8:47 pm

Hi.

Try this script.
:local ipPing ("8.8.8.8")
:local pingip
:set pingip [/ping $ipPing count=10]
:if ($pingip = 1) do={
	:log info ("90% lost")
    /interface ethernet disable ether1
} else={
    /interface ethernet enable ether1
}
Thank you sir, exactly what i was looking for. Netwatch is just not good enough
Is it possible to run the script forever without using schedules?
 
JaviGL93
just joined
Posts: 12
Joined: Thu Mar 03, 2022 7:13 pm

Re: a script for monitoring packet loss for ping 10 times

Fri Mar 11, 2022 9:15 pm

Hi.

Try this script.
:local ipPing ("8.8.8.8")
:local pingip
:set pingip [/ping $ipPing count=10]
:if ($pingip = 1) do={
	:log info ("90% lost")
    /interface ethernet disable ether1
} else={
    /interface ethernet enable ether1
}
btw if packet loss is between 91 and 100% wont work as intended
:if ($pingip = 1) should be :if ($pingip <= 1)

I know it's an old post but i would love to read what are your experiences using netwatch VS script + schedule VS script only (if possible)

Best regards.
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3291
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: a script for monitoring packet loss for ping 10 times

Sat Mar 12, 2022 8:34 am

Not only are you quoating post above, but you do it 3 times!!!!

Next time your post, see under the post and click big green Post Reply button.

There is also an edit button, If you like to add more to an post.
You can see this thread: viewtopic.php?t=168474
Last edited by Jotne on Sat Mar 12, 2022 7:44 pm, edited 1 time in total.
 
msatter
Forum Guru
Forum Guru
Posts: 2897
Joined: Tue Feb 18, 2014 12:56 am
Location: Netherlands / Nīderlande

Re: a script for monitoring packet loss for ping 10 times

Sat Mar 12, 2022 4:22 pm

Or the big green 'post reply' button.
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3291
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: a script for monitoring packet loss for ping 10 times

Sat Mar 12, 2022 7:46 pm

Edited my post.
Original phpBB skin prosilver (that I use) it red :)
 
JaviGL93
just joined
Posts: 12
Joined: Thu Mar 03, 2022 7:13 pm

Re: a script for monitoring packet loss for ping 10 times

Sun Mar 13, 2022 5:47 am

You mean like this?

Why on earth would you have a quote button if it is not to quote the comment that you want to thank / improve, i give you 1/3 of my quote as unnecesary.. is that enough to you to behave like an asshole?

I actually have lots of things to thank u for... thanks for this incredible off topic, thanks for beeing always vigilant in case anyone new to the forum decides to go crazy again and quote 3 times!!! someone else comment (god saves us) and my favourite, thanks for sharing the thread, i was happy to read comments like this one:

´´Well, forum etiquette is not something you are born with. And in this particular case it's nothing to pay attention to compared to the BLOB'ed reply. It's something you need to consider, especially regarding how to treat new forum users. Being nice spreads good vibes for everyone, Cheers!´´

Or like this one:

´´Please stop harassing forum users about this question. It is more annoying than quotes. Thanks.´´ (If you don´t remember whom post this you better go check again)

It´s getting late i have to go. Please, it doesn´t take that much of your time to double check your comments in google translator or any other software, don´t disrespect language and readers like that.
Best regards (trully),
a noobie.
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3291
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: a script for monitoring packet loss for ping 10 times

Sun Mar 13, 2022 9:08 am

Why on earth would you have a quote button if it is not to quote the comment that you want to thank
When you reply to the post above you, quote is not needed, since its a continuation of the conversation.
But you can like this quote part of it if its to reply to specific part of the post.

You did not just Quote the post above you, but you did it 3 times to the same post. And even quoted your own post.
Since there was not comment inn between you should have edited your own post instead.
forum etiquette is not something you are born with
This past is true. But how did some learn to click this button " (quote buttotn) to reply, when there is a Post Reply button?

There is also another thing that happens when you quote with name in Quoting. The person who get Quoted get an email that someone quoted your post. This is ok when you have just on post here and there, but when you have many post and read the forum every day, this will just fill opp the innbox.

Hopefully you (and other) learn some by takning feedback :)
Use Quoting when its needed, and pick only the part of a post that needs to be Quoted.
 
pgabor
just joined
Posts: 4
Joined: Mon Mar 21, 2022 12:57 am

Re: a script for monitoring packet loss for ping 10 times

Sun Apr 16, 2023 4:16 pm

/ip/route/print
# DST-ADDRESS GATEWAY DISTANCE
0 As 0.0.0.0/0 192.168.0.1 1 (This is the main internet connection on ether1 interface, comment:wire)
1 s 0.0.0.0/0 192.168.8.1 2 (This is the backup LTE connection)
2 As 1.1.1.0/24 192.168.0.1 1 (This is the main internet connection monitoring route)

/system/script/print
0 name="netcheck" owner="gabor" policy=read,write,test dont-require-permissions=no last-started=apr/16/2023 15:09:16 run-count=701 source=
:local pingip
:set pingip [/ping 1.1.1.1 count=1 interface=ether1 as-value]
:if ($pingip = ".id=*0;host=1.1.1.1;seq=0;status=timeout") do={
:log info ("internet unavailable")
ip/route/set [find comment=wire] distance=3
} else={
:log info ("internet available")
ip/route/set [find comment=wire] distance=1
}

/system/scheduler/print
# NAME START-DATE START-TIME INTERVAL ON-EVENT RUN-COUNT
0 netcheck apr/12/2023 23:10:36 1m netcheck 702
 
eldoncito2019
Member
Member
Posts: 333
Joined: Fri Jun 14, 2019 1:07 pm

Re: a script for monitoring packet loss for ping 10 times

Wed Apr 19, 2023 8:40 pm

Hi.

Try this script.
:local ipPing ("8.8.8.8")
:local pingip
:set pingip [/ping $ipPing count=10]
:if ($pingip = 1) do={
	:log info ("90% lost")
    /interface ethernet disable ether1
} else={
    /interface ethernet enable ether1
}
I need help with a script similar to this one, I use 700 Mbps and I would like the script to ping 8.8.8.8 and when the internet goes down to 250 Mbps send the router to restart. Thanks for the help.
 
eldoncito2019
Member
Member
Posts: 333
Joined: Fri Jun 14, 2019 1:07 pm

Re: a script for monitoring packet loss for ping 10 times

Fri Apr 21, 2023 1:26 am

Can someone help me
 
pgabor
just joined
Posts: 4
Joined: Mon Mar 21, 2022 12:57 am

Re: a script for monitoring packet loss for ping 10 times

Fri Apr 28, 2023 12:47 am

Hi.

Try this script.
:local ipPing ("8.8.8.8")
:local pingip
:set pingip [/ping $ipPing count=10]
:if ($pingip = 1) do={
	:log info ("90% lost")
    /interface ethernet disable ether1
} else={
    /interface ethernet enable ether1
}
I need help with a script similar to this one, I use 700 Mbps and I would like the script to ping 8.8.8.8 and when the internet goes down to 250 Mbps send the router to restart. Thanks for the help.
You should check the speed-test results. If the speed goes down to 250, then run the restart command: /system/reboot

https://wiki.mikrotik.com/wiki/Manual:Tools/Speed_Test
https://wiki.mikrotik.com/wiki/Manual:Scripting
https://wiki.mikrotik.com/wiki/Manual:System/Scheduler
 
Matthiastik
newbie
Posts: 40
Joined: Wed Apr 25, 2018 1:31 am

Re: a script for monitoring packet loss for ping 10 times

Fri Apr 28, 2023 5:40 am

guys.. need some in help here
can u please teach me to make a script "if" "do" "then" for monitoring packet loss on ping for 10 times, when packet loss reach for 90% then the script will "do" disable interface and "then" enable another interface.
Hi

i am using network with ROS7 and seen in the manual that is can hadle % of ping loss as an parameter but i am using thr basic icmp only but i think
netwatch is your best option and less coding and can even see realtime charaterstics it seems but again i have not used it but can be set according to neds
according to the manuals or wiki for netwatch, seems like a neat tool.

good luck and spemd time with netwatch and i think you will like it.

Who is online

Users browsing this forum: No registered users and 21 guests