def phymem_usage(): """Physical system memory as a (total, used, free) tuple.""" total = _psutil_osx.get_total_phymem() free = _psutil_osx.get_avail_phymem() used = total - free percent = usage_percent(used, total, _round=1) return ntuple_sysmeminfo(total, used, free, percent)
import errno import os import _psutil_osx import _psutil_posix import _psposix from psutil.error import AccessDenied, NoSuchProcess, TimeoutExpired from psutil._compat import namedtuple from psutil._common import * __all__ = base_module_namespace[:] # --- constants NUM_CPUS = _psutil_osx.get_num_cpus() TOTAL_PHYMEM = _psutil_osx.get_total_phymem() BOOT_TIME = _psutil_osx.get_system_boot_time() # --- functions def avail_phymem(): "Return the amount of physical memory available on the system, in bytes." return _psutil_osx.get_avail_phymem() def used_phymem(): "Return the amount of physical memory currently in use on the system, in bytes." return TOTAL_PHYMEM - _psutil_osx.get_avail_phymem() def total_virtmem(): "Return the amount of total virtual memory available on the system, in bytes." return _psutil_osx.get_total_virtmem()