Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mikrotik Traceroute #125

Open
agent-squirrel opened this issue Jul 6, 2020 · 2 comments
Open

Mikrotik Traceroute #125

agent-squirrel opened this issue Jul 6, 2020 · 2 comments
Assignees

Comments

@agent-squirrel
Copy link
Contributor

The Traceroute tool on Mikrotik ROS operates like an MTR and continually updates the console with metrics. This can be avoided with count=1 but if the traceroute encounters a blank hop for any reason, the router rewrites the console anyway. If running the traceroute with no controlling terminal, as in the case of an LG, the result gets output in chunks and only the final chunk is actually useful.

A solution is to explode the resultant string data into an array using the blank line between each chunk as a deliminator and then takes the final index as the resultant string.

Adding $filtered = end(explode("\n\n",trim($filtered))); Somewhere before the filtered output is returned has fixed this issue on our install of LG. We have added it just before return preg_replace('/(?:\n|\r\n|\r)$/D', '', $filtered);

@gmazoyer gmazoyer self-assigned this Jul 6, 2020
@safnz
Copy link

safnz commented Jul 20, 2020

Can confirm the above fix works, great stuff @agent-squirrel

@jordandalley
Copy link

jordandalley commented May 4, 2024

The above solution didn't work for me unfortunately.. might be due to a different routeros or php version.

Instead, I placed the following as the first line of the format_output function in router.php:

$output = substr($output, strrpos($output, "\r\n\r\nColumns:") + 2, strlen($output));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants