8.1. Parser classes¶
- class pingparsing.PingParsing(timezone: tzinfo | None = None)[source]¶
Parser class to parsing ping command output.
- Parameters:
timezone (Optional[tzinfo]) – Time zone for parsing timestamps.
- parse(ping_message: str | PingResult) PingStats [source]¶
Parse ping command output.
- Parameters:
ping_message (str or
PingResult
) –ping
command output.- Returns:
Parsed result.
- Return type:
- class pingparsing.PingStats(*args, **kwargs)[source]¶
- as_dict(include_icmp_replies: bool = False) Dict[str, str | int | float | Sequence[Dict[str, str | bool | float | int | datetime]] | None] [source]¶
ping statistics.
- Return type:
Examples
>>> import pingparsing >>> parser = pingparsing.PingParsing() >>> parser.parse(ping_result) >>> parser.as_dict() { "destination": "google.com", "packet_transmit": 60, "packet_receive": 60, "packet_loss_rate": 0.0, "packet_loss_count": 0, "rtt_min": 61.425, "rtt_avg": 99.731, "rtt_max": 212.597, "rtt_mdev": 27.566, "packet_duplicate_rate": 0.0, "packet_duplicate_count": 0 }
- as_tuple() Tuple [source]¶
ping statistics.
- Return type:
Examples
>>> import pingparsing >>> parser = pingparsing.PingParsing() >>> parser.parse(ping_result) >>> parser.as_tuple() PingResult(destination='google.com', packet_transmit=60, packet_receive=60, packet_loss_rate=0.0, packet_loss_count=0, rtt_min=61.425, rtt_avg=99.731, rtt_max=212.597, rtt_mdev=27.566, packet_duplicate_rate=0.0, packet_duplicate_count=0)
- property icmp_replies: Sequence[Dict[str, str | bool | float | int | datetime]]¶
ICMP packet reply information.
- property rtt_avg: float | None¶
Average round trip time of transmitted ICMP packets
[msec]
.- Return type:
- property rtt_max: float | None¶
Maximum round trip time of transmitted ICMP packets
[msec]
.- Return type: