예제 #1
0
def sync_status():
    conn = connect()
    real_status = conn.listDefinedDomains()

    servers = data.get_all_servers()

    message_sync = "Syncing real state with database states."
    create_log(message_sync, 1)

    for server in servers:
        try:
            if server['type'] == "do" or server['type'] == "linode":
                break
        except:
            pass
        real_id = "vm%s" % str(server['_id'])
        if server['state'] == 0 and real_id not in real_status:
            message = "Checked %s, DB says it should not be running, but it is running." % real_id
            create_log(message, 2)

            inconsistent_event(server['_id'])

            data.set_server_inconsistent(server['_id'], 1)
        elif server['state'] == 1 and real_id in real_status:
            message = "Checked %s, DB says it should be running, but it is not running." % real_id
            create_log(message, 2)

            inconsistent_event(server['_id'])

            data.set_server_inconsistent(server['_id'], 1)
예제 #2
0
def get_host_stats():
    con = connect()
    memory_stats = con.getMemoryStats(0, 0)
    total_memory = memory_stats['total'] / 1024
    free_memory = memory_stats['free'] / 1024
    res = psutil.cpu_times_percent()
    cpu_system = float(res.system)
    cpu_user = float(res.user)
    cpu_guest = float(res.guest)
    io_wait = float(res.iowait)
    memory_used = total_memory - free_memory
    data.make_host_statistic(round(cpu_system, 5), round(cpu_user, 5),
                             round(cpu_guest, 5), int(memory_used),
                             int(total_memory), round(io_wait, 5),
                             datetime.datetime.now())
예제 #3
0
def get_host_stats():
    con = connect()
    memory_stats = con.getMemoryStats(0, 0)
    total_memory = memory_stats['total'] / 1024
    free_memory = memory_stats['free'] / 1024
    res = psutil.cpu_times_percent()
    cpu_system = float(res.system)
    cpu_user = float(res.user)
    cpu_guest = float(res.guest)
    io_wait = float(res.iowait)
    memory_used = total_memory - free_memory
    data.make_host_statistic(round(cpu_system, 5),
                             round(cpu_user, 5),
                             round(cpu_guest, 5),
                             int(memory_used),
                             int(total_memory),
                             round(io_wait, 5),
                             datetime.datetime.now())
예제 #4
0
def get_host_stats():
    con = connect()
    memory_stats = con.getMemoryStats(0,0)

    total_memory = memory_stats['total'] / 1024
    free_memory = memory_stats['free'] / 1024

    command = "virsh nodecpustats --percent"

    p = subprocess.Popen(command.split(), stdout=subprocess.PIPE)
    output = p.communicate()[0]

    output = output.replace(" ", "")
    output = output.split("\n")

    cpu_system = output[0].split(":")[1]
    io_wait = output[4].split(":")[1]

    memory_used = total_memory - free_memory

    data.make_host_statistic(float(cpu_system.replace("%","")), int(memory_used), int(total_memory), float(io_wait.replace("%","")), datetime.datetime.now())
예제 #5
0
def get_host_stats():
    con = connect()
    memory_stats = con.getMemoryStats(0, 0)

    total_memory = memory_stats['total'] / 1024
    free_memory = memory_stats['free'] / 1024

    command = "virsh nodecpustats --percent"

    p = subprocess.Popen(command.split(), stdout=subprocess.PIPE)
    output = p.communicate()[0]

    output = output.replace(" ", "")
    output = output.split("\n")

    cpu_system = output[0].split(":")[1]
    io_wait = output[4].split(":")[1]

    memory_used = total_memory - free_memory

    data.make_host_statistic(float(cpu_system.replace("%", "")),
                             int(memory_used), int(total_memory),
                             float(io_wait.replace("%", "")),
                             datetime.datetime.now())