1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-01-31 14:08:06 +08:00

fix: 修复了概览页 io 延迟数据错误的问题 (#441)

This commit is contained in:
ssongliu 2023-03-29 20:56:13 +08:00 committed by GitHub
parent 4a1aa84fa8
commit 57329a26c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 29 additions and 16 deletions

View File

@ -55,7 +55,8 @@ type DashboardCurrent struct {
IOReadBytes uint64 `json:"ioReadBytes"` IOReadBytes uint64 `json:"ioReadBytes"`
IOWriteBytes uint64 `json:"ioWriteBytes"` IOWriteBytes uint64 `json:"ioWriteBytes"`
IOCount uint64 `json:"ioCount"` IOCount uint64 `json:"ioCount"`
IOTime uint64 `json:"ioTime"` IOReadTime uint64 `json:"ioReadTime"`
IOWriteTime uint64 `json:"ioWriteTime"`
Total uint64 `json:"total"` Total uint64 `json:"total"`
Free uint64 `json:"free"` Free uint64 `json:"free"`

View File

@ -136,20 +136,17 @@ func (u *DashboardService) LoadCurrentInfo(ioOption string, netOption string) *d
currentInfo.IOReadBytes += state.ReadBytes currentInfo.IOReadBytes += state.ReadBytes
currentInfo.IOWriteBytes += state.WriteBytes currentInfo.IOWriteBytes += state.WriteBytes
currentInfo.IOCount += (state.ReadCount + state.WriteCount) currentInfo.IOCount += (state.ReadCount + state.WriteCount)
currentInfo.IOTime += state.ReadTime / 1000 / 1000 currentInfo.IOReadTime += state.ReadTime
if state.WriteTime > state.ReadTime { currentInfo.IOWriteTime += state.WriteTime
currentInfo.IOTime += state.WriteTime / 1000 / 1000
}
} }
} else { } else {
diskInfo, _ := disk.IOCounters(ioOption) diskInfo, _ := disk.IOCounters(ioOption)
for _, state := range diskInfo { for _, state := range diskInfo {
currentInfo.IOReadBytes += state.ReadBytes currentInfo.IOReadBytes += state.ReadBytes
currentInfo.IOWriteBytes += state.WriteBytes currentInfo.IOWriteBytes += state.WriteBytes
currentInfo.IOTime += state.ReadTime / 1000 / 1000 currentInfo.IOCount += (state.ReadCount + state.WriteCount)
if state.WriteTime > state.ReadTime { currentInfo.IOReadTime += state.ReadTime
currentInfo.IOTime += state.WriteTime / 1000 / 1000 currentInfo.IOWriteTime += state.WriteTime
}
} }
} }

View File

@ -9260,12 +9260,15 @@ var doc = `{
"ioReadBytes": { "ioReadBytes": {
"type": "integer" "type": "integer"
}, },
"ioTime": { "ioReadTime": {
"type": "integer" "type": "integer"
}, },
"ioWriteBytes": { "ioWriteBytes": {
"type": "integer" "type": "integer"
}, },
"ioWriteTime": {
"type": "integer"
},
"load1": { "load1": {
"type": "number" "type": "number"
}, },

View File

@ -9246,12 +9246,15 @@
"ioReadBytes": { "ioReadBytes": {
"type": "integer" "type": "integer"
}, },
"ioTime": { "ioReadTime": {
"type": "integer" "type": "integer"
}, },
"ioWriteBytes": { "ioWriteBytes": {
"type": "integer" "type": "integer"
}, },
"ioWriteTime": {
"type": "integer"
},
"load1": { "load1": {
"type": "number" "type": "number"
}, },

View File

@ -502,10 +502,12 @@ definitions:
type: integer type: integer
ioReadBytes: ioReadBytes:
type: integer type: integer
ioTime: ioReadTime:
type: integer type: integer
ioWriteBytes: ioWriteBytes:
type: integer type: integer
ioWriteTime:
type: integer
load1: load1:
type: number type: number
load5: load5:

View File

@ -49,8 +49,9 @@ export namespace Dashboard {
ioReadBytes: number; ioReadBytes: number;
ioWriteBytes: number; ioWriteBytes: number;
ioTime: number;
ioCount: number; ioCount: number;
ioReadTime: number;
ioWriteTime: number;
total: number; total: number;
free: number; free: number;

View File

@ -104,7 +104,7 @@
<el-tag> <el-tag>
{{ $t('home.rwPerSecond') }}: {{ currentChartInfo.ioCount }} {{ $t('home.time') }} {{ $t('home.rwPerSecond') }}: {{ currentChartInfo.ioCount }} {{ $t('home.time') }}
</el-tag> </el-tag>
<el-tag>{{ $t('home.ioDelay') }}: {{ currentInfo.ioTime }} ms</el-tag> <el-tag>{{ $t('home.ioDelay') }}: {{ currentChartInfo.ioTime }} ms</el-tag>
</div> </div>
<div v-if="chartOption === 'io'" style="margin-top: 40px"> <div v-if="chartOption === 'io'" style="margin-top: 40px">
@ -282,8 +282,9 @@ const currentInfo = ref<Dashboard.CurrentInfo>({
ioReadBytes: 0, ioReadBytes: 0,
ioWriteBytes: 0, ioWriteBytes: 0,
ioTime: 0,
ioCount: 0, ioCount: 0,
ioReadTime: 0,
ioWriteTime: 0,
total: 0, total: 0,
free: 0, free: 0,
@ -304,6 +305,7 @@ const currentChartInfo = reactive({
ioReadBytes: 0, ioReadBytes: 0,
ioWriteBytes: 0, ioWriteBytes: 0,
ioCount: 0, ioCount: 0,
ioTime: 0,
netBytesSent: 0, netBytesSent: 0,
netBytesRecv: 0, netBytesRecv: 0,
@ -389,7 +391,11 @@ const onLoadCurrentInfo = async () => {
if (ioWriteBytes.value.length > 20) { if (ioWriteBytes.value.length > 20) {
ioWriteBytes.value.splice(0, 1); ioWriteBytes.value.splice(0, 1);
} }
currentChartInfo.ioCount = Number(((res.data.ioCount - currentInfo.value.ioCount) / 3).toFixed(2)); currentChartInfo.ioCount = Math.round(Number((res.data.ioCount - currentInfo.value.ioCount) / 3));
let ioReadTime = res.data.ioReadTime - currentInfo.value.ioReadTime;
let ioWriteTime = res.data.ioWriteTime - currentInfo.value.ioWriteTime;
let ioChoose = ioReadTime > ioWriteTime ? ioReadTime : ioWriteTime;
currentChartInfo.ioTime = Math.round(Number(ioChoose / 3));
timeIODatas.value.push(dateFormatForSecond(res.data.shotTime)); timeIODatas.value.push(dateFormatForSecond(res.data.shotTime));
if (timeIODatas.value.length > 20) { if (timeIODatas.value.length > 20) {