Page 1 of 1

traceroute-script

Posted: Mon Feb 04, 2013 3:33 pm
by ciscosystem
hello guys
i need a script to run traceroute with source-address every 12 hours i need hops to be logged in my log server .
is it possible ?
thanks

Re: traceroute-script

Posted: Thu Feb 07, 2013 6:37 am
by jgellis
It is not possible to do it natively in ROS (you cannot redirect the output of /tool traceroute to a file or variable that could later be written to a syslog, file or web server).

You *could* implement it from a remote server that performs an SSH into the box and executes the traceroute from the cmdlin and redirects the output to a file. Best to utilize certificates so that the SSH utility does not need to pass username/passwords.

Re: traceroute-script

Posted: Sat Feb 09, 2013 8:17 am
by ciscosystem
thanks body but how can i save the output in a file ? does it need a special command ?

Re: traceroute-script

Posted: Sat Feb 09, 2013 9:32 am
by zindy
hi, you can save something to file with
/file set file_name.txt contents="Whatever you want to save to file $IncludingVariablesContents or $[/system clock get time]"
but you have to create this file at first and there is no /file add unfortunately. You can also set variable to contain return value of command, but it wont log whole command output.
:local pingVar [/ping 8.8.8.8 count=10]
this will return number of successful pings, but not whole ping command output.

The easiest way to get command output from mikrotik is using ssh. From linux or cygwin you can ssh to mikrotik device and redirect outpu to file.
ssh admin@1.2.3.4 ':put "$[/system clock get time], $[/system clock get date]";/tool traceroute address=8.8.8.8' >> mikrotik-log.txt
Run this from cron and it will append whole mikrotik commands output to file mikrotik-log.txt. First put will return time and date before traceroute output.

Re: traceroute-script

Posted: Tue Feb 12, 2013 10:08 am
by ciscosystem
thank u so muchhh :)