nikademus79 / psutil

Automatically exported from code.google.com/p/psutil
Other
0 stars 0 forks source link

System memory functions refactoring + addition of memory percentage #171

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Currently we have:

psutil.TOTAL_PHYMEM
psutil.avail_phymem()
psutil.used_phymem()

psutil.total_virtmem()
psutil.avail_virtmem()
psutil.used_virtmem()

I think it makes sense to deprecate them and provide 2 separate functions 
instead, returning a namedtuple:

>>> psutil.get_phymem()
mem(total=..., used=..., free=..., percent=...)
>>>
>>> psutil.get_virtmem()
mem(total=..., used=..., free=..., percent=...)

Pros:
- it would be compliant with  the rest of the API which massively uses 
namedtuples (see 
http://code.google.com/p/psutil/source/browse/tags/release-0.2.1/psutil/_common.
py#37 )
- more compact
- extra "percent" value which is what we usually need when we do system 
monitoring
- the total physical memory can be recalculated every time solving the issue 
related with virtualized OSes changing it at runtime (see original proposal: 
http://code.google.com/p/psutil/issues/detail?id=140#c5 )

Original issue reported on code.google.com by g.rodola on 9 Jun 2011 at 1:55

GoogleCodeExporter commented 8 years ago
Linux implementation added as r1009.

Original comment by g.rodola on 9 Jun 2011 at 10:03

GoogleCodeExporter commented 8 years ago
Implemented in r1011 and r1012 for FreeBSD and Windows.
OSX implemented in r1013 (not tested - Jay please close this one once you're 
verified everything's ok).

Original comment by g.rodola on 9 Jun 2011 at 10:31

GoogleCodeExporter commented 8 years ago

Original comment by g.rodola on 9 Jun 2011 at 10:33

GoogleCodeExporter commented 8 years ago

Original comment by g.rodola on 17 Jun 2011 at 9:10

GoogleCodeExporter commented 8 years ago
Any idea when 0.2.2 might roll out?  I'd love to use this.

Original comment by jcscoob...@gmail.com on 21 Jun 2011 at 12:03

GoogleCodeExporter commented 8 years ago
Python 2.6 on OS X 10.6

[user@host ]$ python -c 'import psutil; print psutil.virtmem_usage()'
usage(total=2147483648L, used=1403551744L, free=743931904L, 
percent=65.400000000000006)
[user@host ]$ python -c 'import psutil; print psutil.phymem_usage()'
(4294967296L, 4227334144L, 67633152L)

Does that look right? I'm not sure if the phymem_usage() results should be 
showing named values?

Original comment by jlo...@gmail.com on 21 Jun 2011 at 12:54

GoogleCodeExporter commented 8 years ago
> Any idea when 0.2.2 might roll out

Not sure when exactly but it's close.
What's missing is Process.terminal and disk information implementations for OSX.

> Does that look right? I'm not sure if the phymem_usage() 
> results should be showing named values?

No, it should return a namedtuple.
ps: I'm at euro python now.

Original comment by g.rodola on 22 Jun 2011 at 3:59

GoogleCodeExporter commented 8 years ago

Original comment by g.rodola on 27 Jun 2011 at 5:40

GoogleCodeExporter commented 8 years ago

Original comment by g.rodola on 27 Jun 2011 at 5:52

GoogleCodeExporter commented 8 years ago

Original comment by g.rodola on 8 Jul 2011 at 7:07

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Updated csets after the SVN -> Mercurial migration:
r1009 == revision 1e3ece6ac254
r1011 == revision abe30f28e04a
r1013 == revision ac5a7c50d3d0

Original comment by g.rodola on 2 Mar 2013 at 12:00