7

I am trying out mtr (My traceroute) for educational purposes. However it is quite disturbing that I can't manage it to print results to stdout directly. Per default it opens a GTK-Window where it prints its results to. If I use the option -t I can force it to use ncurses in terminal. But this isn't helpful at all.

  • I can't redirect the stuff into a file or pipe (well I can but there is a lot of disturbing stuff like ESC[?1049h from ncurses or so).

  • When I define cycles e.g. with -r -c 1 the result immediately disappears from the prompt after the run is through.

  • If I stop the program the results also disappears.

Is there any way to use this program "the UNIX-way"? I just want the result out to stdout, no fancy extras!

I have installed the package mtr on a current debian wheezy.

$ mtr --version
mtr 0.82
Boris Däppen
  • 175
  • 1
  • 7
  • 1
    On multiple systems (Debian,Ubuntu, CentOS - without X) that I just tried, `mtr -r -c 1 IP_ADDRESS` always prints the results directly on the terminal. Nothing gets disappeared or anything like that. Also redirecting works fine without any weird characters in file. Maybe you could elaborate more on your issue? – Cha0s Jan 26 '14 at 15:19
  • Do you have the package `mtr-tiny` installed (instead of `mtr`)? I'll try this one out. – Boris Däppen Jan 26 '14 at 15:21
  • 1
    I have the standard mtr package installed. Versions 0.75 and 0.80. – Cha0s Jan 26 '14 at 15:23
  • The solution is: "Install `mtr-tiny` instead of `mtr`, because on Debian Wheezy `mtr` is the 'Graphical-Package', bringing along the problems you have." @Cha0s can you bring this up as a solution? I'll then accept and thx for you help! (Bad design decision from Debian, imho) – Boris Däppen Jan 26 '14 at 15:24
  • iain actually posted pretty much the same answer as mine. You can accept his answer as a solution, I don't mind. Glad I could help :) To be honest I didn't even know there was a `mtr-tiny` package. `mtr` would always work on all my servers without GTK. – Cha0s Jan 26 '14 at 15:28
  • But the answer lies in the `mtr-tiny`, not in the correct shell-arguments ;-) I can't answer my own question directly, need to wait. Somebody do this, points 4 free :-P – Boris Däppen Jan 26 '14 at 15:30
  • Fair enough :) I did post the solution. – Cha0s Jan 26 '14 at 15:38

3 Answers3

6

Open a terminal/console window and use -r (-c n). This will do what you want. Alternatively ssh into the server.

Ubuntu - mtr 0.85

 mtr -c 1 -r google.com
Start: Sun Jan 26 15:19:11 2014
HOST: host1                       Loss%   Snt   Last   Avg  Best  Wrst StDev
  1.|-- firewall                   0.0%     1    0.8   0.8   0.8   0.8   0.0
  2.|-- 192.168.1.254              0.0%     1    1.8   1.8   1.8   1.8   0.0
  3.|-- 217.32.143.44              0.0%     1    8.5   8.5   8.5   8.5   0.0
  4.|-- 217.32.143.110             0.0%     1    8.3   8.3   8.3   8.3   0.0
  5.|-- 213.120.158.242            0.0%     1   11.4  11.4  11.4  11.4   0.0
  6.|-- 31.55.165.171              0.0%     1   12.6  12.6  12.6  12.6   0.0
  7.|-- 31.55.165.109              0.0%     1   12.1  12.1  12.1  12.1   0.0
  8.|-- 31.55.167.5                0.0%     1   11.3  11.3  11.3  11.3   0.0
  9.|-- 31.55.167.151              0.0%     1   11.2  11.2  11.2  11.2   0.0

CentOS mtr version 0.75

[iain@host ~]$ sudo mtr -c1 -r www.google.com
HOST: host                         Loss%   Snt   Last   Avg  Best  Wrst StDev
  1. 2001:470:1f05:6e9::1          0.0%     1    0.6   0.6   0.6   0.6   0.0
  2. Iain-1.tunnel.tserv        .  0.0%     1   25.3  25.3  25.3  25.3   0.0
  3. ge4-8.core1.lon1.he.net       0.0%     1   21.3  21.3  21.3  21.3   0.0
  4. 2001:4860:1:1:0:1b1b:0:5      0.0%     1   21.1  21.1  21.1  21.1   0.0
  5. 2001:4860::1:0:3067           0.0%     1   21.5  21.5  21.5  21.5   0.0
  6. 2001:4860::8:0:5bb9           0.0%     1   21.2  21.2  21.2  21.2   0.0
  7. 2001:4860::8:0:51a0           0.0%     1   27.6  27.6  27.6  27.6   0.0
  8. 2001:4860::8:0:5039           0.0%     1   36.3  36.3  36.3  36.3   0.0
  9. 2001:4860::1:0:4ca2           0.0%     1   33.9  33.9  33.9  33.9   0.0
 10. 2001:4860:0:1::6eb            0.0%     1   34.2  34.2  34.2  34.2   0.0
 11. fra02s17-in-x10.1e100.net     0.0%     1   34.4  34.4  34.4  34.4   0.0

This can be redirected to a file too.

user9517
  • 114,104
  • 20
  • 206
  • 289
  • Thx, but I found the problem. It's the graphical package from Debian, imho. But your post will surely help others, showing how to use the arguments. – Boris Däppen Jan 26 '14 at 15:28
  • I get weird [<-H123] character sequences when redirecting -r -c1 output to file on Centos 7 – simonpa71 Sep 01 '17 at 09:32
5

Try using the package mtr-tiny on Debian to get it to work without GTK or ncurses.

mtr-tiny is compiled without support for X and conserves disk space.

root@mail:~# apt-cache show mtr-tiny
Package: mtr-tiny
Priority: optional
Section: net
Installed-Size: 120
Maintainer: Robert Woodcock <rcw@debian.org>
Architecture: amd64
Source: mtr
Version: 0.75-2
Replaces: mtr
Depends: libc6 (>= 2.7-1), libncurses5 (>= 5.6+20071006-3)
Conflicts: mtr, suidmanager (<< 0.50)
Filename: pool/main/m/mtr/mtr-tiny_0.75-2_amd64.deb
Size: 40740
MD5sum: 46cbf5da3e22772d34a7a696cc6648a5
SHA1: 40d6427a48c0dac7b6e31e0a9592ef6381445001
SHA256: 9a32f07375e09f11109cd207f8875647bd3f3b88170c071f3a13aca614182e15
Description: Full screen ncurses traceroute tool
 mtr combines the functionality of the 'traceroute' and 'ping' programs
 in a single network diagnostic tool.
 .
 As mtr starts, it investigates the network connection between the host
 mtr runs on and a user-specified destination host.  After it
 determines the address of each network hop between the machines,
 it sends a sequence ICMP ECHO requests to each one to determine the
 quality of the link to each machine.  As it does this, it prints
 running statistics about each machine.
 .
 mtr-tiny is compiled without support for X and conserves disk space.
Tag: interface::text-mode, network::scanner, protocol::ip, role::program, scope::utility, uitoolkit::ncurses, use::checking
Boris Däppen
  • 175
  • 1
  • 7
Cha0s
  • 2,432
  • 2
  • 15
  • 26
0

You could add an alias. Edit the file /etc/bash.bashrc and add this at the end:

alias mtr="mtr -t" 

Reboot and try it.

nope
  • 9
  • 1