1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-17 00:07:37 +02:00
Files
jc/docs/parsers/ping.md

176 lines
4.1 KiB
Markdown
Raw Normal View History

2020-07-30 16:20:24 -07:00
2020-07-18 12:35:46 -07:00
# jc.parsers.ping
jc - JSON CLI output utility ping Parser
Usage:
specify --ping as the first argument if the piped input is coming from ping
2020-07-19 15:30:54 -07:00
Note: Use the ping -c (count) option, otherwise data will not be piped to jc.
2020-07-18 12:35:46 -07:00
Compatibility:
2020-07-19 15:30:54 -07:00
'linux', 'darwin', 'freebsd'
2020-07-18 12:35:46 -07:00
Examples:
2020-07-19 15:30:54 -07:00
$ ping -c 3 -p ff cnn.com | jc --ping -p
{
"destination_ip": "151.101.1.67",
"data_bytes": 56,
"pattern": "0xff",
"destination": "cnn.com",
"packets_transmitted": 3,
"packets_received": 3,
"packet_loss_percent": 0.0,
2020-07-21 15:16:39 -07:00
"duplicates": 0,
2020-07-19 15:30:54 -07:00
"round_trip_ms_min": 28.015,
"round_trip_ms_avg": 32.848,
"round_trip_ms_max": 39.376,
"round_trip_ms_stddev": 4.79,
"responses": [
{
"type": "reply",
"bytes": 64,
"response_ip": "151.101.1.67",
"icmp_seq": 0,
"ttl": 59,
2020-07-21 15:16:39 -07:00
"time_ms": 28.015,
"duplicate": false
2020-07-19 15:30:54 -07:00
},
{
"type": "reply",
"bytes": 64,
"response_ip": "151.101.1.67",
"icmp_seq": 1,
"ttl": 59,
2020-07-21 15:16:39 -07:00
"time_ms": 39.376,
"duplicate": false
2020-07-19 15:30:54 -07:00
},
{
"type": "reply",
"bytes": 64,
"response_ip": "151.101.1.67",
"icmp_seq": 2,
"ttl": 59,
2020-07-21 15:16:39 -07:00
"time_ms": 31.153,
"duplicate": false
2020-07-19 15:30:54 -07:00
}
]
}
$ ping -c 3 -p ff cnn.com | jc --ping -p -r
{
"destination_ip": "151.101.129.67",
"data_bytes": "56",
"pattern": "0xff",
"destination": "cnn.com",
"packets_transmitted": "3",
"packets_received": "3",
"packet_loss_percent": "0.0",
2020-07-21 15:16:39 -07:00
"duplicates": "0",
2020-07-19 15:30:54 -07:00
"round_trip_ms_min": "25.078",
"round_trip_ms_avg": "29.543",
"round_trip_ms_max": "32.553",
"round_trip_ms_stddev": "3.221",
"responses": [
{
"type": "reply",
"bytes": "64",
"response_ip": "151.101.129.67",
"icmp_seq": "0",
"ttl": "59",
2020-07-21 15:16:39 -07:00
"time_ms": "25.078",
"duplicate": false
2020-07-19 15:30:54 -07:00
},
{
"type": "reply",
"bytes": "64",
"response_ip": "151.101.129.67",
"icmp_seq": "1",
"ttl": "59",
2020-07-21 15:16:39 -07:00
"time_ms": "30.999",
"duplicate": false
2020-07-19 15:30:54 -07:00
},
{
"type": "reply",
"bytes": "64",
"response_ip": "151.101.129.67",
"icmp_seq": "2",
"ttl": "59",
2020-07-21 15:16:39 -07:00
"time_ms": "32.553",
"duplicate": false
2020-07-19 15:30:54 -07:00
}
]
}
2020-07-18 12:35:46 -07:00
2020-07-30 16:20:24 -07:00
2020-07-18 12:35:46 -07:00
## info
```python
2020-07-30 16:20:24 -07:00
info()
2020-07-18 12:35:46 -07:00
```
2020-07-30 16:20:24 -07:00
2020-07-18 12:35:46 -07:00
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
2020-07-19 15:30:54 -07:00
Dictionary. Structured data with the following schema:
{
2020-07-21 09:02:44 -07:00
"source_ip": string,
2020-07-19 15:30:54 -07:00
"destination_ip": string,
"data_bytes": integer,
"pattern": string, (null if not set)
"destination": string,
"packets_transmitted": integer,
"packets_received": integer,
"packet_loss_percent": float,
2020-07-21 14:47:25 -07:00
"duplicates": integer,
2020-07-19 15:30:54 -07:00
"round_trip_ms_min": float,
"round_trip_ms_avg": float,
"round_trip_ms_max": float,
"round_trip_ms_stddev": float,
"responses": [
{
2020-07-21 14:47:25 -07:00
"type": string, ('reply' or 'timeout')
2020-07-19 15:30:54 -07:00
"timestamp": float,
"bytes": integer,
"response_ip": string,
"icmp_seq": integer,
"ttl": integer,
2020-07-21 14:47:25 -07:00
"time_ms": float,
"duplicate": boolean
2020-07-19 15:30:54 -07:00
}
]
}
2020-07-18 12:35:46 -07:00
2020-07-30 16:20:24 -07:00
2020-07-18 12:35:46 -07:00
## parse
```python
parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) output preprocessed JSON if True
quiet: (boolean) suppress warning messages if True
Returns:
2020-07-19 15:30:54 -07:00
Dictionary. Raw or processed structured data.
2020-07-18 12:35:46 -07:00