You are not logged in.
Pages: 1
Topic closed
I am trying to show the available RAM in the i3status bar. However, the manual only provides instructions on how to provide the available hard disk space, not RAM. Ideally, I show the total available RAM in MB or GB. As a newbie, I have two questions about this:
1. Is there a built-in way to display the available RAM in i3status?
2. If I need to use a script that gets the available RAM, what is the best way to do this? I have found several methods, but am wondering what is considered a good practice? For instance, I found the following:
cat /proc/meminfo | grep MemFree
From: http://blog.scoutapp.com/articles/2010/ … oc-meminfo
vmstat 1 2 | sed -n '$ p' | awk '{print $4}'
From: http://www.unix.com/solaris/25527-getti … l-ram.html
With the second script I obtain a number, which I figure is easier to divide and show as MB or GB. However, it appears to be slow. Is this the right way to do so?
Last edited by george55 (2012-12-30 19:43:03)
Offline
awk '/MemFree/ {print $2}' /proc/meminfo
will give you a number (representing kB).
Offline
Excellent, thanks!
Offline
sorry for the necrobump but this can actually help someone!
awk can do a bit more work and get you the percentage of used or available memory:
# used memory
awk '/MemTotal/ {memtotal=$2}; /MemAvailable/ {memavail=$2}; END { printf("%.0f", (100- (memavail / memtotal * 100))) }' /proc/meminfo
# available memory
awk '/MemTotal/ {memtotal=$2}; /MemAvailable/ {memavail=$2}; END { printf("%.0f", memavail / memtotal * 100) }' /proc/meminfo
output will be a rounded up percentage of a hole number ex: 50%
Last edited by redowk (2016-08-17 23:11:01)
Offline
Thanks for sharing, redowk. However, I'm going to take this opportunity to close this old thread.
Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD
Making lemonade from lemons since 2015.
Offline
Pages: 1
Topic closed