Skip to content

Instantly share code, notes, and snippets.

@overplumbum
Last active August 29, 2015 14:05
Show Gist options
  • Save overplumbum/b1482e46ea7b5b9d3384 to your computer and use it in GitHub Desktop.
Save overplumbum/b1482e46ea7b5b9d3384 to your computer and use it in GitHub Desktop.
#!/usr/bin/python2.7 -u
from os.path import basename, join, dirname
from glob import glob
from pprint import pprint as pp
for proc in glob('/proc/*/status'):
try:
meta = dict(line.split(':\t', 1) for line in open(proc).read().splitlines())
except IOError:
continue
if int(meta['PPid']) != 1:
continue
cgroup = open(join(dirname(proc), 'cgroup')).read().splitlines()
cgroup = dict(line.split(':', 2)[1:] for line in cgroup)
if cgroup['memory'] != '/':
print('{}\t{}'.format(meta['Pid'], meta['Name']))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment