Created
May 13, 2021 22:41
-
-
Save netletic/f18badfe9fef4eaad8a36ef4f07f1ab0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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