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

pull/441/merge
ssongliu 2 years ago committed by GitHub
parent 4a1aa84fa8
commit 57329a26c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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

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

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

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

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

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

@ -104,7 +104,7 @@
<el-tag>
{{ $t('home.rwPerSecond') }}: {{ currentChartInfo.ioCount }} {{ $t('home.time') }}
</el-tag>
<el-tag>{{ $t('home.ioDelay') }}: {{ currentInfo.ioTime }} ms</el-tag>
<el-tag>{{ $t('home.ioDelay') }}: {{ currentChartInfo.ioTime }} ms</el-tag>
</div>
<div v-if="chartOption === 'io'" style="margin-top: 40px">
@ -282,8 +282,9 @@ const currentInfo = ref<Dashboard.CurrentInfo>({
ioReadBytes: 0,
ioWriteBytes: 0,
ioTime: 0,
ioCount: 0,
ioReadTime: 0,
ioWriteTime: 0,
total: 0,
free: 0,
@ -304,6 +305,7 @@ const currentChartInfo = reactive({
ioReadBytes: 0,
ioWriteBytes: 0,
ioCount: 0,
ioTime: 0,
netBytesSent: 0,
netBytesRecv: 0,
@ -389,7 +391,11 @@ const onLoadCurrentInfo = async () => {
if (ioWriteBytes.value.length > 20) {
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));
if (timeIODatas.value.length > 20) {

Loading…
Cancel
Save