Exemple #1
0
def get_sysinfo():
    """ 取得系统资源使用情况"""
    import system_info
    from multiprocessing import cpu_count
    info = {}
    info['cpu'] = (cpu_count(),int(round(float(system_info.get_cpu_usage()))),system_info.get_cpu_style())
    info['mem'] = system_info.get_mem_usage()
    info['ip'] = system_info.get_ip()
    return info 
Exemple #2
0
def report(start_time):
    """ 转换器向服务器报告状态 """
    cpu_style = get_cpu_style()
    cpu_percent = get_cpu_usage() 
    mem_percent, mem_total = get_mem_usage()
    ip = CONFIG['server']['alias']

    traceback_dict = {}
    for thread_id, frame in sys._current_frames().items():
        traceback_dict[thread_id] = traceback.format_stack(frame)

    # 向服务器报告
    return dict( ip=ip,
            cpu_style=cpu_style, 
            cpu_percent=cpu_percent, 
            mem_total=mem_total, 
            mem_percent=mem_percent, 
            started=start_time, 
            timestamp=int(time.time()),
            traceback=traceback_dict,
            )
Exemple #3
0
def report(start_time):
    """ 转换器向服务器报告状态 """
    cpu_style = get_cpu_style()
    cpu_percent = get_cpu_usage()
    mem_percent, mem_total = get_mem_usage()
    ip = safe_get_host('server', 'alias')

    traceback_dict = {}
    for thread_id, frame in sys._current_frames().items():
        traceback_dict[thread_id] = traceback.format_stack(frame)

    # 向服务器报告
    return dict(
        ip=ip,
        cpu_style=cpu_style,
        cpu_percent=cpu_percent,
        mem_total=mem_total,
        mem_percent=mem_percent,
        started=start_time,
        timestamp=int(time.time()),
        traceback=traceback_dict,
    )
Exemple #4
0
def report(start_time):
    """ 转换器向服务器报告状态 """
    cpu_style = get_cpu_style()
    cpu_percent = get_cpu_usage()
    mem_percent, mem_total = get_mem_usage()
    ip = CONFIG['server']['alias']

    traceback_dict = {}
    for thread_id, frame in sys._current_frames().items():
        traceback_dict[thread_id] = traceback.format_stack(frame)

    # 向服务器报告
    return dict(
        ip=ip,
        cpu_style=cpu_style,
        cpu_percent=cpu_percent,
        mem_total=mem_total,
        mem_percent=mem_percent,
        cron_running=ztq_core.cron.CRON_RUNNING,
        started=start_time,
        timestamp=int(time.time()),
        traceback=traceback_dict,
    )