From a7e254a05336426cc76fe7873dc7bd2bd97af8f0 Mon Sep 17 00:00:00 2001 From: "von Rudorff, Guido Falk" Date: Wed, 19 Jul 2023 13:27:27 +0200 Subject: [PATCH] Add datacenters to dashboard --- src/dashboard/app/dashboard.py | 14 ++++++++++---- src/server/app/routers/compute.py | 9 +++++++++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/dashboard/app/dashboard.py b/src/dashboard/app/dashboard.py index 60b3214..b4bbd83 100644 --- a/src/dashboard/app/dashboard.py +++ b/src/dashboard/app/dashboard.py @@ -11,7 +11,7 @@ col1, col2 = st.columns(2) -result = requests.get("http://hmq/usage/inspect") +result = requests.get("http://hmq/queue/inspect") rows = [] for minutes_ago, data in result.json().items(): @@ -24,9 +24,15 @@ col2.caption("Queue depth") col2.line_chart(df, x="age", y=["tasks_queued"]) col2.line_chart(df, x="age", y=["tasks_running"]) + +col1, col2 = st.columns(2) +col1.caption("Datacenters") +result = requests.get("http://hmq/datacenters/inspect") +rows = [] +for datacenter, last_seen in result.json().items(): + rows.append({"datacenter": datacenter, "minutes ago": last_seen}) +df = pd.DataFrame(rows) +col1.dataframe(df) # col2.caption("Tags") # for tag in "foo bar sdjfhwsökgdjhsökgj".split(): # col2.progress(0.54, tag)# - -# col1, col2 = st.columns(2) -# col1.caption("Hello") diff --git a/src/server/app/routers/compute.py b/src/server/app/routers/compute.py index ae68597..2b9f6db 100644 --- a/src/server/app/routers/compute.py +++ b/src/server/app/routers/compute.py @@ -256,6 +256,15 @@ def inspect_usage(): return ret +@app.get("/datacenters/inspect", tags=["statistics"]) +def inspect_usage(): + now = time.time() + ret = {} + for dc in auth.db.heartbeat.find(): + ret[dc["datacenter"]] = max(0, int(now - dc["ts"])) + return ret + + class QueueHasWork(BaseModel): challenge: str = Field(..., description="Encrypted challenge from /auth/challenge") datacenter: str = Field(..., description="Datacenter checking in.")