🐛 fix service stats

This commit is contained in:
naiba
2022-10-12 23:06:25 +08:00
parent 998784d177
commit 1bb99494e3
9 changed files with 115 additions and 112 deletions

View File

@@ -103,6 +103,8 @@ type Config struct {
Cover uint8 // 覆盖范围0:提醒未被 IgnoredIPNotification 包含的所有服务器; 1:仅提醒被 IgnoredIPNotification 包含的服务器;
IgnoredIPNotification string // 特定服务器IP多个服务器用逗号分隔
Location string // 时区,默认为 Asia/Shanghai
v *viper.Viper
IgnoredIPNotificationServerIDs map[uint64]bool // [ServerID] -> bool(值为true代表当前ServerID在特定服务器列表内
}
@@ -136,6 +138,9 @@ func (c *Config) Read(path string) error {
if c.EnableIPChangeNotification && c.IPChangeNotificationTag == "" {
c.IPChangeNotificationTag = "default"
}
if c.Location == "" {
c.Location = "Asia/Shanghai"
}
c.updateIgnoredIPNotificationID()
return nil

View File

@@ -1,23 +1,11 @@
package model
import (
pb "github.com/naiba/nezha/proto"
)
// MonitorHistory 历史监控记录
type MonitorHistory struct {
Common
MonitorID uint64
Delay float32 // 延迟,毫秒
Data string
Successful bool // 是否成功
}
func PB2MonitorHistory(r *pb.TaskResult) MonitorHistory {
return MonitorHistory{
Delay: r.GetDelay(),
Successful: r.GetSuccessful(),
MonitorID: r.GetId(),
Data: r.GetData(),
}
MonitorID uint64
AvgDelay float32 // 平均延迟,毫秒
Up uint64 // 检查状态良好计数
Down uint64 // 检查状态异常计数
Data string
}