import errno import os import sys import _psutil_bsd import _psutil_posix from psutil import _psposix from psutil.error import AccessDenied, NoSuchProcess, TimeoutExpired from psutil._compat import namedtuple from psutil._common import * __extra__all__ = [] # --- constants NUM_CPUS = _psutil_bsd.get_num_cpus() BOOT_TIME = _psutil_bsd.get_system_boot_time() TOTAL_PHYMEM = _psutil_bsd.get_virtual_mem()[0] _TERMINAL_MAP = _psposix._get_terminal_map() _PAGESIZE = os.sysconf("SC_PAGE_SIZE") _cputimes_ntuple = namedtuple('cputimes', 'user nice system idle irq') # --- public functions nt_virtmem_info = namedtuple( 'vmem', ' '.join([ # all platforms 'total', 'available', 'percent',
import errno import os import sys import _psutil_bsd import _psutil_posix from psutil import _psposix from psutil.error import AccessDenied, NoSuchProcess, TimeoutExpired from psutil._compat import namedtuple from psutil._common import * __extra__all__ = [] # --- constants NUM_CPUS = _psutil_bsd.get_num_cpus() BOOT_TIME = _psutil_bsd.get_system_boot_time() _TERMINAL_MAP = _psposix._get_terminal_map() _cputimes_ntuple = namedtuple('cputimes', 'user nice system idle irq') # --- public functions def phymem_usage(): """Physical system memory as a (total, used, free) tuple.""" total = _psutil_bsd.get_total_phymem() free = _psutil_bsd.get_avail_phymem() used = total - free # XXX check out whether we have to do the same math we do on Linux percent = usage_percent(used, total, _round=1) return nt_sysmeminfo(total, used, free, percent)