def backend_status() -> BackendStatusSchema: """ Returns the current status of backend services, and returns it. Intended to be used by the webpage. This endpoint is not stable and may be subject to change in the future. """ agents = [] components = { "mquery": mquery_version(), } for name, agent_spec in db.get_active_agents().items(): try: ursa = UrsaDb(agent_spec.ursadb_url) status = ursa.status() tasks = status["result"]["tasks"] ursadb_version = status["result"]["ursadb_version"] agents.append( AgentSchema( name=name, alive=True, tasks=tasks, spec=agent_spec ) ) components[f"ursadb ({name})"] = ursadb_version except Again: agents.append( AgentSchema(name=name, alive=False, tasks=[], spec=agent_spec) ) components[f"ursadb ({name})"] = "unknown" return BackendStatusSchema(agents=agents, components=components,)
def server() -> ServerSchema: return ServerSchema( version=mquery_version(), auth_enabled=db.get_mquery_config_key("auth_enabled"), openid_auth_url=db.get_mquery_config_key("openid_auth_url"), openid_login_url=db.get_mquery_config_key("openid_login_url"), openid_client_id=db.get_mquery_config_key("openid_client_id"), )
def backend_status() -> Response: db_alive = True status = db.status() try: tasks = status.get("result", {}).get("tasks", []) ursadb_version = status.get("result", {}).get("ursadb_version", "unknown") except Again: db_alive = False tasks = [] ursadb_version = [] return jsonify({ "db_alive": db_alive, "tasks": tasks, "components": { "mquery": mquery_version(), "ursadb": str(ursadb_version), }, })
def backend_status() -> BackendStatusSchema: db_alive = True status = db.status() try: tasks = status.get("result", {}).get("tasks", []) ursadb_version = status.get("result", {}).get("ursadb_version", "unknown") except Again: db_alive = False tasks = [] ursadb_version = [] return BackendStatusSchema( db_alive=db_alive, tasks=tasks, components={ "mquery": mquery_version(), "ursadb": str(ursadb_version), }, )
def backend_status() -> BackendStatusSchema: agents = [] components = { "mquery": mquery_version(), } for name, agent_spec in db.get_active_agents().items(): try: ursa = UrsaDb(agent_spec.ursadb_url) status = ursa.status() tasks = status["result"]["tasks"] ursadb_version = status["result"]["ursadb_version"] agents.append( AgentSchema( name=name, alive=True, tasks=tasks, spec=agent_spec ) ) components[f"ursadb ({name})"] = ursadb_version except Again: agents.append( AgentSchema(name=name, alive=False, tasks=[], spec=agent_spec) ) components[f"ursadb ({name})"] = "unknown" return BackendStatusSchema(agents=agents, components=components,)