Skip to content

Instantly share code, notes, and snippets.

@netletic
Created May 13, 2021 22:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save netletic/5b9def1968b3ae7ee98d360b9ca72874 to your computer and use it in GitHub Desktop.
Save netletic/5b9def1968b3ae7ee98d360b9ca72874 to your computer and use it in GitHub Desktop.
def get_rx_bytes(file: Path) -> Counter:
rx = {}
with open(file) as fp:
for line in fp.readlines():
if "Chassis/Slot/Port" in line:
_, port, _ = line.split()
elif "Bytes Received" in line:
_, bytes_rx, *_ = line.split(":")
bytes_rx = bytes_rx.replace(", Unicast Frames ", "").lstrip()
rx[port] = int(bytes_rx)
return Counter(rx)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment