When running psutil.virtual_memory() i'm getting output like this:
>>psutil.virtual_memory()
vmem(total=8374149120L, available=1247768576L)
But what unit of measurement are these values? The documentation simply claims that its the "total physical memory available" but nothing more. I'm trying to translate it into values that the user can actually relate to (ie GBs).
Thanks in advance
Psutil is a Python cross-platform library used to access system details and process utilities. It is used to keep track of various resources utilization in the system. Usage of resources like CPU, memory, disks, network, sensors can be monitored.
psutil (process and system utilities) is a cross-platform library for retrieving information on running processes and system utilization (CPU, memory, disks, network, sensors) in Python. It is useful mainly for system monitoring, profiling and limiting process resources and management of running processes.
why not use bit shift operator: if you want to display in human readable way, just like this!
values = psutil.virtual_memory()
display in MB format
total = values.total >> 20
display in GB format
total = values.total >> 30
1024^3 = Byte to Gigabyte
So I think this work:
import psutil
memory = psutil.virtual_memory().total / (1024.0 ** 3)
print(memory)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With