Results of MTR on STDOUT?
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
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 <[email protected]>
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
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.