当前位置: 首页>>代码示例>>Python>>正文


Python utils.readMemInfo函数代码示例

本文整理汇总了Python中vdsm.utils.readMemInfo函数的典型用法代码示例。如果您正苦于以下问题:Python readMemInfo函数的具体用法?Python readMemInfo怎么用?Python readMemInfo使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了readMemInfo函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

    def __init__(self, pid):
        """
        Initialize a HostSample.

        :param pid: The PID of this vdsm host.
        :type pid: int
        """
        TimedSample.__init__(self)
        self.interfaces = dict(
            (link.name, InterfaceSample(link)) for link in getLinks())
        self.pidcpu = PidCpuSample(pid)
        self.totcpu = TotalCpuSample()
        meminfo = utils.readMemInfo()
        freeOrCached = (meminfo['MemFree'] +
                        meminfo['Cached'] + meminfo['Buffers'])
        self.memUsed = 100 - int(100.0 * (freeOrCached) / meminfo['MemTotal'])
        self.anonHugePages = meminfo.get('AnonHugePages', 0) / 1024
        try:
            self.cpuLoad = file('/proc/loadavg').read().split()[1]
        except:
            self.cpuLoad = '0.0'
        self.diskStats = self._getDiskStats()
        try:
            with file(_THP_STATE_PATH) as f:
                s = f.read()
                self.thpState = s[s.index('[') + 1:s.index(']')]
        except:
            self.thpState = 'never'
        self.cpuCores = CpuCoreSample()
        self.numaNodeMem = NumaNodeMemorySample()
开发者ID:futurice,项目名称:vdsm,代码行数:30,代码来源:sampling.py

示例2: __init__

    def __init__(self, pid, ifids):
        """
        Initialize a HostSample.

        :param pid: The PID of this vdsm host.
        :type pid: int
        :param ifids: The IDs of the interfaces you want to sample.
        :type: list
        """
        BaseSample.__init__(self, pid, ifids)
        self.totcpu = TotalCpuSample()
        meminfo = utils.readMemInfo()
        freeOrCached = (meminfo['MemFree'] +
                        meminfo['Cached'] + meminfo['Buffers'])
        self.memUsed = 100 - int(100.0 * (freeOrCached) / meminfo['MemTotal'])
        self.anonHugePages = meminfo.get('AnonHugePages', 0) / 1024
        try:
            self.cpuLoad = file('/proc/loadavg').read().split()[1]
        except:
            self.cpuLoad = '0.0'
        self.diskStats = self._getDiskStats()
        try:
            with file(_THP_STATE_PATH) as f:
                s = f.read()
                self.thpState = s[s.index('[') + 1:s.index(']')]
        except:
            self.thpState = 'never'
        self.cpuCores = CpuCoreSample()
        self.numaNodeMem = NumaNodeMemorySample()
开发者ID:fzkbass,项目名称:vdsm,代码行数:29,代码来源:sampling.py

示例3: _memFree

def _memFree():
    """
    Return the actual free mem on host.
    """
    meminfo = utils.readMemInfo()
    return (meminfo['MemFree'] +
            meminfo['Cached'] + meminfo['Buffers']) * Kbytes
开发者ID:EdDev,项目名称:vdsm,代码行数:7,代码来源:api.py

示例4: __init__

    def __init__(self, pid):
        """
        Initialize a HostSample.

        :param pid: The PID of this vdsm host.
        :type pid: int
        """
        self.timestamp = time.time()
        self.pidcpu = PidCpuSample(pid)
        self.ncpus = os.sysconf('SC_NPROCESSORS_ONLN')
        self.totcpu = TotalCpuSample()
        meminfo = utils.readMemInfo()
        freeOrCached = (meminfo['MemFree'] +
                        meminfo['Cached'] + meminfo['Buffers'])
        self.memUsed = 100 - int(100.0 * (freeOrCached) / meminfo['MemTotal'])
        self.anonHugePages = meminfo.get('AnonHugePages', 0) // 1024
        try:
            with open('/proc/loadavg') as loadavg:
                self.cpuLoad = loadavg.read().split()[1]
        except:
            self.cpuLoad = '0.0'
        self.diskStats = self._getDiskStats()
        try:
            with open(_THP_STATE_PATH) as f:
                s = f.read()
                self.thpState = s[s.index('[') + 1:s.index(']')]
        except:
            self.thpState = 'never'
        self.hugepages = hugepages.state()
        self.cpuCores = CpuCoreSample()
        self.numaNodeMem = NumaNodeMemorySample()
开发者ID:nirs,项目名称:vdsm,代码行数:31,代码来源:sampling.py

示例5: getUMAHostMemoryStats

def getUMAHostMemoryStats():
    """
    Get the memory stats of a UMA host, the unit is MiB.

    :return: dict like {'total': '49141', 'free': '46783'}
    """
    memDict = {}
    memInfo = utils.readMemInfo()
    memDict['total'] = str(memInfo['MemTotal'] / 1024)
    memDict['free'] = str(memInfo['MemFree'] / 1024)
    return memDict
开发者ID:carriercomm,项目名称:vdsm,代码行数:11,代码来源:caps.py

示例6: testReadMemInfo

 def testReadMemInfo(self):
     meminfo = utils.readMemInfo()
     # most common fields as per man 5 proc
     # add your own here
     fields = ('MemTotal', 'MemFree', 'Buffers', 'Cached', 'SwapCached',
               'Active', 'Inactive', 'SwapTotal', 'SwapFree', 'Dirty',
               'Writeback', 'Mapped', 'Slab', 'VmallocTotal',
               'VmallocUsed', 'VmallocChunk')
     for field in fields:
         self.assertIn(field, meminfo)
         self.assertTrue(isinstance(meminfo[field], int))
开发者ID:yingyun001,项目名称:vdsm,代码行数:11,代码来源:utilsTests.py

示例7: get

def get():
    caps = {}

    caps['kvmEnabled'] = \
        str(config.getboolean('vars', 'fake_kvm_support') or
            os.path.exists('/dev/kvm')).lower()

    cpuInfo = CpuInfo()
    cpuTopology = CpuTopology()
    if config.getboolean('vars', 'report_host_threads_as_cores'):
        caps['cpuCores'] = str(cpuTopology.threads())
    else:
        caps['cpuCores'] = str(cpuTopology.cores())

    caps['cpuThreads'] = str(cpuTopology.threads())
    caps['cpuSockets'] = str(cpuTopology.sockets())
    caps['cpuSpeed'] = cpuInfo.mhz()
    if config.getboolean('vars', 'fake_kvm_support'):
        caps['cpuModel'] = 'Intel(Fake) CPU'
        flags = set(cpuInfo.flags() + ['vmx', 'sse2', 'nx'])
        caps['cpuFlags'] = ','.join(flags) + 'model_486,model_pentium,' \
            'model_pentium2,model_pentium3,model_pentiumpro,model_qemu32,' \
            'model_coreduo,model_core2duo,model_n270,model_Conroe,' \
            'model_Penryn,model_Nehalem,model_Opteron_G1'
    else:
        caps['cpuModel'] = cpuInfo.model()
        caps['cpuFlags'] = ','.join(cpuInfo.flags() +
                                    _getCompatibleCpuModels())

    caps.update(dsaversion.version_info)
    caps.update(netinfo.get())

    try:
        caps['hooks'] = hooks.installed()
    except:
        logging.debug('not reporting hooks', exc_info=True)

    caps['operatingSystem'] = osversion()
    caps['uuid'] = utils.getHostUUID()
    caps['packages2'] = _getKeyPackages()
    caps['emulatedMachines'] = _getEmulatedMachines()
    caps['ISCSIInitiatorName'] = _getIscsiIniName()
    caps['HBAInventory'] = storage.hba.HBAInventory()
    caps['vmTypes'] = ['kvm']

    caps['memSize'] = str(utils.readMemInfo()['MemTotal'] / 1024)
    caps['reservedMem'] = str(config.getint('vars', 'host_mem_reserve') +
                              config.getint('vars', 'extra_mem_reserve'))
    caps['guestOverhead'] = config.get('vars', 'guest_ram_overhead')

    return caps
开发者ID:edwardbadboy,项目名称:vdsm-ubuntu,代码行数:51,代码来源:caps.py

示例8: _memUsageInfo

def _memUsageInfo(cif):
    """
    Return an approximation of available memory for new VMs.
    """
    # These values are not used by Engine >= 4.2 anymore, but they are still
    # processed, stored to the database and must be present.  Let's return
    # something very roughly meaningful until it's removed from Engine
    # completely -- that means just free memory and sum of VM sizes.
    committed = 0
    for v in cif.vmContainer.values():
        committed += v.mem_size_mb() * Mbytes
    meminfo = utils.readMemInfo()
    freeOrCached = (meminfo['MemFree'] +
                    meminfo['Cached'] + meminfo['Buffers']) * Kbytes
    available = (
        freeOrCached + config.getint('vars', 'host_mem_reserve') * Mbytes
    )
    return available, committed
开发者ID:oVirt,项目名称:vdsm,代码行数:18,代码来源:api.py

示例9: _memUsageInfo

def _memUsageInfo(cif):
    """
    Return an approximation of available memory for new VMs.
    """
    committed = 0
    resident = 0
    for v in cif.vmContainer.values():
        mem_info = v.memory_info()
        resident += mem_info.get('rss', 0) * Kbytes
        committed += mem_info.get('commit', 0) * Kbytes
    meminfo = utils.readMemInfo()
    freeOrCached = (meminfo['MemFree'] +
                    meminfo['Cached'] + meminfo['Buffers']) * Kbytes
    available = (
        freeOrCached + resident - committed -
        config.getint('vars', 'host_mem_reserve') * Mbytes
    )
    return available, committed
开发者ID:EdDev,项目名称:vdsm,代码行数:18,代码来源:api.py

示例10: get

def get():
    caps = {}

    caps["kvmEnabled"] = str(config.getboolean("vars", "fake_kvm_support") or os.path.exists("/dev/kvm")).lower()

    cpuInfo = CpuInfo()
    caps["cpuCores"] = str(cpuInfo.cores())
    caps["cpuSockets"] = str(cpuInfo.sockets())
    caps["cpuSpeed"] = cpuInfo.mhz()
    if config.getboolean("vars", "fake_kvm_support"):
        caps["cpuModel"] = "Intel(Fake) CPU"
        flags = set(cpuInfo.flags() + ["vmx", "sse2", "nx"])
        caps["cpuFlags"] = (
            ",".join(flags) + "model_486,model_pentium,"
            "model_pentium2,model_pentium3,model_pentiumpro,model_qemu32,"
            "model_coreduo,model_core2duo,model_n270,model_Conroe,"
            "model_Penryn,model_Nehalem,model_Opteron_G1"
        )
    else:
        caps["cpuModel"] = cpuInfo.model()
        caps["cpuFlags"] = ",".join(cpuInfo.flags() + _getCompatibleCpuModels())

    caps.update(dsaversion.version_info)
    caps.update(netinfo.get())

    try:
        caps["hooks"] = hooks.installed()
    except:
        logging.debug("not reporting hooks", exc_info=True)

    caps["operatingSystem"] = osversion()
    caps["uuid"] = utils.getHostUUID()
    caps["packages2"] = _getKeyPackages()
    caps["emulatedMachines"] = _getEmulatedMachines()
    caps["ISCSIInitiatorName"] = _getIscsiIniName()
    caps["HBAInventory"] = storage.hba.HBAInventory()
    caps["vmTypes"] = ["kvm"]

    caps["memSize"] = str(utils.readMemInfo()["MemTotal"] / 1024)
    caps["reservedMem"] = str(config.getint("vars", "host_mem_reserve") + config.getint("vars", "extra_mem_reserve"))
    caps["guestOverhead"] = config.get("vars", "guest_ram_overhead")

    return caps
开发者ID:ekohl,项目名称:vdsm,代码行数:43,代码来源:caps.py

示例11: _memAvailable

 def _memAvailable(self):
     """
     Return an approximation of available memory for new VMs.
     """
     memCommitted = self._memCommitted()
     resident = 0
     for v in self._cif.vmContainer.values():
         if v.conf['pid'] == '0': continue
         try:
             statmfile = file('/proc/' + v.conf['pid'] + '/statm')
             resident += int(statmfile.read().split()[1])
         except:
             pass
     resident *= PAGE_SIZE_BYTES
     meminfo = utils.readMemInfo()
     freeOrCached = (meminfo['MemFree'] +
                     meminfo['Cached'] + meminfo['Buffers']) * Kbytes
     return freeOrCached + resident - memCommitted - \
             config.getint('vars', 'host_mem_reserve') * Mbytes
开发者ID:ekohl,项目名称:vdsm,代码行数:19,代码来源:API.py

示例12: __init__

    def __init__(self, pid):
        """
        Initialize a HostSample.

        :param pid: The PID of this vdsm host.
        :type pid: int
        """
        super(HostSample, self).__init__()
        self.interfaces = _get_interfaces_and_samples()
        self.pidcpu = PidCpuSample(pid)
        self.ncpus = os.sysconf('SC_NPROCESSORS_ONLN')
        self.totcpu = TotalCpuSample()
        meminfo = utils.readMemInfo()
        freeOrCached = (meminfo['MemFree'] +
                        meminfo['Cached'] + meminfo['Buffers'])
        self.memUsed = 100 - int(100.0 * (freeOrCached) / meminfo['MemTotal'])
        self.anonHugePages = meminfo.get('AnonHugePages', 0) / 1024
        try:
            with open('/proc/loadavg') as loadavg:
                self.cpuLoad = loadavg.read().split()[1]
        except:
            self.cpuLoad = '0.0'
        self.diskStats = self._getDiskStats()
        try:
            with open(_THP_STATE_PATH) as f:
                s = f.read()
                self.thpState = s[s.index('[') + 1:s.index(']')]
        except:
            self.thpState = 'never'
        self.hugepages = hugepages.state()
        self.cpuCores = CpuCoreSample()
        self.numaNodeMem = NumaNodeMemorySample()
        ENGINE_DEFAULT_POLL_INTERVAL = 15
        try:
            self.recentClient = (
                self.timestamp - os.stat(P_VDSM_CLIENT_LOG).st_mtime <
                2 * ENGINE_DEFAULT_POLL_INTERVAL)
        except OSError as e:
            if e.errno == errno.ENOENT:
                self.recentClient = False
            else:
                raise
开发者ID:EdDev,项目名称:vdsm,代码行数:42,代码来源:sampling.py

示例13: __init__

    def __init__(self, pid):
        """
        Initialize a HostSample.

        :param pid: The PID of this vdsm host.
        :type pid: int
        """
        TimedSample.__init__(self)
        self.interfaces = dict(
            (link.name, InterfaceSample(link)) for link in getLinks())
        self.pidcpu = PidCpuSample(pid)
        self.totcpu = TotalCpuSample()
        meminfo = utils.readMemInfo()
        freeOrCached = (meminfo['MemFree'] +
                        meminfo['Cached'] + meminfo['Buffers'])
        self.memUsed = 100 - int(100.0 * (freeOrCached) / meminfo['MemTotal'])
        self.anonHugePages = meminfo.get('AnonHugePages', 0) / 1024
        try:
            self.cpuLoad = file('/proc/loadavg').read().split()[1]
        except:
            self.cpuLoad = '0.0'
        self.diskStats = self._getDiskStats()
        try:
            with file(_THP_STATE_PATH) as f:
                s = f.read()
                self.thpState = s[s.index('[') + 1:s.index(']')]
        except:
            self.thpState = 'never'
        self.cpuCores = CpuCoreSample()
        self.numaNodeMem = NumaNodeMemorySample()
        ENGINE_DEFAULT_POLL_INTERVAL = 15
        try:
            self.recentClient = (
                self.timestamp - os.stat(P_VDSM_CLIENT_LOG).st_mtime <
                2 * ENGINE_DEFAULT_POLL_INTERVAL)
        except OSError as e:
            if e.errno == errno.ENOENT:
                self.recentClient = False
            else:
                raise
开发者ID:mpavlase,项目名称:vdsm,代码行数:40,代码来源:sampling.py

示例14: _readSwapTotalFree

def _readSwapTotalFree():
    meminfo = utils.readMemInfo()
    return meminfo['SwapTotal'] / 1024, meminfo['SwapFree'] / 1024
开发者ID:EdDev,项目名称:vdsm,代码行数:3,代码来源:api.py

示例15: get

def get():
    caps = {}
    cpu_topology = numa.cpu_topology()

    caps['kvmEnabled'] = str(os.path.exists('/dev/kvm')).lower()

    if config.getboolean('vars', 'report_host_threads_as_cores'):
        caps['cpuCores'] = str(cpu_topology.threads)
    else:
        caps['cpuCores'] = str(cpu_topology.cores)

    caps['cpuThreads'] = str(cpu_topology.threads)
    caps['cpuSockets'] = str(cpu_topology.sockets)
    caps['onlineCpus'] = ','.join(cpu_topology.online_cpus)
    caps['cpuSpeed'] = cpuinfo.frequency()
    caps['cpuModel'] = cpuinfo.model()
    caps['cpuFlags'] = ','.join(cpuinfo.flags() +
                                machinetype.compatible_cpu_models())

    caps.update(_getVersionInfo())

    net_caps = supervdsm.getProxy().network_caps()
    caps.update(net_caps)

    try:
        caps['hooks'] = hooks.installed()
    except:
        logging.debug('not reporting hooks', exc_info=True)

    caps['operatingSystem'] = osinfo.version()
    caps['uuid'] = host.uuid()
    caps['packages2'] = osinfo.package_versions()
    caps['realtimeKernel'] = osinfo.runtime_kernel_flags().realtime
    caps['kernelArgs'] = osinfo.kernel_args()
    caps['nestedVirtualization'] = osinfo.nested_virtualization().enabled
    caps['emulatedMachines'] = machinetype.emulated_machines(
        cpuarch.effective())
    caps['ISCSIInitiatorName'] = _getIscsiIniName()
    caps['HBAInventory'] = hba.HBAInventory()
    caps['vmTypes'] = ['kvm']

    caps['memSize'] = str(utils.readMemInfo()['MemTotal'] // 1024)
    caps['reservedMem'] = str(config.getint('vars', 'host_mem_reserve') +
                              config.getint('vars', 'extra_mem_reserve'))
    caps['guestOverhead'] = config.get('vars', 'guest_ram_overhead')

    caps['rngSources'] = rngsources.list_available()

    caps['numaNodes'] = dict(numa.topology())
    caps['numaNodeDistance'] = dict(numa.distances())
    caps['autoNumaBalancing'] = numa.autonuma_status()

    caps['selinux'] = osinfo.selinux_status()

    caps['liveSnapshot'] = 'true'
    caps['liveMerge'] = 'true'
    caps['kdumpStatus'] = osinfo.kdump_status()

    caps['hostdevPassthrough'] = str(hostdev.is_supported()).lower()
    # TODO This needs to be removed after adding engine side support
    # and adding gdeploy support to enable libgfapi on RHHI by default
    caps['additionalFeatures'] = ['libgfapi_supported']
    if osinfo.glusterEnabled:
        from vdsm.gluster.api import glusterAdditionalFeatures
        caps['additionalFeatures'].extend(glusterAdditionalFeatures())
    caps['hostedEngineDeployed'] = _isHostedEngineDeployed()
    caps['hugepages'] = hugepages.supported()
    caps['kernelFeatures'] = osinfo.kernel_features()
    caps['vncEncrypted'] = _isVncEncrypted()
    caps['backupEnabled'] = False

    try:
        caps["connector_info"] = managedvolume.connector_info()
    except se.ManagedVolumeNotSupported as e:
        logging.info("managedvolume not supported: %s", e)
    except se.ManagedVolumeHelperFailed as e:
        logging.exception("Error getting managedvolume connector info: %s", e)

    return caps
开发者ID:nirs,项目名称:vdsm,代码行数:79,代码来源:caps.py


注:本文中的vdsm.utils.readMemInfo函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。