Compare commits

...
8 Commits
Author SHA1 Message Date
xykt dbfea9a00b 对历史延迟图表进行了相关修复/美化工作 (#321)
* Update network.html

修复以下问题:
- 延迟默认最高300ms,超过后默认抹平
- 曲线上有很多ping值为0的无效散点,导致毛刺很多,干扰效果
- 图标的y轴比例失调,上方大片留白,大大降低了有效显示区域
- 默认只显示最近不到半小时左右的延迟表现,想看全天需要拖动,影响效果
- 曲线不显示极大极小值,不够直观

* Update config.go

修复了以下问题:
- 延迟默认最高300ms,超过后默认抹平
- 曲线上有很多ping值为0的无效散点,导致毛刺很多,干扰效果
- 图标的y轴比例失调,上方大片留白,大大降低了有效显示区域
- 默认只显示最近不到半小时左右的延迟表现,想看全天需要拖动,影响效果
- 曲线不显示极大极小值,不够直观
2024-02-19 13:52:43 +08:00
github-actions[bot] e8b208edfa update contributors[no ci] 2024-02-18 12:00:59 +00:00
Ko no dio 7d38634933 feat: add index on monitor history (#320) 2024-02-18 20:00:36 +08:00
github-actions[bot] 5bd4b57cbf update contributors[no ci] 2024-02-14 05:12:49 +00:00
Ko no dioandLvGJ fdb2fd8839 fix: revert service html and block service in backend (#318)
Co-authored-by: LvGJ <[email protected]>
2024-02-14 13:12:24 +08:00
github-actions[bot] f3fac9325c update contributors[no ci] 2024-02-13 15:09:58 +00:00
Ko no dioandLvGJ 626613441d fix: add toggle to service (#317)
* fix: short nework word

* fix: add toggle on service

* fix: delete console log update main.js version

---------

Co-authored-by: LvGJ <[email protected]>
2024-02-13 23:09:40 +08:00
github-actions[bot] b86b73a433 update contributors[no ci] 2024-02-12 06:16:26 +00:00
17 changed files with 72 additions and 27 deletions
+3
View File
@@ -77,6 +77,9 @@ You can change the dashboard language in the settings page (`/setting`) after th
<a href="https://github.com/uubulb" title="UUBulb"> <a href="https://github.com/uubulb" title="UUBulb">
<img src="https://avatars.githubusercontent.com/u/35923940?v=4" width="50;" alt="UUBulb"/> <img src="https://avatars.githubusercontent.com/u/35923940?v=4" width="50;" alt="UUBulb"/>
</a> </a>
<a href="https://github.com/lvgj-stack" title="Ko no dio">
<img src="https://avatars.githubusercontent.com/u/38449861?v=4" width="50;" alt="Ko no dio"/>
</a>
<a href="https://github.com/hhhkkk520" title="Kris"> <a href="https://github.com/hhhkkk520" title="Kris">
<img src="https://avatars.githubusercontent.com/u/52115472?v=4" width="50;" alt="Kris"/> <img src="https://avatars.githubusercontent.com/u/52115472?v=4" width="50;" alt="Kris"/>
</a> </a>
+5
View File
@@ -118,6 +118,11 @@ func (p *commonPage) service(c *gin.Context) {
var statsStore map[uint64]model.CycleTransferStats var statsStore map[uint64]model.CycleTransferStats
copier.Copy(&stats, singleton.ServiceSentinelShared.LoadStats()) copier.Copy(&stats, singleton.ServiceSentinelShared.LoadStats())
copier.Copy(&statsStore, singleton.AlertsCycleTransferStatsStore) copier.Copy(&statsStore, singleton.AlertsCycleTransferStatsStore)
for k, service := range stats {
if !service.Monitor.EnableShowInService {
delete(stats, k)
}
}
return []interface { return []interface {
}{ }{
stats, statsStore, stats, statsStore,
+2
View File
@@ -394,6 +394,7 @@ type monitorForm struct {
MaxLatency float32 MaxLatency float32
LatencyNotify string LatencyNotify string
EnableTriggerTask string EnableTriggerTask string
EnableShowInService string
FailTriggerTasksRaw string FailTriggerTasksRaw string
RecoverTriggerTasksRaw string RecoverTriggerTasksRaw string
} }
@@ -415,6 +416,7 @@ func (ma *memberAPI) addOrEditMonitor(c *gin.Context) {
m.LatencyNotify = mf.LatencyNotify == "on" m.LatencyNotify = mf.LatencyNotify == "on"
m.MinLatency = mf.MinLatency m.MinLatency = mf.MinLatency
m.MaxLatency = mf.MaxLatency m.MaxLatency = mf.MaxLatency
m.EnableShowInService = mf.EnableShowInService == "on"
m.EnableTriggerTask = mf.EnableTriggerTask == "on" m.EnableTriggerTask = mf.EnableTriggerTask == "on"
m.RecoverTriggerTasksRaw = mf.RecoverTriggerTasksRaw m.RecoverTriggerTasksRaw = mf.RecoverTriggerTasksRaw
m.FailTriggerTasksRaw = mf.FailTriggerTasksRaw m.FailTriggerTasksRaw = mf.FailTriggerTasksRaw
+1 -1
View File
@@ -147,7 +147,7 @@ func (c *Config) Read(path string) error {
c.Location = "Asia/Shanghai" c.Location = "Asia/Shanghai"
} }
if c.MaxTCPPingValue == 0 { if c.MaxTCPPingValue == 0 {
c.MaxTCPPingValue = 300 c.MaxTCPPingValue = 1000
} }
if c.AvgPingCount == 0 { if c.AvgPingCount == 0 {
c.AvgPingCount = 2 c.AvgPingCount = 2
+1
View File
@@ -50,6 +50,7 @@ type Monitor struct {
Cover uint8 Cover uint8
EnableTriggerTask bool `gorm:"default: false"` EnableTriggerTask bool `gorm:"default: false"`
EnableShowInService bool `gorm:"default: false"`
FailTriggerTasksRaw string `gorm:"default:'[]'"` FailTriggerTasksRaw string `gorm:"default:'[]'"`
RecoverTriggerTasksRaw string `gorm:"default:'[]'"` RecoverTriggerTasksRaw string `gorm:"default:'[]'"`
FailTriggerTasks []uint64 `gorm:"-" json:"-"` // 失败时执行的触发任务id FailTriggerTasks []uint64 `gorm:"-" json:"-"` // 失败时执行的触发任务id
+14 -12
View File
@@ -1,20 +1,22 @@
package model package model
const ( import (
Cycle = iota "time"
Hour
Day "gorm.io/gorm"
Week
Month
) )
// MonitorHistory 历史监控记录 // MonitorHistory 历史监控记录
type MonitorHistory struct { type MonitorHistory struct {
Common ID uint64 `gorm:"primaryKey"`
MonitorID uint64 CreatedAt time.Time `gorm:"index;<-:create;index:idx_server_id_created_at_monitor_id_avg_delay"`
ServerID uint64 UpdatedAt time.Time `gorm:"autoUpdateTime"`
AvgDelay float32 // 平均延迟,毫秒 DeletedAt gorm.DeletedAt `gorm:"index"`
Up uint64 // 检查状态良好计数 MonitorID uint64 `gorm:"index:idx_server_id_created_at_monitor_id_avg_delay"`
Down uint64 // 检查状态异常计数 ServerID uint64 `gorm:"index:idx_server_id_created_at_monitor_id_avg_delay"`
AvgDelay float32 `gorm:"index:idx_server_id_created_at_monitor_id_avg_delay"` // 平均延迟,毫秒
Up uint64 // 检查状态良好计数
Down uint64 // 检查状态异常计数
Data string Data string
} }
+4 -1
View File
@@ -611,4 +611,7 @@ other = "Hide for Guest"
other = "Menu" other = "Menu"
[NetworkSpiter] [NetworkSpiter]
other = "Network Monitor" other = "Network"
[EnableShowInService]
other = "Enable Show in Service"
+4 -1
View File
@@ -611,4 +611,7 @@ other = "Ocultar para Invitados"
other = "Menú" other = "Menú"
[NetworkSpiter] [NetworkSpiter]
other = "Supervisión De Redes" other = "Red"
[EnableShowInService]
other = "Mostrar en servicio"
+4 -1
View File
@@ -611,4 +611,7 @@ other = "对游客隐藏"
other = "菜单" other = "菜单"
[NetworkSpiter] [NetworkSpiter]
other = "网络监控" other = "网络"
[EnableShowInService]
other = "在服务中显示"
+4 -1
View File
@@ -611,4 +611,7 @@ other = "對遊客隱藏"
other = "菜單" other = "菜單"
[NetworkSpiter] [NetworkSpiter]
other = "網絡監控" other = "網絡"
[EnableShowInService]
other = "在服務中顯示"
+5
View File
@@ -339,6 +339,11 @@ function addOrEditMonitor(monitor) {
modal.find("select[name=Type]").val(monitor ? monitor.Type : 1); modal.find("select[name=Type]").val(monitor ? monitor.Type : 1);
modal.find("select[name=Cover]").val(monitor ? monitor.Cover : 0); modal.find("select[name=Cover]").val(monitor ? monitor.Cover : 0);
modal.find("input[name=NotificationTag]").val(monitor ? monitor.NotificationTag : null); modal.find("input[name=NotificationTag]").val(monitor ? monitor.NotificationTag : null);
if (monitor && monitor.EnableShowInService) {
modal.find(".ui.nb-show-in-service.checkbox").checkbox("set checked")
} else {
modal.find(".ui.nb-show-in-service.checkbox").checkbox("set unchecked")
}
if (monitor && monitor.Notify) { if (monitor && monitor.Notify) {
modal.find(".ui.nb-notify.checkbox").checkbox("set checked"); modal.find(".ui.nb-notify.checkbox").checkbox("set checked");
} else { } else {
+1 -1
View File
@@ -10,7 +10,7 @@
<script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-y/semantic-ui/2.4.1/semantic.min.js"></script> <script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-y/semantic-ui/2.4.1/semantic.min.js"></script>
<script src="/static/semantic-ui-alerts.min.js"></script> <script src="/static/semantic-ui-alerts.min.js"></script>
<script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-y/vue/2.6.14/vue.min.js"></script> <script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-y/vue/2.6.14/vue.min.js"></script>
<script src="/static/main.js?v20230614"></script> <script src="/static/main.js?v20240213"></script>
<script> <script>
(function () { (function () {
updateLang({{.LANG }}); updateLang({{.LANG }});
+7
View File
@@ -24,6 +24,12 @@
<option value="3">TCP-Ping</option> <option value="3">TCP-Ping</option>
</select> </select>
</div> </div>
<div class="field">
<div class="ui nb-show-in-service checkbox">
<input name="EnableShowInService" type="checkbox" tabindex="0" class="hidden" />
<label>{{tr "EnableShowInService"}}</label>
</div>
</div>
<div class="field"> <div class="field">
<label>{{tr "Duration"}}</label> <label>{{tr "Duration"}}</label>
<input type="number" name="Duration" placeholder="{{tr "Seconds"}}" /> <input type="number" name="Duration" placeholder="{{tr "Seconds"}}" />
@@ -110,3 +116,4 @@
</div> </div>
</div> </div>
{{end}} {{end}}
+1 -1
View File
@@ -68,4 +68,4 @@
<script> <script>
$(".checkbox").checkbox(); $(".checkbox").checkbox();
</script> </script>
{{end}} {{end}}
+1 -1
View File
@@ -12,7 +12,7 @@
<script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-y/semantic-ui/2.4.1/semantic.min.js"></script> <script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-y/semantic-ui/2.4.1/semantic.min.js"></script>
<script src="/static/semantic-ui-alerts.min.js"></script> <script src="/static/semantic-ui-alerts.min.js"></script>
<script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-y/vue/2.6.14/vue.min.js"></script> <script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-y/vue/2.6.14/vue.min.js"></script>
<script src="/static/main.js?v20230614"></script> <script src="/static/main.js?v20240213"></script>
<script> <script>
(function () { (function () {
updateLang({{.LANG }}); updateLang({{.LANG }});
+1 -1
View File
@@ -81,7 +81,7 @@
{{end}} {{end}}
</div> </div>
</section> </section>
{{end}} {{end}}
</section> </section>
{{if .CycleTransferStats}} {{if .CycleTransferStats}}
<h2 class="mdui-m-t-5 mdui-text-center">{{tr "CycleTransferStats"}}</h2> <h2 class="mdui-m-t-5 mdui-text-center">{{tr "CycleTransferStats"}}</h2>
+14 -6
View File
@@ -30,7 +30,7 @@
const initData = JSON.parse('{{.Servers}}').servers; const initData = JSON.parse('{{.Servers}}').servers;
let MaxTCPPingValue = {{.MaxTCPPingValue}}; let MaxTCPPingValue = {{.MaxTCPPingValue}};
if (MaxTCPPingValue == null) { if (MaxTCPPingValue == null) {
MaxTCPPingValue = 300; MaxTCPPingValue = 1000;
} }
new Vue({ new Vue({
el: '#app', el: '#app',
@@ -77,7 +77,7 @@
}, },
dataZoom: [ dataZoom: [
{ {
start: 94, start: 0,
end: 100 end: 100
} }
], ],
@@ -87,7 +87,7 @@
}, },
yAxis: { yAxis: {
type: 'value', type: 'value',
boundaryGap: [0, '100%'] boundaryGap: false
}, },
series: [], series: [],
}, },
@@ -178,11 +178,13 @@
let loss = 0; let loss = 0;
let data = []; let data = [];
for (let j = 0; j < monitorInfo.result[i].created_at.length; j++) { 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) { if (avgDelay > 0.9 * MaxTCPPingValue) {
loss += 1 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); lossRate = ((loss / monitorInfo.result[i].created_at.length) * 100).toFixed(1);
legendName = monitorInfo.result[i].monitor_name +" "+ lossRate + "%"; legendName = monitorInfo.result[i].monitor_name +" "+ lossRate + "%";
@@ -192,7 +194,13 @@
type: 'line', type: 'line',
smooth: true, smooth: true,
symbol: 'none', 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; this.option.title.text = monitorInfo.result[0].server_name;