Browse Source

feat: 增加 Intel Arc 显卡 适配 (#6435)

pull/6437/head
zhengkunwang 2 months ago committed by GitHub
parent
commit
7cdcf9b757
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 11
      backend/app/dto/dashboard.go
  2. 17
      backend/app/service/dashboard.go
  3. 4
      backend/utils/xpack/xpack.go
  4. 11
      frontend/src/api/interface/dashboard.ts
  5. 1
      frontend/src/views/home/index.vue
  6. 56
      frontend/src/views/home/status/index.vue

11
backend/app/dto/dashboard.go

@ -73,6 +73,7 @@ type DashboardCurrent struct {
NetBytesRecv uint64 `json:"netBytesRecv"`
GPUData []GPUInfo `json:"gpuData"`
XPUData []XPUInfo `json:"xpuData"`
ShotTime time.Time `json:"shotTime"`
}
@ -106,3 +107,13 @@ type GPUInfo struct {
MemTotal string `json:"memTotal"`
FanSpeed string `json:"fanSpeed"`
}
type XPUInfo struct {
DeviceID int `json:"deviceID"`
DeviceName string `json:"deviceName"`
Memory string `json:"memory"`
Temperature string `json:"temperature"`
MemoryUsed string `json:"memoryUsed"`
Power string `json:"power"`
MemoryUtil string `json:"memoryUtil"`
}

17
backend/app/service/dashboard.go

@ -178,6 +178,7 @@ func (u *DashboardService) LoadCurrentInfo(ioOption string, netOption string) *d
currentInfo.DiskData = loadDiskInfo()
currentInfo.GPUData = loadGPUInfo()
currentInfo.XPUData = loadXpuInfo()
if ioOption == "all" {
diskInfo, _ := disk.IOCounters()
@ -346,3 +347,19 @@ func loadGPUInfo() []dto.GPUInfo {
}
return data
}
func loadXpuInfo() []dto.XPUInfo {
list := xpack.LoadXpuInfo()
if len(list) == 0 {
return nil
}
var data []dto.XPUInfo
for _, gpu := range list {
var dataItem dto.XPUInfo
if err := copier.Copy(&dataItem, &gpu); err != nil {
continue
}
data = append(data, dataItem)
}
return data
}

4
backend/utils/xpack/xpack.go

@ -32,6 +32,10 @@ func LoadGpuInfo() []interface{} {
return nil
}
func LoadXpuInfo() []interface{} {
return nil
}
func StartClam(startClam model.Clam, isUpdate bool) (int, error) {
return 0, buserr.New(constant.ErrXpackNotFound)
}

11
frontend/src/api/interface/dashboard.ts

@ -64,6 +64,7 @@ export namespace Dashboard {
diskData: Array<DiskInfo>;
gpuData: Array<GPUInfo>;
xpuData: Array<XPUInfo>;
netBytesSent: number;
netBytesRecv: number;
@ -94,4 +95,14 @@ export namespace Dashboard {
memoryUsage: string;
fanSpeed: string;
}
export interface XPUInfo {
deviceID: number;
deviceName: string;
memory: string;
temperature: string;
memoryUsed: string;
power: string;
memoryUtil: string;
}
}

1
frontend/src/views/home/index.vue

@ -364,6 +364,7 @@ const currentInfo = ref<Dashboard.CurrentInfo>({
diskData: [],
gpuData: [],
xpuData: [],
netBytesSent: 0,
netBytesRecv: 0,

56
frontend/src/views/home/status/index.vue

@ -222,6 +222,51 @@
<span class="input-help" v-else>{{ item.productName }}</span>
</el-col>
</template>
<template v-for="(item, index) of currentInfo.xpuData" :key="index">
<el-col
:xs="12"
:sm="12"
:md="6"
:lg="6"
:xl="6"
align="center"
v-if="showMore || index < 4 - currentInfo.diskData.length"
>
<el-popover placement="bottom" :width="250" trigger="hover" v-if="chartsOption[`gpu${index}`]">
<el-row :gutter="5">
<el-tag style="font-weight: 500">{{ $t('home.baseInfo') }}:</el-tag>
</el-row>
<el-row :gutter="5">
<el-tag class="tagClass">{{ $t('monitor.gpuUtil') }}: {{ item.memoryUtil }}</el-tag>
</el-row>
<el-row :gutter="5">
<el-tag class="tagClass">{{ $t('monitor.temperature') }}: {{ item.temperature }}</el-tag>
</el-row>
<el-row :gutter="5">
<el-tag class="tagClass">{{ $t('monitor.powerUsage') }}: {{ item.power }}</el-tag>
</el-row>
<el-row :gutter="5">
<el-tag class="tagClass">
{{ $t('monitor.memoryUsage') }}: {{ item.memoryUsed }}/{{ item.memory }}
</el-tag>
</el-row>
<template #reference>
<v-charts
@click="goGPU()"
height="160px"
:id="`gpu${index}`"
type="pie"
:option="chartsOption[`gpu${index}`]"
v-if="chartsOption[`gpu${index}`]"
/>
</template>
</el-popover>
<el-tooltip :content="item.deviceName" v-if="item.deviceName.length > 25">
<span class="input-help">{{ item.deviceName.substring(0, 22) }}...</span>
</el-tooltip>
<span class="input-help" v-else>{{ item.deviceName }}</span>
</el-col>
</template>
<el-col :xs="12" :sm="12" :md="6" :lg="6" :xl="6" align="center">
<el-button v-if="!showMore" link type="primary" @click="showMore = true" class="buttonClass">
{{ $t('tabs.more') }}
@ -268,6 +313,9 @@ const baseInfo = ref<Dashboard.BaseInfo>({
cpuLogicalCores: 0,
cpuModelName: '',
currentInfo: null,
ipv4Addr: '',
systemProxy: '',
});
const currentInfo = ref<Dashboard.CurrentInfo>({
uptime: 0,
@ -301,6 +349,7 @@ const currentInfo = ref<Dashboard.CurrentInfo>({
diskData: [],
gpuData: [],
xpuData: [],
netBytesSent: 0,
netBytesRecv: 0,
@ -346,6 +395,13 @@ const acceptParams = (current: Dashboard.CurrentInfo, base: Dashboard.BaseInfo,
if (currentInfo.value.diskData.length + currentInfo.value.gpuData.length > 5) {
showMore.value = isInit ? false : showMore.value || false;
}
currentInfo.value.xpuData = currentInfo.value.xpuData || [];
for (let i = 0; i < currentInfo.value.xpuData.length; i++) {
chartsOption.value['gpu' + i] = {
title: 'GPU-' + currentInfo.value.xpuData[i].deviceID,
data: formatNumber(Number(currentInfo.value.xpuData[i].memoryUtil.replaceAll('%', ''))),
};
}
});
};

Loading…
Cancel
Save