mirror of
https://github.com/jmagar/unraid-mcp.git
synced 2026-03-02 08:14:43 -08:00
- dashboard.sh: Add // [] jq null guard on .data.array.disks[] (L176-177) Resolves review thread PRRT_kwDOO6Hdxs5uvO21 - dashboard.sh: Default NAME to server key when env var unset (L221) Resolves review thread PRRT_kwDOO6Hdxs5uvO22 - unraid-query.sh: Check curl exit code, empty response, and JSON validity before piping to jq (L112-129) Resolves review thread PRRT_kwDOO6Hdxs5uvO24 - disk-health.sh: Guard against missing query script and invalid responses Resolves review thread PRRT_kwDOO6Hdxs5uvKrh
37 lines
1.1 KiB
Bash
Executable File
37 lines
1.1 KiB
Bash
Executable File
#!/bin/bash
|
|
# Check disk health and temperatures
|
|
# Quick overview of all disks with temperature warnings
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
QUERY_SCRIPT="$SCRIPT_DIR/../scripts/unraid-query.sh"
|
|
|
|
if [[ ! -x "$QUERY_SCRIPT" ]]; then
|
|
echo "Error: Query script not found or not executable: $QUERY_SCRIPT" >&2
|
|
exit 1
|
|
fi
|
|
|
|
QUERY='{ array { disks { name device temp status isSpinning } } }'
|
|
|
|
echo "=== Disk Health Report ==="
|
|
echo ""
|
|
|
|
RESPONSE=$("$QUERY_SCRIPT" -q "$QUERY" -f raw) || {
|
|
echo "Error: Query failed." >&2
|
|
exit 1
|
|
}
|
|
|
|
if [[ -z "$RESPONSE" ]] || ! echo "$RESPONSE" | jq -e . > /dev/null 2>&1; then
|
|
echo "Error: Invalid or empty response from query." >&2
|
|
exit 1
|
|
fi
|
|
|
|
echo "$RESPONSE" | jq -r '.array.disks[] | "\(.name) (\(.device)): \(.temp)°C - \(.status) - \(if .isSpinning then "Spinning" else "Spun down" end)"'
|
|
|
|
echo ""
|
|
echo "Temperature warnings:"
|
|
echo "$RESPONSE" | jq -r '.array.disks[] | select(.temp > 45) | "⚠️ \(.name): \(.temp)°C (HIGH)"'
|
|
|
|
HOTTEST=$(echo "$RESPONSE" | jq -r '[.array.disks[].temp] | max')
|
|
echo ""
|
|
echo "Hottest disk: ${HOTTEST}°C"
|