Community discussions

MikroTik App
 
ciscosystem
newbie
Topic Author
Posts: 26
Joined: Mon Feb 04, 2013 3:25 pm

traceroute-script

Mon Feb 04, 2013 3:33 pm

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
 
User avatar
jgellis
Member Candidate
Member Candidate
Posts: 140
Joined: Wed May 30, 2007 10:57 am
Location: USA

Re: traceroute-script

Thu Feb 07, 2013 6:37 am

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.
 
ciscosystem
newbie
Topic Author
Posts: 26
Joined: Mon Feb 04, 2013 3:25 pm

Re: traceroute-script

Sat Feb 09, 2013 8:17 am

thanks body but how can i save the output in a file ? does it need a special command ?
 
zindy
just joined
Posts: 11
Joined: Mon Feb 15, 2010 1:37 pm

Re: traceroute-script

Sat Feb 09, 2013 9:32 am

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.
 
ciscosystem
newbie
Topic Author
Posts: 26
Joined: Mon Feb 04, 2013 3:25 pm

Re: traceroute-script

Tue Feb 12, 2013 10:08 am

thank u so muchhh :)

Who is online

Users browsing this forum: rextended and 31 guests