Skip to content

Instantly share code, notes, and snippets.

@spellancer
Created November 17, 2013 09:46
Show Gist options
  • Save spellancer/7511384 to your computer and use it in GitHub Desktop.
Save spellancer/7511384 to your computer and use it in GitHub Desktop.
cgroups
import tarfile, re
cpusage = re.compile ("sys/fs/cgroup/cpuacct/lxc/.*/cpuacct.usage$")
ainput = tarfile.open ("input.tgz","r:gz")
res_value = 0
for i in ainput:
if cpusage.search(i.name)!=None:
l = ainput.extractfile(i.name)
current = int(l.readline())
if (current > res_value):
res_value = current
res_name = i.name.split('/')[5]
ainput.close()
output = open("output.txt","w")
output.write(res_name)
output.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment