Skip to content

Commit 3042bc5

Browse files
author
jialong.wang
committed
fix: monitor bug
1 parent 767fcb4 commit 3042bc5

File tree

9 files changed

+69
-56
lines changed

9 files changed

+69
-56
lines changed

configs/config.toml

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# http监听地址
33
Host = "0.0.0.0"
44
# http监听端口
5-
Port = 8000
5+
Port = 9527
66
# http优雅关闭等待超时时长(单位秒)
77
ShutdownTimeout = 30
88
SeverHeader = "probe"
@@ -14,7 +14,7 @@ Prefork = false
1414
# 定时任务执行间隔配置
1515
[Gorm]
1616
# 是否开启调试模式
17-
Debug = false
17+
Debug = true
1818
# 数据库类型(目前支持的数据库类型:postgres)
1919
DBType = "sqlite"
2020
# 设置连接可以重用的最长时间(单位:秒)
@@ -38,25 +38,27 @@ User = ""
3838
# 密码
3939
Password = ""
4040
# 数据库
41-
#DBName = "/app/probe"
42-
DBName = "/Users/amu/Desktop/probe"
41+
DBName = "/app/probe"
4342
# SSL模式
4443
SSLMode = ""
4544

4645
[Disk]
47-
Devices = ["/dev/vda1", "/dev/vda3", "/dev/disk3s1s1"]
46+
# 需要监控的磁盘设备,可以根据 lsblk 命令查看
47+
Devices = ["sda", "sdb2"]
4848

4949
[Ethernet]
50-
Names = ["eth0", "en0"]
50+
# 需要监控的网口,可以通过 ifconfig 命令查看
51+
Names = ["mgmt"]
5152

5253
[Task]
53-
Interval = 60 # 单位 s
54+
# 主机监控数据的采集频率
55+
Interval = 30 # 单位 s
5456

5557
[Logger]
56-
File = "/Users/amu/Desktop/probe.log"
58+
File = "/app/probe.log"
5759
Level = "debug"
58-
RotationTime = "1" # 每天切分一个日志文件
59-
MaxAge = "7" # 最多保留 7 天的日志
60+
RotationTime = "1" # 每天切分一个日志文件
61+
MaxAge = "7" # 最多保留 7 天的日志
6062

6163
[Auth]
6264
# 是否启用
@@ -65,15 +67,12 @@ Enable = true
6567
SigningMethod = "HS512"
6668
# 签名key
6769
SigningKey = "amprobe"
68-
# access_token 过期时间(单位秒, 2h
70+
# 过期时间(单位秒)
6971
Expired = 7200
70-
# refresh_token 过期时间(单位秒, 1d)
71-
RefreshExpired = 86400
7272
# key 前缀
7373
Prefix = "auth_"
7474

7575

7676
[InitData]
7777
Enable = true
78-
#InitConfigFile = "/app/configs/init.yaml"
79-
InitConfigFile = "/Users/amu/Desktop/github/amprobe/configs/init.yaml"
78+
InitConfigFile = "/app/configs/init.yaml"

configs/init.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
users:
22
- username: admin
3-
password: amu123456
3+
password: 123456
44
status: 1
55
is_admin: 1
66
- username: amprobe

web/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"@iconify-json/ep": "^1.1.15",
2727
"@types/lodash-es": "^4.17.12",
2828
"@types/node": "^20.11.30",
29+
"@types/numeral": "^2.0.5",
2930
"@typescript-eslint/eslint-plugin": "^7.3.1",
3031
"@typescript-eslint/parser": "^7.3.1",
3132
"@vitejs/plugin-vue": "^5.0.4",
@@ -34,6 +35,7 @@
3435
"eslint-plugin-import": "^2.29.1",
3536
"eslint-plugin-prettier": "^5.1.3",
3637
"eslint-plugin-vue": "^9.23.0",
38+
"numeral": "^2.0.6",
3739
"prettier": "^3.2.5",
3840
"sass": "^1.72.0",
3941
"terser": "^5.30.3",

web/pnpm-lock.yaml

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/src/components/Echarts/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,6 @@ onMounted(() => {
4545
<style scoped lang="scss">
4646
@include b(box) {
4747
width: 100%;
48-
height: 90%;
48+
height: 80%;
4949
}
5050
</style>

web/src/components/Echarts/line.ts

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,9 @@ export const cpuOptions: EChartsOption = {
4646
{
4747
name: 'CPU 使用率',
4848
type: 'line',
49-
stack: 'Total',
50-
areaStyle: {},
51-
emphasis: {
52-
focus: 'series'
49+
smooth: true,
50+
lineStyle: {
51+
width: 2
5352
},
5453
data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
5554
}
@@ -94,10 +93,9 @@ export const memOptions: EChartsOption = {
9493
{
9594
name: '内存使用率',
9695
type: 'line',
97-
stack: 'Total',
98-
areaStyle: {},
99-
emphasis: {
100-
focus: 'series'
96+
smooth: true,
97+
lineStyle: {
98+
width: 2
10199
},
102100
data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
103101
}
@@ -153,20 +151,18 @@ export const diskOptions: EChartsOption = {
153151
{
154152
name: 'Read',
155153
type: 'line',
156-
stack: 'Total',
157-
areaStyle: {},
158-
emphasis: {
159-
focus: 'series'
154+
smooth: true,
155+
lineStyle: {
156+
width: 2
160157
},
161158
data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
162159
},
163160
{
164161
name: 'Write',
165162
type: 'line',
166-
stack: 'Total',
167-
areaStyle: {},
168-
emphasis: {
169-
focus: 'series'
163+
smooth: true,
164+
lineStyle: {
165+
width: 2
170166
},
171167
data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
172168
}
@@ -222,20 +218,18 @@ export const netOptions: EChartsOption = {
222218
{
223219
name: 'Receive',
224220
type: 'line',
225-
stack: 'Total',
226-
areaStyle: {},
227-
emphasis: {
228-
focus: 'series'
221+
smooth: true,
222+
lineStyle: {
223+
width: 2
229224
},
230225
data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
231226
},
232227
{
233228
name: 'Send',
234229
type: 'line',
235-
stack: 'Total',
236-
areaStyle: {},
237-
emphasis: {
238-
focus: 'series'
230+
smooth: true,
231+
lineStyle: {
232+
width: 2
239233
},
240234
data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
241235
}

web/src/utils/convert.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66

77
export function convertBytesToReadable(bytes: number): string {
8-
const units = ['Bps', 'KBps', 'MBps', 'GBps', 'TBps']
8+
const units = ['B', 'KB', 'MB', 'GB', 'TB']
99
let unitIndex = 0
1010
while (bytes >= 1024 && unitIndex < units.length - 1) {
1111
bytes /= 1024

web/src/views/host/monitor/index.vue

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ const renderCPU = async () => {
123123
set(cpuOption, 'series', [
124124
{
125125
name: 'CPU使用率',
126-
data: cpuData.map((item) => item.value),
126+
data: cpuData.map((item) => item.value.toFixed(2)),
127127
type: 'line',
128128
smooth: true,
129129
showSymbol: false
@@ -165,7 +165,7 @@ const renderMem = async () => {
165165
set(memOption, 'series', [
166166
{
167167
name: '内存使用率',
168-
data: memData.map((item) => item.value),
168+
data: memData.map((item) => item.value.toFixed(2)),
169169
type: 'line',
170170
smooth: true,
171171
showSymbol: false
@@ -220,17 +220,17 @@ const renderDisk = async () => {
220220
set(diskOption, 'series', [
221221
{
222222
name: 'Read',
223-
data: diskData.data.map((item: DiskIO) => convertBytesToReadable(item.io_read)),
223+
data: diskData.data.map((item: DiskIO) => item.io_read),
224224
type: 'line',
225225
smooth: true,
226-
showSymbol: false
226+
showSymbol: true
227227
},
228228
{
229229
name: 'Write',
230-
data: diskData.data.map((item: DiskIO) => convertBytesToReadable(item.io_write)),
230+
data: diskData.data.map((item: DiskIO) => item.io_write),
231231
type: 'line',
232232
smooth: true,
233-
showSymbol: false
233+
showSymbol: true
234234
}
235235
])
236236
console.log('disk options: ', diskOption)
@@ -267,17 +267,21 @@ const renderNet = async () => {
267267
set(netOption, 'series', [
268268
{
269269
name: 'Receive',
270-
data: netData.data.map((item: NetIO) => convertBytesToReadable(item.bytes_recv)),
270+
data: netData.data.map((item: NetIO) => item.bytes_recv),
271271
type: 'line',
272-
smooth: true,
273-
showSymbol: false
272+
showSymbol: true,
273+
symbolSize: 2,
274+
hoverAnimation: true,
275+
smooth: true
274276
},
275277
{
276278
name: 'Send',
277-
data: netData.data.map((item: NetIO) => convertBytesToReadable(item.bytes_sent)),
279+
data: netData.data.map((item: NetIO) => item.bytes_sent),
278280
type: 'line',
279-
smooth: true,
280-
showSymbol: false
281+
showSymbol: true,
282+
symbolSize: 2,
283+
hoverAnimation: true,
284+
smooth: true
281285
}
282286
])
283287
console.log('net options: ', netOption)
@@ -331,7 +335,7 @@ watch(
331335
.el-row {
332336
margin-bottom: 4px;
333337
.el-col {
334-
height: 300px;
338+
height: 360px;
335339
}
336340
}
337341

web/vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
1111

1212
// https://vitejs.dev/config/
1313
export default defineConfig({
14-
base: './', // 设置打包路径
14+
base: '/', // 设置打包路径
1515
plugins: [
1616
vue(),
1717
AutoImport({

0 commit comments

Comments
 (0)