agents

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2020 License: MIT, MIT Imports: 48 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SourceCategoryBasic  = "basic"  // 基础
	SourceCategoryCommon = "common" // 常用
	SourceCategoryPlugin = "plugin" // 插件
)
View Source
const (
	SourceDataFormatSingeLine    = 1 // 单行
	SourceDataFormatMultipleLine = 2 // 多行
	SourceDataFormatJSON         = 3 // JSON
	SourceDataFormatYAML         = 4 // YAML
)

Variables

View Source
var RegexpParamNamedVariable = regexp.MustCompile(`(?U)\${[$\w\s.-]+(\s*\|.+)?}`)

参数值正则

Functions

func AllActions

func AllActions() []maps.Map

获取所有的数据源信息

func AllDataSources

func AllDataSources() []maps.Map

func AllSourceDataFormats

func AllSourceDataFormats() []maps.Map

所有的数据格式

func AllThresholdOperators

func AllThresholdOperators() []maps.Map

所有的运算符

func ConvertSourceToMap

func ConvertSourceToMap(source SourceInterface) map[string]interface{}

将Source转换为Map

func DecodeSource

func DecodeSource(data []byte, format SourceDataFormat) (value interface{}, err error)

解码数据

func EvalParam

func EvalParam(param string, value interface{}, old interface{}, varMapping maps.Map, supportsMath bool) (string, error)

使用某个参数执行数值运算,使用Javascript语法

func FindAction

func FindAction(code string) maps.Map

查找单个数据源信息

func FindDataSource

func FindDataSource(code string) maps.Map

查找单个数据源信息

func FindSourceDataFormat

func FindSourceDataFormat(dataFormat SourceDataFormat) maps.Map

取得单个数据格式

func FindThresholdOperator

func FindThresholdOperator(op string) maps.Map

查找某个运算符信息

func FuncAppend

func FuncAppend(args ...interface{}) interface{}

附加字符串 append('a', 'b')

func FuncCeil

func FuncCeil(args ...interface{}) interface{}

对数字进行取不小于它的整数 ceil

func FuncFloat

func FuncFloat(args ...interface{}) interface{}

浮点数处理 float | float('%.2f')

func FuncFloor

func FuncFloor(args ...interface{}) interface{}

对数字进行取不大于它的整数 floor

func FuncFormat

func FuncFormat(args ...interface{}) interface{}

格式化 format('%.2f')

func FuncRound

func FuncRound(args ...interface{}) interface{}

对数字四舍五入 round | round(2)

func NotifyAgentsChange

func NotifyAgentsChange()

通知Agent变化

func RegisterAllDataSources

func RegisterAllDataSources()

注册内置的数据源信息

func RegisterDataSource

func RegisterDataSource(dataSource SourceInterface, category SourceCategory)

单个数据源信息

func RegisterFunc

func RegisterFunc(code string, f interface{})

注册一个函数

func RunFuncExpr

func RunFuncExpr(value interface{}, expr []byte) (interface{}, error)

执行函数表达式

Types

type ActionInterface

type ActionInterface interface {
	// 名称
	Name() string

	// 代号
	Code() string

	// 描述
	Description() string

	// 校验
	Validate() error

	// 执行
	Run(params map[string]string) (result string, err error)

	// 获取简要信息
	Summary() maps.Map
}

动作

func FindActionInstance

func FindActionInstance(code string, options map[string]interface{}) ActionInterface

查找单个数据源实例

type AgentConfig

type AgentConfig struct {
	Id                  string       `yaml:"id" json:"id"`                                   // ID
	On                  bool         `yaml:"on" json:"on"`                                   // 是否启用
	Name                string       `yaml:"name" json:"name"`                               // 名称
	Host                string       `yaml:"host" json:"host"`                               // 主机地址
	Key                 string       `yaml:"key" json:"key"`                                 // 密钥
	AllowAll            bool         `yaml:"allowAll" json:"allowAll"`                       // 是否允许所有的IP
	Allow               []string     `yaml:"allow" json:"allow"`                             // 允许的IP地址
	Apps                []*AppConfig `yaml:"apps" json:"apps"`                               // Apps
	TeaVersion          string       `yaml:"teaVersion" json:"teaVersion"`                   // TeaWeb版本
	Version             uint         `yaml:"version" json:"version"`                         // 版本
	CheckDisconnections bool         `yaml:"checkDisconnections" json:"checkDisconnections"` // 是否检查离线
	CountDisconnections int          `yaml:"countDisconnections" json:"countDisconnections"` // 错误次数
	GroupIds            []string     `yaml:"groupIds" json:"groupIds"`                       // 分组IDs
	AutoUpdates         bool         `yaml:"autoUpdates" json:"autoUpdates"`                 // 是否开启自动更新
	AppsIsInitialized   bool         `yaml:"appsIsInitialized" json:"appsIsInitialized"`     // 是否已经初始化App
	GroupKey            string       `yaml:"groupKey" json:"groupKey"`                       // 注册使用的密钥

	NoticeSetting map[notices.NoticeLevel][]*notices.NoticeReceiver `yaml:"noticeSetting" json:"noticeSetting"`
}

Agent定义

func AllSharedAgents

func AllSharedAgents() []*AgentConfig

取得AgentId列表,包括Local

func LocalAgentConfig

func LocalAgentConfig() *AgentConfig

func NewAgentConfig

func NewAgentConfig() *AgentConfig

获取新对象

func NewAgentConfigFromFile

func NewAgentConfigFromFile(filename string) *AgentConfig

从文件中获取对象

func NewAgentConfigFromId

func NewAgentConfigFromId(agentId string) *AgentConfig

根据ID获取对象

func SharedAgents

func SharedAgents() []*AgentConfig

取得AgentId列表,不包括Local

func (*AgentConfig) AddApp

func (this *AgentConfig) AddApp(app *AppConfig)

添加App

func (*AgentConfig) AddApps

func (this *AgentConfig) AddApps(apps []*AppConfig)

添加一组App

func (*AgentConfig) AddDefaultApps

func (this *AgentConfig) AddDefaultApps()

添加内置的App

func (*AgentConfig) AddGroup

func (this *AgentConfig) AddGroup(groupId string)

添加分组

func (*AgentConfig) AddNoticeReceiver

func (this *AgentConfig) AddNoticeReceiver(level notices.NoticeLevel, receiver *notices.NoticeReceiver)

添加通知接收者

func (*AgentConfig) BelongsToGroup

func (this *AgentConfig) BelongsToGroup(groupId string) bool

判断是否有某个分组

func (*AgentConfig) BelongsToGroups

func (this *AgentConfig) BelongsToGroups(groupIds []string) bool

判断是否有某些分组

func (*AgentConfig) CountNoticeReceivers

func (this *AgentConfig) CountNoticeReceivers() int

获取通知接收者数量

func (*AgentConfig) Delete

func (this *AgentConfig) Delete() error

删除

func (*AgentConfig) EncodeYAML

func (this *AgentConfig) EncodeYAML() ([]byte, error)

YAML编码

func (*AgentConfig) Filename

func (this *AgentConfig) Filename() string

文件名

func (*AgentConfig) FindAllNoticeReceivers

func (this *AgentConfig) FindAllNoticeReceivers(level ...notices.NoticeLevel) []*notices.NoticeReceiver

查找一个或多个级别对应的接收者,并合并相同的接收者

func (*AgentConfig) FindApp

func (this *AgentConfig) FindApp(appId string) *AppConfig

查找App

func (*AgentConfig) FindItem

func (this *AgentConfig) FindItem(itemId string) (appConfig *AppConfig, item *Item)

查找监控项

func (*AgentConfig) FindTask

func (this *AgentConfig) FindTask(taskId string) (appConfig *AppConfig, taskConfig *TaskConfig)

查找任务

func (*AgentConfig) FirstGroup

func (this *AgentConfig) FirstGroup() *Group

取得第一个分组

func (*AgentConfig) GroupName

func (this *AgentConfig) GroupName() string

获取分组名

func (*AgentConfig) HasApp

func (this *AgentConfig) HasApp(appId string) bool

判断是否有某个App

func (*AgentConfig) IsLocal

func (this *AgentConfig) IsLocal() bool

判断是否为Local Agent

func (*AgentConfig) MatchKeyword

func (this *AgentConfig) MatchKeyword(keyword string) (matched bool, name string, tags []string)

判断是否匹配关键词

func (*AgentConfig) MoveApp

func (this *AgentConfig) MoveApp(fromIndex int, toIndex int)

移动App位置

func (*AgentConfig) RemoveApp

func (this *AgentConfig) RemoveApp(appId string)

删除App

func (*AgentConfig) RemoveGroup

func (this *AgentConfig) RemoveGroup(groupId string)

删除分组

func (*AgentConfig) RemoveMedia

func (this *AgentConfig) RemoveMedia(mediaId string) (found bool)

删除媒介

func (*AgentConfig) RemoveNoticeReceiver

func (this *AgentConfig) RemoveNoticeReceiver(level notices.NoticeLevel, receiverId string)

删除通知接收者

func (*AgentConfig) ReplaceApp

func (this *AgentConfig) ReplaceApp(app *AppConfig)

替换App,如果不存在则增加

func (*AgentConfig) Save

func (this *AgentConfig) Save() error

保存

func (*AgentConfig) Validate

func (this *AgentConfig) Validate() error

校验

type AgentList

type AgentList struct {
	Files []string `yaml:"files" json:"files"`
	// contains filtered or unexported fields
}

Agent列表

func SharedAgentList

func SharedAgentList() (*AgentList, error)

取得Agent列表

func (*AgentList) AddAgent

func (this *AgentList) AddAgent(agentFile string)

添加Agent

func (*AgentList) CountAgentsInGroup

func (this *AgentList) CountAgentsInGroup(groupId string) int

计算所有分组中的Agent

func (*AgentList) FindAllAgents

func (this *AgentList) FindAllAgents() []*AgentConfig

查找所有Agents

func (*AgentList) MoveAgent

func (this *AgentList) MoveAgent(fromId string, toId string)

移动位置

func (*AgentList) RemoveAgent

func (this *AgentList) RemoveAgent(agentFile string)

删除Agent

func (*AgentList) Save

func (this *AgentList) Save() error

保存

type AppConfig

type AppConfig struct {
	Id    string        `yaml:"id" json:"id"`       // ID
	On    bool          `yaml:"on" json:"on"`       // 是否启用
	Tasks []*TaskConfig `yaml:"tasks" json:"tasks"` // 任务设置
	Items []*Item       `yaml:"item" json:"items"`  // 监控项
	Name  string        `yaml:"name" json:"name"`   // 名称

	IsSharedWithGroup bool     `yaml:"issharedwithgroup" json:"isSharedWithGroup"` // 是否与当前组共享,使用issharedwithgroup是为了兼容v0.1.6之前的版本
	SharedAgentIds    []string `yaml:"sharedAgentIds" json:"sharedAgentIds"`       // 共享的Agents TODO 暂不实现

	NoticeSetting map[notices.NoticeLevel][]*notices.NoticeReceiver `yaml:"noticeSetting" json:"noticeSetting"`
}

App定义

func NewAppConfig

func NewAppConfig() *AppConfig

获取新对象

func (*AppConfig) AddItem

func (this *AppConfig) AddItem(item *Item)

添加监控项

func (*AppConfig) AddNoticeReceiver

func (this *AppConfig) AddNoticeReceiver(level notices.NoticeLevel, receiver *notices.NoticeReceiver)

添加通知接收者

func (*AppConfig) AddTask

func (this *AppConfig) AddTask(task *TaskConfig)

添加任务

func (*AppConfig) CountNoticeReceivers

func (this *AppConfig) CountNoticeReceivers() int

获取通知接收者数量

func (*AppConfig) FindAllNoticeReceivers

func (this *AppConfig) FindAllNoticeReceivers(level ...notices.NoticeLevel) []*notices.NoticeReceiver

查找一个或多个级别对应的接收者,并合并相同的接收者

func (*AppConfig) FindBootingTasks

func (this *AppConfig) FindBootingTasks() []*TaskConfig

Boot Tasks

func (*AppConfig) FindItem

func (this *AppConfig) FindItem(itemId string) *Item

查找监控项

func (*AppConfig) FindManualTasks

func (this *AppConfig) FindManualTasks() []*TaskConfig

Manual Tasks

func (*AppConfig) FindSchedulingTasks

func (this *AppConfig) FindSchedulingTasks() []*TaskConfig

Schedule Tasks

func (*AppConfig) FindTask

func (this *AppConfig) FindTask(taskId string) *TaskConfig

查找任务

func (*AppConfig) MatchKeyword

func (this *AppConfig) MatchKeyword(keyword string) (matched bool, name string, tags []string)

匹配关键词

func (*AppConfig) RemoveItem

func (this *AppConfig) RemoveItem(itemId string)

删除监控项

func (*AppConfig) RemoveMedia

func (this *AppConfig) RemoveMedia(mediaId string) (found bool)

删除媒介

func (*AppConfig) RemoveNoticeReceiver

func (this *AppConfig) RemoveNoticeReceiver(level notices.NoticeLevel, receiverId string)

删除通知接收者

func (*AppConfig) RemoveTask

func (this *AppConfig) RemoveTask(taskId string)

删除任务

func (*AppConfig) Validate

func (this *AppConfig) Validate() error

校验

type AppProcessesSource

type AppProcessesSource struct {
	Source `yaml:",inline"`

	CmdlineKeyword string `yaml:"cmdlineKeyword" json:"cmdlineKeyword"` // 命令行匹配关键词
}

App进程

func NewAppProcessesSource

func NewAppProcessesSource() *AppProcessesSource

获取新对象

func (*AppProcessesSource) Charts

func (this *AppProcessesSource) Charts() []*widgets.Chart

图表

func (*AppProcessesSource) Code

func (this *AppProcessesSource) Code() string

代号

func (*AppProcessesSource) Description

func (this *AppProcessesSource) Description() string

描述

func (*AppProcessesSource) Execute

func (this *AppProcessesSource) Execute(params map[string]string) (value interface{}, err error)

执行

func (*AppProcessesSource) Form

func (this *AppProcessesSource) Form() *forms.Form

表单信息

func (*AppProcessesSource) Name

func (this *AppProcessesSource) Name() string

名称

func (*AppProcessesSource) Platforms

func (this *AppProcessesSource) Platforms() []string

平台限制

func (*AppProcessesSource) Presentation

func (this *AppProcessesSource) Presentation() *forms.Presentation

显示信息

func (*AppProcessesSource) Thresholds

func (this *AppProcessesSource) Thresholds() []*Threshold

阈值

func (*AppProcessesSource) Variables

func (this *AppProcessesSource) Variables() []*SourceVariable

变量

type Board

type Board struct {
	TeaVersion string        `yaml:"teaVersion" json:"teaVersion"`
	Filename   string        `yaml:"filename" json:"filename"`
	Charts     []*BoardChart `yaml:"charts" json:"charts"`
}

看板

func NewAgentBoard

func NewAgentBoard(agentId string) *Board

取得Agent看板

func (*Board) AddChart

func (this *Board) AddChart(appId, itemId, chartId string)

添加图表

func (*Board) FindChart

func (this *Board) FindChart(chartId string) *BoardChart

查找图表

func (*Board) HasChart

func (this *Board) HasChart(chartId string) bool

查看是否有图表

func (*Board) MoveChart

func (this *Board) MoveChart(fromIndex int, toIndex int)

移动图表

func (*Board) RemoveApp

func (this *Board) RemoveApp(appId string)

删除App相关的所有图表

func (*Board) RemoveChart

func (this *Board) RemoveChart(chartId string)

删除图表

func (*Board) Save

func (this *Board) Save() error

保存

type BoardChart

type BoardChart struct {
	AppId   string `yaml:"appId" json:"appId"`
	ItemId  string `yaml:"itemId" json:"itemId"`
	ChartId string `yaml:"chartId" json:"chartId"`

	Name     string              `yaml:"name" json:"name"`
	TimeType string              `yaml:"timeType" json:"timeType"` // default, past, range
	TimePast teaconfigs.TimePast `yaml:"timePast" json:"timePast"` // 时间范围
	DayFrom  string              `yaml:"dayFrom" json:"dayFrom"`
	DayTo    string              `yaml:"dayTo" json:"dayTo"`
}

看板图表定义

type CPUSource

type CPUSource struct {
	Source `yaml:",inline"`
}

CPU使用量

func NewCPUSource

func NewCPUSource() *CPUSource

获取新对象

func (*CPUSource) Charts

func (this *CPUSource) Charts() []*widgets.Chart

图表

func (*CPUSource) Code

func (this *CPUSource) Code() string

代号

func (*CPUSource) Description

func (this *CPUSource) Description() string

描述

func (*CPUSource) Execute

func (this *CPUSource) Execute(params map[string]string) (value interface{}, err error)

执行

func (*CPUSource) Form

func (this *CPUSource) Form() *forms.Form

表单信息

func (*CPUSource) Name

func (this *CPUSource) Name() string

名称

func (*CPUSource) Thresholds

func (this *CPUSource) Thresholds() []*Threshold

阈值

func (*CPUSource) Variables

func (this *CPUSource) Variables() []*SourceVariable

变量

type ConnectionsSource

type ConnectionsSource struct {
	Source `yaml:",inline"`
}

网络连接数

func NewConnectionsSource

func NewConnectionsSource() *ConnectionsSource

获取新对象

func (*ConnectionsSource) Charts

func (this *ConnectionsSource) Charts() []*widgets.Chart

图表

func (*ConnectionsSource) Code

func (this *ConnectionsSource) Code() string

代号

func (*ConnectionsSource) Description

func (this *ConnectionsSource) Description() string

描述

func (*ConnectionsSource) Execute

func (this *ConnectionsSource) Execute(params map[string]string) (value interface{}, err error)

执行

func (*ConnectionsSource) Form

func (this *ConnectionsSource) Form() *forms.Form

表单信息

func (*ConnectionsSource) Name

func (this *ConnectionsSource) Name() string

名称

func (*ConnectionsSource) Presentation

func (this *ConnectionsSource) Presentation() *forms.Presentation

显示信息

func (*ConnectionsSource) Thresholds

func (this *ConnectionsSource) Thresholds() []*Threshold

阈值

func (*ConnectionsSource) Variables

func (this *ConnectionsSource) Variables() []*SourceVariable

变量

type DNSSource

type DNSSource struct {
	Source `yaml:",inline"`

	Domain string `yaml:"domain" json:"domain"`
	Type   string `yaml:"type" json:"type"` // A, MX等
}

DNS检查

func NewDNSSource

func NewDNSSource() *DNSSource

获取新对象

func (*DNSSource) Charts

func (this *DNSSource) Charts() []*widgets.Chart

图表

func (*DNSSource) Code

func (this *DNSSource) Code() string

代号

func (*DNSSource) Description

func (this *DNSSource) Description() string

描述

func (*DNSSource) Execute

func (this *DNSSource) Execute(params map[string]string) (value interface{}, err error)

执行

func (*DNSSource) Form

func (this *DNSSource) Form() *forms.Form

表单信息

func (*DNSSource) Name

func (this *DNSSource) Name() string

名称

func (*DNSSource) Presentation

func (this *DNSSource) Presentation() *forms.Presentation

显示信息

func (*DNSSource) Thresholds

func (this *DNSSource) Thresholds() []*Threshold

阈值

func (*DNSSource) Variables

func (this *DNSSource) Variables() []*SourceVariable

变量

type DateSource

type DateSource struct {
	Source `yaml:",inline"`
}

日期相关

func NewDateSource

func NewDateSource() *DateSource

获取新对象

func (*DateSource) Charts

func (this *DateSource) Charts() []*widgets.Chart

图表

func (*DateSource) Code

func (this *DateSource) Code() string

代号

func (*DateSource) Description

func (this *DateSource) Description() string

描述

func (*DateSource) Execute

func (this *DateSource) Execute(params map[string]string) (value interface{}, err error)

执行

func (*DateSource) Form

func (this *DateSource) Form() *forms.Form

表单信息

func (*DateSource) Name

func (this *DateSource) Name() string

名称

func (*DateSource) Presentation

func (this *DateSource) Presentation() *forms.Presentation

显示信息

func (*DateSource) Thresholds

func (this *DateSource) Thresholds() []*Threshold

阈值

func (*DateSource) Variables

func (this *DateSource) Variables() []*SourceVariable

变量

type DiskSource

type DiskSource struct {
	Source `yaml:",inline"`

	ContainsAllMountPoints bool `yaml:"containsAllMountPoints" json:"containsAllMountPoints"`
}

文件系统信息

func NewDiskSource

func NewDiskSource() *DiskSource

获取新对象

func (*DiskSource) Charts

func (this *DiskSource) Charts() []*widgets.Chart

图表

func (*DiskSource) Code

func (this *DiskSource) Code() string

代号

func (*DiskSource) Description

func (this *DiskSource) Description() string

描述

func (*DiskSource) Execute

func (this *DiskSource) Execute(params map[string]string) (value interface{}, err error)

执行

func (*DiskSource) Form

func (this *DiskSource) Form() *forms.Form

表单信息

func (*DiskSource) Name

func (this *DiskSource) Name() string

名称

func (*DiskSource) Presentation

func (this *DiskSource) Presentation() *forms.Presentation

显示信息

func (*DiskSource) Thresholds

func (this *DiskSource) Thresholds() []*Threshold

阈值

func (*DiskSource) Variables

func (this *DiskSource) Variables() []*SourceVariable

变量

type DockerSource

type DockerSource struct {
	Source `yaml:",inline"`
}

Docker相关数据源

func NewDockerSource

func NewDockerSource() *DockerSource

获取新对象

func (*DockerSource) Charts

func (this *DockerSource) Charts() []*widgets.Chart

图表

func (*DockerSource) Code

func (this *DockerSource) Code() string

代号

func (*DockerSource) Description

func (this *DockerSource) Description() string

描述

func (*DockerSource) Execute

func (this *DockerSource) Execute(params map[string]string) (value interface{}, err error)

执行

func (*DockerSource) Form

func (this *DockerSource) Form() *forms.Form

表单信息

func (*DockerSource) Name

func (this *DockerSource) Name() string

名称

func (*DockerSource) Thresholds

func (this *DockerSource) Thresholds() []*Threshold

阈值

func (*DockerSource) Variables

func (this *DockerSource) Variables() []*SourceVariable

变量

type FileChangeSource

type FileChangeSource struct {
	Source `yaml:",inline"`
	Path   string `yaml:"path" json:"path"`
	// contains filtered or unexported fields
}

监控文件变化 TODO 增加权限变化监控

func NewFileChangeSource

func NewFileChangeSource() *FileChangeSource

获取新对象

func (*FileChangeSource) Charts

func (this *FileChangeSource) Charts() []*widgets.Chart

图表

func (*FileChangeSource) Code

func (this *FileChangeSource) Code() string

代号

func (*FileChangeSource) Description

func (this *FileChangeSource) Description() string

描述

func (*FileChangeSource) Execute

func (this *FileChangeSource) Execute(params map[string]string) (value interface{}, err error)

执行

func (*FileChangeSource) Form

func (this *FileChangeSource) Form() *forms.Form

表单信息

func (*FileChangeSource) Name

func (this *FileChangeSource) Name() string

名称

func (*FileChangeSource) Presentation

func (this *FileChangeSource) Presentation() *forms.Presentation

显示信息

func (*FileChangeSource) Thresholds

func (this *FileChangeSource) Thresholds() []*Threshold

阈值

func (*FileChangeSource) Variables

func (this *FileChangeSource) Variables() []*SourceVariable

变量

type FileSource

type FileSource struct {
	Source `yaml:",inline"`

	Path string `yaml:"path" json:"path"`
}

数据文件

func NewFileSource

func NewFileSource() *FileSource

获取新对象

func (*FileSource) Code

func (this *FileSource) Code() string

代号

func (*FileSource) Description

func (this *FileSource) Description() string

描述

func (*FileSource) Execute

func (this *FileSource) Execute(params map[string]string) (value interface{}, err error)

执行

func (*FileSource) Form

func (this *FileSource) Form() *forms.Form

选项表单

func (*FileSource) Name

func (this *FileSource) Name() string

名称

func (*FileSource) Presentation

func (this *FileSource) Presentation() *forms.Presentation

显示信息

func (*FileSource) Validate

func (this *FileSource) Validate() error

校验

type Group

type Group struct {
	Id            string                                            `yaml:"id" json:"id"`
	IsDefault     bool                                              `yaml:"isDefault" json:"isDefault"`
	On            bool                                              `yaml:"on" json:"on"`
	Name          string                                            `yaml:"name" json:"name"`
	Index         int                                               `yaml:"index" json:"index"`
	NoticeSetting map[notices.NoticeLevel][]*notices.NoticeReceiver `yaml:"noticeSetting" json:"noticeSetting"`
	Key           string                                            `yaml:"key" json:"key"` // 密钥

	DayFrom     string `yaml:"dayFrom" json:"dayFrom"`         // 有效开始日期
	DayTo       string `yaml:"dayTo" json:"dayTo"`             // 有效结束日期
	MaxAgents   int    `yaml:"maxAgents" json:"maxAgents"`     // 可以容纳的Agents最大数量
	CountAgents int    `yaml:"countAgents" json:"countAgents"` //

	Keys []*GroupKey `yaml:"keys" json:"keys"` // 临时的Key
}

Agent分组

func NewGroup

func NewGroup(name string) *Group

获取新分组

func (*Group) AddKey

func (this *Group) AddKey(key *GroupKey)

添加密钥

func (*Group) AddNoticeReceiver

func (this *Group) AddNoticeReceiver(level notices.NoticeLevel, receiver *notices.NoticeReceiver)

添加通知接收者

func (*Group) FindAllNoticeReceivers

func (this *Group) FindAllNoticeReceivers(level ...notices.NoticeLevel) []*notices.NoticeReceiver

查找一个或多个级别对应的接收者,并合并相同的接收者

func (*Group) FindKey

func (this *Group) FindKey(key string) *GroupKey

查找密钥

func (*Group) GenerateKey

func (this *Group) GenerateKey() string

生成密钥

func (*Group) IsAvailable

func (this *Group) IsAvailable() bool

是否可用

func (*Group) IsDateAvailable

func (this *Group) IsDateAvailable() bool

当前分组日期是否可用

func (*Group) MatchKeyword

func (this *Group) MatchKeyword(keyword string) (matched bool, name string, tags []string)

匹配关键词

func (*Group) RemoveMedia

func (this *Group) RemoveMedia(mediaId string) (found bool)

删除媒介

func (*Group) RemoveNoticeReceiver

func (this *Group) RemoveNoticeReceiver(level notices.NoticeLevel, receiverId string)

删除通知接收者

func (*Group) WriteToFile

func (this *Group) WriteToFile(path string) error

写入文件

type GroupKey

type GroupKey struct {
	Id          string `yaml:"id" json:"id"`
	On          bool   `yaml:"on" json:"on"`
	Name        string `yaml:"name" json:"name"`               // 说明
	Key         string `yaml:"key" json:"key"`                 // 密钥
	DayFrom     string `yaml:"dayFrom" json:"dayFrom"`         // 开始生效日期
	DayTo       string `yaml:"dayTo" json:"dayTo"`             // 结束生效日期
	MaxAgents   int    `yaml:"maxAgents" json:"maxAgents"`     // 可以容纳的Agents最大数量
	CountAgents int    `yaml:"countAgents" json:"countAgents"` // 已使用的Agent
}

Agent组密钥管理

func NewGroupKey

func NewGroupKey() *GroupKey

创建新Key

func (*GroupKey) IsAvailable

func (this *GroupKey) IsAvailable() bool

当前分组Key是否可用

func (*GroupKey) IsDateAvailable

func (this *GroupKey) IsDateAvailable() bool

当前分组Key日期是否可用

type GroupList

type GroupList struct {
	Groups     []*Group `yaml:"groups" json:"groups"`
	TeaVersion string   `yaml:"teaVersion" json:"teaVersion"`
}

分组配置

func SharedGroupList

func SharedGroupList() *GroupList

取得公用的配置 一定会返回一个不为nil的GroupConfig

func (*GroupList) AddGroup

func (this *GroupList) AddGroup(group *Group)

添加分组

func (*GroupList) BuildIndexes

func (this *GroupList) BuildIndexes() error

重建索引

func (*GroupList) FindAllGroups

func (this *GroupList) FindAllGroups() []*Group

获取所有分组,包括默认分组

func (*GroupList) FindDefaultGroup

func (this *GroupList) FindDefaultGroup() *Group

查找默认的分组

func (*GroupList) FindGroup

func (this *GroupList) FindGroup(groupId string) *Group

根据ID查找分组

func (*GroupList) FindGroupWithKey

func (this *GroupList) FindGroupWithKey(key string) *Group

根据密钥查找分组

func (*GroupList) Move

func (this *GroupList) Move(fromIndex int, toIndex int)

移动位置

func (*GroupList) RemoveGroup

func (this *GroupList) RemoveGroup(groupId string)

删除分组

func (*GroupList) Save

func (this *GroupList) Save() error

保存

type IOStatSource

type IOStatSource struct {
	Source `yaml:",inline"`
	// contains filtered or unexported fields
}

IO统计

func NewIOStatSource

func NewIOStatSource() *IOStatSource

获取新对象

func (*IOStatSource) Charts

func (this *IOStatSource) Charts() []*widgets.Chart

图表

func (*IOStatSource) Code

func (this *IOStatSource) Code() string

代号

func (*IOStatSource) Description

func (this *IOStatSource) Description() string

描述

func (*IOStatSource) Execute

func (this *IOStatSource) Execute(params map[string]string) (value interface{}, err error)

执行

func (*IOStatSource) Form

func (this *IOStatSource) Form() *forms.Form

表单信息

func (*IOStatSource) Name

func (this *IOStatSource) Name() string

名称

func (*IOStatSource) Thresholds

func (this *IOStatSource) Thresholds() []*Threshold

阈值

func (*IOStatSource) Variables

func (this *IOStatSource) Variables() []*SourceVariable

变量

type Item

type Item struct {
	On               bool                   `yaml:"on" json:"on"`
	Id               string                 `yaml:"id" json:"id"`
	Name             string                 `yaml:"name" json:"name"`
	SourceCode       string                 `yaml:"sourceCode" json:"sourceCode"`             // 数据源代号
	SourceOptions    map[string]interface{} `yaml:"sourceOptions" json:"sourceOptions"`       // 数据源选项
	Interval         string                 `yaml:"interval" json:"interval"`                 // 刷新间隔
	Thresholds       []*Threshold           `yaml:"thresholds" json:"thresholds"`             // 阈值设置
	Charts           []*widgets.Chart       `yaml:"charts" json:"charts"`                     // 图表
	RecoverSuccesses int                    `yaml:"recoverSuccesses" json:"recoverSuccesses"` // 恢复的成功次数
	// contains filtered or unexported fields
}

数据指标项

func NewItem

func NewItem() *Item

获取新对象

func (*Item) AddChart

func (this *Item) AddChart(chart *widgets.Chart)

添加图表

func (*Item) AddFilterCharts

func (this *Item) AddFilterCharts(charts []*widgets.Chart, chartId ...string)

添加一组图表中的某几个

func (*Item) AddThreshold

func (this *Item) AddThreshold(t ...*Threshold)

添加阈值

func (*Item) FindChart

func (this *Item) FindChart(chartId string) *widgets.Chart

查找图表

func (*Item) IntervalDuration

func (this *Item) IntervalDuration() time.Duration

获取刷新间隔

func (*Item) MatchKeyword

func (this *Item) MatchKeyword(keyword string) (matched bool, name string, tags []string)

匹配关键词

func (*Item) RemoveChart

func (this *Item) RemoveChart(chartId string)

删除图表

func (*Item) Source

func (this *Item) Source() SourceInterface

数据源对象

func (*Item) TestValue

func (this *Item) TestValue(value interface{}, oldValue interface{}) (threshold *Threshold, row interface{}, level notices.NoticeLevel, message string, err error)

检查某个值对应的通知级别

func (*Item) Validate

func (this *Item) Validate() error

校验

type LoadSource

type LoadSource struct {
	Source `yaml:",inline"`
}

负载

func NewLoadSource

func NewLoadSource() *LoadSource

获取新对象

func (*LoadSource) Charts

func (this *LoadSource) Charts() []*widgets.Chart

图表

func (*LoadSource) Code

func (this *LoadSource) Code() string

代号

func (*LoadSource) Description

func (this *LoadSource) Description() string

描述

func (*LoadSource) Execute

func (this *LoadSource) Execute(params map[string]string) (value interface{}, err error)

执行

func (*LoadSource) Form

func (this *LoadSource) Form() *forms.Form

表单信息

func (*LoadSource) Name

func (this *LoadSource) Name() string

名称

func (*LoadSource) Thresholds

func (this *LoadSource) Thresholds() []*Threshold

阈值

func (*LoadSource) Variables

func (this *LoadSource) Variables() []*SourceVariable

变量

type MemorySource

type MemorySource struct {
	Source `yaml:",inline"`
}

内存使用量

func NewMemorySource

func NewMemorySource() *MemorySource

获取新对象

func (*MemorySource) Charts

func (this *MemorySource) Charts() []*widgets.Chart

图表

func (*MemorySource) Code

func (this *MemorySource) Code() string

代号

func (*MemorySource) Description

func (this *MemorySource) Description() string

描述

func (*MemorySource) Execute

func (this *MemorySource) Execute(params map[string]string) (value interface{}, err error)

执行

func (*MemorySource) Form

func (this *MemorySource) Form() *forms.Form

表单信息

func (*MemorySource) Name

func (this *MemorySource) Name() string

名称

func (*MemorySource) Thresholds

func (this *MemorySource) Thresholds() []*Threshold

阈值

func (*MemorySource) Variables

func (this *MemorySource) Variables() []*SourceVariable

变量

type MySQLSource

type MySQLSource struct {
	Source `yaml:",inline"`

	Addr           string `yaml:"addr" json:"addr"`
	Username       string `yaml:"username" json:"username"`
	Password       string `yaml:"password" json:"password"`
	DatabaseName   string `yaml:"databaseName" json:"databaseName"`
	TimeoutSeconds int    `yaml:"timeoutSeconds" json:"timeoutSeconds"`
	SQL            string `yaml:"sql" json:"sql"`
	// contains filtered or unexported fields
}

MySQL SQL

func NewMySQLSource

func NewMySQLSource() *MySQLSource

获取新对象

func (*MySQLSource) Charts

func (this *MySQLSource) Charts() []*widgets.Chart

图表

func (*MySQLSource) Code

func (this *MySQLSource) Code() string

代号

func (*MySQLSource) Description

func (this *MySQLSource) Description() string

描述

func (*MySQLSource) Execute

func (this *MySQLSource) Execute(params map[string]string) (value interface{}, err error)

执行

func (*MySQLSource) Form

func (this *MySQLSource) Form() *forms.Form

表单信息

func (*MySQLSource) Name

func (this *MySQLSource) Name() string

名称

func (*MySQLSource) Presentation

func (this *MySQLSource) Presentation() *forms.Presentation

显示信息

func (*MySQLSource) Stop

func (this *MySQLSource) Stop() error

停止

func (*MySQLSource) Thresholds

func (this *MySQLSource) Thresholds() []*Threshold

阈值

func (*MySQLSource) Variables

func (this *MySQLSource) Variables() []*SourceVariable

变量

type NetworkSource

type NetworkSource struct {
	Source `yaml:",inline"`

	InterfaceNames []string `yaml:"interfaceNames" json:"interfaceNames"`
	// contains filtered or unexported fields
}

网络带宽等信息

func NewNetworkSource

func NewNetworkSource() *NetworkSource

获取新对象

func (*NetworkSource) Charts

func (this *NetworkSource) Charts() []*widgets.Chart

图表

func (*NetworkSource) Code

func (this *NetworkSource) Code() string

代号

func (*NetworkSource) Description

func (this *NetworkSource) Description() string

描述

func (*NetworkSource) Execute

func (this *NetworkSource) Execute(params map[string]string) (value interface{}, err error)

执行

func (*NetworkSource) Form

func (this *NetworkSource) Form() *forms.Form

表单信息

func (*NetworkSource) Name

func (this *NetworkSource) Name() string

名称

func (*NetworkSource) Presentation

func (this *NetworkSource) Presentation() *forms.Presentation

显示信息

func (*NetworkSource) Thresholds

func (this *NetworkSource) Thresholds() []*Threshold

阈值

func (*NetworkSource) Variables

func (this *NetworkSource) Variables() []*SourceVariable

变量

type NginxStatusSource

type NginxStatusSource struct {
	Source `yaml:",inline"`

	URL string `yaml:"url" json:"url"`
	// contains filtered or unexported fields
}

Nginx Status数据源

func NewNginxStatusSource

func NewNginxStatusSource() *NginxStatusSource

获取新对象

func (*NginxStatusSource) Charts

func (this *NginxStatusSource) Charts() []*widgets.Chart

图表

func (*NginxStatusSource) Code

func (this *NginxStatusSource) Code() string

代号

func (*NginxStatusSource) Description

func (this *NginxStatusSource) Description() string

描述

func (*NginxStatusSource) Execute

func (this *NginxStatusSource) Execute(params map[string]string) (value interface{}, err error)

执行

func (*NginxStatusSource) Form

func (this *NginxStatusSource) Form() *forms.Form

选项表单

func (*NginxStatusSource) Name

func (this *NginxStatusSource) Name() string

名称

func (*NginxStatusSource) Presentation

func (this *NginxStatusSource) Presentation() *forms.Presentation

显示信息

func (*NginxStatusSource) Thresholds

func (this *NginxStatusSource) Thresholds() []*Threshold

阈值

func (*NginxStatusSource) Validate

func (this *NginxStatusSource) Validate() error

校验

func (*NginxStatusSource) Variables

func (this *NginxStatusSource) Variables() []*SourceVariable

变量

type PingSource

type PingSource struct {
	Source `yaml:",inline"`

	Host string `yaml:"host" json:"host"`
}

Ping

func NewPingSource

func NewPingSource() *PingSource

获取新对象

func (*PingSource) Charts

func (this *PingSource) Charts() []*widgets.Chart

图表

func (*PingSource) Code

func (this *PingSource) Code() string

代号

func (*PingSource) Description

func (this *PingSource) Description() string

描述

func (*PingSource) Execute

func (this *PingSource) Execute(params map[string]string) (value interface{}, err error)

执行

func (*PingSource) Form

func (this *PingSource) Form() *forms.Form

表单信息

func (*PingSource) Name

func (this *PingSource) Name() string

名称

func (*PingSource) Presentation

func (this *PingSource) Presentation() *forms.Presentation

显示信息

func (*PingSource) Thresholds

func (this *PingSource) Thresholds() []*Threshold

阈值

func (*PingSource) Variables

func (this *PingSource) Variables() []*SourceVariable

变量

type PostgreSQLSource

type PostgreSQLSource struct {
	Source `yaml:",inline"`

	Addr           string `yaml:"addr" json:"addr"`
	Username       string `yaml:"username" json:"username"`
	Password       string `yaml:"password" json:"password"`
	DatabaseName   string `yaml:"databaseName" json:"databaseName"`
	TimeoutSeconds int    `yaml:"timeoutSeconds" json:"timeoutSeconds"`
	//SSLMode        string `yaml:"sslMode" json:"sslMode"`
	SQL string `yaml:"sql" json:"sql"`
	// contains filtered or unexported fields
}

Postgre SQL

func NewPostgreSQLSource

func NewPostgreSQLSource() *PostgreSQLSource

获取新对象

func (*PostgreSQLSource) Charts

func (this *PostgreSQLSource) Charts() []*widgets.Chart

图表

func (*PostgreSQLSource) Code

func (this *PostgreSQLSource) Code() string

代号

func (*PostgreSQLSource) Description

func (this *PostgreSQLSource) Description() string

描述

func (*PostgreSQLSource) Execute

func (this *PostgreSQLSource) Execute(params map[string]string) (value interface{}, err error)

执行

func (*PostgreSQLSource) Form

func (this *PostgreSQLSource) Form() *forms.Form

表单信息

func (*PostgreSQLSource) Name

func (this *PostgreSQLSource) Name() string

名称

func (*PostgreSQLSource) Presentation

func (this *PostgreSQLSource) Presentation() *forms.Presentation

显示信息

func (*PostgreSQLSource) Stop

func (this *PostgreSQLSource) Stop() error

停止

func (*PostgreSQLSource) Thresholds

func (this *PostgreSQLSource) Thresholds() []*Threshold

阈值

func (*PostgreSQLSource) Variables

func (this *PostgreSQLSource) Variables() []*SourceVariable

变量

type ProcessLog

type ProcessLog struct {
	Id         shared.ObjectId `var:"id" bson:"_id" json:"id"` // 数据库存储的ID
	AgentId    string          `bson:"agentId" json:"agentId"`
	TaskId     string          `bson:"taskId" json:"taskId"`
	ProcessId  string          `bson:"processId" json:"processId"`
	ProcessPid int             `bson:"processPid" json:"processPid"`
	EventType  string          `bson:"eventType" json:"eventType"` // start, log, stop
	Data       string          `bson:"data" json:"data"`
	Timestamp  int64           `bson:"timestamp" json:"timestamp"` // unix时间戳,单位为秒
	TimeFormat struct {
		Year   string `bson:"year" json:"year"`
		Month  string `bson:"month" json:"month"`
		Week   string `bson:"week" json:"week"`
		Day    string `bson:"day" json:"day"`
		Hour   string `bson:"hour" json:"hour"`
		Minute string `bson:"minute" json:"minute"`
		Second string `bson:"second" json:"second"`
	} `bson:"timeFormat" json:"timeFormat"`
}

进程日志

func (*ProcessLog) DBColumns

func (this *ProcessLog) DBColumns() maps.Map

获取数据库列值

func (*ProcessLog) SetDBColumns

func (this *ProcessLog) SetDBColumns(v maps.Map)

设置数据库列值

func (*ProcessLog) SetTime

func (this *ProcessLog) SetTime(t time.Time)

设置时间

type ProcessesSource

type ProcessesSource struct {
	Source `yaml:",inline"`
}

进程数

func NewProcessesSource

func NewProcessesSource() *ProcessesSource

获取新对象

func (*ProcessesSource) Charts

func (this *ProcessesSource) Charts() []*widgets.Chart

图表

func (*ProcessesSource) Code

func (this *ProcessesSource) Code() string

代号

func (*ProcessesSource) Description

func (this *ProcessesSource) Description() string

描述

func (*ProcessesSource) Execute

func (this *ProcessesSource) Execute(params map[string]string) (value interface{}, err error)

执行

func (*ProcessesSource) Form

func (this *ProcessesSource) Form() *forms.Form

表单信息

func (*ProcessesSource) Name

func (this *ProcessesSource) Name() string

名称

func (*ProcessesSource) Presentation

func (this *ProcessesSource) Presentation() *forms.Presentation

显示信息

func (*ProcessesSource) Thresholds

func (this *ProcessesSource) Thresholds() []*Threshold

阈值

func (*ProcessesSource) Variables

func (this *ProcessesSource) Variables() []*SourceVariable

变量

type ScheduleConfig

type ScheduleConfig struct {
	SecondRanges  []*ScheduleRangeConfig `yaml:"secondRanges" json:"secondRanges"`   // 秒
	MinuteRanges  []*ScheduleRangeConfig `yaml:"minuteRanges" json:"minuteRanges"`   // 分
	HourRanges    []*ScheduleRangeConfig `yaml:"hourRanges" json:"hourRanges"`       // 小时
	DayRanges     []*ScheduleRangeConfig `yaml:"dayRanges" json:"dayRanges"`         // 天
	MonthRanges   []*ScheduleRangeConfig `yaml:"monthRanges" json:"monthRanges"`     // 月
	YearRanges    []*ScheduleRangeConfig `yaml:"yearRanges" json:"yearRanges"`       // 年份
	WeekDayRanges []*ScheduleRangeConfig `yaml:"weekDayRanges" json:"weekDayRanges"` // 一周中的某天,1-7
	// contains filtered or unexported fields
}

定时

func NewScheduleConfig

func NewScheduleConfig() *ScheduleConfig

定时新对象

func (*ScheduleConfig) AddDayRanges

func (this *ScheduleConfig) AddDayRanges(r ...*ScheduleRangeConfig)

添加天设置

func (*ScheduleConfig) AddHourRanges

func (this *ScheduleConfig) AddHourRanges(r ...*ScheduleRangeConfig)

添加小时设置

func (*ScheduleConfig) AddMinuteRanges

func (this *ScheduleConfig) AddMinuteRanges(r ...*ScheduleRangeConfig)

添加分钟设置

func (*ScheduleConfig) AddMonthRanges

func (this *ScheduleConfig) AddMonthRanges(r ...*ScheduleRangeConfig)

添加月设置

func (*ScheduleConfig) AddSecondRanges

func (this *ScheduleConfig) AddSecondRanges(r ...*ScheduleRangeConfig)

添加秒设置

func (*ScheduleConfig) AddWeekDayRanges

func (this *ScheduleConfig) AddWeekDayRanges(r ...*ScheduleRangeConfig)

添加周N设置

func (*ScheduleConfig) AddYearRanges

func (this *ScheduleConfig) AddYearRanges(r ...*ScheduleRangeConfig)

添加年设置

func (*ScheduleConfig) Next

func (this *ScheduleConfig) Next(now time.Time) (t time.Time, ok bool)

下次运行时间

func (*ScheduleConfig) ShouldRun

func (this *ScheduleConfig) ShouldRun(t time.Time) bool

判断时间是否匹配

func (*ScheduleConfig) Summary

func (this *ScheduleConfig) Summary() string

Summary

func (*ScheduleConfig) Validate

func (this *ScheduleConfig) Validate() error

校验

type ScheduleRangeConfig

type ScheduleRangeConfig struct {
	Every bool `yaml:"every" json:"every"`
	From  int  `yaml:"from" json:"from"`
	To    int  `yaml:"to" json:"to"`
	Step  int  `yaml:"step" json:"step"`
	Value int  `yaml:"value" json:"value"`
}

Schedule时间范围

func NewScheduleRangeConfig

func NewScheduleRangeConfig() *ScheduleRangeConfig

获取新对象

type ScheduleRangeList

type ScheduleRangeList struct {
	Every  bool
	Ranges []*ScheduleRangeConfig
}

定时列表

func NewScheduleRangeList

func NewScheduleRangeList() *ScheduleRangeList

获取新对象

func (*ScheduleRangeList) Convert

func (this *ScheduleRangeList) Convert(ranges []*ScheduleRangeConfig)

转换

func (*ScheduleRangeList) Next

func (this *ScheduleRangeList) Next(current int, defaultValue int) int

下一个数值

type ScriptAction

type ScriptAction struct {
	Path       string             `yaml:"path" json:"path"`
	ScriptType string             `yaml:"scriptType" json:"scriptType"` // 脚本类型,可以为path, code
	ScriptLang string             `yaml:"scriptLang" json:"scriptLang"` // 脚本语言
	Script     string             `yaml:"script" json:"script"`         // 脚本代码
	Env        []*shared.Variable `yaml:"env" json:"env"`               // 环境变量设置
	Cwd        string             `yaml:"cwd" json:"cwd"`
}

Script文件数据源

func NewScriptAction

func NewScriptAction() *ScriptAction

获取新对象

func (*ScriptAction) AddEnv

func (this *ScriptAction) AddEnv(name, value string)

添加环境变量

func (*ScriptAction) Code

func (this *ScriptAction) Code() string

代号

func (*ScriptAction) Description

func (this *ScriptAction) Description() string

描述

func (*ScriptAction) FormattedScript

func (this *ScriptAction) FormattedScript() string

格式化脚本

func (*ScriptAction) Generate

func (this *ScriptAction) Generate(id string) (path string, err error)

保存到本地

func (*ScriptAction) Name

func (this *ScriptAction) Name() string

func (*ScriptAction) Run

func (this *ScriptAction) Run(params map[string]string) (result string, err error)

执行

func (*ScriptAction) Summary

func (this *ScriptAction) Summary() maps.Map

获取简要信息

func (*ScriptAction) Validate

func (this *ScriptAction) Validate() error

type ScriptSource

type ScriptSource struct {
	Source `yaml:",inline"`

	Path       string             `yaml:"path" json:"path"`
	ScriptType string             `yaml:"scriptType" json:"scriptType"` // 脚本类型,可以为path, code
	ScriptLang string             `yaml:"scriptLang" json:"scriptLang"` // 脚本语言
	Script     string             `yaml:"script" json:"script"`         // 脚本代码
	Env        []*shared.Variable `yaml:"env" json:"env"`               // 环境变量设置
	Cwd        string             `yaml:"cwd" json:"cwd"`
}

Script文件数据源

func NewScriptSource

func NewScriptSource() *ScriptSource

获取新对象

func (*ScriptSource) AddEnv

func (this *ScriptSource) AddEnv(name, value string)

添加环境变量

func (*ScriptSource) Code

func (this *ScriptSource) Code() string

代号

func (*ScriptSource) Description

func (this *ScriptSource) Description() string

描述

func (*ScriptSource) Execute

func (this *ScriptSource) Execute(params map[string]string) (value interface{}, err error)

执行

func (*ScriptSource) Form

func (this *ScriptSource) Form() *forms.Form

选项表单

func (*ScriptSource) FormattedScript

func (this *ScriptSource) FormattedScript() string

格式化脚本

func (*ScriptSource) Generate

func (this *ScriptSource) Generate(id string) (path string, err error)

保存到本地

func (*ScriptSource) Name

func (this *ScriptSource) Name() string

名称

func (*ScriptSource) Presentation

func (this *ScriptSource) Presentation() *forms.Presentation

显示界面

func (*ScriptSource) Validate

func (this *ScriptSource) Validate() error

校验

type SocketConnectivitySource

type SocketConnectivitySource struct {
	Source `yaml:",inline"`

	Address string `yaml:"address" json:"address"`
	Network string `yaml:"network" json:"network"`
}

Socket连通性

func NewSocketConnectivitySource

func NewSocketConnectivitySource() *SocketConnectivitySource

获取新对象

func (*SocketConnectivitySource) Charts

func (this *SocketConnectivitySource) Charts() []*widgets.Chart

图表

func (*SocketConnectivitySource) Code

func (this *SocketConnectivitySource) Code() string

代号

func (*SocketConnectivitySource) Description

func (this *SocketConnectivitySource) Description() string

描述

func (*SocketConnectivitySource) Execute

func (this *SocketConnectivitySource) Execute(params map[string]string) (value interface{}, err error)

执行

func (*SocketConnectivitySource) Form

func (this *SocketConnectivitySource) Form() *forms.Form

表单信息

func (*SocketConnectivitySource) Name

func (this *SocketConnectivitySource) Name() string

名称

func (*SocketConnectivitySource) Presentation

func (this *SocketConnectivitySource) Presentation() *forms.Presentation

显示信息

func (*SocketConnectivitySource) Thresholds

func (this *SocketConnectivitySource) Thresholds() []*Threshold

阈值

func (*SocketConnectivitySource) Variables

func (this *SocketConnectivitySource) Variables() []*SourceVariable

变量

type Source

type Source struct {
	DataFormat SourceDataFormat `yaml:"dataFormat" json:"dataFormat"` // 数据格式
}

数据源基础定义

func (*Source) Charts

func (this *Source) Charts() []*widgets.Chart

图表

func (*Source) Code

func (this *Source) Code() string

代号

func (*Source) DataFormatCode

func (this *Source) DataFormatCode() SourceDataFormat

获得数据格式

func (*Source) Description

func (this *Source) Description() string

描述

func (*Source) Platforms

func (this *Source) Platforms() []string

支持的平台

func (*Source) Presentation

func (this *Source) Presentation() *forms.Presentation

显示信息

func (*Source) Stop

func (this *Source) Stop() error

停止

func (*Source) Thresholds

func (this *Source) Thresholds() []*Threshold

阈值

func (*Source) Validate

func (this *Source) Validate() error

校验

func (*Source) Variables

func (this *Source) Variables() []*SourceVariable

数据变量定义

type SourceCategory

type SourceCategory = string

数据源分类

type SourceDataFormat

type SourceDataFormat = uint8

数据格式

type SourceInterface

type SourceInterface interface {
	// 名称
	Name() string

	// 代号
	Code() string

	// 描述
	Description() string

	// 校验
	Validate() error

	// 执行
	Execute(params map[string]string) (value interface{}, err error)

	// 获得数据格式
	DataFormatCode() SourceDataFormat

	// 表单信息
	Form() *forms.Form

	// 显示信息
	Presentation() *forms.Presentation

	// 数据变量定义
	Variables() []*SourceVariable

	// 阈值
	Thresholds() []*Threshold

	// 图表
	Charts() []*widgets.Chart

	// 支持的平台
	Platforms() []string

	// 停止
	Stop() error
}

数据源接口定义

func FindDataSourceInstance

func FindDataSourceInstance(code string, options map[string]interface{}) SourceInterface

查找单个数据源实例

type SourceVariable

type SourceVariable struct {
	Code        string `yaml:"code" json:"code"`
	Description string `yaml:"description" json:"description"`
}

数据源变量

type TaskConfig

type TaskConfig struct {
	Id        string             `yaml:"id" json:"id"`               // ID
	On        bool               `yaml:"on" json:"on"`               // 是否启用
	Name      string             `yaml:"name" json:"name"`           // 名称
	Cwd       string             `yaml:"cwd" json:"cwd"`             // 当前工作目录(Current Working Directory)
	Env       []*shared.Variable `yaml:"env" json:"env"`             // 环境变量设置
	Script    string             `yaml:"script" json:"script"`       // 脚本
	IsBooting bool               `yaml:"isBooting" json:"isBooting"` // 在Boot时启动
	Schedule  []*ScheduleConfig  `yaml:"schedule" json:"schedule"`   // 定时
	IsManual  bool               `yaml:"isManual" json:"isManual"`   // 是否手工调用
	Version   uint               `yaml:"version" json:"version"`     // 版本
}

任务 日志存储在 task.${id}

func NewTaskConfig

func NewTaskConfig() *TaskConfig

获取新对象

func (*TaskConfig) AddEnv

func (this *TaskConfig) AddEnv(name string, value string)

添加环境变量

func (*TaskConfig) AddSchedule

func (this *TaskConfig) AddSchedule(schedule *ScheduleConfig)

添加定时

func (*TaskConfig) FormattedScript

func (this *TaskConfig) FormattedScript() string

格式化脚本

func (*TaskConfig) Generate

func (this *TaskConfig) Generate() (path string, err error)

保存到本地

func (*TaskConfig) GenerateAgain

func (this *TaskConfig) GenerateAgain() (path string, err error)

重新生成

func (*TaskConfig) MatchKeyword

func (this *TaskConfig) MatchKeyword(keyword string) (matched bool, name string, tags []string)

匹配关键词

func (*TaskConfig) Next

func (this *TaskConfig) Next(now time.Time) (next time.Time, ok bool)

取得下次运行时间

func (*TaskConfig) Validate

func (this *TaskConfig) Validate() error

校验

type TeaWebSource

type TeaWebSource struct {
	Source `yaml:",inline"`

	API     string `yaml:"api" json:"api"`
	Timeout int    `yaml:"timeout" json:"timeout"`
}

TeaWeb相关数据源

func NewTeaWebSource

func NewTeaWebSource() *TeaWebSource

获取新对象

func (*TeaWebSource) Charts

func (this *TeaWebSource) Charts() []*widgets.Chart

图表

func (*TeaWebSource) Code

func (this *TeaWebSource) Code() string

代号

func (*TeaWebSource) Description

func (this *TeaWebSource) Description() string

描述

func (*TeaWebSource) Execute

func (this *TeaWebSource) Execute(params map[string]string) (value interface{}, err error)

执行

func (*TeaWebSource) Form

func (this *TeaWebSource) Form() *forms.Form

表单信息

func (*TeaWebSource) Name

func (this *TeaWebSource) Name() string

名称

func (*TeaWebSource) Presentation

func (this *TeaWebSource) Presentation() *forms.Presentation

显示信息

func (*TeaWebSource) Thresholds

func (this *TeaWebSource) Thresholds() []*Threshold

阈值

func (*TeaWebSource) Variables

func (this *TeaWebSource) Variables() []*SourceVariable

变量

type Threshold

type Threshold struct {
	Id            string                   `yaml:"id" json:"id"`                       // ID
	Param         string                   `yaml:"param" json:"param"`                 // 参数
	Operator      ThresholdOperator        `yaml:"operator" json:"operator"`           // 运算符
	Value         string                   `yaml:"value" json:"value"`                 // 对比值
	NoticeLevel   notices.NoticeLevel      `yaml:"noticeLevel" json:"noticeLevel"`     // 通知级别
	NoticeMessage string                   `yaml:"noticeMessage" json:"noticeMessage"` // 通知消息
	Actions       []map[string]interface{} `yaml:"actions" json:"actions"`             // 动作配置
	MaxFails      int                      `yaml:"maxFails" json:"maxFails"`           // 连续失败次数
	// contains filtered or unexported fields
}

阈值定义

func NewThreshold

func NewThreshold() *Threshold

新阈值对象

func (*Threshold) Eval

func (this *Threshold) Eval(value interface{}, old interface{}) (string, error)

执行数值运算,使用Javascript语法

func (*Threshold) Expression

func (this *Threshold) Expression() string

取得描述文本

func (*Threshold) RunActions

func (this *Threshold) RunActions(params map[string]string) error

执行动作

func (*Threshold) Test

func (this *Threshold) Test(value interface{}, oldValue interface{}) (ok bool, err error)

将此条件应用于阈值,检查是否匹配

func (*Threshold) TestRow

func (this *Threshold) TestRow(value interface{}, oldValue interface{}) (ok bool, row interface{}, err error)

将此条件应用于阈值,检查是否匹配,如果匹配同时也返回$匹配的行数据

func (*Threshold) Validate

func (this *Threshold) Validate() error

校验

type ThresholdOperator

type ThresholdOperator = string

运算符定义

const (
	ThresholdOperatorRegexp       ThresholdOperator = "regexp"
	ThresholdOperatorNotRegexp    ThresholdOperator = "not regexp"
	ThresholdOperatorGt           ThresholdOperator = "gt"
	ThresholdOperatorGte          ThresholdOperator = "gte"
	ThresholdOperatorLt           ThresholdOperator = "lt"
	ThresholdOperatorLte          ThresholdOperator = "lte"
	ThresholdOperatorEq           ThresholdOperator = "eq"
	ThresholdOperatorNumberEq     ThresholdOperator = "number eq"
	ThresholdOperatorNot          ThresholdOperator = "not"
	ThresholdOperatorPrefix       ThresholdOperator = "prefix"
	ThresholdOperatorSuffix       ThresholdOperator = "suffix"
	ThresholdOperatorContains     ThresholdOperator = "contains"
	ThresholdOperatorNotContains  ThresholdOperator = "not contains"
	ThresholdOperatorVersionRange ThresholdOperator = "version range"

	// IP相关
	ThresholdOperatorEqIP    ThresholdOperator = "eq ip"
	ThresholdOperatorGtIP    ThresholdOperator = "gt ip"
	ThresholdOperatorGteIP   ThresholdOperator = "gte ip"
	ThresholdOperatorLtIP    ThresholdOperator = "lt ip"
	ThresholdOperatorLteIP   ThresholdOperator = "lte ip"
	ThresholdOperatorIPRange ThresholdOperator = "ip range"
)

type URLConnectivitySource

type URLConnectivitySource struct {
	Source `yaml:",inline"`

	Timeout  int                `yaml:"timeout" json:"timeout"` // 连接超时
	URL      string             `yaml:"url" json:"url"`
	Method   string             `yaml:"method" json:"method"`
	Headers  []*shared.Variable `yaml:"headers" json:"headers"`
	Params   []*shared.Variable `yaml:"params" json:"params"`
	TextBody string             `yaml:"textBody" json:"textBody"`
}

URL连通性

func NewURLConnectivitySource

func NewURLConnectivitySource() *URLConnectivitySource

获取新对象

func (*URLConnectivitySource) Charts

func (this *URLConnectivitySource) Charts() []*widgets.Chart

图表

func (*URLConnectivitySource) Code

func (this *URLConnectivitySource) Code() string

代号

func (*URLConnectivitySource) Description

func (this *URLConnectivitySource) Description() string

描述

func (*URLConnectivitySource) Execute

func (this *URLConnectivitySource) Execute(params map[string]string) (value interface{}, err error)

执行

func (*URLConnectivitySource) Form

func (this *URLConnectivitySource) Form() *forms.Form

表单信息

func (*URLConnectivitySource) Name

func (this *URLConnectivitySource) Name() string

名称

func (*URLConnectivitySource) Presentation

func (this *URLConnectivitySource) Presentation() *forms.Presentation

显示信息

func (*URLConnectivitySource) Thresholds

func (this *URLConnectivitySource) Thresholds() []*Threshold

阈值

func (*URLConnectivitySource) Variables

func (this *URLConnectivitySource) Variables() []*SourceVariable

变量

type Value

type Value struct {
	Id          shared.ObjectId     `bson:"_id" json:"id"`                  // 数据库存储的ID
	NodeId      string              `bson:"nodeId" json:"nodeId"`           // 节点ID
	AgentId     string              `bson:"agentId" json:"agentId"`         // Agent ID
	AppId       string              `bson:"appId" json:"appId"`             // App ID
	ItemId      string              `bson:"itemId" json:"itemId"`           // 监控项ID
	Timestamp   int64               `bson:"timestamp" json:"timestamp"`     // Agent时间戳
	CreatedAt   int64               `bson:"createdAt" json:"createdAt"`     // 触发时间
	CostMs      float64             `bson:"costMs" json:"costMs"`           // 耗时ms
	Value       interface{}         `bson:"value" json:"value"`             // 值,可以是个标量,或者一个组合的值
	Error       string              `bson:"error" json:"error"`             // 错误信息
	NoticeLevel notices.NoticeLevel `bson:"noticeLevel" json:"noticeLevel"` // 通知级别
	IsNotified  bool                `bson:"isNotified" json:"isNotified"`   // 是否已通知
	ThresholdId string              `bson:"thresholdId" json:"thresholdId"` // 阈值ID
	Threshold   string              `bson:"threshold" json:"threshold"`     // 阈值描述

	TimeFormat struct {
		Year   string `bson:"year" json:"year"`
		Month  string `bson:"month" json:"month"`
		Week   string `bson:"week" json:"week"`
		Day    string `bson:"day" json:"day"`
		Hour   string `bson:"hour" json:"hour"`
		Minute string `bson:"minute" json:"minute"`
		Second string `bson:"second" json:"second"`
	} `bson:"timeFormat" json:"timeFormat"`
}

应用指标值定义

func NewValue

func NewValue() *Value

获取新对象

func (*Value) AllFlatKeys

func (this *Value) AllFlatKeys() []string

将Value扁平化然后获取Key

func (*Value) DBColumns

func (this *Value) DBColumns() maps.Map

获取数据库列值

func (*Value) SetDBColumns

func (this *Value) SetDBColumns(v maps.Map)

设置数据库列值

func (*Value) SetTime

func (this *Value) SetTime(t time.Time)

设置时间

type WebHookSource

type WebHookSource struct {
	Source `yaml:",inline"`

	URL      string             `yaml:"url" json:"url"`
	Timeout  string             `yaml:"timeout" json:"timeout"`
	Method   string             `yaml:"method" json:"method"` // 请求方法
	Headers  []*shared.Variable `yaml:"headers" json:"headers"`
	Params   []*shared.Variable `yaml:"params" json:"params"`
	TextBody string             `yaml:"textBody" json:"textBody"`
	// contains filtered or unexported fields
}

WebHook

func NewWebHookSource

func NewWebHookSource() *WebHookSource

获取新对象

func (*WebHookSource) Code

func (this *WebHookSource) Code() string

代号

func (*WebHookSource) Description

func (this *WebHookSource) Description() string

描述

func (*WebHookSource) Execute

func (this *WebHookSource) Execute(params map[string]string) (value interface{}, err error)

执行

func (*WebHookSource) Form

func (this *WebHookSource) Form() *forms.Form

选项表单

func (*WebHookSource) Name

func (this *WebHookSource) Name() string

名称

func (*WebHookSource) Presentation

func (this *WebHookSource) Presentation() *forms.Presentation

func (*WebHookSource) Validate

func (this *WebHookSource) Validate() error

校验

Jump to

Keyboard shortcuts

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