Documentation ¶
Index ¶
- Constants
- Variables
- func AddNotificationGroupToList(ng *model.NotificationGroup, ngn []uint64)
- func AddNotificationToList(n *model.Notification)
- func AlertSentinelStart()
- func CleanServiceHistory()
- func CronTrigger(cr *model.Cron, triggerServer ...uint64) func()
- func GetDDNSProvidersFromProfiles(profileId []uint64, ip *ddns2.IP) ([]*ddns2.Provider, error)
- func GetNATConfigByDomain(domain string) *model.NAT
- func GetStatusCode[T float32 | uint64](percent T) int
- func IPDesensitize(ip string) string
- func InitConfigFromPath(path string)
- func InitCronTask()
- func InitDBFromPath(path string)
- func InitNotification()
- func InitServer()
- func InitTimezoneAndCache()
- func LoadSingleton()
- func ManualTrigger(c *model.Cron)
- func NewServiceSentinel(serviceSentinelDispatchBus chan<- model.Service)
- func OnDDNSDelete(id []uint64)
- func OnDDNSUpdate(p *model.DDNSProfile)
- func OnDeleteAlert(id []uint64)
- func OnDeleteCron(id []uint64)
- func OnDeleteNotification(id []uint64)
- func OnDeleteNotificationGroup(gids []uint64)
- func OnNATDelete(id []uint64)
- func OnNATUpdate(n *model.NAT)
- func OnNameserverUpdate()
- func OnRefreshOrAddAlert(alert *model.AlertRule)
- func OnRefreshOrAddCron(c *model.Cron)
- func OnRefreshOrAddNotification(n *model.Notification)
- func OnRefreshOrAddNotificationGroup(ng *model.NotificationGroup, ngn []uint64)
- func OnServerDelete(sid []uint64)
- func OnUpdateLang(lang string) error
- func ReSortServer()
- func RecordTransferHourlyUsage()
- func SendNotification(notificationGroupID uint64, desc string, muteLabel *string, ...)
- func SendTriggerTasks(taskIDs []uint64, triggerServer uint64)
- func StatusCodeToString(statusCode int) string
- func UnMuteNotification(notificationGroupID uint64, muteLabel *string)
- func UpdateCronList()
- func UpdateDDNSList()
- func UpdateNATList()
- func UpdateNotificationGroupInList(ng *model.NotificationGroup, ngn []uint64)
- func UpdateNotificationInList(n *model.Notification)
- func UpdateNotificationList()
- type NotificationHistory
- type ReportData
- type ServiceSentinel
- func (ss *ServiceSentinel) Dispatch(r ReportData)
- func (ss *ServiceSentinel) GetServiceList() []*model.Service
- func (ss *ServiceSentinel) LoadStats() map[uint64]*model.ServiceResponseItem
- func (ss *ServiceSentinel) OnServiceDelete(ids []uint64)
- func (ss *ServiceSentinel) OnServiceUpdate(m model.Service) error
Constants ¶
const ( StatusNoData StatusGood StatusLowAvailability StatusDown )
Variables ¶
var ( AlertsLock sync.RWMutex Alerts []*model.AlertRule AlertsCycleTransferStatsStore map[uint64]*model.CycleTransferStats // [alert_id] -> 对应报警规则的周期流量统计 )
报警规则
var ( Cron *cron.Cron Crons map[uint64]*model.Cron // [CronID] -> *model.Cron CronLock sync.RWMutex CronList []*model.Cron )
var ( DDNSCache map[uint64]*model.DDNSProfile DDNSCacheLock sync.RWMutex DDNSList []*model.DDNSProfile )
var ( NATCache = make(map[string]*model.NAT) NATCacheRwLock sync.RWMutex NATIDToDomain = make(map[uint64]string) NATList []*model.NAT )
var ( NotificationList map[uint64]map[uint64]*model.Notification // [NotificationGroupID][NotificationID] -> model.Notification NotificationIDToGroups map[uint64]map[uint64]struct{} // [NotificationID] -> NotificationGroupID NotificationMap map[uint64]*model.Notification NotificationListSorted []*model.Notification NotificationGroup map[uint64]string // [NotificationGroupID] -> [NotificationGroupName] NotificationsLock sync.RWMutex NotificationGroupLock sync.RWMutex )
通知方式
var ( ServerList map[uint64]*model.Server // [ServerID] -> model.Server ServerUUIDToID map[string]uint64 // [ServerUUID] -> ServerID ServerLock sync.RWMutex SortedServerList []*model.Server // 用于存储服务器列表的 slice,按照服务器 ID 排序 SortedServerListForGuest []*model.Server SortedServerLock sync.RWMutex )
var Localizer *i18n.Localizer
var NotificationMuteLabel _NotificationMuteLabel
var Version = "debug"
Functions ¶
func AddNotificationGroupToList ¶
func AddNotificationGroupToList(ng *model.NotificationGroup, ngn []uint64)
AddNotificationGroupToList 添加通知方式组到map中
func AddNotificationToList ¶
func AddNotificationToList(n *model.Notification)
AddNotificationToList 添加通知方式到map中
func CronTrigger ¶
func GetNATConfigByDomain ¶
func GetStatusCode ¶
func IPDesensitize ¶
IPDesensitize 根据设置选择是否对IP进行打码处理 返回处理后的IP(关闭打码则返回原IP)
func InitCronTask ¶
func InitCronTask()
func InitNotification ¶
func InitNotification()
InitNotification 初始化 GroupID <-> ID <-> Notification 的映射
func InitServer ¶
func InitServer()
func InitTimezoneAndCache ¶
func InitTimezoneAndCache()
func ManualTrigger ¶
func NewServiceSentinel ¶
NewServiceSentinel 创建服务监控器
func OnDDNSDelete ¶
func OnDDNSDelete(id []uint64)
func OnDDNSUpdate ¶
func OnDDNSUpdate(p *model.DDNSProfile)
func OnDeleteAlert ¶
func OnDeleteAlert(id []uint64)
func OnDeleteCron ¶
func OnDeleteCron(id []uint64)
func OnDeleteNotification ¶
func OnDeleteNotification(id []uint64)
OnDeleteNotification 在map和表中删除通知方式
func OnDeleteNotificationGroup ¶
func OnDeleteNotificationGroup(gids []uint64)
UpdateNotificationGroupInList 删除通知方式组
func OnNATDelete ¶
func OnNATDelete(id []uint64)
func OnNATUpdate ¶
func OnNameserverUpdate ¶
func OnNameserverUpdate()
func OnRefreshOrAddAlert ¶
func OnRefreshOrAddCron ¶
func OnRefreshOrAddNotification ¶
func OnRefreshOrAddNotification(n *model.Notification)
OnRefreshOrAddNotification 刷新通知方式相关参数
func OnRefreshOrAddNotificationGroup ¶
func OnRefreshOrAddNotificationGroup(ng *model.NotificationGroup, ngn []uint64)
OnRefreshOrAddNotificationGroup 刷新通知方式组相关参数
func OnServerDelete ¶
func OnServerDelete(sid []uint64)
func OnUpdateLang ¶
func RecordTransferHourlyUsage ¶
func RecordTransferHourlyUsage()
RecordTransferHourlyUsage 对流量记录进行打点
func SendNotification ¶
func SendNotification(notificationGroupID uint64, desc string, muteLabel *string, ext ...*model.Server)
SendNotification 向指定的通知方式组的所有通知方式发送通知
func SendTriggerTasks ¶
func StatusCodeToString ¶
func UnMuteNotification ¶
func UpdateCronList ¶
func UpdateCronList()
func UpdateDDNSList ¶
func UpdateDDNSList()
func UpdateNATList ¶
func UpdateNATList()
func UpdateNotificationGroupInList ¶
func UpdateNotificationGroupInList(ng *model.NotificationGroup, ngn []uint64)
UpdateNotificationGroupInList 在 map 中更新通知方式组
func UpdateNotificationInList ¶
func UpdateNotificationInList(n *model.Notification)
UpdateNotificationInList 在 map 中更新通知方式
func UpdateNotificationList ¶
func UpdateNotificationList()
Types ¶
type NotificationHistory ¶
type ReportData ¶
type ReportData struct { Data *pb.TaskResult Reporter uint64 }
type ServiceSentinel ¶
type ServiceSentinel struct { ServicesLock sync.RWMutex Services map[uint64]*model.Service // contains filtered or unexported fields }
使用缓存 channel,处理上报的 Service 请求结果,然后判断是否需要报警 需要记录上一次的状态信息
加锁顺序:serviceResponseDataStoreLock > monthlyStatusLock > servicesLock
func (*ServiceSentinel) Dispatch ¶
func (ss *ServiceSentinel) Dispatch(r ReportData)
Dispatch 将传入的 ReportData 传给 服务状态汇报管道
func (*ServiceSentinel) GetServiceList ¶
func (ss *ServiceSentinel) GetServiceList() []*model.Service
func (*ServiceSentinel) LoadStats ¶
func (ss *ServiceSentinel) LoadStats() map[uint64]*model.ServiceResponseItem
func (*ServiceSentinel) OnServiceDelete ¶
func (ss *ServiceSentinel) OnServiceDelete(ids []uint64)
func (*ServiceSentinel) OnServiceUpdate ¶
func (ss *ServiceSentinel) OnServiceUpdate(m model.Service) error