mtr --csv


I have added a `--csv` format for `mtr`.

The result format is shown below:

    VERSION;TIMESTAMP;STATUS;HOSTNAME;TTL;ENDPOINT;ASN;PING(µs)

A sample IPv4 traceroute lookup is shown below:

    $ sudo ./mtr -c 1 --no-dns -6 --csv --aslookup www.facebook.com
    MTR.0.84+git:ce36701d;1367775366;OK;www.facebook.com;1;2001:638:709:3000::1;AS680;4049
    MTR.0.84+git:ce36701d;1367775366;OK;www.facebook.com;2;???;AS???;0
    MTR.0.84+git:ce36701d;1367775366;OK;www.facebook.com;3;???;AS???;0
    MTR.0.84+git:ce36701d;1367775366;OK;www.facebook.com;4;???;AS???;0
    MTR.0.84+git:ce36701d;1367775366;OK;www.facebook.com;5;2003:0:1308:4000::1;AS3320;8550
    MTR.0.84+git:ce36701d;1367775366;OK;www.facebook.com;6;2003:0:1308:4009::2;AS3320;8650
    MTR.0.84+git:ce36701d;1367775366;OK;www.facebook.com;7;2620:0:1cff:dead:beef::1345;AS32934;8839
    MTR.0.84+git:ce36701d;1367775366;OK;www.facebook.com;8;2620:0:1cff:dead:beee::22c;AS32934;19167
    MTR.0.84+git:ce36701d;1367775366;OK;www.facebook.com;9;2620:0:1cff:dead:beee::1aa;AS32934;96152
    MTR.0.84+git:ce36701d;1367775366;OK;www.facebook.com;10;2620:0:1cff:dead:beef::475;AS32934;96062
    MTR.0.84+git:ce36701d;1367775366;OK;www.facebook.com;11;2620:0:1cff:dead:beef::d2;AS32934;112455
    MTR.0.84+git:ce36701d;1367775366;OK;www.facebook.com;12;2620:0:1cff:dead:beef::97;AS32934;105817
    MTR.0.84+git:ce36701d;1367775366;OK;www.facebook.com;13;2620:0:1cff:dead:beef::1329;AS32934;106714
    MTR.0.84+git:ce36701d;1367775366;OK;www.facebook.com;14;2a03:2880:2110:cf01:face:b00c:0:9;AS32934;105930

A sample IPv4 traceroute lookup is shown below:

    $ sudo ./mtr -c 1 --no-dns -4 --csv --aslookup www.facebook.com
    MTR.0.84+git:ff538f10;1367853394;OK;www.facebook.com;1;212.201.49.11;AS680;336
    MTR.0.84+git:ff538f10;1367853394;OK;www.facebook.com;2;212.201.49.251;AS680;556
    MTR.0.84+git:ff538f10;1367853394;OK;www.facebook.com;3;212.201.44.214;AS680;1632
    MTR.0.84+git:ff538f10;1367853394;OK;www.facebook.com;4;134.102.121.125;AS680;1216
    MTR.0.84+git:ff538f10;1367853394;OK;www.facebook.com;5;188.1.239.205;AS680;1673
    MTR.0.84+git:ff538f10;1367853394;OK;www.facebook.com;6;188.1.145.241;AS680;3362
    MTR.0.84+git:ff538f10;1367853394;OK;www.facebook.com;7;188.1.145.217;AS680;11361
    MTR.0.84+git:ff538f10;1367853394;OK;www.facebook.com;8;80.239.128.181;AS1299;45610
    MTR.0.84+git:ff538f10;1367853394;OK;www.facebook.com;9;213.155.135.86;AS1299;29106
    MTR.0.84+git:ff538f10;1367853394;OK;www.facebook.com;10;80.91.245.183;AS1299;18359
    MTR.0.84+git:ff538f10;1367853394;OK;www.facebook.com;11;80.91.246.99;AS1299;19077
    MTR.0.84+git:ff538f10;1367853394;OK;www.facebook.com;12;195.12.255.142;AS1299;18139
    MTR.0.84+git:ff538f10;1367853394;OK;www.facebook.com;13;31.13.24.57;AS32934;19527
    MTR.0.84+git:ff538f10;1367853394;OK;www.facebook.com;14;31.13.29.87;AS32934;18299
    MTR.0.84+git:ff538f10;1367853394;OK;www.facebook.com;15;31.13.64.1;AS32934;18767

features added:

- capable of reading multiple service names as arguments:

        $ sudo ./mtr -c 1 --no-dns -6 --csv --aslookup \
          www.google.com www.facebook.com

  The multiple service names argument are only used by `--csv`. I
  figured it cannot be used for curses-based display. If multiple service
  names are given for any other switch than `--csv`, then only the first
  service name is used for traceroute lookup. 

  If there is a dns resolution error on one the service names. `mtr`
  does not exit on this first failure, instead it writes the error to
  `stderr`, skips that service name and moves on in the list

- capable of reading service names from a file with --filename

        $ sudo ./mtr -c 1 --no-dns -6 --csv --aslookup \
          --filename topsites 

  The `--filename` flag can also take input from `stdin`.

        $ cat topsites | sudo ./mtr -c 1 --no-dns -6 \
          --csv --aslookup --filename -

- file locking capability 

  If the results of `mtr` are written to a regular file, `mtr` locks the
  file in order to coordinate writes to a common file from multiple `mtr`
  instances. This is useful when multiple `mtr` instances try to append
  results to a common file.  

We have cross-compiled this build for the OpenWrt platform, and are
currently running this test from multiple SamKnows boxes spread across
Europe. We use the test to capture forwarding path information of a list
of destinations along with the latency to each hop. The `--csv` results
format allows us to capture this result on the server-side in a database.

We would appreciate if you can accept our pull request and recognize our
effort by adding us in the AUTHORS list.

Contributers:

- Vaibhav Bajpai <contact@vaibhavbajpai.com>
- Jürgen Schönwälder <j.schoenwaelder@jacobs-university.de>