STDOUT 的 MTR 结果?

Bor*_*pen 7 linux-networking mtr

我正在尝试mtr (My traceroute) 用于教育目的。然而,令人不安的是我无法stdout直接打印结果。默认情况下,它会打开一个 GTK 窗口,将结果打印到其中。如果我使用该选项,-t我可以强制它ncurses在终端中使用。但这根本没有帮助。

  • 我无法将这些东西重定向到文件或管道中(我可以,但是有很多令人不安的东西,例如ESC[?1049h来自 ncurses 之类的东西)。

  • 当我定义循环时,例如,运行完成后-r -c 1结果立即从提示中消失

  • 如果我停止程序,结果也会消失。

有没有办法以“UNIX 方式”使用这个程序?我只想要结果stdout,没有花哨的附加功能!

我已经mtr在当前的debian wheezy.

$ mtr --version
mtr 0.82
Run Code Online (Sandbox Code Playgroud)

use*_*517 5

打开终端/控制台窗口并使用-r( -c n)。这会做你想做的。或者 ssh 进入服务器。

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
Run Code Online (Sandbox Code Playgroud)

CentOS mtr 版本 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
Run Code Online (Sandbox Code Playgroud)

这也可以重定向到文件。


Cha*_*a0s 5

尝试mtr-tinyDebian上使用该软件包以使其在没有 GTK 或 ncurses 的情况下工作。

mtr-tiny 编译时不支持 X 并节省磁盘空间。

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
Run Code Online (Sandbox Code Playgroud)