mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-02-06 13:40:06 +00:00
✨ dashboard: 服务监控请求时间间隔
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package model
|
||||
|
||||
type ServiceItemResponse struct {
|
||||
Monitor Monitor
|
||||
Monitor *Monitor
|
||||
TotalUp uint64
|
||||
TotalDown uint64
|
||||
CurrentUp uint64
|
||||
|
||||
@@ -2,8 +2,10 @@ package model
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
pb "github.com/naiba/nezha/proto"
|
||||
"github.com/robfig/cron/v3"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
@@ -36,9 +38,12 @@ type Monitor struct {
|
||||
Type uint8
|
||||
Target string
|
||||
SkipServersRaw string
|
||||
Duration uint64
|
||||
Notify bool
|
||||
Cover uint8
|
||||
SkipServers map[uint64]bool `gorm:"-" json:"-"`
|
||||
|
||||
SkipServers map[uint64]bool `gorm:"-" json:"-"`
|
||||
CronJobID cron.EntryID `gorm:"-" json:"-"`
|
||||
}
|
||||
|
||||
func (m *Monitor) PB() *pb.Task {
|
||||
@@ -49,6 +54,14 @@ func (m *Monitor) PB() *pb.Task {
|
||||
}
|
||||
}
|
||||
|
||||
func (m *Monitor) CronSpec() string {
|
||||
if m.Duration == 0 {
|
||||
// 默认间隔 30 秒
|
||||
m.Duration = 30
|
||||
}
|
||||
return fmt.Sprintf("@every %ds", m.Duration)
|
||||
}
|
||||
|
||||
func (m *Monitor) AfterFind(tx *gorm.DB) error {
|
||||
var skipServers []uint64
|
||||
if err := json.Unmarshal([]byte(m.SkipServersRaw), &skipServers); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user