2021-04-09 10:36:42 -07:00
|
|
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
2022-01-25 17:07:47 -08:00
|
|
|
<a id="jc.parsers.traceroute"></a>
|
2020-07-30 16:20:24 -07:00
|
|
|
|
2020-07-23 16:44:57 -07:00
|
|
|
# jc.parsers.traceroute
|
2022-01-25 17:07:47 -08:00
|
|
|
|
2022-03-04 13:27:39 -08:00
|
|
|
jc - JSON Convert `traceroute` command output parser
|
2020-08-05 16:51:58 -07:00
|
|
|
|
|
|
|
Supports `traceroute` and `traceroute6` output.
|
|
|
|
|
2022-05-26 15:54:39 -07:00
|
|
|
> Note: On some operating systems you will need to redirect `STDERR` to
|
|
|
|
> `STDOUT` for destination info since the header line is sent to
|
|
|
|
> `STDERR`. A warning message will be printed to `STDERR` if the
|
|
|
|
> header row is not found.
|
|
|
|
>
|
|
|
|
> e.g. `$ traceroute 8.8.8.8 2>&1 | jc --traceroute`
|
2020-07-23 16:44:57 -07:00
|
|
|
|
2020-08-05 13:32:59 -07:00
|
|
|
Usage (cli):
|
2020-07-23 16:44:57 -07:00
|
|
|
|
2022-01-25 18:03:34 -08:00
|
|
|
$ traceroute 1.2.3.4 | jc --traceroute
|
2020-07-23 16:44:57 -07:00
|
|
|
|
2022-01-25 18:03:34 -08:00
|
|
|
or
|
2020-07-31 10:56:51 -07:00
|
|
|
|
2022-01-25 18:03:34 -08:00
|
|
|
$ jc traceroute 1.2.3.4
|
2020-07-23 16:44:57 -07:00
|
|
|
|
2020-08-05 13:32:59 -07:00
|
|
|
Usage (module):
|
|
|
|
|
2022-01-25 18:03:34 -08:00
|
|
|
import jc
|
|
|
|
result = jc.parse('traceroute', traceroute_command_output)
|
2022-01-18 15:38:03 -08:00
|
|
|
|
2021-04-08 15:52:49 -07:00
|
|
|
Schema:
|
|
|
|
|
2022-01-25 18:03:34 -08:00
|
|
|
{
|
|
|
|
"destination_ip": string,
|
|
|
|
"destination_name": string,
|
|
|
|
"hops": [
|
|
|
|
{
|
|
|
|
"hop": integer,
|
|
|
|
"probes": [
|
|
|
|
{
|
|
|
|
"annotation": string,
|
|
|
|
"asn": integer,
|
|
|
|
"ip": string,
|
|
|
|
"name": string,
|
|
|
|
"rtt": float
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
Examples:
|
|
|
|
|
|
|
|
$ traceroute google.com | jc --traceroute -p
|
|
|
|
{
|
|
|
|
"destination_ip": "216.58.194.46",
|
|
|
|
"destination_name": "google.com",
|
|
|
|
"hops": [
|
|
|
|
{
|
|
|
|
"hop": 1,
|
|
|
|
"probes": [
|
|
|
|
{
|
|
|
|
"annotation": null,
|
|
|
|
"asn": null,
|
|
|
|
"ip": "216.230.231.141",
|
|
|
|
"name": "216-230-231-141.static.houston.tx.oplink.net",
|
|
|
|
"rtt": 198.574
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"annotation": null,
|
|
|
|
"asn": null,
|
|
|
|
"ip": "216.230.231.141",
|
|
|
|
"name": "216-230-231-141.static.houston.tx.oplink.net",
|
|
|
|
"rtt": null
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"annotation": null,
|
|
|
|
"asn": null,
|
|
|
|
"ip": "216.230.231.141",
|
|
|
|
"name": "216-230-231-141.static.houston.tx.oplink.net",
|
|
|
|
"rtt": 198.65
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
...
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
$ traceroute google.com | jc --traceroute -p -r
|
|
|
|
{
|
|
|
|
"destination_ip": "216.58.194.46",
|
|
|
|
"destination_name": "google.com",
|
|
|
|
"hops": [
|
|
|
|
{
|
|
|
|
"hop": "1",
|
|
|
|
"probes": [
|
|
|
|
{
|
|
|
|
"annotation": null,
|
|
|
|
"asn": null,
|
|
|
|
"ip": "216.230.231.141",
|
|
|
|
"name": "216-230-231-141.static.houston.tx.oplink.net",
|
|
|
|
"rtt": "198.574"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"annotation": null,
|
|
|
|
"asn": null,
|
|
|
|
"ip": "216.230.231.141",
|
|
|
|
"name": "216-230-231-141.static.houston.tx.oplink.net",
|
|
|
|
"rtt": null
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"annotation": null,
|
|
|
|
"asn": null,
|
|
|
|
"ip": "216.230.231.141",
|
|
|
|
"name": "216-230-231-141.static.houston.tx.oplink.net",
|
|
|
|
"rtt": "198.650"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
...
|
|
|
|
]
|
|
|
|
}
|
2022-01-25 17:07:47 -08:00
|
|
|
|
|
|
|
<a id="jc.parsers.traceroute.parse"></a>
|
|
|
|
|
2022-03-05 12:15:14 -08:00
|
|
|
### parse
|
2022-01-25 17:07:47 -08:00
|
|
|
|
2020-07-23 16:44:57 -07:00
|
|
|
```python
|
2022-01-25 17:07:47 -08:00
|
|
|
def parse(data, raw=False, quiet=False)
|
2020-07-23 16:44:57 -07:00
|
|
|
```
|
|
|
|
|
|
|
|
Main text parsing function
|
|
|
|
|
2022-01-25 18:03:34 -08:00
|
|
|
Parameters:
|
2020-07-23 16:44:57 -07:00
|
|
|
|
2022-01-25 18:03:34 -08:00
|
|
|
data: (string) text data to parse
|
|
|
|
raw: (boolean) unprocessed output if True
|
|
|
|
quiet: (boolean) suppress warning messages if True
|
2020-07-23 16:44:57 -07:00
|
|
|
|
2022-01-25 18:03:34 -08:00
|
|
|
Returns:
|
2020-07-23 16:44:57 -07:00
|
|
|
|
2022-01-25 18:03:34 -08:00
|
|
|
Dictionary. Raw or processed structured data.
|
2020-07-23 16:44:57 -07:00
|
|
|
|
2022-01-25 19:18:54 -08:00
|
|
|
### Parser Information
|
2021-04-09 10:36:42 -07:00
|
|
|
Compatibility: linux, darwin, freebsd
|
|
|
|
|
2022-07-16 20:52:19 -07:00
|
|
|
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
|