add "network page" api (#460)

* add network api

* a minor change

* only show service name if unauthorized

* update

* 除了 load/初始化 避免在 singleton 进行查询等操作

---------

Co-authored-by: naiba <hi@nai.ba>
This commit is contained in:
UUBulb 2024-10-27 14:43:37 +08:00 committed by GitHub
parent b4edb4cc95
commit ff0ff9a9ee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 180 additions and 50 deletions

View File

@ -55,6 +55,10 @@ func routers(r *gin.Engine) {
optionalAuth.GET("/ws/server", commonHandler(serverStream)) optionalAuth.GET("/ws/server", commonHandler(serverStream))
optionalAuth.GET("/server-group", commonHandler(listServerGroup)) optionalAuth.GET("/server-group", commonHandler(listServerGroup))
optionalAuth.GET("/service", commonHandler(listService))
optionalAuth.GET("/service/:id", commonHandler(listServiceHistory))
optionalAuth.GET("/service/server", commonHandler(listServerWithServices))
optionalAuth.GET("/setting", commonHandler(listConfig)) optionalAuth.GET("/setting", commonHandler(listConfig))
auth := api.Group("", authMiddleware.MiddlewareFunc()) auth := api.Group("", authMiddleware.MiddlewareFunc())
@ -71,7 +75,6 @@ func routers(r *gin.Engine) {
auth.POST("/user", commonHandler(createUser)) auth.POST("/user", commonHandler(createUser))
auth.POST("/batch-delete/user", commonHandler(batchDeleteUser)) auth.POST("/batch-delete/user", commonHandler(batchDeleteUser))
auth.GET("/service", commonHandler(listService))
auth.POST("/service", commonHandler(createService)) auth.POST("/service", commonHandler(createService))
auth.PATCH("/service/:id", commonHandler(updateService)) auth.PATCH("/service/:id", commonHandler(updateService))
auth.POST("/batch-delete/service", commonHandler(batchDeleteService)) auth.POST("/batch-delete/service", commonHandler(batchDeleteService))

View File

@ -1,12 +1,15 @@
package controller package controller
import ( import (
"errors"
"fmt" "fmt"
"strconv" "strconv"
"strings" "strings"
"time"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/jinzhu/copier" "github.com/jinzhu/copier"
"github.com/naiba/nezha/model" "github.com/naiba/nezha/model"
"github.com/naiba/nezha/service/singleton" "github.com/naiba/nezha/service/singleton"
"gorm.io/gorm" "gorm.io/gorm"
@ -17,7 +20,7 @@ import (
// @Security BearerAuth // @Security BearerAuth
// @Schemes // @Schemes
// @Description List service // @Description List service
// @Tags auth required // @Tags common
// @Produce json // @Produce json
// @Success 200 {object} model.CommonResponse[model.ServiceResponse] // @Success 200 {object} model.CommonResponse[model.ServiceResponse]
// @Router /service [get] // @Router /service [get]
@ -29,10 +32,16 @@ func listService(c *gin.Context) (*model.ServiceResponse, error) {
var statsStore map[uint64]model.CycleTransferStats var statsStore map[uint64]model.CycleTransferStats
copier.Copy(&stats, singleton.ServiceSentinelShared.LoadStats()) copier.Copy(&stats, singleton.ServiceSentinelShared.LoadStats())
copier.Copy(&statsStore, singleton.AlertsCycleTransferStatsStore) copier.Copy(&statsStore, singleton.AlertsCycleTransferStatsStore)
_, isMember := c.Get(model.CtxKeyAuthorizedUser)
authorized := isMember // TODO || isViewPasswordVerfied
for k, service := range stats { for k, service := range stats {
if !service.Service.EnableShowInService { if !service.Service.EnableShowInService {
delete(stats, k) delete(stats, k)
} }
if !authorized {
service.Service = &model.Service{Name: service.Service.Name}
stats[k] = service
}
} }
return []interface { return []interface {
}{ }{
@ -49,6 +58,114 @@ func listService(c *gin.Context) (*model.ServiceResponse, error) {
}, nil }, nil
} }
// List service histories by server id
// @Summary List service histories by server id
// @Security BearerAuth
// @Schemes
// @Description List service histories by server id
// @Tags common
// @param id path uint true "Server ID"
// @Produce json
// @Success 200 {object} model.CommonResponse[[]model.ServiceInfos]
// @Router /service/{id} [get]
func listServiceHistory(c *gin.Context) ([]*model.ServiceInfos, error) {
idStr := c.Param("id")
id, err := strconv.ParseUint(idStr, 10, 64)
if err != nil {
return nil, err
}
singleton.ServerLock.RLock()
server, ok := singleton.ServerList[id]
if !ok {
return nil, errors.New("server not found")
}
_, isMember := c.Get(model.CtxKeyAuthorizedUser)
authorized := isMember // TODO || isViewPasswordVerfied
if server.HideForGuest && !authorized {
return nil, errors.New("unauthorized")
}
singleton.ServerLock.RUnlock()
var serviceHistories []*model.ServiceHistory
if err := singleton.DB.Model(&model.ServiceHistory{}).Select("service_id, created_at, server_id, avg_delay").
Where("server_id = ?", id).Where("created_at >= ?", time.Now().Add(-24*time.Hour)).Order("service_id, created_at").
Scan(&serviceHistories).Error; err != nil {
return nil, err
}
singleton.ServiceSentinelShared.ServicesLock.RLock()
defer singleton.ServiceSentinelShared.ServicesLock.RUnlock()
singleton.ServerLock.RLock()
defer singleton.ServerLock.RUnlock()
var sortedServiceIDs []uint64
resultMap := make(map[uint64]*model.ServiceInfos)
for _, history := range serviceHistories {
infos, ok := resultMap[history.ServiceID]
if !ok {
infos = &model.ServiceInfos{
ServiceID: history.ServiceID,
ServerID: history.ServerID,
// ServiceName: singleton.ServiceSentinel.Services[history.ServiceID].Name,
ServerName: singleton.ServerList[history.ServerID].Name,
}
resultMap[history.ServiceID] = infos
sortedServiceIDs = append(sortedServiceIDs, history.ServiceID)
}
infos.CreatedAt = append(infos.CreatedAt, history.CreatedAt.Truncate(time.Minute).Unix()*1000)
infos.AvgDelay = append(infos.AvgDelay, history.AvgDelay)
}
ret := make([]*model.ServiceInfos, 0, len(sortedServiceIDs))
for _, id := range sortedServiceIDs {
ret = append(ret, resultMap[id])
}
return ret, nil
}
// List server with service
// @Summary List server with service
// @Security BearerAuth
// @Schemes
// @Description List server with service
// @Tags common
// @Produce json
// @Success 200 {object} model.CommonResponse[[]uint64]
// @Router /service/server [get]
func listServerWithServices(c *gin.Context) ([]uint64, error) {
var serverIdsWithService []uint64
if err := singleton.DB.Model(&model.ServiceHistory{}).
Select("distinct(server_id)").
Where("server_id != 0").
Find(&serverIdsWithService).Error; err != nil {
return nil, newGormError("%v", err)
}
_, isMember := c.Get(model.CtxKeyAuthorizedUser)
authorized := isMember // TODO || isViewPasswordVerfied
var ret []uint64
for _, id := range serverIdsWithService {
singleton.ServerLock.RLock()
server, ok := singleton.ServerList[id]
if !ok {
singleton.ServerLock.RUnlock()
return nil, errors.New("server not found")
}
if !server.HideForGuest || authorized {
ret = append(ret, id)
}
singleton.ServerLock.RUnlock()
}
return ret, nil
}
// Create service // Create service
// @Summary Create service // @Summary Create service
// @Security BearerAuth // @Security BearerAuth

View File

@ -0,0 +1,10 @@
package model
type ServiceInfos struct {
ServiceID uint64 `json:"monitor_id"`
ServerID uint64 `json:"server_id"`
ServiceName string `json:"monitor_name"`
ServerName string `json:"server_name"`
CreatedAt []int64 `json:"created_at"`
AvgDelay []float32 `json:"avg_delay"`
}

View File

@ -42,7 +42,7 @@ func NewServiceSentinel(serviceSentinelDispatchBus chan<- model.Service) {
serviceResponseDataStoreCurrentDown: make(map[uint64]uint64), serviceResponseDataStoreCurrentDown: make(map[uint64]uint64),
serviceResponseDataStoreCurrentAvgDelay: make(map[uint64]float32), serviceResponseDataStoreCurrentAvgDelay: make(map[uint64]float32),
serviceResponsePing: make(map[uint64]map[uint64]*pingStore), serviceResponsePing: make(map[uint64]map[uint64]*pingStore),
services: make(map[uint64]*model.Service), Services: make(map[uint64]*model.Service),
sslCertCache: make(map[uint64]string), sslCertCache: make(map[uint64]string),
// 30天数据缓存 // 30天数据缓存
monthlyStatus: make(map[uint64]*model.ServiceResponseItem), monthlyStatus: make(map[uint64]*model.ServiceResponseItem),
@ -104,8 +104,8 @@ type ServiceSentinel struct {
lastStatus map[uint64]int lastStatus map[uint64]int
sslCertCache map[uint64]string sslCertCache map[uint64]string
servicesLock sync.RWMutex ServicesLock sync.RWMutex
services map[uint64]*model.Service Services map[uint64]*model.Service
// 30天数据缓存 // 30天数据缓存
monthlyStatusLock sync.Mutex monthlyStatusLock sync.Mutex
@ -157,11 +157,11 @@ func (ss *ServiceSentinel) Dispatch(r ReportData) {
ss.serviceReportChannel <- r ss.serviceReportChannel <- r
} }
func (ss *ServiceSentinel) Services() []*model.Service { func (ss *ServiceSentinel) GetServiceList() []*model.Service {
ss.servicesLock.RLock() ss.ServicesLock.RLock()
defer ss.servicesLock.RUnlock() defer ss.ServicesLock.RUnlock()
var services []*model.Service var services []*model.Service
for _, v := range ss.services { for _, v := range ss.Services {
services = append(services, v) services = append(services, v)
} }
sort.SliceStable(services, func(i, j int) bool { sort.SliceStable(services, func(i, j int) bool {
@ -182,8 +182,8 @@ func (ss *ServiceSentinel) loadServiceHistory() {
defer ss.serviceResponseDataStoreLock.Unlock() defer ss.serviceResponseDataStoreLock.Unlock()
ss.monthlyStatusLock.Lock() ss.monthlyStatusLock.Lock()
defer ss.monthlyStatusLock.Unlock() defer ss.monthlyStatusLock.Unlock()
ss.servicesLock.Lock() ss.ServicesLock.Lock()
defer ss.servicesLock.Unlock() defer ss.ServicesLock.Unlock()
for i := 0; i < len(services); i++ { for i := 0; i < len(services); i++ {
task := *services[i] task := *services[i]
@ -194,7 +194,7 @@ func (ss *ServiceSentinel) loadServiceHistory() {
if err != nil { if err != nil {
panic(err) panic(err)
} }
ss.services[services[i].ID] = services[i] ss.Services[services[i].ID] = services[i]
ss.serviceCurrentStatusData[services[i].ID] = make([]*pb.TaskResult, _CurrentStatusSize) ss.serviceCurrentStatusData[services[i].ID] = make([]*pb.TaskResult, _CurrentStatusSize)
ss.serviceStatusToday[services[i].ID] = &_TodayStatsOfService{} ss.serviceStatusToday[services[i].ID] = &_TodayStatsOfService{}
} }
@ -234,8 +234,8 @@ func (ss *ServiceSentinel) OnServiceUpdate(m model.Service) error {
defer ss.serviceResponseDataStoreLock.Unlock() defer ss.serviceResponseDataStoreLock.Unlock()
ss.monthlyStatusLock.Lock() ss.monthlyStatusLock.Lock()
defer ss.monthlyStatusLock.Unlock() defer ss.monthlyStatusLock.Unlock()
ss.servicesLock.Lock() ss.ServicesLock.Lock()
defer ss.servicesLock.Unlock() defer ss.ServicesLock.Unlock()
var err error var err error
// 写入新任务 // 写入新任务
@ -245,9 +245,9 @@ func (ss *ServiceSentinel) OnServiceUpdate(m model.Service) error {
if err != nil { if err != nil {
return err return err
} }
if ss.services[m.ID] != nil { if ss.Services[m.ID] != nil {
// 停掉旧任务 // 停掉旧任务
Cron.Remove(ss.services[m.ID].CronJobID) Cron.Remove(ss.Services[m.ID].CronJobID)
} else { } else {
// 新任务初始化数据 // 新任务初始化数据
ss.monthlyStatus[m.ID] = &model.ServiceResponseItem{ ss.monthlyStatus[m.ID] = &model.ServiceResponseItem{
@ -260,7 +260,7 @@ func (ss *ServiceSentinel) OnServiceUpdate(m model.Service) error {
ss.serviceStatusToday[m.ID] = &_TodayStatsOfService{} ss.serviceStatusToday[m.ID] = &_TodayStatsOfService{}
} }
// 更新这个任务 // 更新这个任务
ss.services[m.ID] = &m ss.Services[m.ID] = &m
return nil return nil
} }
@ -269,8 +269,8 @@ func (ss *ServiceSentinel) OnServiceDelete(ids []uint64) {
defer ss.serviceResponseDataStoreLock.Unlock() defer ss.serviceResponseDataStoreLock.Unlock()
ss.monthlyStatusLock.Lock() ss.monthlyStatusLock.Lock()
defer ss.monthlyStatusLock.Unlock() defer ss.monthlyStatusLock.Unlock()
ss.servicesLock.Lock() ss.ServicesLock.Lock()
defer ss.servicesLock.Unlock() defer ss.ServicesLock.Unlock()
for _, id := range ids { for _, id := range ids {
delete(ss.serviceCurrentStatusIndex, id) delete(ss.serviceCurrentStatusIndex, id)
@ -283,8 +283,8 @@ func (ss *ServiceSentinel) OnServiceDelete(ids []uint64) {
delete(ss.serviceStatusToday, id) delete(ss.serviceStatusToday, id)
// 停掉定时任务 // 停掉定时任务
Cron.Remove(ss.services[id].CronJobID) Cron.Remove(ss.Services[id].CronJobID)
delete(ss.services, id) delete(ss.Services, id)
delete(ss.monthlyStatus, id) delete(ss.monthlyStatus, id)
} }
@ -297,8 +297,8 @@ func (ss *ServiceSentinel) LoadStats() map[uint64]*model.ServiceResponseItem {
defer ss.monthlyStatusLock.Unlock() defer ss.monthlyStatusLock.Unlock()
// 刷新最新一天的数据 // 刷新最新一天的数据
for k := range ss.services { for k := range ss.Services {
ss.monthlyStatus[k].Service = ss.services[k] ss.monthlyStatus[k].Service = ss.Services[k]
v := ss.serviceStatusToday[k] v := ss.serviceStatusToday[k]
// 30 天在线率, // 30 天在线率,
@ -329,7 +329,7 @@ func (ss *ServiceSentinel) LoadStats() map[uint64]*model.ServiceResponseItem {
func (ss *ServiceSentinel) worker() { func (ss *ServiceSentinel) worker() {
// 从服务状态汇报管道获取汇报的服务数据 // 从服务状态汇报管道获取汇报的服务数据
for r := range ss.serviceReportChannel { for r := range ss.serviceReportChannel {
if ss.services[r.Data.GetId()] == nil || ss.services[r.Data.GetId()].ID == 0 { if ss.Services[r.Data.GetId()] == nil || ss.Services[r.Data.GetId()].ID == 0 {
log.Printf("NEZHA>> 错误的服务监控上报 %+v", r) log.Printf("NEZHA>> 错误的服务监控上报 %+v", r)
continue continue
} }
@ -427,23 +427,23 @@ func (ss *ServiceSentinel) worker() {
// 延迟报警 // 延迟报警
if mh.Delay > 0 { if mh.Delay > 0 {
ss.servicesLock.RLock() ss.ServicesLock.RLock()
if ss.services[mh.GetId()].LatencyNotify { if ss.Services[mh.GetId()].LatencyNotify {
notificationGroupID := ss.services[mh.GetId()].NotificationGroupID notificationGroupID := ss.Services[mh.GetId()].NotificationGroupID
minMuteLabel := NotificationMuteLabel.ServiceLatencyMin(mh.GetId()) minMuteLabel := NotificationMuteLabel.ServiceLatencyMin(mh.GetId())
maxMuteLabel := NotificationMuteLabel.ServiceLatencyMax(mh.GetId()) maxMuteLabel := NotificationMuteLabel.ServiceLatencyMax(mh.GetId())
if mh.Delay > ss.services[mh.GetId()].MaxLatency { if mh.Delay > ss.Services[mh.GetId()].MaxLatency {
// 延迟超过最大值 // 延迟超过最大值
ServerLock.RLock() ServerLock.RLock()
reporterServer := ServerList[r.Reporter] reporterServer := ServerList[r.Reporter]
msg := fmt.Sprintf("[Latency] %s %2f > %2f, Reporter: %s", ss.services[mh.GetId()].Name, mh.Delay, ss.services[mh.GetId()].MaxLatency, reporterServer.Name) msg := fmt.Sprintf("[Latency] %s %2f > %2f, Reporter: %s", ss.Services[mh.GetId()].Name, mh.Delay, ss.Services[mh.GetId()].MaxLatency, reporterServer.Name)
go SendNotification(notificationGroupID, msg, minMuteLabel) go SendNotification(notificationGroupID, msg, minMuteLabel)
ServerLock.RUnlock() ServerLock.RUnlock()
} else if mh.Delay < ss.services[mh.GetId()].MinLatency { } else if mh.Delay < ss.Services[mh.GetId()].MinLatency {
// 延迟低于最小值 // 延迟低于最小值
ServerLock.RLock() ServerLock.RLock()
reporterServer := ServerList[r.Reporter] reporterServer := ServerList[r.Reporter]
msg := fmt.Sprintf("[Latency] %s %2f < %2f, Reporter: %s", ss.services[mh.GetId()].Name, mh.Delay, ss.services[mh.GetId()].MinLatency, reporterServer.Name) msg := fmt.Sprintf("[Latency] %s %2f < %2f, Reporter: %s", ss.Services[mh.GetId()].Name, mh.Delay, ss.Services[mh.GetId()].MinLatency, reporterServer.Name)
go SendNotification(notificationGroupID, msg, maxMuteLabel) go SendNotification(notificationGroupID, msg, maxMuteLabel)
ServerLock.RUnlock() ServerLock.RUnlock()
} else { } else {
@ -452,24 +452,24 @@ func (ss *ServiceSentinel) worker() {
UnMuteNotification(notificationGroupID, maxMuteLabel) UnMuteNotification(notificationGroupID, maxMuteLabel)
} }
} }
ss.servicesLock.RUnlock() ss.ServicesLock.RUnlock()
} }
// 状态变更报警+触发任务执行 // 状态变更报警+触发任务执行
if stateCode == StatusDown || stateCode != ss.lastStatus[mh.GetId()] { if stateCode == StatusDown || stateCode != ss.lastStatus[mh.GetId()] {
ss.servicesLock.Lock() ss.ServicesLock.Lock()
lastStatus := ss.lastStatus[mh.GetId()] lastStatus := ss.lastStatus[mh.GetId()]
// 存储新的状态值 // 存储新的状态值
ss.lastStatus[mh.GetId()] = stateCode ss.lastStatus[mh.GetId()] = stateCode
// 判断是否需要发送通知 // 判断是否需要发送通知
isNeedSendNotification := ss.services[mh.GetId()].Notify && (lastStatus != 0 || stateCode == StatusDown) isNeedSendNotification := ss.Services[mh.GetId()].Notify && (lastStatus != 0 || stateCode == StatusDown)
if isNeedSendNotification { if isNeedSendNotification {
ServerLock.RLock() ServerLock.RLock()
reporterServer := ServerList[r.Reporter] reporterServer := ServerList[r.Reporter]
notificationGroupID := ss.services[mh.GetId()].NotificationGroupID notificationGroupID := ss.Services[mh.GetId()].NotificationGroupID
notificationMsg := fmt.Sprintf("[%s] %s Reporter: %s, Error: %s", StatusCodeToString(stateCode), ss.services[mh.GetId()].Name, reporterServer.Name, mh.Data) notificationMsg := fmt.Sprintf("[%s] %s Reporter: %s, Error: %s", StatusCodeToString(stateCode), ss.Services[mh.GetId()].Name, reporterServer.Name, mh.Data)
muteLabel := NotificationMuteLabel.ServiceStateChanged(mh.GetId()) muteLabel := NotificationMuteLabel.ServiceStateChanged(mh.GetId())
// 状态变更时,清除静音缓存 // 状态变更时,清除静音缓存
@ -482,7 +482,7 @@ func (ss *ServiceSentinel) worker() {
} }
// 判断是否需要触发任务 // 判断是否需要触发任务
isNeedTriggerTask := ss.services[mh.GetId()].EnableTriggerTask && lastStatus != 0 isNeedTriggerTask := ss.Services[mh.GetId()].EnableTriggerTask && lastStatus != 0
if isNeedTriggerTask { if isNeedTriggerTask {
ServerLock.RLock() ServerLock.RLock()
reporterServer := ServerList[r.Reporter] reporterServer := ServerList[r.Reporter]
@ -490,14 +490,14 @@ func (ss *ServiceSentinel) worker() {
if stateCode == StatusGood && lastStatus != stateCode { if stateCode == StatusGood && lastStatus != stateCode {
// 当前状态正常 前序状态非正常时 触发恢复任务 // 当前状态正常 前序状态非正常时 触发恢复任务
go SendTriggerTasks(ss.services[mh.GetId()].RecoverTriggerTasks, reporterServer.ID) go SendTriggerTasks(ss.Services[mh.GetId()].RecoverTriggerTasks, reporterServer.ID)
} else if lastStatus == StatusGood && lastStatus != stateCode { } else if lastStatus == StatusGood && lastStatus != stateCode {
// 前序状态正常 当前状态非正常时 触发失败任务 // 前序状态正常 当前状态非正常时 触发失败任务
go SendTriggerTasks(ss.services[mh.GetId()].FailTriggerTasks, reporterServer.ID) go SendTriggerTasks(ss.Services[mh.GetId()].FailTriggerTasks, reporterServer.ID)
} }
} }
ss.servicesLock.Unlock() ss.ServicesLock.Unlock()
} }
ss.serviceResponseDataStoreLock.Unlock() ss.serviceResponseDataStoreLock.Unlock()
@ -509,22 +509,22 @@ func (ss *ServiceSentinel) worker() {
!strings.HasSuffix(mh.Data, "EOF") && !strings.HasSuffix(mh.Data, "EOF") &&
!strings.HasSuffix(mh.Data, "timed out") { !strings.HasSuffix(mh.Data, "timed out") {
errMsg = mh.Data errMsg = mh.Data
ss.servicesLock.RLock() ss.ServicesLock.RLock()
if ss.services[mh.GetId()].Notify { if ss.Services[mh.GetId()].Notify {
muteLabel := NotificationMuteLabel.ServiceSSL(mh.GetId(), "network") muteLabel := NotificationMuteLabel.ServiceSSL(mh.GetId(), "network")
go SendNotification(ss.services[mh.GetId()].NotificationGroupID, fmt.Sprintf("[SSL] Fetch cert info failed, %s %s", ss.services[mh.GetId()].Name, errMsg), muteLabel) go SendNotification(ss.Services[mh.GetId()].NotificationGroupID, fmt.Sprintf("[SSL] Fetch cert info failed, %s %s", ss.Services[mh.GetId()].Name, errMsg), muteLabel)
} }
ss.servicesLock.RUnlock() ss.ServicesLock.RUnlock()
} }
} else { } else {
// 清除网络错误静音缓存 // 清除网络错误静音缓存
UnMuteNotification(ss.services[mh.GetId()].NotificationGroupID, NotificationMuteLabel.ServiceSSL(mh.GetId(), "network")) UnMuteNotification(ss.Services[mh.GetId()].NotificationGroupID, NotificationMuteLabel.ServiceSSL(mh.GetId(), "network"))
var newCert = strings.Split(mh.Data, "|") var newCert = strings.Split(mh.Data, "|")
if len(newCert) > 1 { if len(newCert) > 1 {
ss.servicesLock.Lock() ss.ServicesLock.Lock()
enableNotify := ss.services[mh.GetId()].Notify enableNotify := ss.Services[mh.GetId()].Notify
// 首次获取证书信息时,缓存证书信息 // 首次获取证书信息时,缓存证书信息
if ss.sslCertCache[mh.GetId()] == "" { if ss.sslCertCache[mh.GetId()] == "" {
@ -542,9 +542,9 @@ func (ss *ServiceSentinel) worker() {
ss.sslCertCache[mh.GetId()] = mh.Data ss.sslCertCache[mh.GetId()] = mh.Data
} }
notificationGroupID := ss.services[mh.GetId()].NotificationGroupID notificationGroupID := ss.Services[mh.GetId()].NotificationGroupID
serviceName := ss.services[mh.GetId()].Name serviceName := ss.Services[mh.GetId()].Name
ss.servicesLock.Unlock() ss.ServicesLock.Unlock()
// 需要发送提醒 // 需要发送提醒
if enableNotify { if enableNotify {