Sorry if this is a bit vague, or already been asked, but I wasn't sure of the terminology so I couldn't google it. What I'm looking for is how to assign the arguments that psutil.virtual_memory() gives to different variables.
For example, calling psutil.virtual_memory() gives (total=8374149120L, available=1247768576L, percent=85.1, used=8246628352L, free=127520768L, active=3208777728, inactive=1133408256, buffers=342413312L, cached=777834496)
I only want to get the percent value, and assign it to a variable. How can I so this?
Documentation: https://code.google.com/p/psutil/wiki/Documentation#Memory
1 Answer 1
It returns a namedtuple (called vrem) so use percent = psutil.virtual_memory().percent
>>> help(psutil.virtual_memory)
Help on function virtual_memory in module psutil:
virtual_memory()
Return statistics about system memory usage as a namedtuple
including the following fields, expressed in bytes: