mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-12-17 12:58:51 +08:00
fix: Fix the issue of abnormal time filtering in GPU monitoring (#11139)
This commit is contained in:
parent
94f7d78cc9
commit
d4edf2f874
3 changed files with 19 additions and 15 deletions
|
|
@ -20,6 +20,7 @@ import (
|
|||
"github.com/1Panel-dev/1Panel/agent/utils/common"
|
||||
"github.com/1Panel-dev/1Panel/agent/utils/controller"
|
||||
"github.com/1Panel-dev/1Panel/agent/utils/ntp"
|
||||
"github.com/1Panel-dev/1Panel/agent/utils/psutil"
|
||||
"github.com/shirou/gopsutil/v4/mem"
|
||||
)
|
||||
|
||||
|
|
@ -134,6 +135,7 @@ func (u *DeviceService) Update(key, value string) error {
|
|||
if err := cmd.RunDefaultBashCf("%s hostnamectl set-hostname %s", cmd.SudoHandleCmd(), value); err != nil {
|
||||
return err
|
||||
}
|
||||
_, _ = psutil.HOST.GetHostInfo(true)
|
||||
case "Ntp", "LocalTime":
|
||||
if cmd.CheckIllegal(value) {
|
||||
return buserr.New("ErrCmdIllegal")
|
||||
|
|
|
|||
|
|
@ -178,7 +178,6 @@ const chartsOption = ref({
|
|||
loadSpeedChart: null,
|
||||
});
|
||||
|
||||
const searchTime = ref();
|
||||
const searchInfo = reactive<Host.MonitorGPUSearch>({
|
||||
productName: '',
|
||||
startTime: new Date(new Date().setHours(0, 0, 0, 0)),
|
||||
|
|
@ -201,27 +200,30 @@ const loadOptions = async () => {
|
|||
};
|
||||
|
||||
const search = async () => {
|
||||
if (searchTime.value && searchTime.value.length === 2) {
|
||||
searchInfo.startTime = searchTime.value[0];
|
||||
searchInfo.endTime = searchTime.value[1];
|
||||
if (timeRangeGlobal.value && timeRangeGlobal.value.length === 2) {
|
||||
searchInfo.startTime = timeRangeGlobal.value[0];
|
||||
searchInfo.endTime = timeRangeGlobal.value[1];
|
||||
}
|
||||
loading.value = true;
|
||||
await loadGPUMonitor(searchInfo)
|
||||
.then((res) => {
|
||||
loading.value = false;
|
||||
let baseDate = res.data.date.length === 0 ? loadEmptyDate(timeRangeGlobal.value) : res.data.date;
|
||||
let baseDate = res.data.date || [];
|
||||
if (baseDate.length === 0) {
|
||||
baseDate = loadEmptyDate(timeRangeGlobal.value);
|
||||
}
|
||||
let date = baseDate.map(function (item: any) {
|
||||
return dateFormatWithoutYear(item);
|
||||
});
|
||||
initCPUCharts(date, res.data.gpuValue);
|
||||
initMemoryCharts(date, res.data.memoryValue);
|
||||
initCPUCharts(date, res.data.gpuValue || []);
|
||||
initMemoryCharts(date, res.data.memoryValue || []);
|
||||
if (gpuType.value === 'gpu') {
|
||||
initPowerCharts(date, res.data.powerValue);
|
||||
initPowerCharts(date, res.data.powerValue || []);
|
||||
} else {
|
||||
initXpuPowerCharts(date, res.data.powerValue);
|
||||
initXpuPowerCharts(date, res.data.powerValue || []);
|
||||
}
|
||||
initSpeedCharts(date, res.data.speedValue);
|
||||
initTemperatureCharts(date, res.data.temperatureValue);
|
||||
initSpeedCharts(date, res.data.speedValue || []);
|
||||
initTemperatureCharts(date, res.data.temperatureValue || []);
|
||||
})
|
||||
.catch(() => {
|
||||
loading.value = false;
|
||||
|
|
@ -370,8 +372,8 @@ function loadEmptyData() {
|
|||
}
|
||||
function loadEmptyData2() {
|
||||
return [
|
||||
{ value: 0, data: {} },
|
||||
{ value: 0, data: {} },
|
||||
{ value: 0, data: { total: 0, used: 0 } },
|
||||
{ value: 0, data: { total: 0, used: 0 } },
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button @click="drawerVisible = false">{{ $t('commons.button.cancel') }}</el-button>
|
||||
<el-button :disabled="loading" type="primary" @click="onSaveHostame(formRef)">
|
||||
<el-button :disabled="loading" type="primary" @click="onSaveHostname(formRef)">
|
||||
{{ $t('commons.button.confirm') }}
|
||||
</el-button>
|
||||
</span>
|
||||
|
|
@ -43,7 +43,7 @@ const acceptParams = (params: DialogProps): void => {
|
|||
drawerVisible.value = true;
|
||||
};
|
||||
|
||||
const onSaveHostame = async (formEl: FormInstance | undefined) => {
|
||||
const onSaveHostname = async (formEl: FormInstance | undefined) => {
|
||||
if (!formEl) return;
|
||||
formEl.validate(async (valid) => {
|
||||
if (!valid) return;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue