diff --git a/docs/parsers/ping.md b/docs/parsers/ping.md index fe15ae1c..27a1b3fe 100644 --- a/docs/parsers/ping.md +++ b/docs/parsers/ping.md @@ -5,17 +5,96 @@ Usage: specify --ping as the first argument if the piped input is coming from ping + Note: Use the ping -c (count) option, otherwise data will not be piped to jc. + Compatibility: - 'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd' + 'linux', 'darwin', 'freebsd' Examples: - $ ping | jc --ping -p - [] + $ 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, + "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, + "time_ms": 28.015 + }, + { + "type": "reply", + "bytes": 64, + "response_ip": "151.101.1.67", + "icmp_seq": 1, + "ttl": 59, + "time_ms": 39.376 + }, + { + "type": "reply", + "bytes": 64, + "response_ip": "151.101.1.67", + "icmp_seq": 2, + "ttl": 59, + "time_ms": 31.153 + } + ] + } - $ ping | jc --ping -p -r - [] + + $ 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", + "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", + "time_ms": "25.078" + }, + { + "type": "reply", + "bytes": "64", + "response_ip": "151.101.129.67", + "icmp_seq": "1", + "ttl": "59", + "time_ms": "30.999" + }, + { + "type": "reply", + "bytes": "64", + "response_ip": "151.101.129.67", + "icmp_seq": "2", + "ttl": "59", + "time_ms": "32.553" + } + ] + } ## info ```python @@ -35,15 +114,32 @@ Parameters: Returns: - List of dictionaries. Structured data with the following schema: + Dictionary. Structured data with the following schema: - [ - { - "ping": string, - "bar": boolean, - "baz": integer - } - ] + { + "destination_ip": string, + "data_bytes": integer, + "pattern": string, (null if not set) + "destination": string, + "packets_transmitted": integer, + "packets_received": integer, + "packet_loss_percent": float, + "round_trip_ms_min": float, + "round_trip_ms_avg": float, + "round_trip_ms_max": float, + "round_trip_ms_stddev": float, + "responses": [ + { + "type": string, ('reply' or 'timeout') + "timestamp": float, + "bytes": integer, + "response_ip": string, + "icmp_seq": integer, + "ttl": integer, + "time_ms": float + } + ] + } ## parse ```python @@ -60,5 +156,5 @@ Parameters: Returns: - List of dictionaries. Raw or processed structured data. + Dictionary. Raw or processed structured data. diff --git a/jc/parsers/ping.py b/jc/parsers/ping.py index f0edada4..e66ae776 100644 --- a/jc/parsers/ping.py +++ b/jc/parsers/ping.py @@ -4,6 +4,8 @@ Usage: specify --ping as the first argument if the piped input is coming from ping + Note: Use the ping -c (count) option, otherwise data will not be piped to jc. + Compatibility: 'linux', 'darwin', 'freebsd'