From d6c23765de19e2f18d3135ec673264414c1c1326 Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Fri, 18 Aug 2023 16:01:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=8A=82=E7=82=B9=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E7=9B=91=E6=8E=A7=E4=B8=AD=E7=A3=81=E7=9B=98=E7=A9=BA?= =?UTF-8?q?=E9=97=B4=E5=8F=AF=E8=83=BD=E4=B8=BA0=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/nodes/node_status_executor.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/internal/nodes/node_status_executor.go b/internal/nodes/node_status_executor.go index 1c44a487..044af6bf 100644 --- a/internal/nodes/node_status_executor.go +++ b/internal/nodes/node_status_executor.go @@ -137,8 +137,8 @@ func (this *NodeStatusExecutor) updateDisk(status *nodeconfigs.NodeStatus) { }) // 当前TeaWeb所在的fs - rootFS := "" - rootTotal := uint64(0) + var rootFS = "" + var rootTotal = uint64(0) if lists.ContainsString([]string{"darwin", "linux", "freebsd"}, runtime.GOOS) { for _, p := range partitions { if p.Mountpoint == "/" { @@ -152,9 +152,9 @@ func (this *NodeStatusExecutor) updateDisk(status *nodeconfigs.NodeStatus) { } } - total := rootTotal - totalUsage := uint64(0) - maxUsage := float64(0) + var total = rootTotal + var totalUsage = uint64(0) + var maxUsage = float64(0) for _, partition := range partitions { if runtime.GOOS != "windows" && !strings.Contains(partition.Device, "/") && !strings.Contains(partition.Device, "\\") { continue @@ -180,6 +180,8 @@ func (this *NodeStatusExecutor) updateDisk(status *nodeconfigs.NodeStatus) { } } status.DiskTotal = total - status.DiskUsage = float64(totalUsage) / float64(total) + if total > 0 { + status.DiskUsage = float64(totalUsage) / float64(total) + } status.DiskMaxUsage = maxUsage / 100 }