mirror of
https://github.com/nezhahq/nezha.git
synced 2025-02-02 01:28:13 -05:00
🚸 增大当前服务状态容错率
This commit is contained in:
parent
6286e34af0
commit
6f565ba022
@ -1,7 +1,7 @@
|
|||||||
<div align="center" style="background-color: white">
|
<div align="center" style="background-color: white">
|
||||||
<img width="500" style="max-width:100%" src="https://raw.githubusercontent.com/naiba/nezha/master/resource/static/brand.png" title="哪吒监控">
|
<img width="500" style="max-width:100%" src="https://raw.githubusercontent.com/naiba/nezha/master/resource/static/brand.png" title="哪吒监控">
|
||||||
<br><br>
|
<br><br>
|
||||||
<img src="https://img.shields.io/github/workflow/status/naiba/nezha/Dashboard%20image?label=Dash%20v0.6.1&logo=github&style=for-the-badge"> <img src="https://img.shields.io/github/v/release/naiba/nezha?color=brightgreen&label=Agent&style=for-the-badge&logo=github"> <img src="https://img.shields.io/github/workflow/status/naiba/nezha/Agent%20release?label=Agent%20CI&logo=github&style=for-the-badge"> <img src="https://img.shields.io/badge/Installer-v0.4.10-brightgreen?style=for-the-badge&logo=linux">
|
<img src="https://img.shields.io/github/workflow/status/naiba/nezha/Dashboard%20image?label=Dash%20v0.6.2&logo=github&style=for-the-badge"> <img src="https://img.shields.io/github/v/release/naiba/nezha?color=brightgreen&label=Agent&style=for-the-badge&logo=github"> <img src="https://img.shields.io/github/workflow/status/naiba/nezha/Agent%20release?label=Agent%20CI&logo=github&style=for-the-badge"> <img src="https://img.shields.io/badge/Installer-v0.4.10-brightgreen?style=for-the-badge&logo=linux">
|
||||||
<br>
|
<br>
|
||||||
<p>:trollface: 哪吒监控 一站式轻监控轻运维系统。支持系统状态、HTTP(SSL 证书变更、即将到期、到期)、TCP、Ping 监控报警,命令批量执行和计划任务。</p>
|
<p>:trollface: 哪吒监控 一站式轻监控轻运维系统。支持系统状态、HTTP(SSL 证书变更、即将到期、到期)、TCP、Ping 监控报警,命令批量执行和计划任务。</p>
|
||||||
</div>
|
</div>
|
||||||
|
@ -13,7 +13,7 @@ import (
|
|||||||
pb "github.com/naiba/nezha/proto"
|
pb "github.com/naiba/nezha/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
var Version = "v0.6.1" // !!记得修改 README 重的 badge 版本!!
|
var Version = "v0.6.2" // !!记得修改 README 重的 badge 版本!!
|
||||||
|
|
||||||
const (
|
const (
|
||||||
SnapshotDelay = 3
|
SnapshotDelay = 3
|
||||||
|
@ -11,6 +11,8 @@ import (
|
|||||||
pb "github.com/naiba/nezha/proto"
|
pb "github.com/naiba/nezha/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const _CurrentStatusSize = 60 // 统计 10 分钟内的数据为当前状态
|
||||||
|
|
||||||
var ServiceSentinelShared *ServiceSentinel
|
var ServiceSentinelShared *ServiceSentinel
|
||||||
|
|
||||||
func NewServiceSentinel() {
|
func NewServiceSentinel() {
|
||||||
@ -99,7 +101,7 @@ func (ss *ServiceSentinel) OnMonitorUpdate() {
|
|||||||
for i := 0; i < len(monitors); i++ {
|
for i := 0; i < len(monitors); i++ {
|
||||||
ss.monitors[monitors[i].ID] = monitors[i]
|
ss.monitors[monitors[i].ID] = monitors[i]
|
||||||
if len(ss.serviceCurrentStatusData[monitors[i].ID]) == 0 {
|
if len(ss.serviceCurrentStatusData[monitors[i].ID]) == 0 {
|
||||||
ss.serviceCurrentStatusData[monitors[i].ID] = make([]model.MonitorHistory, 20)
|
ss.serviceCurrentStatusData[monitors[i].ID] = make([]model.MonitorHistory, _CurrentStatusSize)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -184,7 +186,7 @@ func (ss *ServiceSentinel) LoadStats() map[uint64]*model.ServiceItemResponse {
|
|||||||
msm[k].Delay[29] = (msm[k].Delay[29]*float32(msm[k].Up[29]) + v[i].Delay) / float32(msm[k].Up[29]+1)
|
msm[k].Delay[29] = (msm[k].Delay[29]*float32(msm[k].Up[29]) + v[i].Delay) / float32(msm[k].Up[29]+1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 最后20分钟的状态 与 monitor 对象填充
|
// 最后 10 分钟的状态 与 monitor 对象填充
|
||||||
for k, v := range ss.serviceResponseDataStoreCurrentDown {
|
for k, v := range ss.serviceResponseDataStoreCurrentDown {
|
||||||
msm[k].CurrentDown = v
|
msm[k].CurrentDown = v
|
||||||
}
|
}
|
||||||
@ -242,7 +244,7 @@ func (ss *ServiceSentinel) worker() {
|
|||||||
// 写入当前数据
|
// 写入当前数据
|
||||||
ss.serviceCurrentStatusData[mh.MonitorID][ss.serviceCurrentStatusIndex[mh.MonitorID]] = mh
|
ss.serviceCurrentStatusData[mh.MonitorID][ss.serviceCurrentStatusIndex[mh.MonitorID]] = mh
|
||||||
ss.serviceCurrentStatusIndex[mh.MonitorID]++
|
ss.serviceCurrentStatusIndex[mh.MonitorID]++
|
||||||
if ss.serviceCurrentStatusIndex[mh.MonitorID] == 20 {
|
if ss.serviceCurrentStatusIndex[mh.MonitorID] == _CurrentStatusSize {
|
||||||
ss.serviceCurrentStatusIndex[mh.MonitorID] = 0
|
ss.serviceCurrentStatusIndex[mh.MonitorID] = 0
|
||||||
}
|
}
|
||||||
// 更新当前状态
|
// 更新当前状态
|
||||||
|
Loading…
Reference in New Issue
Block a user