From fe2872bbb37079932c967732e964e936b5ad166f Mon Sep 17 00:00:00 2001 From: xykt <152045469+xykt@users.noreply.github.com> Date: Mon, 19 Feb 2024 01:14:26 +0800 Subject: [PATCH 1/7] Update network.html MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复以下问题: - 延迟默认最高300ms,超过后默认抹平 - 曲线上有很多ping值为0的无效散点,导致毛刺很多,干扰效果 - 图标的y轴比例失调,上方大片留白,大大降低了有效显示区域 - 默认只显示最近不到半小时左右的延迟表现,想看全天需要拖动,影响效果 - 曲线不显示极大极小值,不够直观 --- resource/template/theme-default/network.html | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/resource/template/theme-default/network.html b/resource/template/theme-default/network.html index b321eeebb3..77d4f4f038 100644 --- a/resource/template/theme-default/network.html +++ b/resource/template/theme-default/network.html @@ -30,7 +30,7 @@ const initData = JSON.parse('{{.Servers}}').servers; let MaxTCPPingValue = {{.MaxTCPPingValue}}; if (MaxTCPPingValue == null) { - MaxTCPPingValue = 300; + MaxTCPPingValue = 1000; } new Vue({ el: '#app', @@ -77,7 +77,7 @@ }, dataZoom: [ { - start: 94, + start: 0, end: 100 } ], @@ -87,7 +87,7 @@ }, yAxis: { type: 'value', - boundaryGap: [0, '100%'] + boundaryGap: false }, series: [], }, @@ -178,11 +178,13 @@ let loss = 0; let data = []; for (let j = 0; j < monitorInfo.result[i].created_at.length; j++) { - avgDelay = monitorInfo.result[i].avg_delay[j]; + avgDelay = Math.round(monitorInfo.result[i].avg_delay[j]); if (avgDelay > 0.9 * MaxTCPPingValue) { loss += 1 } - data.push([monitorInfo.result[i].created_at[j], avgDelay]); + if (avgDelay > 0) { + data.push([monitorInfo.result[i].created_at[j], avgDelay]); + } } lossRate = ((loss / monitorInfo.result[i].created_at.length) * 100).toFixed(1); legendName = monitorInfo.result[i].monitor_name +" "+ lossRate + "%"; @@ -192,7 +194,13 @@ type: 'line', smooth: true, symbol: 'none', - data: data + data: data, + markPoint: { + data: [ + { type: 'max', symbol: 'pin', name: 'Max', itemStyle: { color: '#f00' } }, + { type: 'min', symbol: 'pin', name: 'Min', itemStyle: { color: '#0f0' } } + ] + } }); } this.option.title.text = monitorInfo.result[0].server_name; From 4e5cc0b642fbce1510efb55859d6db579feebb4b Mon Sep 17 00:00:00 2001 From: xykt <152045469+xykt@users.noreply.github.com> Date: Mon, 19 Feb 2024 01:17:42 +0800 Subject: [PATCH 2/7] Update config.go MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复了以下问题: - 延迟默认最高300ms,超过后默认抹平 - 曲线上有很多ping值为0的无效散点,导致毛刺很多,干扰效果 - 图标的y轴比例失调,上方大片留白,大大降低了有效显示区域 - 默认只显示最近不到半小时左右的延迟表现,想看全天需要拖动,影响效果 - 曲线不显示极大极小值,不够直观 --- model/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/model/config.go b/model/config.go index fb4ad917a2..c18bb3f21e 100644 --- a/model/config.go +++ b/model/config.go @@ -147,7 +147,7 @@ func (c *Config) Read(path string) error { c.Location = "Asia/Shanghai" } if c.MaxTCPPingValue == 0 { - c.MaxTCPPingValue = 300 + c.MaxTCPPingValue = 1000 } if c.AvgPingCount == 0 { c.AvgPingCount = 2 From a7d1bd74872def010bf9fe75ccbc09fda8f03f8e Mon Sep 17 00:00:00 2001 From: xykt <152045469+xykt@users.noreply.github.com> Date: Sun, 24 Mar 2024 01:04:03 +0800 Subject: [PATCH 3/7] Update network.html MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 美化了三网延迟界面: 1. 将Marker缩小降低曲线遮挡 2. 设置为曲线对应的颜色使其更加直观 3. 设置Marker透明度降低对画面的影响 4. 将延迟极小值的Marker倒置显示以快速区别极大值 5. 将超过MaxTCPPingValue的点删除 6. 显示丢包分布(细线),以及服务器断流区间(粗线) --- resource/template/theme-default/network.html | 44 +++++++++++++++++--- 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/resource/template/theme-default/network.html b/resource/template/theme-default/network.html index b3ecf594c6..c353a9e662 100644 --- a/resource/template/theme-default/network.html +++ b/resource/template/theme-default/network.html @@ -185,19 +185,37 @@ parseMonitorInfo(monitorInfo) { let tSeries = []; let tLegendData = []; + var lcolors = ['#5470c6', '#91cc75', '#fac858', '#ee6666', '#73c0de', '#3ba272', '#fc8452', '#9a60b4', '#ea7ccc']; + let maxPing = 0; for (let i = 0; i < monitorInfo.result.length; i++) { + for (let j = 0; j < monitorInfo.result[i].created_at.length; j++) { + avgDelay = Math.round(monitorInfo.result[i].avg_delay[j]); + if ( avgDelay < MaxTCPPingValue && avgDelay > maxPing) { + maxPing = avgDelay; + } + } + } + for (let i = 0; i < monitorInfo.result.length; i++) { + var lcolor = lcolors[i % lcolors.length]; + var rgbaColorMarker = 'rgba(' + parseInt(lcolor.slice(1, 3), 16) + ',' + parseInt(lcolor.slice(3, 5), 16) + ',' + parseInt(lcolor.slice(5, 7), 16) + ',0.5)'; + var rgbaColorBar = 'rgba(' + parseInt(lcolor.slice(1, 3), 16) + ',' + parseInt(lcolor.slice(3, 5), 16) + ',' + parseInt(lcolor.slice(5, 7), 16) + ',0.35)'; let loss = 0; let data = []; + let datal = []; for (let j = 0; j < monitorInfo.result[i].created_at.length; j++) { avgDelay = Math.round(monitorInfo.result[i].avg_delay[j]); - if (avgDelay > 0.9 * MaxTCPPingValue) { - loss += 1 - } - if (avgDelay > 0) { + if (avgDelay > 0 && avgDelay < MaxTCPPingValue) { data.push([monitorInfo.result[i].created_at[j], avgDelay]); } + else { + loss += 1; + datal.push([monitorInfo.result[i].created_at[j], maxPing]); + } } lossRate = ((loss / monitorInfo.result[i].created_at.length) * 100).toFixed(1); + if (lossRate > 99) { + datal = []; + } legendName = monitorInfo.result[i].monitor_name +" "+ lossRate + "%"; tLegendData.push(legendName); tSeries.push({ @@ -208,17 +226,31 @@ data: data, markPoint: { data: [ - { type: 'max', symbol: 'pin', name: 'Max', itemStyle: { color: '#f00' } }, - { type: 'min', symbol: 'pin', name: 'Min', itemStyle: { color: '#0f0' } } + { type: 'max', symbol: 'pin', name: 'Max', itemStyle: { color: rgbaColorMarker }, symbolSize: 30, label: { fontSize: 8 } }, + { type: 'min', symbol: 'pin', name: 'Min', itemStyle: { color: rgbaColorMarker }, symbolSize: 30, label: { fontSize: 8, offset: [0, 7.5] }, symbolRotate: 180 } ] } }); + tSeries.push({ + name: legendName, + type: 'bar', + smooth: true, + symbol: 'none', + data: datal, + itemStyle: { color: rgbaColorBar } + }); } this.option.title.text = monitorInfo.result[0].server_name; this.option.series = tSeries; this.option.legend.data = tLegendData; this.myChart.clear(); this.myChart.setOption(this.option); + }, + this.option.title.text = monitorInfo.result[0].server_name; + this.option.series = tSeries; + this.option.legend.data = tLegendData; + this.myChart.clear(); + this.myChart.setOption(this.option); }, isWindowsPlatform(str) { return str.includes('Windows') From bad910b686c224907c358c2664b0732ec945d08a Mon Sep 17 00:00:00 2001 From: xykt <152045469+xykt@users.noreply.github.com> Date: Sun, 24 Mar 2024 09:16:41 +0800 Subject: [PATCH 4/7] Update network.html --- resource/template/theme-mdui/network.html | 40 +++++++++++++++++++---- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/resource/template/theme-mdui/network.html b/resource/template/theme-mdui/network.html index 9bd54a205f..6e9f4433cb 100644 --- a/resource/template/theme-mdui/network.html +++ b/resource/template/theme-mdui/network.html @@ -208,19 +208,37 @@ parseMonitorInfo(monitorInfo) { let tSeries = []; let tLegendData = []; + var lcolors = ['#5470c6', '#91cc75', '#fac858', '#ee6666', '#73c0de', '#3ba272', '#fc8452', '#9a60b4', '#ea7ccc']; + let maxPing = 0; for (let i = 0; i < monitorInfo.result.length; i++) { + for (let j = 0; j < monitorInfo.result[i].created_at.length; j++) { + avgDelay = Math.round(monitorInfo.result[i].avg_delay[j]); + if ( avgDelay < MaxTCPPingValue && avgDelay > maxPing) { + maxPing = avgDelay; + } + } + } + for (let i = 0; i < monitorInfo.result.length; i++) { + var lcolor = lcolors[i % lcolors.length]; + var rgbaColorMarker = 'rgba(' + parseInt(lcolor.slice(1, 3), 16) + ',' + parseInt(lcolor.slice(3, 5), 16) + ',' + parseInt(lcolor.slice(5, 7), 16) + ',0.5)'; + var rgbaColorBar = 'rgba(' + parseInt(lcolor.slice(1, 3), 16) + ',' + parseInt(lcolor.slice(3, 5), 16) + ',' + parseInt(lcolor.slice(5, 7), 16) + ',0.35)'; let loss = 0; let data = []; + let datal = []; for (let j = 0; j < monitorInfo.result[i].created_at.length; j++) { avgDelay = Math.round(monitorInfo.result[i].avg_delay[j]); - if (avgDelay > 0.9 * MaxTCPPingValue) { - loss += 1 - } - if (avgDelay > 0) { + if (avgDelay > 0 && avgDelay < MaxTCPPingValue) { data.push([monitorInfo.result[i].created_at[j], avgDelay]); } + else { + loss += 1; + datal.push([monitorInfo.result[i].created_at[j], maxPing]); + } } lossRate = ((loss / monitorInfo.result[i].created_at.length) * 100).toFixed(1); + if (lossRate > 99) { + datal = []; + } legendName = monitorInfo.result[i].monitor_name +" "+ lossRate + "%"; tLegendData.push(legendName); tSeries.push({ @@ -230,12 +248,20 @@ symbol: 'none', data: data, markPoint: { - data: [ - { type: 'max', symbol: 'pin', name: 'Max', itemStyle: { color: '#f00' } }, - { type: 'min', symbol: 'pin', name: 'Min', itemStyle: { color: '#0f0' } } + data: [ + { type: 'max', symbol: 'pin', name: 'Max', itemStyle: { color: rgbaColorMarker }, symbolSize: 30, label: { fontSize: 8 } }, + { type: 'min', symbol: 'pin', name: 'Min', itemStyle: { color: rgbaColorMarker }, symbolSize: 30, label: { fontSize: 8, offset: [0, 7.5] }, symbolRotate: 180 } ] } }); + tSeries.push({ + name: legendName, + type: 'bar', + smooth: true, + symbol: 'none', + data: datal, + itemStyle: { color: rgbaColorBar } + }); } this.option.title.text = monitorInfo.result[0].server_name; this.option.series = tSeries; From 78134a0e8b07e0ddec9a634f7a4ec1eb9592879f Mon Sep 17 00:00:00 2001 From: xykt <152045469+xykt@users.noreply.github.com> Date: Sun, 24 Mar 2024 09:20:53 +0800 Subject: [PATCH 5/7] Update network.html --- resource/template/theme-daynight/network.html | 63 ++++++++++++++----- 1 file changed, 46 insertions(+), 17 deletions(-) diff --git a/resource/template/theme-daynight/network.html b/resource/template/theme-daynight/network.html index b4136737aa..2f218ed4f2 100644 --- a/resource/template/theme-daynight/network.html +++ b/resource/template/theme-daynight/network.html @@ -212,37 +212,66 @@

@#server.Name#@

parseMonitorInfo(monitorInfo) { let tSeries = []; let tLegendData = []; + var lcolors = ['#5470c6', '#91cc75', '#fac858', '#ee6666', '#73c0de', '#3ba272', '#fc8452', '#9a60b4', '#ea7ccc']; + let maxPing = 0; for (let i = 0; i < monitorInfo.result.length; i++) { + for (let j = 0; j < monitorInfo.result[i].created_at.length; j++) { + avgDelay = Math.round(monitorInfo.result[i].avg_delay[j]); + if ( avgDelay < MaxTCPPingValue && avgDelay > maxPing) { + maxPing = avgDelay; + } + } + } + for (let i = 0; i < monitorInfo.result.length; i++) { + var lcolor = lcolors[i % lcolors.length]; + var rgbaColorMarker = 'rgba(' + parseInt(lcolor.slice(1, 3), 16) + ',' + parseInt(lcolor.slice(3, 5), 16) + ',' + parseInt(lcolor.slice(5, 7), 16) + ',0.5)'; + var rgbaColorBar = 'rgba(' + parseInt(lcolor.slice(1, 3), 16) + ',' + parseInt(lcolor.slice(3, 5), 16) + ',' + parseInt(lcolor.slice(5, 7), 16) + ',0.35)'; let loss = 0; let data = []; + let datal = []; for (let j = 0; j < monitorInfo.result[i].created_at.length; j++) { - avgDelay = monitorInfo.result[i].avg_delay[j]; - if (avgDelay > 0.9 * MaxTCPPingValue) { - loss += 1 + avgDelay = Math.round(monitorInfo.result[i].avg_delay[j]); + if (avgDelay > 0 && avgDelay < MaxTCPPingValue) { + data.push([monitorInfo.result[i].created_at[j], avgDelay]); + } + else { + loss += 1; + datal.push([monitorInfo.result[i].created_at[j], maxPing]); } - data.push([monitorInfo.result[i].created_at[j], avgDelay]); } lossRate = ((loss / monitorInfo.result[i].created_at.length) * 100).toFixed(1); - legendName = monitorInfo.result[i].monitor_name +" "+ lossRate + "%"; + if (lossRate > 99) { + datal = []; + } + legendName = monitorInfo.result[i].monitor_name +" "+ lossRate + "%"; tLegendData.push(legendName); tSeries.push({ - name: legendName, - type: 'line', - smooth: true, - symbol: 'none', - data: data + name: legendName, + type: 'line', + smooth: true, + symbol: 'none', + data: data, + markPoint: { + data: [ + { type: 'max', symbol: 'pin', name: 'Max', itemStyle: { color: rgbaColorMarker }, symbolSize: 30, label: { fontSize: 8 } }, + { type: 'min', symbol: 'pin', name: 'Min', itemStyle: { color: rgbaColorMarker }, symbolSize: 30, label: { fontSize: 8, offset: [0, 7.5] }, symbolRotate: 180 } + ] + } + }); + tSeries.push({ + name: legendName, + type: 'bar', + smooth: true, + symbol: 'none', + data: datal, + itemStyle: { color: rgbaColorBar } }); } this.option.title.text = monitorInfo.result[0].server_name; this.option.series = tSeries; this.option.legend.data = tLegendData; - const hour = new Date(Date.now()).getHours() - if (hour > 17 || hour < 4) { - this.option.legend.textStyle.color = "#F1F1F2"; - this.option.title.textStyle.color = "#ccc"; - } - myChart.clear(); - myChart.setOption(this.option); + this.myChart.clear(); + this.myChart.setOption(this.option); }, resizeHandle () { this.myChart.resize(); From 800af7ce4ef1b055672bc48284b90ad41b0c896e Mon Sep 17 00:00:00 2001 From: xykt <152045469+xykt@users.noreply.github.com> Date: Sun, 24 Mar 2024 09:22:13 +0800 Subject: [PATCH 6/7] Update network.html --- .../template/theme-server-status/network.html | 38 ++++++++++++++++--- 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/resource/template/theme-server-status/network.html b/resource/template/theme-server-status/network.html index 0d4487ce8b..deaa4d7de2 100644 --- a/resource/template/theme-server-status/network.html +++ b/resource/template/theme-server-status/network.html @@ -171,19 +171,37 @@ parseMonitorInfo(monitorInfo) { let tSeries = []; let tLegendData = []; + var lcolors = ['#5470c6', '#91cc75', '#fac858', '#ee6666', '#73c0de', '#3ba272', '#fc8452', '#9a60b4', '#ea7ccc']; + let maxPing = 0; for (let i = 0; i < monitorInfo.result.length; i++) { + for (let j = 0; j < monitorInfo.result[i].created_at.length; j++) { + avgDelay = Math.round(monitorInfo.result[i].avg_delay[j]); + if ( avgDelay < MaxTCPPingValue && avgDelay > maxPing) { + maxPing = avgDelay; + } + } + } + for (let i = 0; i < monitorInfo.result.length; i++) { + var lcolor = lcolors[i % lcolors.length]; + var rgbaColorMarker = 'rgba(' + parseInt(lcolor.slice(1, 3), 16) + ',' + parseInt(lcolor.slice(3, 5), 16) + ',' + parseInt(lcolor.slice(5, 7), 16) + ',0.5)'; + var rgbaColorBar = 'rgba(' + parseInt(lcolor.slice(1, 3), 16) + ',' + parseInt(lcolor.slice(3, 5), 16) + ',' + parseInt(lcolor.slice(5, 7), 16) + ',0.35)'; let loss = 0; let data = []; + let datal = []; for (let j = 0; j < monitorInfo.result[i].created_at.length; j++) { avgDelay = Math.round(monitorInfo.result[i].avg_delay[j]); - if (avgDelay > 0.9 * MaxTCPPingValue) { - loss += 1 - } - if (avgDelay > 0) { + if (avgDelay > 0 && avgDelay < MaxTCPPingValue) { data.push([monitorInfo.result[i].created_at[j], avgDelay]); } + else { + loss += 1; + datal.push([monitorInfo.result[i].created_at[j], maxPing]); + } } lossRate = ((loss / monitorInfo.result[i].created_at.length) * 100).toFixed(1); + if (lossRate > 99) { + datal = []; + } legendName = monitorInfo.result[i].monitor_name +" "+ lossRate + "%"; tLegendData.push(legendName); tSeries.push({ @@ -194,11 +212,19 @@ data: data, markPoint: { data: [ - { type: 'max', symbol: 'pin', name: 'Max', itemStyle: { color: '#f00' } }, - { type: 'min', symbol: 'pin', name: 'Min', itemStyle: { color: '#0f0' } } + { type: 'max', symbol: 'pin', name: 'Max', itemStyle: { color: rgbaColorMarker }, symbolSize: 30, label: { fontSize: 8 } }, + { type: 'min', symbol: 'pin', name: 'Min', itemStyle: { color: rgbaColorMarker }, symbolSize: 30, label: { fontSize: 8, offset: [0, 7.5] }, symbolRotate: 180 } ] } }); + tSeries.push({ + name: legendName, + type: 'bar', + smooth: true, + symbol: 'none', + data: datal, + itemStyle: { color: rgbaColorBar } + }); } this.option.title.text = monitorInfo.result[0].server_name; this.option.series = tSeries; From 9a8c0e7118e77cc5a6bde1b50e3645a20db22d8f Mon Sep 17 00:00:00 2001 From: xykt <152045469+xykt@users.noreply.github.com> Date: Sun, 24 Mar 2024 09:24:23 +0800 Subject: [PATCH 7/7] Update network.html --- resource/template/theme-daynight/network.html | 352 +++++++++++------- 1 file changed, 212 insertions(+), 140 deletions(-) diff --git a/resource/template/theme-daynight/network.html b/resource/template/theme-daynight/network.html index 2f218ed4f2..6ac655bcc3 100644 --- a/resource/template/theme-daynight/network.html +++ b/resource/template/theme-daynight/network.html @@ -107,145 +107,200 @@

@#server.Name#@

+ }); + } + this.option.title.text = monitorInfo.result[0].server_name; + this.option.series = tSeries; + this.option.legend.data = tLegendData; + this.myChart.clear(); + this.myChart.setOption(this.option); + }, + this.option.title.text = monitorInfo.result[0].server_name; + this.option.series = tSeries; + this.option.legend.data = tLegendData; + this.myChart.clear(); + this.myChart.setOption(this.option); + }, + isWindowsPlatform(str) { + return str.includes('Windows') + }, + renderChart() { + this.myChart = echarts.init(this.$refs.chartDom); + this.myChart.setOption(this.option); + }, + resizeHandle () { + this.myChart.resize(); + }, + }, + beforeDestroy() { + this.myChart.dispose(); + this.myChart = null; + }, + }); +