Skip to content

Commit d4edf2f

Browse files
authored
fix: Fix the issue of abnormal time filtering in GPU monitoring (#11139)
1 parent 94f7d78 commit d4edf2f

File tree

3 files changed

+19
-15
lines changed

3 files changed

+19
-15
lines changed

agent/app/service/device.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"github.com/1Panel-dev/1Panel/agent/utils/common"
2121
"github.com/1Panel-dev/1Panel/agent/utils/controller"
2222
"github.com/1Panel-dev/1Panel/agent/utils/ntp"
23+
"github.com/1Panel-dev/1Panel/agent/utils/psutil"
2324
"github.com/shirou/gopsutil/v4/mem"
2425
)
2526

@@ -134,6 +135,7 @@ func (u *DeviceService) Update(key, value string) error {
134135
if err := cmd.RunDefaultBashCf("%s hostnamectl set-hostname %s", cmd.SudoHandleCmd(), value); err != nil {
135136
return err
136137
}
138+
_, _ = psutil.HOST.GetHostInfo(true)
137139
case "Ntp", "LocalTime":
138140
if cmd.CheckIllegal(value) {
139141
return buserr.New("ErrCmdIllegal")

frontend/src/views/ai/gpu/index.vue

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ const chartsOption = ref({
178178
loadSpeedChart: null,
179179
});
180180
181-
const searchTime = ref();
182181
const searchInfo = reactive<Host.MonitorGPUSearch>({
183182
productName: '',
184183
startTime: new Date(new Date().setHours(0, 0, 0, 0)),
@@ -201,27 +200,30 @@ const loadOptions = async () => {
201200
};
202201
203202
const search = async () => {
204-
if (searchTime.value && searchTime.value.length === 2) {
205-
searchInfo.startTime = searchTime.value[0];
206-
searchInfo.endTime = searchTime.value[1];
203+
if (timeRangeGlobal.value && timeRangeGlobal.value.length === 2) {
204+
searchInfo.startTime = timeRangeGlobal.value[0];
205+
searchInfo.endTime = timeRangeGlobal.value[1];
207206
}
208207
loading.value = true;
209208
await loadGPUMonitor(searchInfo)
210209
.then((res) => {
211210
loading.value = false;
212-
let baseDate = res.data.date.length === 0 ? loadEmptyDate(timeRangeGlobal.value) : res.data.date;
211+
let baseDate = res.data.date || [];
212+
if (baseDate.length === 0) {
213+
baseDate = loadEmptyDate(timeRangeGlobal.value);
214+
}
213215
let date = baseDate.map(function (item: any) {
214216
return dateFormatWithoutYear(item);
215217
});
216-
initCPUCharts(date, res.data.gpuValue);
217-
initMemoryCharts(date, res.data.memoryValue);
218+
initCPUCharts(date, res.data.gpuValue || []);
219+
initMemoryCharts(date, res.data.memoryValue || []);
218220
if (gpuType.value === 'gpu') {
219-
initPowerCharts(date, res.data.powerValue);
221+
initPowerCharts(date, res.data.powerValue || []);
220222
} else {
221-
initXpuPowerCharts(date, res.data.powerValue);
223+
initXpuPowerCharts(date, res.data.powerValue || []);
222224
}
223-
initSpeedCharts(date, res.data.speedValue);
224-
initTemperatureCharts(date, res.data.temperatureValue);
225+
initSpeedCharts(date, res.data.speedValue || []);
226+
initTemperatureCharts(date, res.data.temperatureValue || []);
225227
})
226228
.catch(() => {
227229
loading.value = false;
@@ -370,8 +372,8 @@ function loadEmptyData() {
370372
}
371373
function loadEmptyData2() {
372374
return [
373-
{ value: 0, data: {} },
374-
{ value: 0, data: {} },
375+
{ value: 0, data: { total: 0, used: 0 } },
376+
{ value: 0, data: { total: 0, used: 0 } },
375377
];
376378
}
377379

frontend/src/views/toolbox/device/hostname/index.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<template #footer>
1010
<span class="dialog-footer">
1111
<el-button @click="drawerVisible = false">{{ $t('commons.button.cancel') }}</el-button>
12-
<el-button :disabled="loading" type="primary" @click="onSaveHostame(formRef)">
12+
<el-button :disabled="loading" type="primary" @click="onSaveHostname(formRef)">
1313
{{ $t('commons.button.confirm') }}
1414
</el-button>
1515
</span>
@@ -43,7 +43,7 @@ const acceptParams = (params: DialogProps): void => {
4343
drawerVisible.value = true;
4444
};
4545
46-
const onSaveHostame = async (formEl: FormInstance | undefined) => {
46+
const onSaveHostname = async (formEl: FormInstance | undefined) => {
4747
if (!formEl) return;
4848
formEl.validate(async (valid) => {
4949
if (!valid) return;

0 commit comments

Comments
 (0)