def main(): sql.delete_mentrics() servers = sql.select_servers_metrics_for_master() 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)
def main(): sql.delete_mentrics() sql.delete_waf_mentrics() servers = sql.select_servers_metrics_for_master() 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) try: waf_servers = sql.select_all_waf_servers() waf_started_workers = get_waf_worker() waf_servers_list = [] for serv in waf_servers: waf_servers_list.append(serv[0]) waf_need_kill=list(set(waf_started_workers) - set(waf_servers_list)) waf_need_start=list(set(waf_servers_list) - set(waf_started_workers)) if waf_need_kill: for serv in waf_need_kill: kill_waf_worker(serv) if waf_need_start: for serv in waf_need_start: start_waf_worker(serv) except Exception as e: funct.logging("localhost", 'Problems with WAF worker metrics '+e, metrics=1) pass