fix: add json tags to inner struct fields for metrics parsing

This commit is contained in:
tian 2026-05-08 20:04:15 +08:00
parent 08712814d9
commit 1bcd9ae3a5

View File

@ -785,9 +785,9 @@ func (u *UI) pageDashboard(w http.ResponseWriter, r *http.Request) {
body, code, err := u.agent.Do("GET", dev.IP, dev.AgentPort, "/v1/metrics", nil)
if err != nil || code != 200 { continue }
var m struct {
CPU struct{ UsagePct float64 } `json:"cpu"`
CPU struct{ UsagePct float64 `json:"usage_pct"` } `json:"cpu"`
Memory struct{ TotalKB uint64 `json:"total_kb"`; AvailableKB uint64 `json:"available_kb"` } `json:"memory"`
NPU struct{ UsagePct float64 } `json:"npu"`
NPU struct{ UsagePct float64 `json:"usage_pct"` } `json:"npu"`
}
json.Unmarshal(body, &m)
var mem float64