Created
February 3, 2020 13:45
-
-
Save ieaster1/5755401a3f7fadc9353808e432f066ad to your computer and use it in GitHub Desktop.
Output human readable IGMP Groups from /proc/net/igmp
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
import re | |
regex = re.compile(r'[0-9A-F]{8}', flags=re.MULTILINE | re.IGNORECASE) | |
def readable(s): | |
addr = '' | |
for i in range(0, len(s.group()), 2): | |
chunk = str(int(s.group()[i:i+2], 16)) | |
addr = chunk + '.' + addr | |
return addr.rstrip('.') | |
print(re.sub(regex, lambda h: readable(h), open('/proc/net/igmp', 'r').read())) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment