Beispiel #1
0
def scale_up():
    containers = Containers()
    ids = Ids()

    #print("SCALING UP")
    for container_id in ids.ids():
        ins = Inspect(container_id)
        sta = Stats(container_id)
        prc = Process(container_id, ps_args="aux")

        mem_u = sta.memory_stats_usage()
        mem_l = sta.memory_stats_limit()
        mem_usage = int(mem_u) / int(mem_l)
        #print("MEM USAGE", mem_usage)

        if mem_usage >= 0.10:
            print("SCALING UP", container_id)
            new_limit = int(mem_l) * 1.66
            update_process = subprocess.Popen(['docker', 'update', '--memory', str(new_limit), container_id], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
            update_process.wait()
            #print("SCALED", update_process.returncode, update_process.stderr.read(), update_process.stdout.read())

            if update_process.returncode != 0:
                print("FAILED TO SCALE", container_id)
                update_process = subprocess.Popen(['docker', 'update', '--memory-swap', str(new_limit), '--memory', str(new_limit), container_id], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
                update_process.wait()
                print("SCALED2", update_process.returncode, update_process.stderr.read(), update_process.stdout.read())
            else:
                print("SCALED UP", container_id)
Beispiel #2
0
from domonit.stats import Stats

import json

c = Containers()
i = Ids()

print ("Number of containers is : %s " % (sum(1 for i in i.ids())))

if __name__ == "__main__":

    for c_id in i.ids():

        ins = Inspect(c_id)
        sta = Stats(c_id)
        proc = Process(c_id, ps_args = "aux")

        # Container name
        print ("\n#Container name")
        print ins.name()
 
        # Container id
        print ("\n#Container id")
        print ins.id()

        # Memory usage
        mem_u = sta.memory_stats_usage()

        # Memory limit
        mem_l = sta.memory_stats_limit()
Beispiel #3
0
print("\n")

if __name__ == "__main__":

    for c_id in i.ids():

        ins = Inspect(c_id)
        print("Inspect()")
        print dir(ins)
        print("\n")

        sta = Stats(c_id)
        print("Stats()")
        print dir(sta)
        print("\n")

        proc = Process(c_id, ps_args="aux")
        print("Process()")
        print dir(proc)
        print("\n")

        log = Logs(c_id)
        print("Logs()")
        print dir(log)
        print("\n")

        cha = Changes(c_id)
        print("Changes()")
        print dir(cha)
        print("\n")