Fetch per-disk temp and spin state for the Storage card
All checks were successful
Deploy / deploy (push) Successful in 28s
All checks were successful
Deploy / deploy (push) Successful in 28s
The GraphQL query only asked for aggregate array fsSize/fsFree, so the
per-disk breakdown added in templates/dashboard.html (commit 5045316)
had no data to render. Now pulls name/device/temp/isSpinning for data
disks, cache disks, and parity disks, and shapes them into the
disks/caches/parities lists the template expects.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
5045316fa5
commit
1cc5a247cf
1 changed files with 29 additions and 1 deletions
30
app.py
30
app.py
|
|
@ -813,7 +813,12 @@ def get_unraid_stats():
|
||||||
headers = {"x-api-key": UNRAID_API_KEY, "Content-Type": "application/json"}
|
headers = {"x-api-key": UNRAID_API_KEY, "Content-Type": "application/json"}
|
||||||
query = """{
|
query = """{
|
||||||
vars { version }
|
vars { version }
|
||||||
array { state disks { fsSize fsFree type } }
|
array {
|
||||||
|
state
|
||||||
|
disks { name device fsSize fsFree type temp isSpinning }
|
||||||
|
caches { name device fsSize fsFree type temp isSpinning }
|
||||||
|
parities { name device temp isSpinning }
|
||||||
|
}
|
||||||
}"""
|
}"""
|
||||||
try:
|
try:
|
||||||
resp = requests.post(url, json={"query": query}, headers=headers,
|
resp = requests.post(url, json={"query": query}, headers=headers,
|
||||||
|
|
@ -828,6 +833,26 @@ def get_unraid_stats():
|
||||||
free_bytes = sum(int(dk.get("fsFree", 0) or 0) for dk in data_disks)
|
free_bytes = sum(int(dk.get("fsFree", 0) or 0) for dk in data_disks)
|
||||||
used_bytes = total_bytes - free_bytes
|
used_bytes = total_bytes - free_bytes
|
||||||
used_pct = round(used_bytes / total_bytes * 100) if total_bytes else 0
|
used_pct = round(used_bytes / total_bytes * 100) if total_bytes else 0
|
||||||
|
|
||||||
|
def disk_row(dk, with_usage=True):
|
||||||
|
row = {
|
||||||
|
"name": dk.get("name") or dk.get("device") or "disk",
|
||||||
|
"device": dk.get("device", ""),
|
||||||
|
"temp": dk.get("temp"),
|
||||||
|
"spinning": dk.get("isSpinning"),
|
||||||
|
}
|
||||||
|
if with_usage:
|
||||||
|
dtotal = int(dk.get("fsSize", 0) or 0)
|
||||||
|
dfree = int(dk.get("fsFree", 0) or 0)
|
||||||
|
dused = dtotal - dfree
|
||||||
|
row.update({
|
||||||
|
"total": fmt_bytes(dtotal),
|
||||||
|
"used": fmt_bytes(dused),
|
||||||
|
"free": fmt_bytes(dfree),
|
||||||
|
"used_pct": round(dused / dtotal * 100) if dtotal else 0,
|
||||||
|
})
|
||||||
|
return row
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"status": "ok",
|
"status": "ok",
|
||||||
"source": "api",
|
"source": "api",
|
||||||
|
|
@ -838,6 +863,9 @@ def get_unraid_stats():
|
||||||
"array_used": fmt_bytes(used_bytes),
|
"array_used": fmt_bytes(used_bytes),
|
||||||
"array_free": fmt_bytes(free_bytes),
|
"array_free": fmt_bytes(free_bytes),
|
||||||
"array_used_pct": used_pct,
|
"array_used_pct": used_pct,
|
||||||
|
"disks": [disk_row(dk) for dk in data_disks],
|
||||||
|
"caches": [disk_row(dk) for dk in arr.get("caches", [])],
|
||||||
|
"parities": [disk_row(dk, with_usage=False) for dk in arr.get("parities", [])],
|
||||||
}
|
}
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue