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


Python os.getloadavg方法代码示例

本文整理汇总了Python中os.getloadavg方法的典型用法代码示例。如果您正苦于以下问题:Python os.getloadavg方法的具体用法?Python os.getloadavg怎么用?Python os.getloadavg使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在os的用法示例。


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

示例1: display_progress

# 需要导入模块: import os [as 别名]
# 或者: from os import getloadavg [as 别名]
def display_progress(test_index, test):
        # "[ 51/405/1] test_tcl"
        line = "{1:{0}}{2}".format(test_count_width, test_index, test_count)
        fails = len(bad) + len(environment_changed)
        if fails and not pgo:
            line = '{}/{}'.format(line, fails)
        line = '[{}]'.format(line)

        # add the system load prefix: "load avg: 1.80 "
        if hasattr(os, 'getloadavg'):
            load_avg_1min = os.getloadavg()[0]
            line = "load avg: {:.2f} {}".format(load_avg_1min, line)

        # add the timestamp prefix:  "0:01:05 "
        test_time = time.time() - regrtest_start_time
        test_time = datetime.timedelta(seconds=int(test_time))
        line = "%s %s" % (test_time, line)

        # add the test name
        line = "{} {}".format(line, test)

        print(line)
        sys.stdout.flush()

    # For a partial run, we do not need to clutter the output. 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:27,代码来源:regrtest.py

示例2: mon_performance

# 需要导入模块: import os [as 别名]
# 或者: from os import getloadavg [as 别名]
def mon_performance():

    # get system/CPU load
    load1m, _, _ = os.getloadavg()
    # get CPU utilization as a percentage
    cpuload = p.cpu_percent(interval=1)

    print("\nTotal CPU usage:", cpuload, "%")
    print("Total system load:", load1m, "\n")

    if cur_turbo == "0":
        print("Currently turbo boost is: on")
        print("Suggesting to set turbo boost: on")
    else:
        print("Currently turbo boost is: off")
        print("Suggesting to set turbo boost: on")

    footer(79)

# set cpufreq based if device is charging 
开发者ID:AdnanHodzic,项目名称:auto-cpufreq,代码行数:22,代码来源:core.py

示例3: launch

# 需要导入模块: import os [as 别名]
# 或者: from os import getloadavg [as 别名]
def launch(self):
        self.logger.debug('getLoadAvrgs: start')
        
        # Get the triplet from the python function
        try:
            loadAvrgs_1, loadAvrgs_5, loadAvrgs_15 = os.getloadavg()
        except (AttributeError, OSError):
            self.set_not_eligible('Load average is only availabe on unix systems')
            return False
        
        self.logger.debug('getLoadAvrgs: parsing')
        
        loadavrgs = {'load1': loadAvrgs_1, 'load5': loadAvrgs_5, 'load15': loadAvrgs_15}
        
        self.logger.debug('getLoadAvrgs: completed, returning')
        
        return loadavrgs 
开发者ID:naparuba,项目名称:opsbro,代码行数:19,代码来源:collector_loadaverage.py

示例4: idle_cpu_count

# 需要导入模块: import os [as 别名]
# 或者: from os import getloadavg [as 别名]
def idle_cpu_count(mincpu=1):
    """Estimate number of idle CPUs, for use by multiprocessing code
    needing to determine how many processes can be run without excessive
    load. This function uses :func:`os.getloadavg` which is only available
    under a Unix OS.

    Parameters
    ----------
    mincpu : int
      Minimum number of CPUs to report, independent of actual estimate

    Returns
    -------
    idle : int
      Estimate of number of idle CPUs
    """

    if PY2:
        ncpu = mp.cpu_count()
    else:
        ncpu = os.cpu_count()
    idle = int(ncpu - np.floor(os.getloadavg()[0]))
    return max(mincpu, idle) 
开发者ID:alphacsc,项目名称:alphacsc,代码行数:25,代码来源:util.py

示例5: idle_cpu_count

# 需要导入模块: import os [as 别名]
# 或者: from os import getloadavg [as 别名]
def idle_cpu_count(mincpu=1):
    """Estimate number of idle CPUs.

    Estimate number of idle CPUs, for use by multiprocessing code
    needing to determine how many processes can be run without excessive
    load. This function uses :func:`os.getloadavg` which is only available
    under a Unix OS.

    Parameters
    ----------
    mincpu : int
      Minimum number of CPUs to report, independent of actual estimate

    Returns
    -------
    idle : int
      Estimate of number of idle CPUs
    """

    if PY2:
        ncpu = mp.cpu_count()
    else:
        ncpu = os.cpu_count()
    idle = int(ncpu - np.floor(os.getloadavg()[0]))
    return max(mincpu, idle) 
开发者ID:bwohlberg,项目名称:sporco,代码行数:27,代码来源:util.py

示例6: _get_system_information

# 需要导入模块: import os [as 别名]
# 或者: from os import getloadavg [as 别名]
def _get_system_information(self):
        memory_usage = psutil.virtual_memory()
        try:
            disk_usage = psutil.disk_usage(self.config['data_storage']['firmware_file_storage_directory'])
        except Exception:
            disk_usage = psutil.disk_usage('/')
        try:
            cpu_percentage = psutil.cpu_percent()
        except Exception:
            cpu_percentage = 'unknown'

        result = {
            'cpu_cores': psutil.cpu_count(logical=False),
            'virtual_cpu_cores': psutil.cpu_count(),
            'cpu_percentage': cpu_percentage,
            'load_average': ', '.join(str(x) for x in os.getloadavg()),
            'memory_total': memory_usage.total,
            'memory_used': memory_usage.used,
            'memory_percent': memory_usage.percent,
            'disk_total': disk_usage.total,
            'disk_used': disk_usage.used,
            'disk_percent': disk_usage.percent
        }
        return result 
开发者ID:fkie-cad,项目名称:FACT_core,代码行数:26,代码来源:work_load.py

示例7: display_progress

# 需要导入模块: import os [as 别名]
# 或者: from os import getloadavg [as 别名]
def display_progress(self, test_index, test):
        if self.ns.quiet:
            return

        # "[ 51/405/1] test_tcl passed"
        line = f"{test_index:{self.test_count_width}}{self.test_count}"
        fails = len(self.bad) + len(self.environment_changed)
        if fails and not self.ns.pgo:
            line = f"{line}/{fails}"
        line = f"[{line}] {test}"

        # add the system load prefix: "load avg: 1.80 "
        if hasattr(os, 'getloadavg'):
            load_avg_1min = os.getloadavg()[0]
            line = f"load avg: {load_avg_1min:.2f} {line}"

        # add the timestamp prefix:  "0:01:05 "
        test_time = time.monotonic() - self.start_time
        test_time = datetime.timedelta(seconds=int(test_time))
        line = f"{test_time} {line}"
        print(line, flush=True) 
开发者ID:bkerler,项目名称:android_universal,代码行数:23,代码来源:main.py

示例8: ps_info

# 需要导入模块: import os [as 别名]
# 或者: from os import getloadavg [as 别名]
def ps_info():
    import psutil, time
    CMD_DISP_MAX = 80
    data = []
    data.append(('System Load', os.getloadavg()))
    cpu_total = 0
    psdata = ['<table id="procs"><thead><tr><th>PID</th><th>Owner</th><th>CPU %</th><th>VM Use (MB)</th><th>Status</th><th>Command</th></tr></thead><tbody>']
    for proc in psutil.process_iter():
        # start the clock on CPU usage percents
        try:
            proc.cpu_percent()
        except psutil.NoSuchProcess:
            pass

    time.sleep(2)
    for proc in psutil.process_iter():
        try:
            perc = proc.cpu_percent()
            if perc > 0:
                cpu_total += perc
                mem = proc.memory_info().vms / 1024.0 / 1024.0
                cmd = ' '.join(proc.cmdline())
                if len(cmd) > CMD_DISP_MAX:
                    cmd = '<span title="%s">%s</span>' % (escape(cmd), escape(cmd[:(CMD_DISP_MAX-5)]) + '&hellip;')
                else:
                    cmd = escape(cmd)

                psdata.append('<tr><td>%s</td><td>%s</td><td>%s</td><td>%.1f</td><td>%s</td><td>%s</td></tr>' \
                    % (proc.pid, proc.username(), perc, mem, escape(str(proc.status())), cmd))

        except psutil.NoSuchProcess:
            pass
    psdata.append('</tbody></table>')
    data.append(('CPU Percent', cpu_total))
    data.append(('Running Processes', mark_safe(''.join(psdata))))
    return data 
开发者ID:sfu-fas,项目名称:coursys,代码行数:38,代码来源:panel.py

示例9: crawl_load

# 需要导入模块: import os [as 别名]
# 或者: from os import getloadavg [as 别名]
def crawl_load(self):
        load = os.getloadavg()
        feature_key = 'load'
        feature_attributes = LoadFeature(load[0], load[1], load[1])
        yield (feature_key, feature_attributes, 'load') 
开发者ID:cloudviz,项目名称:agentless-system-crawler,代码行数:7,代码来源:load_container_crawler.py

示例10: load_fair

# 需要导入模块: import os [as 别名]
# 或者: from os import getloadavg [as 别名]
def load_fair():
        try:
            load = os.getloadavg()[0] / _cpu_count
        except OSError:  # as of May 2016, Windows' Linux subsystem throws OSError on getloadavg
            load = -1
        return 'load', load 
开发者ID:DMOJ,项目名称:judge-server,代码行数:8,代码来源:sysinfo.py

示例11: get_loadavg

# 需要导入模块: import os [as 别名]
# 或者: from os import getloadavg [as 别名]
def get_loadavg():
    loadavgs = os.getloadavg()
    return {
        'avg1': float(loadavgs[0]),
        'avg5': float(loadavgs[1]),
        'avg15': float(loadavgs[2]),
    } 
开发者ID:510908220,项目名称:heartbeats,代码行数:9,代码来源:script.py

示例12: get_load

# 需要导入模块: import os [as 别名]
# 或者: from os import getloadavg [as 别名]
def get_load():
    """Return current load average.

    Values is average perecntage of CPU used over 1 minute, 5 minutes, 15
    minutes.
    """
    a1, a5, a15 = os.getloadavg()
    cpus = os.cpu_count()
    return a1 / cpus * 100.0, a5 / cpus * 100.0, a15 / cpus * 100.0 
开发者ID:SymbiFlow,项目名称:prjxray,代码行数:11,代码来源:run_fuzzer.py

示例13: _check_load

# 需要导入模块: import os [as 别名]
# 或者: from os import getloadavg [as 别名]
def _check_load(cls):
        if cls._max_load is not None:
            try:
                load = os.getloadavg()
                if load[1] < cls._max_load:
                    cls._load_ok = True
                else:
                    cls._load_ok = False
            except NotImplementedError:
                cls._load_ok = True

        return cls._load_ok 
开发者ID:catkin,项目名称:catkin_tools,代码行数:14,代码来源:job_server.py

示例14: get_load

# 需要导入模块: import os [as 别名]
# 或者: from os import getloadavg [as 别名]
def get_load():
    """
    Get load average
    """
    try:
        data = os.getloadavg()[0]
    except Exception as err:
        data = str(err)

    return data 
开发者ID:xuchaoa,项目名称:CTF_AWD_Platform,代码行数:12,代码来源:services.py

示例15: display_loadavg

# 需要导入模块: import os [as 别名]
# 或者: from os import getloadavg [as 别名]
def display_loadavg(scr):
    lavg = os.getloadavg()
    write(scr, 1, 0, 'System',             curses.color_pair(9))
    write(scr, 1, 7, 'Load:',              curses.color_pair(9))
    write(scr, 1, 13, '%.02f' % lavg[0],   curses.color_pair(9))
    write(scr, 1, 20, '%.02f' % lavg[1],   curses.color_pair(9))
    write(scr, 1, 27, '%.02f' % lavg[2],   curses.color_pair(9)) 
开发者ID:ActiveState,项目名称:code,代码行数:9,代码来源:recipe-577933.py


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