|
|
@ -264,11 +264,18 @@ def get_docker_mem_usage_if_limit():
|
|
|
|
usage_in_bytes = int(f.readline())
|
|
|
|
usage_in_bytes = int(f.readline())
|
|
|
|
|
|
|
|
|
|
|
|
with open('/sys/fs/cgroup/memory/memory.stat') as f:
|
|
|
|
with open('/sys/fs/cgroup/memory/memory.stat') as f:
|
|
|
|
lines = f.readlines()
|
|
|
|
inactive_file = 0
|
|
|
|
name, value = lines[33].split()
|
|
|
|
for line in f:
|
|
|
|
total_inactive_file = int(value)
|
|
|
|
if line.startswith('total_inactive_file'):
|
|
|
|
|
|
|
|
name, inactive_file = line.split()
|
|
|
|
return ((usage_in_bytes - total_inactive_file) / limit_in_bytes) * 100
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if line.startswith('inactive_file'):
|
|
|
|
|
|
|
|
name, inactive_file = line.split()
|
|
|
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inactive_file = int(inactive_file)
|
|
|
|
|
|
|
|
return ((usage_in_bytes - inactive_file) / limit_in_bytes) * 100
|
|
|
|
|
|
|
|
|
|
|
|
except Exception as e:
|
|
|
|
except Exception as e:
|
|
|
|
logger.error(f'Get memory usage by docker limit: {e}')
|
|
|
|
logger.error(f'Get memory usage by docker limit: {e}')
|
|
|
|