Created
June 9, 2022 01:40
-
-
Save brunokim/482bfb459306a84302afb18e23583be3 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
def memory_usage() -> int: | |
with open('/sys/fs/cgroup/memory/memory.memsw.usage_in_bytes') as f: | |
return int(f.read()) | |
def memory_limit() -> int: | |
with open('/sys/fs/cgroup/memory/memory.memsw.limit_in_bytes') as f: | |
return int(f.read()) | |
def memory_stats() -> dict[str, int]: | |
stats: dict[str, int] = {} | |
with open('/sys/fs/cgroup/memory/memory.stat') as f: | |
for line in f: | |
name, value_str = line.strip().split(' ') | |
stats[name] = int(value_str) | |
return stats |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment