Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion pythonping/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ def ping(target,
out=sys.stdout,
match=False,
source=None,
out_format='legacy'):
out_format='legacy',
cisco=False):
"""Pings a remote host and handles the responses

:param target: The remote hostname or IP address to ping
Expand Down Expand Up @@ -85,4 +86,16 @@ def ping(target,

SEED_IDs.remove(seed_id)

if cisco:
# Cisco-like summary
sent = comm.responses.stats_packets_sent
received = comm.responses.stats_packets_returned
loss = int((1 - received / sent) * 100)
min_rtt = comm.responses.rtt_min_ms
avg_rtt = comm.responses.rtt_avg_ms
max_rtt = comm.responses.rtt_max_ms

print(f"\nSuccess rate is {received}/{sent} ({100 - loss}%), "
f"round-trip min/avg/max = {min_rtt}/{avg_rtt}/{max_rtt} ms", file=out)

return comm.responses