Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Memory Detection #13

Open
wdelgenio opened this issue Apr 28, 2021 · 0 comments
Open

Improve Memory Detection #13

wdelgenio opened this issue Apr 28, 2021 · 0 comments

Comments

@wdelgenio
Copy link

Instead of guessing how much memory a system has from /proc/meminfo, it's possible to get an exact value using sysfs.

For example, the lshw util queries the /sys/devices/system/memory dir for available memory blocks and uses /sys/devices/system/memory/block_size_bytes as the block size. Check that each memory block is online by checking the value of /sys/devices/system/memory/memory*/online

Here's the documentation on the sysfs memory blocks https://www.ibm.com/support/knowledgecenter/en/linuxonibm/com.ibm.linux.z.lgdd/lgdd_c_mem_know_sysfs.html

Here's a one-liner:
printf '%c' /sys/devices/system/memory/memory*/online | wc -c | dc -e '?16i' -f /sys/devices/system/memory/block_size_bytes -e '*p' | numfmt --to=iec-i --suffix B

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant