Community discussions

MikroTik App
 
rmichael
Forum Veteran
Forum Veteran
Topic Author
Posts: 718
Joined: Sun Mar 08, 2009 11:00 pm

dump traceroute to file

Tue Dec 14, 2010 12:30 am

Is there a way to output traceroute to a file instead of the terminal? I want netwatch run traceroute everytime delay is longer than xxx ms...

TIA
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 6013
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: dump traceroute to file

Wed Dec 15, 2010 4:08 pm

Currently from router itself it is not possible.
 
wifi442
Frequent Visitor
Frequent Visitor
Posts: 79
Joined: Tue Jan 12, 2010 11:01 pm

Re: dump traceroute to file

Fri Sep 09, 2011 12:02 am

I need to monitor our connection that is at a data center. Data center has a RB1100 installed. They are asking for traceroutes whenever the latency jumps up so they can troubleshoot. Is there any way for netwatch to run and save a traceroute when pings drop? I am always away from the computer when the problem occurs. There must be a way yes?
 
changeip
Forum Guru
Forum Guru
Posts: 3810
Joined: Fri May 28, 2004 5:22 pm

Re: dump traceroute to file

Tue Nov 01, 2011 6:25 am

i need this badly too ...
Colo and Wholesale Bandwidth Available! Sales at SanDiegoBroadband dot com
 
shdwmstff
newbie
Posts: 43
Joined: Wed May 30, 2012 12:00 am

Re: dump traceroute to file

Thu Dec 17, 2015 5:16 pm

Did you ever find a solution for dumping the traceroute to a file.
I have a similar situation where I see a GRE tunnel dropping and want to confirm where in the traceroute it is
getting dropped.

Thanx
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 6013
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: dump traceroute to file

Thu Dec 17, 2015 5:21 pm

You still can't from console. But you can get traceroute data from API.
 
User avatar
PaulsMT
MikroTik Support
MikroTik Support
Posts: 283
Joined: Tue Feb 10, 2015 3:21 pm

Re: dump traceroute to file

Fri Dec 18, 2015 10:13 am

You can also save console output with :execute command. With this example you will get 5 second traceroute output saved to TRACEROUTE.txt.

:execute {/tool traceroute 8.8.8.8 duration=5} file=TRACEROUTE
 
shdwmstff
newbie
Posts: 43
Joined: Wed May 30, 2012 12:00 am

Re: dump traceroute to file

Fri Dec 18, 2015 7:29 pm

WHOLEY FANTASTIC-NESS!!!!


it works on 6.33
but not on 6.29
I suspect some weird version bug... but that gets me in the right direction.
curious if it will append...for me but , I'm not complaining.!

Thank you
 
shdwmstff
newbie
Posts: 43
Joined: Wed May 30, 2012 12:00 am

Re: dump traceroute to file

Fri Dec 18, 2015 10:49 pm

ok I have been having a problem where a remote circuit fails intermittently and is causing packet loss.
but by the time I get to the device I don't see any of the errors and can't pinpoint where the failure is occuring.
And as always the upstream gives me the DE-FACTO "Everything is running clean" line.

So I needed to be able to run a trace at the moment the failure happened to see what is failing.
had a heck of a time getting the router to script what I needed so I figured I'll let people know.



Ok Doing this will let you run netwatch and post the output data to a text log file. netwatch,.0.txt

Then if netwatch fails it will run a ping to the tested ip address (count set to 100 but you can change it) ping-fail.txt

It will also execute a traceroute to the device and write the traceroutes to a file. "TRACEROUTE.txt"

Need to be running 6.33 or higher to get it all to work.
the ":execute" command only works after 6.30




Do this to create the netwatch logging option. (this log will stay and get appended, and time stamped)

/system logging action add disk-file-count=100 disk-file-name=netwatch, name=netwatch target=disk

/system logging add action=netwatch topics=script,info



Then create a netwatch instance to 8.8.8.8

put this in the "up script" area

:log info "\rNW-8.8.8.8 up\r";

put this in the "down script" area

SCRIPT-PING-TRACE


Create a Script called "SCRIPT-PING-TRACE" or call it what you want and make it match above
put this in the script. (the trace and ping logs will get overwritten each time this occurs , so you will need to get to them quick)

:log info "\rNW-8.8.8.8 down\r";
:execute {/ping 8.8.8.8 count=100} file=ping-fail;
:execute {/tool traceroute 8.8.8.8 duration=5} file=TRACEROUTE




I hope this helps anyone who has a similar problem.
 
User avatar
PaulsMT
MikroTik Support
MikroTik Support
Posts: 283
Joined: Tue Feb 10, 2015 3:21 pm

Re: dump traceroute to file

Mon Dec 21, 2015 9:55 am

WHOLEY FANTASTIC-NESS!!!!


it works on 6.33
but not on 6.29
I suspect some weird version bug... but that gets me in the right direction.
curious if it will append...for me but , I'm not complaining.!

Thank you

:execute is a new feature, you will find it only starting from RouterOS 6.30

By the way, to be sure that :execute command will not overwrite the output file (if script is executed more then once), add some dynamic text to the file name, for example clock..

:execute {/tool traceroute 8.8.8.8 duration=5} file=([/system clock get time]."_"."filename")
 
mvalsasna
just joined
Posts: 18
Joined: Tue Sep 30, 2014 2:10 pm

Re: dump traceroute to file

Wed Apr 26, 2017 5:45 pm

not working in 6.33 : create an empty file
 
User avatar
normis
MikroTik Support
MikroTik Support
Posts: 24556
Joined: Fri May 28, 2004 11:04 am
Location: Riga, Latvia

Re: dump traceroute to file

Thu Apr 27, 2017 10:08 am

not working in 6.33 : create an empty file
works fine in 6.38
No answer to your question? How to write posts
 
pkelly1603
Frequent Visitor
Frequent Visitor
Posts: 85
Joined: Mon Jun 15, 2009 11:13 pm

Re: dump traceroute to file

Thu Nov 29, 2018 9:47 pm

not working in 6.33 : create an empty file
works fine in 6.38
The command below does not work from netwatch in version 6.42.9. Is that due to the security changes where netwatch has limited permission? Is there anyway to run a traceroute from netwatch in up to date versions?

:execute {/tool traceroute 8.8.8.8 duration=5} file=([/system clock get time]."_"."filename")
 
Ehman
Member
Member
Posts: 364
Joined: Mon Nov 15, 2010 10:49 pm

Re: dump traceroute to file

Fri Feb 28, 2020 1:17 pm

Create a Script called "SCRIPT-PING-TRACE" or call it what you want and make it match above
put this in the script. (the trace and ping logs will get overwritten each time this occurs , so you will need to get to them quick)

:log info "\rNW-8.8.8.8 down\r";
:execute {/ping 8.8.8.8 count=100} file=ping-fail;
:execute {/tool traceroute 8.8.8.8 duration=5} file=TRACEROUTE

Any way of putting in timestamps of time and date to print in that txt file aswell after every traceroute count, because i want to make this script run 24 hours for example to pin point an issue on the network, so I'll just jack up the duration up from 5 to alooot more, but I need timestamps please guys, I dunno how to add it myself :?

Thank You
 
Cris@usai.net
newbie
Posts: 34
Joined: Fri Jun 17, 2005 8:25 pm

Re: dump traceroute to file

Fri Feb 28, 2020 5:53 pm

Now my original script was this.
Made 2 files showing the failed pings. and showing the traceroutes.
:log info "\rNW-8.8.8.8 down\r";
:execute {/ping 8.8.8.8 count=10} file=ping-fail;
:execute {/tool traceroute 8.8.8.8 duration=5} file=TRACEROUTE

would love to add the time /date to them but the files can't be appended (not an option in ROS)
I was thinking you could make another script and run it after the first. to add the time to the end of the file.
-- This does work... but I suspect there is a better way to just run the traceroutes and post the time at the end Or begining of the file

:local test [/file get TRACEROUTE contents]
:local tSubject "$[/system identity get name] @ $[/system clock get date] $[/system clock get time]"
:set test ($test . "$tSubject")
/file set TRACEROUTE contents=$test

Who is online

Users browsing this forum: No registered users and 51 guests