Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Mar 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion backend/app/dto/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
13 changes: 5 additions & 8 deletions backend/app/service/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down
5 changes: 4 additions & 1 deletion cmd/server/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -9260,12 +9260,15 @@ var doc = `{
"ioReadBytes": {
"type": "integer"
},
"ioTime": {
"ioReadTime": {
"type": "integer"
},
"ioWriteBytes": {
"type": "integer"
},
"ioWriteTime": {
"type": "integer"
},
"load1": {
"type": "number"
},
Expand Down
5 changes: 4 additions & 1 deletion cmd/server/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -9246,12 +9246,15 @@
"ioReadBytes": {
"type": "integer"
},
"ioTime": {
"ioReadTime": {
"type": "integer"
},
"ioWriteBytes": {
"type": "integer"
},
"ioWriteTime": {
"type": "integer"
},
"load1": {
"type": "number"
},
Expand Down
4 changes: 3 additions & 1 deletion cmd/server/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -502,10 +502,12 @@ definitions:
type: integer
ioReadBytes:
type: integer
ioTime:
ioReadTime:
type: integer
ioWriteBytes:
type: integer
ioWriteTime:
type: integer
load1:
type: number
load5:
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/api/interface/dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ export namespace Dashboard {

ioReadBytes: number;
ioWriteBytes: number;
ioTime: number;
ioCount: number;
ioReadTime: number;
ioWriteTime: number;

total: number;
free: number;
Expand Down
12 changes: 9 additions & 3 deletions frontend/src/views/home/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down Expand Up @@ -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,
Expand All @@ -304,6 +305,7 @@ const currentChartInfo = reactive({
ioReadBytes: 0,
ioWriteBytes: 0,
ioCount: 0,
ioTime: 0,

netBytesSent: 0,
netBytesRecv: 0,
Expand Down Expand Up @@ -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) {
Expand Down