LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (https://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   Format for reading /proc/self/status and /proc/meminfo (https://www.linuxquestions.org/questions/linux-kernel-70/format-for-reading-proc-self-status-and-proc-meminfo-4175642056/)

ldmarks 11-09-2018 03:39 PM

Format for reading /proc/self/status and /proc/meminfo
 
I want to be able to read the information in /proc/self/status (primarily memory information) and the total available memory from /proc/meminfo. This needs to be done "on the fly" in code which will be used on different systems. Are there include files which specify the format used? While I can (on one system) do a simple search for MemFree for instance, I would prefer not to have to search for MEMFREE, Memfree etc since I am not sure if the format is standardized across all OS.

syg00 11-09-2018 05:45 PM

It will certainly not be consistent across all OS - in fact /proc is different on various *nix let alone others.
But for Linux distros you can assume they will be consistent - /proc is a pseudo filesystem provided by the kernel. "files" may be added to over time, and meminfo certainly has, but pre-existent entries are not going to change retro-spectively.

Personally I always parse those sort of thing case-insenitively.


All times are GMT -5. The time now is 11:26 AM.