feat: add hostname to dashboard
This commit is contained in:
parent
a432a65396
commit
263c66aedd
2 changed files with 16 additions and 2 deletions
12
router.py
12
router.py
|
|
@ -6,7 +6,7 @@ version: 0.7
|
|||
license: AGPL
|
||||
"""
|
||||
# -------------------------------------------------------------
|
||||
import orjson, time, asyncio, yaml, ollama, openai, os, re, aiohttp, ssl, random, base64, io, enhance, secrets, math
|
||||
import orjson, time, asyncio, yaml, ollama, openai, os, re, aiohttp, ssl, random, base64, io, enhance, secrets, math, socket
|
||||
try:
|
||||
import truststore; truststore.inject_into_ssl()
|
||||
except ImportError:
|
||||
|
|
@ -3776,7 +3776,15 @@ async def health_proxy(request: Request):
|
|||
return JSONResponse(content=response_payload, status_code=http_status)
|
||||
|
||||
# -------------------------------------------------------------
|
||||
# 27. SSE route for usage broadcasts
|
||||
# 27. Hostname endpoint
|
||||
# -------------------------------------------------------------
|
||||
@app.get("/api/hostname")
|
||||
async def get_hostname():
|
||||
"""Return the hostname of the machine running the router."""
|
||||
return JSONResponse(content={"hostname": socket.gethostname()})
|
||||
|
||||
# -------------------------------------------------------------
|
||||
# 28. SSE route for usage broadcasts
|
||||
# -------------------------------------------------------------
|
||||
@app.get("/api/usage-stream")
|
||||
async def usage_stream(request: Request):
|
||||
|
|
|
|||
|
|
@ -344,6 +344,7 @@
|
|||
</div>
|
||||
<div class="header-row">
|
||||
<h1>Router Dashboard</h1>
|
||||
<span id="hostname" style="color:#777; font-size:0.85em;"></span>
|
||||
<button id="total-tokens-btn">Stats Total</button>
|
||||
<span id="aggregation-status" class="loading" style="margin-left:8px;"></span>
|
||||
</div>
|
||||
|
|
@ -1418,6 +1419,11 @@ function initStatsChart(timeSeriesData, endpointDistribution) {
|
|||
</script>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
authedFetch('/api/hostname').then(r => r.json()).then(data => {
|
||||
const el = document.getElementById('hostname');
|
||||
if (el && data.hostname) el.textContent = data.hostname;
|
||||
}).catch(() => {});
|
||||
|
||||
const totalBtn = document.getElementById('total-tokens-btn');
|
||||
if (totalBtn) {
|
||||
totalBtn.addEventListener('click', async () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue