コード例 #1
0
def main():
    servers = sql.select_alert()
    started_workers = get_worker()
    servers_list = []

    for serv in servers:
        servers_list.append(serv[0])

    need_kill = list(set(started_workers) - set(servers_list))
    need_start = list(set(servers_list) - set(started_workers))

    if need_kill:
        for serv in need_kill:
            kill_worker(serv)

    if need_start:
        for serv in need_start:
            start_worker(serv)
コード例 #2
0
ファイル: overview.py プロジェクト: heartshare/haproxy-wi
        i = 0
        servers_len = len(servers)

        for s in servers:
            i += 1
            if i != servers_len:
                servers_for_grep += s[2] + '\|'
            else:
                servers_for_grep += s[2]

        cmd = "ps ax |grep -e 'metrics_worker\|metrics_waf_worker.py'|grep -E %s|grep -v grep |wc -l" % servers_for_grep
        metrics_worker, stderr = funct.subprocess_execute(cmd)
        cmd = "ps ax |grep checker_worker|grep -E %s |grep -v grep |wc -l" % servers_for_grep
        checker_worker, stderr = funct.subprocess_execute(cmd)
        i = 0
        for s in sql.select_alert(group=user_group):
            i += 1
        is_checker_worker = i
        is_metrics_workers = sql.select_servers_metrics_for_master(
            group=user_group)
        i = 0
        for s in is_metrics_workers:
            i += 1
        is_metrics_worker = i
        grafana = ''
        prometheus = ''
        host = ''
    else:
        users = sql.select_users()
        cmd = "ps ax |grep -e 'metrics_worker\|metrics_waf_worker.py' |grep -v grep |wc -l"
        metrics_worker, stderr = funct.subprocess_execute(cmd)
コード例 #3
0
ファイル: overview.py プロジェクト: hunter-nl/haproxy-wi
    checker_master, stderr = funct.subprocess_execute(cmd)
    cmd = "ps ax |grep checker_worker |grep -v grep |wc -l"
    checker_worker, stderr = funct.subprocess_execute(cmd)
    cmd = "ps ax |grep metrics_master |grep -v grep |wc -l"
    metrics_master, stderr = funct.subprocess_execute(cmd)
    cmd = "ps ax |grep -e 'metrics_worker\|metrics_waf_worker.py' |grep -v grep |wc -l"
    metrics_worker, stderr = funct.subprocess_execute(cmd)
    cmd = "ps ax |grep -e 'keep_alive.py' |grep -v grep |wc -l"
    keep_alive, stderr = funct.subprocess_execute(cmd)
    cmd = "ps ax |grep '(wsgi:api)'|grep -v grep|wc -l"
    api, stderr = funct.subprocess_execute(cmd)
    cmd = "ps ax |grep grafana|grep -v grep|wc -l"
    grafana, stderr = funct.subprocess_execute(cmd)
    cmd = "ps ax |grep 'prometheus ' |grep -v grep|wc -l"
    prometheus, stderr = funct.subprocess_execute(cmd)
    is_checker_workers = sql.select_alert()
    i = 0
    for s in sql.select_alert():
        i += 1
    is_checker_worker = i
    is_metrics_workers = sql.select_servers_metrics_for_master()
    i = 0
    for s in is_metrics_workers:
        i += 1
    is_metrics_worker = i

except:
    role = ''
    user = ''
    users = ''
    groups = ''