def index(): """ Get dashboard monitoring :return: template """ assets_path = "/" dashboard_url = "http://127.0.0.1:5000/" manager_rabbit = ManagerRabbit() consumers = manager_rabbit.get_list_consumers() check_memcached() except_dbs = ['admin', 'config', 'local', env.MONITORING_DB_NAME] db_names = [database for database in DBAccess.get_dbs_names() if database not in except_dbs and '_results' not in database] return render_template('index.html', service_status=check_service_data(), dashboard_url=dashboard_url, db_names=db_names, cycle=env.RABBITMQ_CYCLE, consumers=consumers, images=images, assets_path=assets_path, nb_pr_page=env.MONITORING_NB_PAGE, count_worker=check_max_worker(env.RABBITMQ_SIMULATOR_QUEUE_NAME), global_result_worker=check_worker_result(RABBITMQ_GLOBAL_RESULT_QUEUE_NAME), detailed_result_worker=check_worker_result(RABBITMQ_DETAILED_RESULT_QUEUE_NAME), queue_simulate=env.RABBITMQ_SIMULATOR_QUEUE_NAME, canvas_url=env.CANVAS_URL, logistics_lp=env.LOGISTICS_LP )
def check_worker(): """ Get information for each Workers :return: JSON """ manager_rabbit = ManagerRabbit() list_queues = manager_rabbit.get_list_queues() consumers = manager_rabbit.get_list_consumers() workers_info = dict() # get status best scenarios for current db_name best_scenarios_status = dict() except_dbs = ['admin', 'config', 'local', env.MONITORING_DB_NAME] db_names = [database for database in DBAccess.get_dbs_names() if database not in except_dbs and '_results' not in database] if ('db_name' in request.json) and (request.json['db_name'] is not None): best_scenarios_status[request.json['db_name']] = env.HTML_STATUS.OK.value if memcached_client.get(request.json['db_name']): best_scenarios_status[request.json['db_name']]=memcached_client.get(request.json['db_name']) else: return jsonify(status=env.HTML_STATUS.ERROR.value) # Status worker global results worker_global_result = check_worker_result(RABBITMQ_GLOBAL_RESULT_QUEUE_NAME) # Status worker detailed results worker_detailed_result = check_worker_result(RABBITMQ_DETAILED_RESULT_QUEUE_NAME) # Count workers running count_worker = check_max_worker(env.RABBITMQ_SIMULATOR_QUEUE_NAME) for phase in range(env.RABBITMQ_CYCLE): if memcached_client.get("workers_info_%i" % phase): workers_info[phase] = memcached_client.get("workers_info_%i" % phase)[str(phase)] return jsonify(workersInfo=workers_info, list_queues=list_queues, consumers=consumers, best_scenarios_status=best_scenarios_status, db_names=db_names, worker_global_result=worker_global_result, worker_detailed_result=worker_detailed_result, count_worker=count_worker )