Linux command - mtr

sycho·2023년 12월 19일
0

Linux Commands

목록 보기
12/30

mtr

  • documentation

  • my traceroute의 약자다

  • 간단하게 말하자면, traceroute + ping이다.

  • 설치가 필요하며, Ubuntu에서는 다음과 같이 한다.

sudo apt install mtr-tiny

basic

  • 다음 command로 실행시 그 다음 화면처럼 나온다. 실시간으로 갱신됨.
$ mtr naver.com

  • host에서 특정 destination으로 가는 경로 상에서 어떤 일이 일어나고 있는지를 실시간으로 파악하는 용도로 이게 쓰이기 때문이다. packet이 얼마나 loss가 생기는지, 그리고 마지막/평균/가장 좋은/가장 않좋은/표준편차 ping 관련 통계를 내는것도 확인이 가능하다. 위의 경우에는 중간에 reply가 아예 오지 않고 있음이 확인 가능하다.

  • 실시간으로 이렇게 분석을 하는 도중 갑자기 packet loss가 엄청 많이 이루어지거나, response time이 엄청 늘어나는 경우 그쪽 경로 부근에 문제가 있다는 것을 바로 파악할 수 있다.

options

--csv, --xml, --json

  • csv/xml/json 형식으로 mtr 출력물을 만든다. 지정된 ping 횟수만큼 시도하고 (기본은 10) 측정을 한 다음에 그 종합 결과물을 저 파일 형식으로 로깅하는 것이다.
$ mtr --csv naver.com
Mtr_Version,Start_Time,Status,Host,Hop,Ip,Loss%,Snt, ,Last,Avg,Best,Wrst,StDev,
MTR.0.95,1702972417,OK,naver.com,1,DESKTOP-4RPUOID,0.00,10,0,0.22,0.21,0.16,0.32,0.05
MTR.0.95,1702972417,OK,naver.com,2,192.168.0.1,0.00,10,0,0.38,0.41,0.35,0.56,0.06
MTR.0.95,1702972417,OK,naver.com,3,110.76.92.1,0.00,10,0,1.24,1.50,1.05,3.04,0.60
MTR.0.95,1702972417,OK,naver.com,4,110.76.127.18,0.00,10,0,1.00,0.99,0.91,1.08,0.06
MTR.0.95,1702972417,OK,naver.com,5,110.76.108.17,0.00,10,0,0.91,0.89,0.66,2.39,0.53
MTR.0.95,1702972417,OK,naver.com,6,110.76.108.1,0.00,10,0,0.87,5.26,0.83,44.40,13.75
MTR.0.95,1702972417,OK,naver.com,7,211.230.12.5,0.00,10,0,1.16,2.79,1.07,12.07,3.62
MTR.0.95,1702972417,OK,naver.com,8,112.188.134.153,0.00,10,0,1.19,1.26,1.03,2.02,0.28
MTR.0.95,1702972417,OK,naver.com,9,???,100.00,10,10,0.00,0.00,0.00,0.00,0.00
MTR.0.95,1702972417,OK,naver.com,10,112.174.75.42,0.00,10,0,3.62,4.28,3.44,7.01,1.20
MTR.0.95,1702972417,OK,naver.com,11,???,100.00,10,10,0.00,0.00,0.00,0.00,0.00
$ mtr --xml naver.com
<?xml version="1.0"?>
<MTR SRC="DESKTOP-4RPUOID" DST="naver.com" TOS="0x0" PSIZE="64" BITPATTERN="0x00" TESTS="10">
    <HUB COUNT="1" HOST="DESKTOP-4RPUOID">
        <Loss>  0.0%</Loss>
        <Snt>    10</Snt>
        <Last>   0.2</Last>
        <Avg>   0.2</Avg>
        <Best>   0.1</Best>
        <Wrst>   0.2</Wrst>
        <StDev>   0.0</StDev>
    </HUB>
	...
$ mtr --json naver.com
{
    "report": {
        "mtr": {
            "src": "DESKTOP-4RPUOID",
            "dst": "naver.com",
            "tos": 0,
            "tests": 10,
            "psize": "64",
            "bitpattern": "0x00"
        },
        "hubs": [
            {
                "count": 1,
                "host": "DESKTOP-4RPUOID",
                "Loss%": 0.0,
                "Snt": 10,
                "Last": 0.252,
                "Avg": 0.203,
                "Best": 0.165,
                "Wrst": 0.252,
                "StDev": 0.029
            },
            ...

-c

  • 앞에서 ping을 할 횟수, 혹은 그냥 mtr에서 ping을 할 횟수를 지정하는데 사용된다.
$ mtr -c 1 --csv naver.com
Mtr_Version,Start_Time,Status,Host,Hop,Ip,Loss%,Snt, ,Last,Avg,Best,Wrst,StDev,
MTR.0.95,1702972863,OK,naver.com,1,DESKTOP-4RPUOID,0.00,1,0,0.25,0.25,0.25,0.25,0.00
MTR.0.95,1702972863,OK,naver.com,2,192.168.0.1,0.00,1,0,0.46,0.46,0.46,0.46,0.00
MTR.0.95,1702972863,OK,naver.com,3,110.76.92.1,0.00,1,0,1.10,1.10,1.10,1.10,0.00
MTR.0.95,1702972863,OK,naver.com,4,110.76.127.18,0.00,1,0,0.94,0.94,0.94,0.94,0.00
MTR.0.95,1702972863,OK,naver.com,5,110.76.108.17,0.00,1,0,1.09,1.09,1.09,1.09,0.00
MTR.0.95,1702972863,OK,naver.com,6,110.76.108.1,0.00,1,0,0.96,0.96,0.96,0.96,0.00
MTR.0.95,1702972863,OK,naver.com,7,211.230.12.5,0.00,1,0,5.84,5.84,5.84,5.84,0.00
MTR.0.95,1702972863,OK,naver.com,8,112.188.134.133,0.00,1,0,2.76,2.76,2.76,2.76,0.00
MTR.0.95,1702972863,OK,naver.com,9,???,100.00,1,1,0.00,0.00,0.00,0.00,0.00

-F

  • 측정에서 destination으로 할 hostname을 file에서 읽을 때 사용한다.

  • 여러개의 hostname 지정이 가능하며, 그것들 전부에 대해서 측정을 한다...는데 필자의 경우 file의 첫번째 hostname에 대해서만 되는데 무슨 이유인지는 잘 모르겠다. script file로 우회하는 방법이 있긴 하다.

-n

  • 각 ip주소에 대한 DNS resolving을 수행하지 않는다. ip주소가 DNS 상의 domain name으로 변환하는 것을 아예 시도하지 않는다. output이 조금 더 빠르게 나온다.

-b

  • IP 주소랑 hostname이 같이 출력되도록 한다.

-r

  • report mode로 mtr을 실행한다. 실시간으로 통계를 보여주는게 아니라 결과가 나오면 그걸 출력하는 형태.
$ sudo mtr -c 5 -r google.com
Start: 2023-12-19T17:25:01+0900
HOST: DESKTOP-4RPUOID             Loss%   Snt   Last   Avg  Best  Wrst StDev
  1.|-- DESKTOP-4RPUOID            0.0%     5    0.1   0.2   0.1   0.2   0.0
  2.|-- 192.168.0.1                0.0%     5    0.4   0.4   0.4   0.5   0.1
  3.|-- 110.76.92.1                0.0%     5    1.0   1.3   1.0   1.5   0.3
  4.|-- 110.76.127.18              0.0%     5    0.9   0.9   0.9   1.1   0.1
  5.|-- 110.76.108.17              0.0%     5    0.7   0.8   0.7   1.0   0.1
  6.|-- 110.76.108.1               0.0%     5    0.9   0.9   0.9   1.0   0.0
  7.|-- 211.230.12.5               0.0%     5    1.3   1.3   1.1   1.4   0.1
  8.|-- 112.188.135.129            0.0%     5    1.5   1.4   1.1   2.0   0.3
  9.|-- 112.174.48.57              0.0%     5    4.4   4.9   4.3   6.2   0.8
 10.|-- 112.174.84.30              0.0%     5    5.2   8.5   5.1  16.2   4.7
 11.|-- 72.14.243.228              0.0%     5   31.2  31.4  30.9  33.0   0.9
 12.|-- 142.251.61.113             0.0%     5   28.5  28.6  28.4  28.8   0.1
 13.|-- 108.170.242.166            0.0%     5   29.1  29.3  29.1  29.8   0.3
 14.|-- 209.85.242.235             0.0%     5   30.1  30.3  30.0  30.8   0.3
 15.|-- 142.250.57.228             0.0%     5   31.5  31.5  31.3  31.7   0.2
 16.|-- 108.170.243.65             0.0%     5   31.0  45.9  31.0 100.4  30.5
 17.|-- 142.251.70.23              0.0%     5   30.6  30.7  30.4  31.5   0.4
 18.|-- kix06s11-in-f14.1e100.net  0.0%     5   30.4  30.4  30.3  30.4   0.0
profile
CS 학부생, 핵심 관심 분야 : Embed/System/Architecture/SWE

0개의 댓글