diff --git a/pkg/gpu/stat/amd_rocm_smi.go b/pkg/gpu/stat/amd_rocm_smi.go index f64def7..f38f621 100644 --- a/pkg/gpu/stat/amd_rocm_smi.go +++ b/pkg/gpu/stat/amd_rocm_smi.go @@ -4,11 +4,12 @@ package stat // Original License: MIT import ( - "encoding/json" "errors" "os" "os/exec" "strconv" + + "github.com/nezhahq/agent/pkg/util" ) type ROCmSMI struct { @@ -48,7 +49,7 @@ func gatherROCmSMI(ret []byte) ([]float64, error) { var gpus map[string]GPU var percentage []float64 - err := json.Unmarshal(ret, &gpus) + err := util.Json.Unmarshal(ret, &gpus) if err != nil { return nil, err } diff --git a/pkg/monitor/myip.go b/pkg/monitor/myip.go index 32e537a..21d57d9 100644 --- a/pkg/monitor/myip.go +++ b/pkg/monitor/myip.go @@ -100,21 +100,23 @@ func fetchGeoIP(servers []string, isV6 bool) geoIP { continue } resp.Body.Close() - if err := ip.Unmarshal(body); err != nil { + newIP := geoIP{} + if err := newIP.Unmarshal(body); err != nil { continue } // 没取到 v6 IP - if isV6 && !strings.Contains(ip.IP, ":") { + if isV6 && !strings.Contains(newIP.IP, ":") { continue } // 没取到 v4 IP - if !isV6 && !strings.Contains(ip.IP, ".") { + if !isV6 && !strings.Contains(newIP.IP, ".") { continue } // 未获取到国家码 - if ip.CountryCode == "" { + if newIP.CountryCode == "" { continue } + ip = newIP return ip } }