alarm

package
v0.0.0-...-abd0671 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 12, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	AlarmMetricList []map[string]string
)

Functions

func GetAlarmLevel

func GetAlarmLevel(k AlarmLevel) string

func GetAlarmLevelMap

func GetAlarmLevelMap() map[AlarmLevel]string

func GetLocalNotifyChannel

func GetLocalNotifyChannel() []map[string]string

func GetLocalNotifyName

func GetLocalNotifyName(id string) string

func GetMetricName

func GetMetricName(id string) string

func GetMetricUnit

func GetMetricUnit(id string) string

func GetNotifyChannel

func GetNotifyChannel() []map[string]string

func GetNotifyName

func GetNotifyName(id string) string

Types

type AlarmContact

type AlarmContact struct {
	ID          int       `json:"id"`                               // ID
	Username    string    `json:"username"`                         // 用户名
	Nickname    string    `json:"nickname"`                         // 姓名
	Password    string    `json:"password"`                         // 密码
	Channel     string    `json:"channel" binding:"required"`       // 通道
	Email       string    `json:"email"`                            // 邮箱
	Phone       string    `json:"phone"`                            // 手机号
	IsActive    bool      `json:"is_active" bson:"is_active"`       // 是否活动
	IsSuperuser bool      `json:"is_superuser" bson:"is_superuser"` // 是否超级管理员
	Role        string    `json:"role"`                             // 用户角色; admin OR user
	Group       string    `json:"group"`                            // 用户组
	DingDing    string    `json:"dingding"`                         // dingding
	Feishu      string    `json:"feishu"`                           // feishu
	WebHook     string    `json:"webhook"`                          // WebHook
	LastLogin   time.Time `json:"last_login" bson:"last_login"`     // 登录时间
	CreateTime  time.Time `json:"create_time" bson:"create_time"`   // 创建时间
}

AlarmContact 联系人

func (AlarmContact) Add

func (t AlarmContact) Add(n AlarmContact) error

Add

func (AlarmContact) Delete

func (t AlarmContact) Delete(selector interface{}) error

Delete

func (AlarmContact) NotifyContact

func (t AlarmContact) NotifyContact() ([]types.Menu, error)

NotifyContact

func (AlarmContact) QueryList

func (t AlarmContact) QueryList(c *gin.Context) (pagination.HTTPResponse, error)

QueryList 列表

func (AlarmContact) TableName

func (t AlarmContact) TableName() string

TableName 表名称

type AlarmLevel

type AlarmLevel int
const (
	Unknown AlarmLevel = iota
	Critical
	Warn
	Info
)

type AlarmRule

type AlarmRule struct {
	types.Currency `bson:"-"`
	ID             int           `json:"id"`                             // ID
	Team           int           `json:"team"`                           // 团队ID
	Name           string        `json:"name"`                           // 规则名称
	Task           types.Model   `json:"task"`                           // 关联任务
	State          bool          `json:"state"`                          // 是否开启
	Status         string        `json:"status"`                         // 运行状态
	Notify         []int         `json:"notify"`                         // 通知对象
	Condition      string        `json:"condition"`                      // 规则条件
	Metric         string        `json:"metric"`                         // 指标名称
	Alarm          []types.Alarm `json:"alarm"`                          // 报警详情
	CreateTime     time.Time     `json:"create_time" bson:"create_time"` // 创建时间
}

AlarmRule 报警规则

func (AlarmRule) Delete

func (r AlarmRule) Delete(selector interface{}) error

Delete 删除

func (AlarmRule) Query

func (r AlarmRule) Query() (result []int, err error)

Query 查询

func (AlarmRule) QueryList

func (r AlarmRule) QueryList(c *gin.Context, team int) (pagination.HTTPResponse, error)

QueryList 列表

func (AlarmRule) QueryMany

func (r AlarmRule) QueryMany(q interface{}) (result []AlarmRule, err error)

QueryMany 查询

func (AlarmRule) QueryTaskRules

func (r AlarmRule) QueryTaskRules(taskID string) (result []AlarmRule, err error)

QueryTaskRules 查询

func (AlarmRule) Save

func (r AlarmRule) Save() (int, error)

Save 添加保存

func (AlarmRule) TableName

func (r AlarmRule) TableName() string

TableName 表名称

type AlarmTask

type AlarmTask struct {
	ID           int           `json:"id"`                                 // ID
	TaskName     string        `json:"task_name" bson:"task_name"`         // 任务名称
	TaskID       string        `json:"task_id" bson:"task_id"`             // 任务ID
	RuleID       int           `json:"rule_id" bson:"rule_id"`             // 规则ID
	Users        []types.Users `json:"users" bson:"users"`                 // 通知用户
	NodeID       int           `json:"node_id" bson:"node_id"`             // 节点ID
	Team         int           `json:"team"`                               // 团队ID
	Level        string        `json:"level"`                              // 级别
	Title        string        `json:"title"`                              // 标题
	CurValue     float64       `json:"cur_value" bson:"cur_value"`         // 当前值
	Threshold    string        `json:"threshold"`                          // 报警阀值
	Unit         string        `json:"unit"`                               // 阀值单位
	Metric       string        `json:"metric"`                             // 指标名称
	Status       string        `json:"status"`                             // 报警状态;trigger OR recovery
	Counter      int           `json:"counter"`                            // 计数器
	Archive      bool          `json:"archive"`                            // 是否归档
	ArchiveTime  time.Time     `json:"archive_time" bson:"archive_time"`   // 归档时间
	RecoveryTime time.Time     `json:"recovery_time" bson:"recovery_time"` // 恢复时间
	CreateTime   time.Time     `json:"create_time" bson:"create_time"`     // 报警时间
}

AlarmTask 报警表

func (AlarmTask) QueryList

func (t AlarmTask) QueryList(c *gin.Context) (pagination.HTTPResponse, error)

QueryList 列表

func (AlarmTask) Recovery

func (t AlarmTask) Recovery() error

func (AlarmTask) Save

func (t AlarmTask) Save() (err error)

func (AlarmTask) TableName

func (t AlarmTask) TableName() string

TableName 表名称

type Metric

type Metric string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL