Skip to content

Instantly share code, notes, and snippets.

@netletic
Created May 13, 2021 22:41
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/f18badfe9fef4eaad8a36ef4f07f1ab0 to your computer and use it in GitHub Desktop.
Save netletic/f18badfe9fef4eaad8a36ef4f07f1ab0 to your computer and use it in GitHub Desktop.
def get_rx_bytes(file: Path) -> Counter:
with open(file) as fp:
pattern = re.compile(
r"Chassis/Slot/Port\s(\d+/\d+/\d+).*?Bytes Received :\s*(\d{1,})",
re.DOTALL,
)
matches = re.findall(pattern, fp.read())
rx = {port: int(bytes_rx) for port, bytes_rx in matches}
return Counter(rx)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment