|
|
|
@@ -881,6 +881,9 @@ func (m *ModelArtsLink) GetResourceSpecs(ctx context.Context) (*collector.Resour |
|
|
|
MoUsage := MoUsage{} |
|
|
|
var cpusum int64 = 0 |
|
|
|
var npusum int64 = 0 |
|
|
|
var RunningTaskNum int64 = 0 |
|
|
|
var BalanceValue float64 = -1 |
|
|
|
var RateValue float64 = 0.930000 |
|
|
|
for _, Flavors := range resp.Items { |
|
|
|
MoUsage.CpuSize, err = strconv.ParseInt(Flavors.Spec.Cpu, 10, 64) //CPU的值 |
|
|
|
if err != nil { |
|
|
|
@@ -914,6 +917,7 @@ func (m *ModelArtsLink) GetResourceSpecs(ctx context.Context) (*collector.Resour |
|
|
|
if TrainLists.Status.Phase == "Running" { |
|
|
|
CoreNum += TrainLists.Spec.Resource.FlavorDetail.FlavorInfo.Cpu.CoreNum |
|
|
|
NpuNum += TrainLists.Spec.Resource.FlavorDetail.FlavorInfo.Npu.UnitNum |
|
|
|
RunningTaskNum += 1 |
|
|
|
} |
|
|
|
} |
|
|
|
MoUsage.CpuAvailable = cpusum - int64(CoreNum) |
|
|
|
@@ -921,11 +925,17 @@ func (m *ModelArtsLink) GetResourceSpecs(ctx context.Context) (*collector.Resour |
|
|
|
|
|
|
|
UsageCPU := &collector.Usage{Type: strings.ToUpper(CPU), Total: &collector.UnitValue{Unit: CPUCORE, Value: cpusum}, Available: &collector.UnitValue{Unit: CPUCORE, Value: MoUsage.CpuAvailable}} |
|
|
|
UsageNPU := &collector.Usage{Type: strings.ToUpper(NPU), Name: ASCEND, Total: &collector.UnitValue{Unit: NUMBER, Value: npusum}, Available: &collector.UnitValue{Unit: NUMBER, Value: MoUsage.NpuAvailable}} |
|
|
|
RunningTask := &collector.Usage{Type: strings.ToUpper(RUNNINGTASK), Total: &collector.UnitValue{Unit: NUMBER, Value: RunningTaskNum}} |
|
|
|
Balance := &collector.Usage{Type: strings.ToUpper(BALANCE), Total: &collector.UnitValue{Unit: RMB, Value: BalanceValue}} |
|
|
|
Rate := &collector.Usage{Type: strings.ToUpper(RATE), Total: &collector.UnitValue{Unit: PERHOUR, Value: RateValue}} |
|
|
|
|
|
|
|
resUsage := &collector.ResourceSpec{ |
|
|
|
ClusterId: strconv.FormatInt(m.participantId, 10), |
|
|
|
} |
|
|
|
resUsage.Resources = append(resUsage.Resources, UsageCPU) |
|
|
|
resUsage.Resources = append(resUsage.Resources, UsageNPU) |
|
|
|
|
|
|
|
resUsage.Resources = append(resUsage.Resources, RunningTask) |
|
|
|
resUsage.Resources = append(resUsage.Resources, Balance) |
|
|
|
resUsage.Resources = append(resUsage.Resources, Rate) |
|
|
|
return resUsage, nil |
|
|
|
} |