traceroute-script

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

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.

thanks body but how can i save the output in a file ? does it need a special command ?

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.

thank u so muchhh :slight_smile: