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

feat: 概览页增加 Swap 分区监控 #2975

Merged
merged 1 commit into from
Nov 17, 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
7 changes: 6 additions & 1 deletion backend/app/dto/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ type DashboardCurrent struct {
MemoryTotal uint64 `json:"memoryTotal"`
MemoryAvailable uint64 `json:"memoryAvailable"`
MemoryUsed uint64 `json:"memoryUsed"`
MemoryUsedPercent float64 `json:"MemoryUsedPercent"`
MemoryUsedPercent float64 `json:"memoryUsedPercent"`

SwapMemoryTotal uint64 `json:"swapMemoryTotal"`
SwapMemoryAvailable uint64 `json:"swapMemoryAvailable"`
SwapMemoryUsed uint64 `json:"swapMemoryUsed"`
SwapMemoryUsedPercent float64 `json:"swapMemoryUsedPercent"`

IOReadBytes uint64 `json:"ioReadBytes"`
IOWriteBytes uint64 `json:"ioWriteBytes"`
Expand Down
6 changes: 6 additions & 0 deletions backend/app/service/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@ func (u *DashboardService) LoadCurrentInfo(ioOption string, netOption string) *d
currentInfo.MemoryUsed = memoryInfo.Used
currentInfo.MemoryUsedPercent = memoryInfo.UsedPercent

swapInfo, _ := mem.SwapMemory()
currentInfo.SwapMemoryTotal = swapInfo.Total
currentInfo.SwapMemoryAvailable = swapInfo.Free
currentInfo.SwapMemoryUsed = swapInfo.Used
currentInfo.SwapMemoryUsedPercent = swapInfo.UsedPercent

currentInfo.DiskData = loadDiskInfo()

if ioOption == "all" {
Expand Down
66 changes: 53 additions & 13 deletions cmd/server/docs/docs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

62 changes: 51 additions & 11 deletions cmd/server/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -13643,9 +13643,6 @@
"dto.DashboardCurrent": {
"type": "object",
"properties": {
"MemoryUsedPercent": {
"type": "number"
},
"cpuPercent": {
"type": "array",
"items": {
Expand Down Expand Up @@ -13703,6 +13700,9 @@
"memoryUsed": {
"type": "integer"
},
"memoryUsedPercent": {
"type": "number"
},
"netBytesRecv": {
"type": "integer"
},
Expand All @@ -13715,6 +13715,18 @@
"shotTime": {
"type": "string"
},
"swapMemoryAvailable": {
"type": "integer"
},
"swapMemoryTotal": {
"type": "integer"
},
"swapMemoryUsed": {
"type": "integer"
},
"swapMemoryUsedPercent": {
"type": "number"
},
"timeSinceUptime": {
"type": "string"
},
Expand Down Expand Up @@ -16409,12 +16421,21 @@
"createdAt": {
"type": "string"
},
"eabHmacKey": {
"type": "string"
},
"eabKid": {
"type": "string"
},
"email": {
"type": "string"
},
"id": {
"type": "integer"
},
"type": {
"type": "string"
},
"updatedAt": {
"type": "string"
},
Expand Down Expand Up @@ -17307,8 +17328,6 @@
"type": "object",
"required": [
"operate",
"password",
"username",
"websiteID"
],
"properties": {
Expand Down Expand Up @@ -17357,8 +17376,7 @@
"request.NginxConfigUpdate": {
"type": "object",
"required": [
"operate",
"websiteId"
"operate"
],
"properties": {
"operate": {
Expand Down Expand Up @@ -17791,11 +17809,27 @@
"request.WebsiteAcmeAccountCreate": {
"type": "object",
"required": [
"email"
"email",
"type"
],
"properties": {
"eabHmacKey": {
"type": "string"
},
"eabKid": {
"type": "string"
},
"email": {
"type": "string"
},
"type": {
"type": "string",
"enum": [
"letsencrypt",
"zerossl",
"buypass",
"google"
]
}
}
},
Expand Down Expand Up @@ -17890,9 +17924,6 @@
},
"request.WebsiteDefaultUpdate": {
"type": "object",
"required": [
"id"
],
"properties": {
"id": {
"type": "integer"
Expand Down Expand Up @@ -18885,12 +18916,21 @@
"createdAt": {
"type": "string"
},
"eabHmacKey": {
"type": "string"
},
"eabKid": {
"type": "string"
},
"email": {
"type": "string"
},
"id": {
"type": "integer"
},
"type": {
"type": "string"
},
"updatedAt": {
"type": "string"
},
Expand Down
Loading
Loading