fix clusterResouces bugs

Former-commit-id: 52c5b84d8957dd7f2529ce3dd5416ee7ffd9b07d
This commit is contained in:
tzwang 2024-06-06 19:08:51 +08:00
parent 83f8865dd2
commit ccbf2a00f1
4 changed files with 19 additions and 8 deletions

View File

@ -382,6 +382,10 @@ func UpdateClusterResource(svc *svc.ServiceContext) {
return
}
} else {
if stat.CpuCoreTotal == 0 || stat.MemTotal == 0 || stat.DiskTotal == 0 {
wg.Done()
return
}
clusterResource.CardTotal = cardTotal
clusterResource.CardTopsTotal = topsTotal
clusterResource.CpuAvail = float64(stat.CpuCoreAvail)

View File

@ -44,7 +44,7 @@ func AddCronGroup(svc *svc.ServiceContext) {
UpdateAiAdapterMaps(svc)
})
svc.Cron.AddFunc("30 21 * * *", func() {
svc.Cron.AddFunc("@every 7h30m", func() {
UpdateClusterResource(svc)
})
}

View File

@ -134,6 +134,10 @@ func (l *GetCenterOverviewLogic) updateClusterResource(mu *sync.RWMutex, ch chan
return
}
} else {
if stat.CpuCoreTotal == 0 || stat.MemTotal == 0 || stat.DiskTotal == 0 {
wg.Done()
return
}
clusterResource.CardTotal = cardTotal
clusterResource.CardTopsTotal = topsTotal
clusterResource.CpuAvail = float64(stat.CpuCoreAvail)

View File

@ -237,10 +237,13 @@ func (s *AiStorage) UpdateClusterResources(clusterResource *models.TClusterResou
ClusterName: clusterResource.ClusterName,
CpuAvail: clusterResource.CpuAvail,
CpuTotal: clusterResource.CpuTotal,
CpuUtilisation: clusterResource.CpuAvail / clusterResource.CpuTotal,
MemoryAvail: clusterResource.MemAvail,
MemoryTotal: clusterResource.MemTotal,
MemoryUtilisation: clusterResource.MemAvail / clusterResource.MemTotal,
DiskAvail: clusterResource.DiskAvail,
DiskTotal: clusterResource.DiskTotal,
DiskUtilisation: clusterResource.DiskAvail / clusterResource.DiskTotal,
}
tracker.SyncClusterLoad(param)
return nil