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

This commit is contained in:
zhengkunwang 2024-09-10 18:55:29 +08:00 committed by GitHub
parent ef0bb12fbd
commit 7cdcf9b757
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 100 additions and 0 deletions

View File

@ -73,6 +73,7 @@ type DashboardCurrent struct {
NetBytesRecv uint64 `json:"netBytesRecv"` NetBytesRecv uint64 `json:"netBytesRecv"`
GPUData []GPUInfo `json:"gpuData"` GPUData []GPUInfo `json:"gpuData"`
XPUData []XPUInfo `json:"xpuData"`
ShotTime time.Time `json:"shotTime"` ShotTime time.Time `json:"shotTime"`
} }
@ -106,3 +107,13 @@ type GPUInfo struct {
MemTotal string `json:"memTotal"` MemTotal string `json:"memTotal"`
FanSpeed string `json:"fanSpeed"` 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"`
}

View File

@ -178,6 +178,7 @@ func (u *DashboardService) LoadCurrentInfo(ioOption string, netOption string) *d
currentInfo.DiskData = loadDiskInfo() currentInfo.DiskData = loadDiskInfo()
currentInfo.GPUData = loadGPUInfo() currentInfo.GPUData = loadGPUInfo()
currentInfo.XPUData = loadXpuInfo()
if ioOption == "all" { if ioOption == "all" {
diskInfo, _ := disk.IOCounters() diskInfo, _ := disk.IOCounters()
@ -346,3 +347,19 @@ func loadGPUInfo() []dto.GPUInfo {
} }
return data 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
}

View File

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

View File

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

View File

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

View File

@ -222,6 +222,51 @@
<span class="input-help" v-else>{{ item.productName }}</span> <span class="input-help" v-else>{{ item.productName }}</span>
</el-col> </el-col>
</template> </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-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"> <el-button v-if="!showMore" link type="primary" @click="showMore = true" class="buttonClass">
{{ $t('tabs.more') }} {{ $t('tabs.more') }}
@ -268,6 +313,9 @@ const baseInfo = ref<Dashboard.BaseInfo>({
cpuLogicalCores: 0, cpuLogicalCores: 0,
cpuModelName: '', cpuModelName: '',
currentInfo: null, currentInfo: null,
ipv4Addr: '',
systemProxy: '',
}); });
const currentInfo = ref<Dashboard.CurrentInfo>({ const currentInfo = ref<Dashboard.CurrentInfo>({
uptime: 0, uptime: 0,
@ -301,6 +349,7 @@ const currentInfo = ref<Dashboard.CurrentInfo>({
diskData: [], diskData: [],
gpuData: [], gpuData: [],
xpuData: [],
netBytesSent: 0, netBytesSent: 0,
netBytesRecv: 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) { if (currentInfo.value.diskData.length + currentInfo.value.gpuData.length > 5) {
showMore.value = isInit ? false : showMore.value || false; 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('%', ''))),
};
}
}); });
}; };