From 23fe8948cd3e87e4a4fbc758f31cb523056215b5 Mon Sep 17 00:00:00 2001 From: make123 Date: Thu, 8 Aug 2024 12:09:33 +0800 Subject: [PATCH] =?UTF-8?q?fix(dbm-services):=20=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E6=97=B6=EF=BC=8C=E8=A7=A3=E6=9E=90=E8=84=9A?= =?UTF-8?q?=E6=9C=AC=E8=BE=93=E5=87=BA=E5=BF=BD=E7=95=A5=E9=94=99=E8=AF=AF?= =?UTF-8?q?message=20#6135?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/db-resource/internal/svr/bk/disk.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/dbm-services/common/db-resource/internal/svr/bk/disk.go b/dbm-services/common/db-resource/internal/svr/bk/disk.go index 3268790127..f6ffe33f89 100644 --- a/dbm-services/common/db-resource/internal/svr/bk/disk.go +++ b/dbm-services/common/db-resource/internal/svr/bk/disk.go @@ -15,6 +15,7 @@ import ( "encoding/json" "fmt" "maps" + "regexp" "time" "dbm-services/common/go-pubpkg/cmutil" @@ -156,6 +157,7 @@ func GetDiskInfo(hosts []IPList, bk_biz_id int, hostOsMap map[string]string) (re } ipLogContentMap := make(map[string]*ShellResCollection) ipFailedLogMap := make(map[string]string) + jsonRe := regexp.MustCompile("{*.*}") for os_type, ipList := range ipListOsMap { if len(ipList) == 0 { continue @@ -169,7 +171,9 @@ func GetDiskInfo(hosts []IPList, bk_biz_id int, hostOsMap map[string]string) (re maps.Copy(ipFailedLogMap, ipFailedLogMapWin) for _, d := range ipLogs.ScriptTaskLogs { var dl PowerShellResCollection - if err = json.Unmarshal([]byte(d.LogContent), &dl); err != nil { + jsonBody := jsonRe.FindString(d.LogContent) + logger.Info("%s shell grab json body: %s", d.Ip, jsonBody) + if err = json.Unmarshal([]byte(jsonBody), &dl); err != nil { logger.Error("unmarshal log content failed %s", err.Error()) continue } @@ -187,7 +191,9 @@ func GetDiskInfo(hosts []IPList, bk_biz_id int, hostOsMap map[string]string) (re maps.Copy(ipFailedLogMap, ipFailedLogMapLiunx) for _, d := range ipLogs.ScriptTaskLogs { var dl ShellResCollection - if err = json.Unmarshal([]byte(d.LogContent), &dl); err != nil { + jsonBody := jsonRe.FindString(d.LogContent) + logger.Info("%s shell grab json body: %s", d.Ip, jsonBody) + if err = json.Unmarshal([]byte(jsonBody), &dl); err != nil { logger.Error("unmarshal log content failed %s", err.Error()) continue }