Created
October 9, 2017 21:44
-
-
Save joshland/a417d17b44cb03d8845feb245c575eed 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
#!/usr/bin/env python | |
import os, string | |
def _pmap(process): | |
import subprocess | |
try: | |
p = subprocess.Popen(["pmap", process], stdout=subprocess.PIPE) | |
retval = [ x.decode() for x in p.stdout] | |
except OSError: | |
raise "Error = This server does not have 'ethtool'" | |
return retval | |
def main(): | |
sets = 0 | |
totes = 0 | |
for pid in os.listdir('/proc'): | |
if pid[0] not in string.digits: | |
continue | |
raw = _pmap(pid)[1:-1] | |
sets += len(set([ x[30:] for x in raw ])) | |
totes += len(raw) | |
continue | |
print("Total MAPS: %d" % totes) | |
print("Total MAPS (sets): %d" % sets) | |
if __name__ == "__main__": | |
import sys | |
results = 0 | |
for x in sys.argv: | |
try: | |
results = int(x) | |
break | |
except ValueError: | |
continue | |
continue | |
if results: | |
import time | |
while 1: | |
main() | |
time.sleep(results) | |
continue | |
else: | |
main() | |
pass | |
sys.exit(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment