Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
share|improve this question
    
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 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 at 15:21
    
I have the standard mtr package installed. Versions 0.75 and 0.80. –  Cha0s Jan 26 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 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 at 15:28
show 2 more comments

2 Answers 2

up vote 3 down vote accepted

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
share|improve this answer
add comment

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.

share|improve this answer
    
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 at 15:28
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.