[Sugar-devel] [DESIGN] Displaying the current status of system resources (such as memory, cpu)

James Cameron quozl at laptop.org
Wed Jun 16 01:55:44 EDT 2010


On Wed, Jun 16, 2010 at 03:18:31AM +0530, Anish Mangal wrote:
> Sugar presently lacks a means to display the current status of system
> resources such as free memory, CPU load, etc. I'd like form an opinion
> as to what should be the ideal way to make these numbers available to
> the user.

Frame slider showing percentage available memory.

CPU load is unimportant.  Most problems occur as a result of depletion
of memory.

Here's some simple and quick code to measure the available memory and
return a percentage:

def percentage_memory_available():
    for line in file('/proc/meminfo').readlines():
        name, value, unit = line.split()[:3]
        if 'MemTotal:' == name: total = value
        elif 'MemFree:' == name: free = value
        elif 'Buffers:' == name: buffers = value
        elif 'Cached:' == name: cached = value
        elif 'Active:' == name: break
    return 100 * (int(free)+int(buffers)+int(cached)) / int(total)

Free, buffers, and cached are added because these are what an activity
is easily able to consume if it makes a demand for memory.

I'd also like to have a mode where a warning message is displayed.

I've also tested some systems with a sound emitted where the frequency
is chosen based on the memory available.  This gives very nice feedback
about what is happening on a system without interfering with the
display.

-- 
James Cameron
http://quozl.linux.org.au/


More information about the Sugar-devel mailing list