代码拉取完成,页面将自动刷新
package v2
// isFlapping determines if the check is flapping, based on the TotalStateChange
// and configured thresholds
func isFlapping(check *Check) bool {
if check == nil {
return false
}
if check.LowFlapThreshold == 0 || check.HighFlapThreshold == 0 {
return false
}
// Is the check already flapping?
if check.State == EventFlappingState {
return check.TotalStateChange > check.LowFlapThreshold
}
// The check was not flapping, now determine if it does now
return check.TotalStateChange >= check.HighFlapThreshold
}
// updateCheckState determines the check state based on whether the check is
// flapping, and its status
func updateCheckState(check *Check) {
check.TotalStateChange = totalStateChange(check)
if check == nil {
return
}
if flapping := isFlapping(check); flapping {
check.State = EventFlappingState
} else if check.Status == 0 {
check.State = EventPassingState
check.LastOK = check.Executed
} else {
check.State = EventFailingState
}
}
// totalStateChange calculates the total state change percentage for the
// history, which is later used for check state flap detection.
func totalStateChange(check *Check) uint32 {
if check == nil || len(check.History) < 21 {
return 0
}
stateChanges := 0.00
changeWeight := 0.80
previousStatus := check.History[len(check.History)-1].Status
for i := len(check.History) - 2; i >= 0; i-- {
if check.History[i].Status != previousStatus {
stateChanges += changeWeight
}
changeWeight += 0.02
previousStatus = check.History[i].Status
}
return uint32(float32(stateChanges) / 20 * 100)
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。