Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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