eris/eris.py
def mon_util_cycle(ctx):
    """
    CPU utilization monitor timer function
        ctx - agent context
    """
    findbe = False
    lc_utils = 0
    be_utils = 0
    date = datetime.now().isoformat()
    bes = []
    newbe = False
    containers = ctx.docker_client.containers.list()
    remove_finished_containers({c.id for c in containers}, ctx.util_cons)

    for container in containers:
        cid = container.id
        name = container.name
        pids = list_pids(container)
        key = cid if ctx.args.key_cid else name
        if cid in ctx.util_cons:
            con = ctx.util_cons[cid]
        else:
            con = Container(ctx.cgroup_driver, cid, name, pids,
                            ctx.args.verbose)
            ctx.util_cons[cid] = con
            if ctx.args.control:
                if key in ctx.be_set:
                    newbe = True
                    ctx.cpuq.set_share(con, CpuQuota.CPU_SHARE_BE)
                else:
                    ctx.cpuq.set_share(con, CpuQuota.CPU_SHARE_LC)
        con.update_cpu_usage()
        if ctx.args.record:
            with open('./util.csv', 'a') as utilf:
                utilf.write(date + ',' + cid + ',' + name +
                            ',' + str(con.utils) + '\n')

        if key in ctx.lc_set:
            lc_utils = lc_utils + con.utils

        if key in ctx.be_set:
            findbe = True
            be_utils = be_utils + con.utils
            bes.append(con)

    loadavg = os.getloadavg()[0]
    if ctx.args.record:
        with open('./util.csv', 'a') as utilf:
            utilf.write(date + ',,lcs,' + str(lc_utils) + '\n')
            utilf.write(date + ',,loadavg1m,' + str(loadavg) + '\n')

    if lc_utils > ctx.sysmax_util:
        update_sysmax(ctx, lc_utils)
        if ctx.args.control:
            ctx.cpuq.update_max_sys_util(lc_utils)

    if newbe:
        ctx.cpuq.budgeting(bes, [])

    if findbe and ctx.args.control:
        exceed, hold = ctx.cpuq.detect_margin_exceed(lc_utils, be_utils)
        if not ctx.args.enable_hold:
            hold = False
        ctx.controllers[Contention.CPU_CYC].update(bes, [], exceed, hold)

    CPU utilization monitor timer function
        ctx - agent context
    
CPU utilization monitor timer function
ctx - agent context
CPU utilization monitor timer function ctx - agent context
def mon_util_cycle(ctx):
    findbe = False
    lc_utils = 0
    be_utils = 0
    date = datetime.now().isoformat()
    bes = []
    newbe = False
    containers = ctx.docker_client.containers.list()
    remove_finished_containers({c.id for c in containers}, ctx.util_cons)
    for container in containers:
        cid = container.id
        name = container.name
        pids = list_pids(container)
        key = cid if ctx.args.key_cid else name
        if cid in ctx.util_cons:
            con = ctx.util_cons[cid]
        else:
            con = Container(ctx.cgroup_driver, cid, name, pids,
                            ctx.args.verbose)
            ctx.util_cons[cid] = con
            if ctx.args.control:
                if key in ctx.be_set:
                    newbe = True
                    ctx.cpuq.set_share(con, CpuQuota.CPU_SHARE_BE)
                else:
                    ctx.cpuq.set_share(con, CpuQuota.CPU_SHARE_LC)
        con.update_cpu_usage()
        if ctx.args.record:
            with open('./util.csv', 'a') as utilf:
                utilf.write(date + ',' + cid + ',' + name +
                            ',' + str(con.utils) + '\n')
        if key in ctx.lc_set:
            lc_utils = lc_utils + con.utils
        if key in ctx.be_set:
            findbe = True
            be_utils = be_utils + con.utils
            bes.append(con)
    loadavg = os.getloadavg()[0]
    if ctx.args.record:
        with open('./util.csv', 'a') as utilf:
            utilf.write(date + ',,lcs,' + str(lc_utils) + '\n')
            utilf.write(date + ',,loadavg1m,' + str(loadavg) + '\n')
    if lc_utils > ctx.sysmax_util:
        update_sysmax(ctx, lc_utils)
        if ctx.args.control:
            ctx.cpuq.update_max_sys_util(lc_utils)
    if newbe:
        ctx.cpuq.budgeting(bes, [])
    if findbe and ctx.args.control:
        exceed, hold = ctx.cpuq.detect_margin_exceed(lc_utils, be_utils)
        if not ctx.args.enable_hold:
            hold = False
        ctx.controllers[Contention.CPU_CYC].update(bes, [], exceed, hold)
def mon_util_cycle ( ctx ) : findbe = False lc_utils = 0 be_utils = 0 date = datetime . now ( ) . isoformat ( ) bes = [ ] newbe = False containers = ctx . docker_client . containers . list ( ) remove_finished_containers ( { c . id for c in containers } , ctx . util_cons ) for container in containers : cid = container . id name = container . name pids = list_pids ( container ) key = cid if ctx . args . key_cid else name if cid in ctx . util_cons : con = ctx . util_cons [ cid ] else : con = Container ( ctx . cgroup_driver , cid , name , pids , ctx . args . verbose ) ctx . util_cons [ cid ] = con if ctx . args . control : if key in ctx . be_set : newbe = True ctx . cpuq . set_share ( con , CpuQuota . CPU_SHARE_BE ) else : ctx . cpuq . set_share ( con , CpuQuota . CPU_SHARE_LC ) con . update_cpu_usage ( ) if ctx . args . record : with open ( './util.csv' , 'a' ) as utilf : utilf . write ( date + ',' + cid + ',' + name + ',' + str ( con . utils ) + '\n' ) if key in ctx . lc_set : lc_utils = lc_utils + con . utils if key in ctx . be_set : findbe = True be_utils = be_utils + con . utils bes . append ( con ) loadavg = os . getloadavg ( ) [ 0 ] if ctx . args . record : with open ( './util.csv' , 'a' ) as utilf : utilf . write ( date + ',,lcs,' + str ( lc_utils ) + '\n' ) utilf . write ( date + ',,loadavg1m,' + str ( loadavg ) + '\n' ) if lc_utils > ctx . sysmax_util : update_sysmax ( ctx , lc_utils ) if ctx . args . control : ctx . cpuq . update_max_sys_util ( lc_utils ) if newbe : ctx . cpuq . budgeting ( bes , [ ] ) if findbe and ctx . args . control : exceed , hold = ctx . cpuq . detect_margin_exceed ( lc_utils , be_utils ) if not ctx . args . enable_hold : hold = False ctx . controllers [ Contention . CPU_CYC ] . update ( bes , [ ] , exceed , hold )
CPU utilization monitor timer function
ctx - agent context
CPU utilization monitor timer function ctx - agent context
"""
    CPU utilization monitor timer function
        ctx - agent context
    """
ctx