Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
xOS committed Feb 11, 2024
1 parent 6dd67ff commit 4b583a0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
10 changes: 5 additions & 5 deletions cmd/dashboard/controller/common_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func (cp *commonPage) network(c *gin.Context) {
Code: http.StatusForbidden,
Title: "请求失败",
Msg: "请求参数有误:" + "server monitor history not found",
Link: "/server",
Link: "/",
Btn: "返回重试",
}, true)
return
Expand All @@ -171,7 +171,7 @@ func (cp *commonPage) network(c *gin.Context) {
Code: http.StatusForbidden,
Title: "请求失败",
Msg: "请求参数有误:" + err.Error(),
Link: "/server",
Link: "/",
Btn: "返回重试",
}, true)
return
Expand All @@ -182,7 +182,7 @@ func (cp *commonPage) network(c *gin.Context) {
Code: http.StatusForbidden,
Title: "请求失败",
Msg: "请求参数有误:" + "server id not found",
Link: "/server",
Link: "/",
Btn: "返回重试",
}, true)
return
Expand All @@ -201,8 +201,8 @@ func (cp *commonPage) network(c *gin.Context) {
mygin.ShowErrorPage(c, mygin.ErrInfo{
Code: http.StatusForbidden,
Title: "请求失败",
Msg: "请求参数有误:" + "server id not found",
Link: "/server",
Msg: "请求参数有误:" + "no server id not found with monitor histories",
Link: "/",
Btn: "返回重试",
}, true)
return
Expand Down
16 changes: 8 additions & 8 deletions service/singleton/servicesentinel.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func NewServiceSentinel(serviceSentinelDispatchBus chan<- model.Monitor) {
serviceResponseDataStoreCurrentUp: make(map[uint64]uint64),
serviceResponseDataStoreCurrentDown: make(map[uint64]uint64),
serviceResponseDataStoreCurrentAvgDelay: make(map[uint64]float32),
serviceResponseTCPPing: make(map[uint64]map[uint64]*tcppingStore),
serviceResponsePing: make(map[uint64]map[uint64]*pingStore),
monitors: make(map[uint64]*model.Monitor),
sslCertCache: make(map[uint64]string),
// 30天数据缓存
Expand Down Expand Up @@ -104,7 +104,7 @@ type ServiceSentinel struct {
serviceResponseDataStoreCurrentUp map[uint64]uint64 // [monitor_id] -> 当前服务在线计数
serviceResponseDataStoreCurrentDown map[uint64]uint64 // [monitor_id] -> 当前服务离线计数
serviceResponseDataStoreCurrentAvgDelay map[uint64]float32 // [monitor_id] -> 当前服务离线计数
serviceResponseTCPPing map[uint64]map[uint64]*tcppingStore // [monitor_id] -> ClientID -> delay
serviceResponsePing map[uint64]map[uint64]*pingStore // [monitor_id] -> ClientID -> delay
lastStatus map[uint64]int
sslCertCache map[uint64]string

Expand All @@ -116,7 +116,7 @@ type ServiceSentinel struct {
monthlyStatus map[uint64]*model.ServiceItemResponse // [monitor_id] -> model.ServiceItemResponse
}

type tcppingStore struct {
type pingStore struct {
count int
ping float32
}
Expand Down Expand Up @@ -336,15 +336,15 @@ func (ss *ServiceSentinel) worker() {
continue
}
mh := r.Data
if mh.Type == model.TaskTypeTCPPing {
monitorTcpMap, ok := ss.serviceResponseTCPPing[mh.GetId()]
if mh.Type == model.TaskTypeTCPPing || mh.Type == model.TaskTypeICMPPing {
monitorTcpMap, ok := ss.serviceResponsePing[mh.GetId()]
if !ok {
monitorTcpMap = make(map[uint64]*tcppingStore)
ss.serviceResponseTCPPing[mh.GetId()] = monitorTcpMap
monitorTcpMap = make(map[uint64]*pingStore)
ss.serviceResponsePing[mh.GetId()] = monitorTcpMap
}
ts, ok := monitorTcpMap[mh.GetServerId()]
if !ok {
ts = &tcppingStore{}
ts = &pingStore{}
}
ts.count++
ts.ping = (ts.ping*float32(ts.count-1) + mh.Delay) / float32(ts.count)
Expand Down

0 comments on commit 4b583a0

Please sign in to comment.