mountainpenguin / pyrt

python rtorrent webUI
GNU General Public License v3.0
34 stars 11 forks source link

memory size reporting #31

Closed skydrome closed 12 years ago

skydrome commented 12 years ago

to get the correct size of used memory you need to add in the cached sized

total = int(re.search("MemTotal:.*?(\d+) kB", meminfo).group(1))*1024
free = int(re.search("MemFree:.*?(\d+) kB", meminfo).group(1))*1024
cached = int(re.search("Cached:.*?(\d+) kB", meminfo).group(1))*1024
free = free+cached
used = total-free

this shows the correct info now. (at least on my system)

mountainpenguin commented 12 years ago

I also included in buffered memory, so at least on linux systems, this should correspond to the same value as free -m


             total       used       free     shared    buffers     cached
Mem:          3961       1719       2241          0        203        459
-/+ buffers/cache:       1056       2904

Previously we were using the Mem: line Now it should report the -/+ buffers/cache line

mountainpenguin commented 12 years ago

Merged changes into master