Commit 5c2b377e authored by luxq's avatar luxq

update worker info and test

parent 53d9845c
...@@ -95,28 +95,12 @@ func (d *dbWorker) UpdateNodeInfo(ctx context.Context, id string, nodeInfo *type ...@@ -95,28 +95,12 @@ func (d *dbWorker) UpdateNodeInfo(ctx context.Context, id string, nodeInfo *type
return err return err
} }
func (d *dbWorker) FindWorkerByInstalledModelId(ctx context.Context, modelId string) ([]*DbWorkerInfo, error) { func (d *dbWorker) FindWorkerByRunningModelAndSortByWaitTime(ctx context.Context, modelId string, limit int) ([]*DbWorkerInfo, error) {
// find all worker that at least one installed model's mode_id is equal modelId
selector := bson.M{"model_infos.installed_models.model_id": modelId}
cursor, err := d.col.Find(ctx, selector)
if err != nil {
return nil, err
}
defer cursor.Close(ctx)
var workers []*DbWorkerInfo
if err = cursor.All(ctx, &workers); err != nil {
return nil, err
}
return workers, nil
}
func (d *dbWorker) FindWorkerByRunningModelIdWithLimit(ctx context.Context, modelId string, limit int64) ([]*DbWorkerInfo, error) {
// find all worker that at least one running model's mode_id is equal modelId // find all worker that at least one running model's mode_id is equal modelId
// sort by wait time
findOptions := options.Find() findOptions := options.Find()
findOptions.SetLimit(limit) findOptions.SetLimit(int64(limit))
findOptions.SetSort(bson.D{{"hardware.gpu.usage", 1}}) findOptions.SetSort(bson.D{{"model_infos.running_models.wait_time", 1}})
selector := bson.M{"model_infos.running_models.model_id": modelId} selector := bson.M{"model_infos.running_models.model_id": modelId}
cursor, err := d.col.Find(ctx, selector, findOptions) cursor, err := d.col.Find(ctx, selector, findOptions)
...@@ -132,27 +116,15 @@ func (d *dbWorker) FindWorkerByRunningModelIdWithLimit(ctx context.Context, mode ...@@ -132,27 +116,15 @@ func (d *dbWorker) FindWorkerByRunningModelIdWithLimit(ctx context.Context, mode
return workers, nil return workers, nil
} }
func (d *dbWorker) FindWorkerByRunningModelId(ctx context.Context, modelId string) ([]*DbWorkerInfo, error) { func (d *dbWorker) FindWorkerByInstallModelAndSortByGpuRam(ctx context.Context, modelId string, performance int, ram int, limit int) ([]*DbWorkerInfo, error) {
// find all worker that at least one running model's mode_id is equal modelId // find all worker that at least one installed model's mode_id is equal modelId
selector := bson.M{"model_infos.running_models.model_id": modelId} // sort by gpu ram
cursor, err := d.col.Find(ctx, selector) findOptions := options.Find()
if err != nil { findOptions.SetLimit(int64(limit))
return nil, err findOptions.SetSort(bson.D{{"hardware.gpu.ram", 1}})
}
defer cursor.Close(ctx)
var workers []*DbWorkerInfo
if err = cursor.All(ctx, &workers); err != nil {
return nil, err
}
return workers, nil
}
func (d *dbWorker) FindWorkerByGpuModel(ctx context.Context, model string) ([]*DbWorkerInfo, error) {
// find all worker that at least one gpu model is equal model.
selector := bson.M{"hardware.gpu.model": model}
cursor, err := d.col.Find(ctx, selector) selector := bson.M{"model_infos.installed_models.model_id": modelId, "hardware.gpu.performance": bson.M{"$gte": performance}, "hardware.gpu.ram": bson.M{"$gte": ram}}
cursor, err := d.col.Find(ctx, selector, findOptions)
if err != nil { if err != nil {
return nil, err return nil, err
} }
...@@ -163,21 +135,5 @@ func (d *dbWorker) FindWorkerByGpuModel(ctx context.Context, model string) ([]*D ...@@ -163,21 +135,5 @@ func (d *dbWorker) FindWorkerByGpuModel(ctx context.Context, model string) ([]*D
return nil, err return nil, err
} }
return workers, nil return workers, nil
}
func (d *dbWorker) FindWorkerByGpuRam(ctx context.Context, ram uint) ([]*DbWorkerInfo, error) {
// find all worker that at least one gpu ram is greater or equal than ram.
selector := bson.M{"hardware.gpu.ram": bson.M{"$gte": ram}}
cursor, err := d.col.Find(ctx, selector)
if err != nil {
return nil, err
}
defer cursor.Close(ctx)
var workers []*DbWorkerInfo
if err = cursor.All(ctx, &workers); err != nil {
return nil, err
}
return workers, nil
} }
...@@ -63,7 +63,7 @@ func generateAWroker() *DbWorkerInfo { ...@@ -63,7 +63,7 @@ func generateAWroker() *DbWorkerInfo {
return &DbWorkerInfo{ return &DbWorkerInfo{
WorkerId: uuid.NewString(), WorkerId: uuid.NewString(),
NodeInfo: generateANodeInfo(), NodeInfo: generateANodeInfo(),
Models: generateAmodel(), Models: generateAModel(),
Hardware: generateAHardware(), Hardware: generateAHardware(),
} }
} }
...@@ -85,28 +85,38 @@ func generateANodeInfo() *types.NodeInfo { ...@@ -85,28 +85,38 @@ func generateANodeInfo() *types.NodeInfo {
func generateACpu() *types.CpuInfo { func generateACpu() *types.CpuInfo {
return &types.CpuInfo{ return &types.CpuInfo{
Model: "Intel i9", Model: "Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz",
Core: 8, Number: 1,
Usage: uint(rand.Intn(50) + 30), Cores: 8,
Threads: 16,
Usage: int(rand.Intn(30) + 40),
} }
} }
func generateADisk() *types.DiskInfo { func generateADisk() *types.DiskInfo {
return &types.DiskInfo{ return &types.DiskInfo{
Size: 1024, Total: 1024 * 1024 * 1024,
Usage: uint(rand.Intn(100) + 100), Free: 100 * 1024 * 1024,
}
}
func generateANet() *types.NetInfo {
return &types.NetInfo{
IP: fmt.Sprintf("192.168.1.%d", rand.Intn(255)),
Mac: fmt.Sprintf("%02x:%02x:%02x:%02x:%02x:%02x", 1, 2, 3, 4, 5, 6),
Bandwidth: rand.Intn(30) + 60,
} }
} }
func generateARam() *types.RamInfo { func generateARam() *types.RamInfo {
return &types.RamInfo{ return &types.RamInfo{
Size: 8 * (1 << 30), Total: 32 * 1024 * 1024 * 1024,
Usage: uint(rand.Intn(30) + 40), Free: rand.Intn(10) * 1024 * 1024 * 1024,
} }
} }
func generateAGpuRam() uint { func generateAGpuRam() int {
return uint(rand.Intn(3)*8 + 8) // 8, 16, 24 return 1024 * 1024 * 1024 * (rand.Intn(3)*8 + 8) // 8, 16, 24
} }
func generateAGpuModel() string { func generateAGpuModel() string {
...@@ -114,61 +124,88 @@ func generateAGpuModel() string { ...@@ -114,61 +124,88 @@ func generateAGpuModel() string {
return fmt.Sprintf("Nvidia %d", m) return fmt.Sprintf("Nvidia %d", m)
} }
func generateAIdleGpu() *types.GpuInfo { func generateAGpuPerformance() int {
return rand.Intn(100) + 500
}
func generateAIdleGpu(seq int) *types.GpuInfo {
ram := generateAGpuRam()
return &types.GpuInfo{ return &types.GpuInfo{
Model: generateAGpuModel(), Seq: seq,
Ram: generateAGpuRam(), UUID: uuid.NewString(),
Model: generateAGpuModel(),
Performance: generateAGpuPerformance(),
PowerRating: 100,
MemTotal: ram,
MemFree: ram,
Usage: 0,
Temp: 40,
PowerRt: 30,
} }
} }
func generateAUsageGpu() *types.GpuInfo { func generateAUsageGpu(seq int) *types.GpuInfo {
ram := generateAGpuRam() ram := generateAGpuRam()
return &types.GpuInfo{ return &types.GpuInfo{
Model: generateAGpuModel(), Seq: seq,
Ram: ram, UUID: uuid.NewString(),
Usage: uint(rand.Intn(10) + 30), Model: generateAGpuModel(),
Occupy: ram * 10 / 7, Performance: generateAGpuPerformance(),
Temp: 60, PowerRating: 100,
MemTotal: ram,
MemFree: ram * (rand.Intn(3) + 3) / 10,
Usage: rand.Intn(20) + 70,
Temp: 40,
PowerRt: 30,
} }
} }
func generateAHardware() *types.HardwareInfo { func generateAHardware() *types.HardwareInfo {
return &types.HardwareInfo{ return &types.HardwareInfo{
Cpu: []*types.CpuInfo{ CPU: generateACpu(),
generateACpu(), GPU: []*types.GpuInfo{
generateAIdleGpu(0),
generateAIdleGpu(1),
generateAUsageGpu(2),
}, },
Gpu: []*types.GpuInfo{ RAM: generateARam(),
generateAIdleGpu(), DISK: generateADisk(),
generateAUsageGpu(), NET: generateANet(),
},
Ram: generateARam(),
Disk: generateADisk(),
} }
} }
func generateAmodel() *types.ModelInfo { func generateAInstallModel() *types.InstalledModel {
return &types.InstalledModel{
ModelID: getRandId(100),
DiskSize: 101,
InstalledTime: time.Now().Unix(),
LastRunTime: time.Now().Unix(),
}
}
func generateARunningModel() *types.RunningModel {
return &types.RunningModel{
ModelID: getRandId(100),
GpuSeq: rand.Intn(3),
GpuRAM: generateAGpuRam(),
StartedTime: time.Now().Unix(),
LastWorkTime: time.Now().Unix(),
TotalRunCount: rand.Intn(100),
WaitTime: rand.Intn(100),
}
}
func generateAModel() *types.ModelInfo {
return &types.ModelInfo{ return &types.ModelInfo{
InstalledModels: []*types.InstalledModelInfo{ InstalledModels: []*types.InstalledModel{
&types.InstalledModelInfo{ generateAInstallModel(),
ModelId: getRandId(100), generateAInstallModel(),
DiskSize: 101, generateAInstallModel(),
},
&types.InstalledModelInfo{
ModelId: getRandId(100),
DiskSize: 44,
},
}, },
RunningModels: []*types.RunningModelInfo{ RunningModels: []*types.RunningModel{
&types.RunningModelInfo{ generateARunningModel(),
ModelId: getRandId(100),
StartedTime: uint64((time.Now().Add(-time.Hour)).Unix()),
LatestTime: uint64(time.Now().Add(-time.Minute * 20).Unix()),
RunCount: 101,
GpuRamUsed: uint64(rand.Intn(20) + 10),
},
}, },
} }
} }
func BenchmarkGenerateWorker(b *testing.B) { func BenchmarkGenerateWorker(b *testing.B) {
...@@ -264,7 +301,7 @@ func BenchmarkDbWorker_UpdateModel(b *testing.B) { ...@@ -264,7 +301,7 @@ func BenchmarkDbWorker_UpdateModel(b *testing.B) {
defer db.client.Disconnect(context.Background()) defer db.client.Disconnect(context.Background())
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
idx := rand.Intn(len(idlist)) idx := rand.Intn(len(idlist))
nresource := generateAmodel() nresource := generateAModel()
if err := db.UpdateModel(context.Background(), idlist[idx], nresource); err != nil { if err := db.UpdateModel(context.Background(), idlist[idx], nresource); err != nil {
panic(fmt.Sprintf("update worker failed with err:%s", err)) panic(fmt.Sprintf("update worker failed with err:%s", err))
} }
...@@ -282,7 +319,7 @@ func BenchmarkDbWorker_UpdateModel_Parallel(b *testing.B) { ...@@ -282,7 +319,7 @@ func BenchmarkDbWorker_UpdateModel_Parallel(b *testing.B) {
b.RunParallel(func(pb *testing.PB) { b.RunParallel(func(pb *testing.PB) {
for pb.Next() { for pb.Next() {
idx := rand.Intn(len(idlist)) idx := rand.Intn(len(idlist))
nresource := generateAmodel() nresource := generateAModel()
if err := db.UpdateModel(context.Background(), idlist[idx], nresource); err != nil { if err := db.UpdateModel(context.Background(), idlist[idx], nresource); err != nil {
panic(fmt.Sprintf("update worker failed with err:%s", err)) panic(fmt.Sprintf("update worker failed with err:%s", err))
} }
...@@ -326,81 +363,7 @@ func BenchmarkDbWorker_UpdateNodeInfo_Parallel(b *testing.B) { ...@@ -326,81 +363,7 @@ func BenchmarkDbWorker_UpdateNodeInfo_Parallel(b *testing.B) {
}) })
} }
func BenchmarkDbWorker_FindWorkerByRunningModelId(b *testing.B) { func BenchmarkDbWorker_FindWorkerByInstallModelAndSortByGpuRam(b *testing.B) {
client, err := ConnectMongoDB("mongodb://localhost:27017")
if err != nil {
log.Fatal(err)
}
db := NewDBWorker(client, database, collection)
defer db.client.Disconnect(context.Background())
b.ResetTimer()
for i := 0; i < b.N; i++ {
runningModelId := getRandId(100)
if w, err := db.FindWorkerByRunningModelId(context.Background(), runningModelId); err != nil {
panic(fmt.Sprintf("find worker failed with err:%s", err))
} else if len(w) == 0 {
b.Logf("FindWorkerByRunningModelId find %d with id %s\n", len(w), runningModelId)
}
}
}
func BenchmarkDbWorker_FindWorkerByRunningModelId_Parallel(b *testing.B) {
client, err := ConnectMongoDB("mongodb://localhost:27017")
if err != nil {
log.Fatal(err)
}
db := NewDBWorker(client, database, collection)
defer db.client.Disconnect(context.Background())
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
runningModelId := getRandId(100)
if w, err := db.FindWorkerByRunningModelId(context.Background(), runningModelId); err != nil {
panic(fmt.Sprintf("find worker failed with err:%s", err))
} else if len(w) == 0 {
b.Logf("FindWorkerByRunningModelId find %d with id %s\n", len(w), runningModelId)
}
}
})
}
func BenchmarkDbWorker_FindWorkerByRunningModelIdWithLimit(b *testing.B) {
client, err := ConnectMongoDB("mongodb://localhost:27017")
if err != nil {
log.Fatal(err)
}
db := NewDBWorker(client, database, collection)
defer db.client.Disconnect(context.Background())
b.ResetTimer()
for i := 0; i < b.N; i++ {
runningModelId := getRandId(100)
if w, err := db.FindWorkerByRunningModelIdWithLimit(context.Background(), runningModelId, 10); err != nil {
panic(fmt.Sprintf("find worker failed with err:%s", err))
} else if len(w) == 0 {
b.Logf("FindWorkerByRunningModelId find %d with id %s\n", len(w), runningModelId)
}
}
}
func BenchmarkDbWorker_FindWorkerByRunningModelIdWithLimit_Parallel(b *testing.B) {
client, err := ConnectMongoDB("mongodb://localhost:27017")
if err != nil {
log.Fatal(err)
}
db := NewDBWorker(client, database, collection)
defer db.client.Disconnect(context.Background())
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
runningModelId := getRandId(100)
if w, err := db.FindWorkerByRunningModelIdWithLimit(context.Background(), runningModelId, 10); err != nil {
panic(fmt.Sprintf("find worker failed with err:%s", err))
} else if len(w) == 0 {
b.Logf("FindWorkerByRunningModelId find %d with id %s\n", len(w), runningModelId)
}
}
})
}
func BenchmarkDbWorker_FindWorkerByInstalledModelId(b *testing.B) {
client, err := ConnectMongoDB("mongodb://localhost:27017") client, err := ConnectMongoDB("mongodb://localhost:27017")
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
...@@ -410,15 +373,17 @@ func BenchmarkDbWorker_FindWorkerByInstalledModelId(b *testing.B) { ...@@ -410,15 +373,17 @@ func BenchmarkDbWorker_FindWorkerByInstalledModelId(b *testing.B) {
b.ResetTimer() b.ResetTimer()
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
installedModelId := getRandId(100) installedModelId := getRandId(100)
if w, err := db.FindWorkerByInstalledModelId(context.Background(), installedModelId); err != nil { performance := generateAGpuPerformance()
ram := generateAGpuRam()
if w, err := db.FindWorkerByInstallModelAndSortByGpuRam(context.Background(), installedModelId, performance, ram, 10); err != nil {
panic(fmt.Sprintf("find worker failed with err:%s", err)) panic(fmt.Sprintf("find worker failed with err:%s", err))
} else if len(w) == 0 { } else if len(w) == 0 {
b.Logf("FindWorkerByInstalledModelId find %d with id %s\n", len(w), installedModelId) b.Logf("FindWorkerByInstallModelAndSortByGpuRam find %d with id %s\n", len(w), installedModelId)
} }
} }
} }
func BenchmarkDbWorker_FindWorkerByInstalledModelId_Parallel(b *testing.B) { func BenchmarkDbWorker_FindWorkerByInstallModelAndSortByGpuRam_Parallel(b *testing.B) {
client, err := ConnectMongoDB("mongodb://localhost:27017") client, err := ConnectMongoDB("mongodb://localhost:27017")
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
...@@ -428,16 +393,18 @@ func BenchmarkDbWorker_FindWorkerByInstalledModelId_Parallel(b *testing.B) { ...@@ -428,16 +393,18 @@ func BenchmarkDbWorker_FindWorkerByInstalledModelId_Parallel(b *testing.B) {
b.RunParallel(func(pb *testing.PB) { b.RunParallel(func(pb *testing.PB) {
for pb.Next() { for pb.Next() {
installedModelId := getRandId(100) installedModelId := getRandId(100)
if w, err := db.FindWorkerByInstalledModelId(context.Background(), installedModelId); err != nil { performance := generateAGpuPerformance()
ram := generateAGpuRam()
if w, err := db.FindWorkerByInstallModelAndSortByGpuRam(context.Background(), installedModelId, performance, ram, 10); err != nil {
panic(fmt.Sprintf("find worker failed with err:%s", err)) panic(fmt.Sprintf("find worker failed with err:%s", err))
} else if len(w) == 0 { } else if len(w) == 0 {
b.Logf("FindWorkerByInstalledModelId find %d with id %s\n", len(w), installedModelId) b.Logf("FindWorkerByInstallModelAndSortByGpuRam find %d with id %s\n", len(w), installedModelId)
} }
} }
}) })
} }
func BenchmarkDbWorker_FindWorkerByGpuRam(b *testing.B) { func BenchmarkDbWorker_FindWorkerByRunningModelAndSortByWaitTime(b *testing.B) {
client, err := ConnectMongoDB("mongodb://localhost:27017") client, err := ConnectMongoDB("mongodb://localhost:27017")
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
...@@ -446,16 +413,16 @@ func BenchmarkDbWorker_FindWorkerByGpuRam(b *testing.B) { ...@@ -446,16 +413,16 @@ func BenchmarkDbWorker_FindWorkerByGpuRam(b *testing.B) {
defer db.client.Disconnect(context.Background()) defer db.client.Disconnect(context.Background())
b.ResetTimer() b.ResetTimer()
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
ram := generateAGpuRam() runningModelId := getRandId(100)
if w, err := db.FindWorkerByGpuRam(context.Background(), ram); err != nil { if w, err := db.FindWorkerByRunningModelAndSortByWaitTime(context.Background(), runningModelId, 10); err != nil {
panic(fmt.Sprintf("find worker failed with err:%s", err)) panic(fmt.Sprintf("find worker failed with err:%s", err))
} else if len(w) == 0 { } else if len(w) == 0 {
b.Logf("FindWorkerByGpuRam find %d with ram %d\n", len(w), ram) b.Logf("FindWorkerByRunningModelAndSortByWaitTime find %d with id %s\n", len(w), runningModelId)
} }
} }
} }
func BenchmarkDbWorker_FindWorkerByGpuRam_Parallel(b *testing.B) { func BenchmarkDbWorker_FindWorkerByRunningModelAndSortByWaitTime_Parallel(b *testing.B) {
client, err := ConnectMongoDB("mongodb://localhost:27017") client, err := ConnectMongoDB("mongodb://localhost:27017")
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
...@@ -464,11 +431,11 @@ func BenchmarkDbWorker_FindWorkerByGpuRam_Parallel(b *testing.B) { ...@@ -464,11 +431,11 @@ func BenchmarkDbWorker_FindWorkerByGpuRam_Parallel(b *testing.B) {
defer db.client.Disconnect(context.Background()) defer db.client.Disconnect(context.Background())
b.RunParallel(func(pb *testing.PB) { b.RunParallel(func(pb *testing.PB) {
for pb.Next() { for pb.Next() {
ram := generateAGpuRam() runningModelId := getRandId(100)
if w, err := db.FindWorkerByGpuRam(context.Background(), ram); err != nil { if w, err := db.FindWorkerByRunningModelAndSortByWaitTime(context.Background(), runningModelId, 10); err != nil {
panic(fmt.Sprintf("find worker failed with err:%s", err)) panic(fmt.Sprintf("find worker failed with err:%s", err))
} else if len(w) == 0 { } else if len(w) == 0 {
b.Logf("FindWorkerByGpuRam find %d with ram %d\n", len(w), ram) b.Logf("FindWorkerByRunningModelAndSortByWaitTime find %d with id %s\n", len(w), runningModelId)
} }
} }
}) })
......
...@@ -6,65 +6,71 @@ type NodeInfo struct { ...@@ -6,65 +6,71 @@ type NodeInfo struct {
DeviceIp string `bson:"device_ip" json:"device_ip"` DeviceIp string `bson:"device_ip" json:"device_ip"`
} }
type InstalledModelInfo struct { type InstalledModel struct {
ModelId string `bson:"model_id" json:"model_id"` ModelID string `bson:"model_id" json:"model_id"`
DiskSize uint64 `bson:"disk_size" json:"disk_size"` DiskSize int `bson:"disk_size" json:"disk_size"`
InstalledTime int64 `bson:"installed_time" json:"installed_time"`
LastRunTime int64 `bson:"last_run_time" json:"last_run_time"`
} }
type RunningModelInfo struct { type RunningModel struct {
ModelId string `bson:"model_id" json:"model_id"` ModelID string `bson:"model_id" json:"model_id"`
StartedTime uint64 `bson:"started_time" json:"started_time"` GpuSeq int `bson:"gpu_seq" json:"gpu_seq"`
LatestTime uint64 `bson:"latest_time" json:"latest_time"` GpuRAM int `bson:"gpu_ram" json:"gpu_ram"`
RunCount uint64 `bson:"run_count" json:"run_count"` StartedTime int64 `bson:"started_time" json:"started_time"`
GpuRamUsed uint64 `bson:"gpu_ram" json:"gpu_ram"` LastWorkTime int64 `bson:"last_work_time" json:"last_work_time"`
TotalRunCount int `bson:"total_run_count" json:"total_run_count"`
WaitTime int `bson:"wait_time" json:"wait_time"`
} }
type ModelInfo struct { type ModelInfo struct {
InstalledModels []*InstalledModelInfo `bson:"installed_models" json:"installed_models"` InstalledModels []*InstalledModel `bson:"installed_models" json:"installed_models"`
RunningModels []*RunningModelInfo `bson:"running_models" json:"running_models"` RunningModels []*RunningModel `bson:"running_models" json:"running_models"`
}
type DeviceInfo struct {
DeviceType string `bson:"device_type" json:"device_type"`
DeviceModel string `bson:"device_model" json:"device_model"`
DeviceParam string `bson:"device_param" json:"device_param"`
DevicePower uint64 `bson:"device_power" json:"device_power"`
} }
type DeviceUsage struct { type HardwareInfo struct {
DeviceType string `bson:"device_type" json:"device_type"` CPU *CpuInfo `bson:"CPU" json:"CPU"`
DeviceUsage uint64 `bson:"device_usage" json:"device_usage"` GPU []*GpuInfo `bson:"GPU" json:"GPU"`
RAM *RamInfo `bson:"RAM" json:"RAM"`
DISK *DiskInfo `bson:"DISK" json:"DISK"`
NET *NetInfo `bson:"NET" json:"NET"`
} }
type CpuInfo struct { type CpuInfo struct {
Model string `bson:"model" json:"model"` Model string `bson:"model" json:"model "`
Core uint `bson:"core" json:"core"` Number int `bson:"number" json:"number"`
Usage uint `bson:"usage" json:"usage"` Cores int `bson:"cores" json:"cores"`
Threads int `bson:"threads" json:"threads"`
Usage int `bson:"usage" json:"usage"`
} }
type GpuInfo struct { type GpuInfo struct {
Model string `bson:"model" json:"model"` Seq int `bson:"seq" json:"seq"`
Ram uint `bson:"ram" json:"ram"` UUID string `bson:"uuid" json:"uuid"`
Usage uint `bson:"usage" json:"usage"` Model string `bson:"model" json:"model "`
Occupy uint `bson:"occupy" json:"occupy"` Performance int `bson:"performance" json:"performance"`
Temp uint `bson:"temp" json:"temp"` PowerRating int `bson:"power_rating" json:"power_rating"`
MemTotal int `bson:"mem_total" json:"mem_total"`
MemFree int `bson:"mem_free" json:"mem_free"`
Usage int `bson:"usage" json:"usage"`
Temp int `bson:"temp" json:"temp "`
PowerRt int `bson:"power_rt" json:"power_rt"`
} }
type RamInfo struct { type RamInfo struct {
Size uint `bson:"size" json:"size"` Total int `bson:"total" json:"total"`
Usage uint `bson:"usage" json:"usage"` Free int `bson:"free" json:"free"`
} }
type DiskInfo struct { type DiskInfo struct {
Size uint `bson:"size" json:"size"` Total int `bson:"total" json:"total"`
Usage uint `bson:"usage" json:"usage"` Free int `bson:"free" json:"free"`
} }
type HardwareInfo struct { type NetInfo struct {
Cpu []*CpuInfo `bson:"cpu" json:"cpu"` IP string `bson:"ip" json:"ip"`
Gpu []*GpuInfo `bson:"gpu" json:"gpu"` Mac string `bson:"mac" json:"mac"`
Ram *RamInfo `bson:"ram" json:"ram"` Bandwidth int `bson:"bandwidth" json:"bandwidth"`
Disk *DiskInfo `bson:"disk" json:"disk"`
} }
type WorkerInfo struct { type WorkerInfo struct {
...@@ -73,3 +79,8 @@ type WorkerInfo struct { ...@@ -73,3 +79,8 @@ type WorkerInfo struct {
ModelInofs *ModelInfo `bson:"model_infos" json:"model_infos"` ModelInofs *ModelInfo `bson:"model_infos" json:"model_infos"`
Hardware *HardwareInfo `bson:"hardware" json:"hardware"` Hardware *HardwareInfo `bson:"hardware" json:"hardware"`
} }
type WorkerModelInfo struct {
WorkerId string `bson:"worker_id" json:"worker_id"`
ModelId string `bson:"model_id" json:"model_id"`
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment