Documentation ¶
Index ¶
- Constants
- Variables
- func IsServiceSentinelNeeded(t uint64) bool
- type AgentCliParam
- type AgentConfig
- type AlertRule
- func (r *AlertRule) AfterFind(tx *gorm.DB) error
- func (r *AlertRule) BeforeSave(tx *gorm.DB) error
- func (r *AlertRule) Check(points [][]interface{}) (int, bool)
- func (r *AlertRule) Enabled() bool
- func (r *AlertRule) Snapshot(cycleTransferStats *CycleTransferStats, server *Server, db *gorm.DB) []interface{}
- type ApiToken
- type Common
- type Config
- type Cron
- type CycleTransferStats
- type Host
- type HostState
- type Monitor
- type MonitorHistory
- type NResult
- type Notification
- type NotificationServerBundle
- type Response
- type Rule
- type Server
- type ServiceItemResponse
- type TerminalTask
- type Transfer
- type User
Constants ¶
View Source
const ( ConfigTypeGitHub = "github" ConfigTypeGitee = "gitee" ConfigTypeGitlab = "gitlab" ConfigTypeJihulab = "jihulab" )
View Source
const ( ConfigCoverAll = iota ConfigCoverIgnoreAll )
View Source
const ( CronCoverIgnoreAll = iota CronCoverAll )
View Source
const ( TaskTypeHTTPGET TaskTypeICMPPing TaskTypeTCPPing TaskTypeCommand TaskTypeTerminal TaskTypeUpgrade TaskTypeKeepalive )
View Source
const ( MonitorCoverAll = iota MonitorCoverIgnoreAll )
View Source
const ( NotificationRequestTypeJSON NotificationRequestTypeForm )
View Source
const ( NotificationRequestMethodGET NotificationRequestMethodPOST )
View Source
const ( RuleCoverAll = iota RuleCoverIgnoreAll )
View Source
const CacheKeyOauth2State = "p:a:state"
View Source
const CtxKeyAuthorizedUser = "ckau"
View Source
const (
MTReportHostState
)
Variables ¶
View Source
var DashboardThemes = map[string]string{
"default": "Default",
"custom": "Custom(local)",
}
View Source
var Languages = map[string]string{
"zh-CN": "简体中文",
"en-US": "English",
"es-ES": "Español",
}
View Source
var Themes = map[string]string{
"default": "Default",
"daynight": "JackieSung DayNight",
"mdui": "Neko Mdui",
"hotaru": "Hotaru",
"custom": "Custom(local)",
}
Functions ¶
func IsServiceSentinelNeeded ¶
IsServiceSentinelNeeded 判断该任务类型是否需要进行服务监控 需要则返回true
Types ¶
type AgentCliParam ¶
type AgentCliParam struct { SkipConnectionCount bool // 跳过连接数检查 SkipProcsCount bool // 跳过进程数量检查 DisableAutoUpdate bool // 关闭自动更新 DisableForceUpdate bool // 关闭强制更新 DisableCommandExecute bool // 关闭命令执行 Debug bool // debug模式 Server string // 服务器地址 ClientSecret string // 客户端密钥 ReportDelay int // 报告间隔 TLS bool // 是否使用TLS加密传输至服务端 MemoryMultiplier int //内存倍率 DiskMultiplier int //磁盘倍率 NetworkTrafficMultiplier int //流量倍率 NetworkSpeedMultiplier int //网速倍率 }
type AgentConfig ¶
type AgentConfig struct { HardDrivePartitionAllowlist []string NICAllowlist map[string]bool // contains filtered or unexported fields }
func (*AgentConfig) Save ¶
func (c *AgentConfig) Save() error
type AlertRule ¶
type AlertRule struct { Common Name string RulesRaw string Enable *bool NotificationTag string // 该报警规则所在的通知组 Rules []Rule `gorm:"-" json:"-"` }
type Config ¶
type Config struct { Debug bool // debug模式开关 Language string // 系统语言,默认 zh-CN Site struct { Brand string // 站点名称 CookieName string // 浏览器 Cookie 名称 Theme string DashboardTheme string CustomCode string ViewPassword string // 前台查看密码 } Oauth2 struct { Type string Admin string // 管理员用户名列表 ClientID string ClientSecret string } HTTPPort uint GRPCPort uint GRPCHost string ProxyGRPCPort uint TLS bool EnablePlainIPInNotification bool // 通知信息IP不打码 // IP变更提醒 EnableIPChangeNotification bool IPChangeNotificationTag string Cover uint8 // 覆盖范围(0:提醒未被 IgnoredIPNotification 包含的所有服务器; 1:仅提醒被 IgnoredIPNotification 包含的服务器;) IgnoredIPNotification string // 特定服务器IP(多个服务器用逗号分隔) IgnoredIPNotificationServerIDs map[uint64]bool // [ServerID] -> bool(值为true代表当前ServerID在特定服务器列表内) // contains filtered or unexported fields }
Config 站点配置
type Cron ¶
type Cron struct { Common Name string Scheduler string //分钟 小时 天 月 星期 Command string Servers []uint64 `gorm:"-"` PushSuccessful bool // 推送成功的通知 NotificationTag string // 指定通知方式的分组 LastExecutedAt time.Time // 最后一次执行时间 LastResult bool // 最后一次执行结果 Cover uint8 // 计划任务覆盖范围 (0:仅覆盖特定服务器 1:仅忽略特定服务器) CronJobID cron.EntryID `gorm:"-"` ServersRaw string }
type CycleTransferStats ¶
type Host ¶
type HostState ¶
type Monitor ¶
type Monitor struct { Common Name string Type uint8 Target string SkipServersRaw string Duration uint64 Notify bool NotificationTag string // 当前服务监控所属的通知组 Cover uint8 SkipServers map[uint64]bool `gorm:"-" json:"-"` CronJobID cron.EntryID `gorm:"-" json:"-"` }
func (*Monitor) InitSkipServers ¶
type MonitorHistory ¶
type MonitorHistory struct { Common MonitorID uint64 Delay float32 // 延迟,毫秒 Data string Successful bool // 是否成功 }
MonitorHistory 历史监控记录
func PB2MonitorHistory ¶
func PB2MonitorHistory(r *pb.TaskResult) MonitorHistory
type Notification ¶
type NotificationServerBundle ¶
type NotificationServerBundle struct { Notification *Notification Server *Server }
func (*NotificationServerBundle) Send ¶
func (ns *NotificationServerBundle) Send(message string) error
type Rule ¶
type Rule struct { // 指标类型,cpu、memory、swap、disk、net_in_speed、net_out_speed // net_all_speed、transfer_in、transfer_out、transfer_all、offline // transfer_in_cycle、transfer_out_cycle、transfer_all_cycle Type string `json:"type,omitempty"` Min float64 `json:"min,omitempty"` // 最小阈值 (百分比、字节 kb ÷ 1024) Max float64 `json:"max,omitempty"` // 最大阈值 (百分比、字节 kb ÷ 1024) CycleStart *time.Time `json:"cycle_start,omitempty"` // 流量统计的开始时间 CycleInterval uint64 `json:"cycle_interval,omitempty"` // 流量统计周期 CycleUnit string `json:"cycle_unit,omitempty"` // 流量统计周期单位,默认hour,可选(hour, day, week, month, year) Duration uint64 `json:"duration,omitempty"` // 持续时间 (秒) Cover uint64 `json:"cover,omitempty"` // 覆盖范围 RuleCoverAll/IgnoreAll Ignore map[uint64]bool `json:"ignore,omitempty"` // 覆盖范围的排除 // 只作为缓存使用,记录下次该检测的时间 NextTransferAt map[uint64]time.Time `json:"-"` LastCycleStatus map[uint64]interface{} `json:"-"` }
func (Rule) GetTransferDurationEnd ¶
GetTransferDurationEnd 获取周期流量结束时间
func (Rule) GetTransferDurationStart ¶
GetTransferDurationStart 获取周期流量的起始时间
func (Rule) IsTransferDurationRule ¶
IsTransferDurationRule 判断该规则是否属于周期流量规则 属于则返回true
type Server ¶
type Server struct { Common Name string Tag string // 分组名 Secret string `gorm:"uniqueIndex" json:"-"` Note string `json:"-"` // 管理员可见备注 DisplayIndex int // 展示排序,越大越靠前 Host *Host `gorm:"-"` State *HostState `gorm:"-"` LastActive time.Time `gorm:"-"` TaskClose chan error `gorm:"-" json:"-"` TaskStream pb.NezhaService_RequestTaskServer `gorm:"-" json:"-"` PrevHourlyTransferIn int64 `gorm:"-" json:"-"` // 上次数据点时的入站使用量 PrevHourlyTransferOut int64 `gorm:"-" json:"-"` // 上次数据点时的出站使用量 }
func (*Server) CopyFromRunningServer ¶
type ServiceItemResponse ¶
type ServiceItemResponse struct { Monitor *Monitor CurrentUp uint64 CurrentDown uint64 TotalUp uint64 TotalDown uint64 Delay *[30]float32 Up *[30]int Down *[30]int }
func (ServiceItemResponse) TotalUptime ¶
func (r ServiceItemResponse) TotalUptime() float32
type TerminalTask ¶
type User ¶
type User struct { Common Login string `json:"login,omitempty"` // 登录名 AvatarURL string `json:"avatar_url,omitempty"` // 头像地址 Name string `json:"name,omitempty"` // 昵称 Blog string `json:"blog,omitempty"` // 网站链接 Email string `json:"email,omitempty"` // 邮箱 Hireable bool `json:"hireable,omitempty"` Bio string `json:"bio,omitempty"` // 个人简介 Token string `json:"-"` // 认证 Token TokenExpired time.Time `json:"token_expired,omitempty"` // Token 过期时间 SuperAdmin bool `json:"super_admin,omitempty"` // 超级管理员 }
func NewUserFromGitHub ¶
func NewUserFromGitlab ¶
func NewUserFromGitlab(gu *gitlab.User) User
func (*User) IssueNewToken ¶
func (u *User) IssueNewToken()
Click to show internal directories.
Click to hide internal directories.