I wanted to log the size of the currently running instance
You don't define what is an instance for you. AFAIK it has a different meaning in AWS and in Docker.
used memory by the current process
Please define what is used memory.
Read much more about virtual address space. What about the page cache ?
available memory for the current process
Please define what is available memory. Are you aware of paging ? What about shared libraries ?
Then, read documentation related to proc(5).
You really should care about the current process, not the entire system. Read a good operating system textbook and the Advanced Linux Programming book, and https://www.linuxatemyram.com/
If you care about the current process, use proc(5) thru /proc/self/stat
If you care about your AWS instances, there are some proprietary APIs for querying their status.
If you are automatizing some system administration tasks, you should explain which ones and why.
Notice that /proc/meminfo
gives system-wide information and relates to virtual memory. AWS is adding hypervisor layers and so does Docker and you could have some process migration at some virtual level.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…