agents

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2019 License: MIT Imports: 47 Imported by: 17

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
)
View Source
const (
	ThresholdOperatorRegexp      = "regexp"
	ThresholdOperatorNotRegexp   = "not regexp"
	ThresholdOperatorGt          = "gt"
	ThresholdOperatorGte         = "gte"
	ThresholdOperatorLt          = "lt"
	ThresholdOperatorLte         = "lte"
	ThresholdOperatorEq          = "eq"
	ThresholdOperatorNumberEq    = "number eq"
	ThresholdOperatorNot         = "not"
	ThresholdOperatorPrefix      = "prefix"
	ThresholdOperatorSuffix      = "suffix"
	ThresholdOperatorContains    = "contains"
	ThresholdOperatorNotContains = "not contains"
)

Variables

This section is empty.

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 added in v0.1.2

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

将Source转换为Map

func DecodeSource

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

解码数据

func DefaultGroupFile added in v0.1.6

func DefaultGroupFile() string

默认的分组文件名

func EvalParam added in v0.1.2

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 NotifyAgentsChange added in v0.1.2

func NotifyAgentsChange()

通知Agent变化

func RegisterAllDataSources added in v0.1.2

func RegisterAllDataSources()

注册内置的数据源信息

func RegisterDataSource added in v0.1.2

func RegisterDataSource(dataSource SourceInterface, category SourceCategory)

单个数据源信息

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
	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

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

Agent定义

func AllSharedAgents added in v0.1.2

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 added in v0.1.2

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 added in v0.1.2

func (this *AgentConfig) AddDefaultApps()

添加内置的App

func (*AgentConfig) AddGroup

func (this *AgentConfig) AddGroup(groupId string)

添加分组

func (*AgentConfig) AddNoticeReceiver added in v0.1.2

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

添加通知接收者

func (*AgentConfig) CountNoticeReceivers added in v0.1.2

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 added in v0.1.2

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) GroupName added in v0.1.3

func (this *AgentConfig) GroupName() string

获取分组名

func (*AgentConfig) HasApp added in v0.1.2

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

判断是否有某个App

func (*AgentConfig) InGroups added in v0.1.2

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

判断是否有某些分组

func (*AgentConfig) IsLocal

func (this *AgentConfig) IsLocal() bool

判断是否为Local Agent

func (*AgentConfig) MoveApp added in v0.1.5

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 added in v0.1.2

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

删除媒介

func (*AgentConfig) RemoveNoticeReceiver added in v0.1.2

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

删除通知接收者

func (*AgentConfig) ReplaceApp added in v0.1.2

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) 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 added in v0.1.2

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

添加通知接收者

func (*AppConfig) AddTask

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

添加任务

func (*AppConfig) CountNoticeReceivers added in v0.1.2

func (this *AppConfig) CountNoticeReceivers() int

获取通知接收者数量

func (*AppConfig) FindAllNoticeReceivers added in v0.1.2

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) RemoveItem

func (this *AppConfig) RemoveItem(itemId string)

删除监控项

func (*AppConfig) RemoveMedia added in v0.1.2

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

删除媒介

func (*AppConfig) RemoveNoticeReceiver added in v0.1.2

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 added in v0.1.2

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

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

App进程

func NewAppProcessesSource added in v0.1.2

func NewAppProcessesSource() *AppProcessesSource

获取新对象

func (*AppProcessesSource) Charts added in v0.1.2

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

图表

func (*AppProcessesSource) Code added in v0.1.2

func (this *AppProcessesSource) Code() string

代号

func (*AppProcessesSource) Description added in v0.1.2

func (this *AppProcessesSource) Description() string

描述

func (*AppProcessesSource) Execute added in v0.1.2

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

执行

func (*AppProcessesSource) Form added in v0.1.2

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

表单信息

func (*AppProcessesSource) Name added in v0.1.2

func (this *AppProcessesSource) Name() string

名称

func (*AppProcessesSource) Platforms added in v0.1.2

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

平台限制

func (*AppProcessesSource) Presentation added in v0.1.2

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

显示信息

func (*AppProcessesSource) Thresholds added in v0.1.2

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

阈值

func (*AppProcessesSource) Variables added in v0.1.2

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

变量

type Board

type Board struct {
	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 added in v0.1.2

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

查看是否有图表

func (*Board) MoveChart added in v0.1.2

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

func (*Board) RemoveApp added in v0.1.2

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"`
}

看板图表定义

type CPUSource added in v0.1.2

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

CPU使用量

func NewCPUSource added in v0.1.2

func NewCPUSource() *CPUSource

获取新对象

func (*CPUSource) Charts added in v0.1.2

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

图表

func (*CPUSource) Code added in v0.1.2

func (this *CPUSource) Code() string

代号

func (*CPUSource) Description added in v0.1.2

func (this *CPUSource) Description() string

描述

func (*CPUSource) Execute added in v0.1.2

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

执行

func (*CPUSource) Form added in v0.1.2

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

表单信息

func (*CPUSource) Name added in v0.1.2

func (this *CPUSource) Name() string

名称

func (*CPUSource) Thresholds added in v0.1.2

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

阈值

func (*CPUSource) Variables added in v0.1.2

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

变量

type ConnectionsSource added in v0.1.2

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

网络连接数

func NewConnectionsSource added in v0.1.2

func NewConnectionsSource() *ConnectionsSource

获取新对象

func (*ConnectionsSource) Charts added in v0.1.2

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

图表

func (*ConnectionsSource) Code added in v0.1.2

func (this *ConnectionsSource) Code() string

代号

func (*ConnectionsSource) Description added in v0.1.2

func (this *ConnectionsSource) Description() string

描述

func (*ConnectionsSource) Execute added in v0.1.2

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

执行

func (*ConnectionsSource) Form added in v0.1.2

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

表单信息

func (*ConnectionsSource) Name added in v0.1.2

func (this *ConnectionsSource) Name() string

名称

func (*ConnectionsSource) Presentation added in v0.1.2

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

显示信息

func (*ConnectionsSource) Thresholds added in v0.1.2

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

阈值

func (*ConnectionsSource) Variables added in v0.1.2

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

变量

type DNSSource added in v0.1.2

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

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

DNS检查

func NewDNSSource added in v0.1.2

func NewDNSSource() *DNSSource

获取新对象

func (*DNSSource) Charts added in v0.1.2

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

图表

func (*DNSSource) Code added in v0.1.2

func (this *DNSSource) Code() string

代号

func (*DNSSource) Description added in v0.1.2

func (this *DNSSource) Description() string

描述

func (*DNSSource) Execute added in v0.1.2

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

执行

func (*DNSSource) Form added in v0.1.2

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

表单信息

func (*DNSSource) Name added in v0.1.2

func (this *DNSSource) Name() string

名称

func (*DNSSource) Presentation added in v0.1.2

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

显示信息

func (*DNSSource) Thresholds added in v0.1.2

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

阈值

func (*DNSSource) Variables added in v0.1.2

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

变量

type DateSource added in v0.1.2

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

日期相关

func NewDateSource added in v0.1.2

func NewDateSource() *DateSource

获取新对象

func (*DateSource) Charts added in v0.1.2

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

图表

func (*DateSource) Code added in v0.1.2

func (this *DateSource) Code() string

代号

func (*DateSource) Description added in v0.1.2

func (this *DateSource) Description() string

描述

func (*DateSource) Execute added in v0.1.2

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

执行

func (*DateSource) Form added in v0.1.2

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

表单信息

func (*DateSource) Name added in v0.1.2

func (this *DateSource) Name() string

名称

func (*DateSource) Presentation added in v0.1.2

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

显示信息

func (*DateSource) Thresholds added in v0.1.2

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

阈值

func (*DateSource) Variables added in v0.1.2

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

变量

type DiskSource added in v0.1.2

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

文件系统信息

func NewDiskSource added in v0.1.2

func NewDiskSource() *DiskSource

获取新对象

func (*DiskSource) Charts added in v0.1.2

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

图表

func (*DiskSource) Code added in v0.1.2

func (this *DiskSource) Code() string

代号

func (*DiskSource) Description added in v0.1.2

func (this *DiskSource) Description() string

描述

func (*DiskSource) Execute added in v0.1.2

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

执行

func (*DiskSource) Form added in v0.1.2

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

表单信息

func (*DiskSource) Name added in v0.1.2

func (this *DiskSource) Name() string

名称

func (*DiskSource) Thresholds added in v0.1.2

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

阈值

func (*DiskSource) Variables added in v0.1.2

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

变量

type DockerSource added in v0.1.2

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

Docker相关数据源

func NewDockerSource added in v0.1.2

func NewDockerSource() *DockerSource

获取新对象

func (*DockerSource) Charts added in v0.1.2

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

图表

func (*DockerSource) Code added in v0.1.2

func (this *DockerSource) Code() string

代号

func (*DockerSource) Description added in v0.1.2

func (this *DockerSource) Description() string

描述

func (*DockerSource) Execute added in v0.1.2

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

执行

func (*DockerSource) Form added in v0.1.2

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

表单信息

func (*DockerSource) Name added in v0.1.2

func (this *DockerSource) Name() string

名称

func (*DockerSource) Thresholds added in v0.1.2

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

阈值

func (*DockerSource) Variables added in v0.1.2

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

变量

type FileChangeSource added in v0.1.2

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

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

func NewFileChangeSource added in v0.1.2

func NewFileChangeSource() *FileChangeSource

获取新对象

func (*FileChangeSource) Charts added in v0.1.2

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

图表

func (*FileChangeSource) Code added in v0.1.2

func (this *FileChangeSource) Code() string

代号

func (*FileChangeSource) Description added in v0.1.2

func (this *FileChangeSource) Description() string

描述

func (*FileChangeSource) Execute added in v0.1.2

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

执行

func (*FileChangeSource) Form added in v0.1.2

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

表单信息

func (*FileChangeSource) Name added in v0.1.2

func (this *FileChangeSource) Name() string

名称

func (*FileChangeSource) Presentation added in v0.1.2

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

显示信息

func (*FileChangeSource) Thresholds added in v0.1.2

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

阈值

func (*FileChangeSource) Variables added in v0.1.2

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 added in v0.1.2

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

选项表单

func (*FileSource) Name

func (this *FileSource) Name() string

名称

func (*FileSource) Presentation added in v0.1.2

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"`
	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"`
}

Agent分组

func LoadDefaultGroup added in v0.1.6

func LoadDefaultGroup() *Group

默认的分组 一定会有返回值

func NewGroup

func NewGroup(name string) *Group

获取新分组

func (*Group) AddNoticeReceiver

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

添加通知接收者

func (*Group) FindAllNoticeReceivers added in v0.1.2

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

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

func (*Group) RemoveMedia added in v0.1.2

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

删除媒介

func (*Group) RemoveNoticeReceiver

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

删除通知接收者

func (*Group) WriteToFile added in v0.1.6

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

写入文件

type GroupConfig

type GroupConfig struct {
	Filename string   `yaml:"filename" json:"filename"`
	Groups   []*Group `yaml:"groups" json:"groups"`
}

分组配置

func SharedGroupConfig

func SharedGroupConfig() *GroupConfig

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

func (*GroupConfig) AddGroup

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

添加分组

func (*GroupConfig) FindAllGroups

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

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

func (*GroupConfig) FindGroup

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

查找分组

func (*GroupConfig) Move

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

移动位置

func (*GroupConfig) RemoveGroup

func (this *GroupConfig) RemoveGroup(groupId string)

删除分组

func (*GroupConfig) Save

func (this *GroupConfig) Save() error

保存

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) 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) 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 added in v0.1.2

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

负载

func NewLoadSource added in v0.1.2

func NewLoadSource() *LoadSource

获取新对象

func (*LoadSource) Charts added in v0.1.2

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

图表

func (*LoadSource) Code added in v0.1.2

func (this *LoadSource) Code() string

代号

func (*LoadSource) Description added in v0.1.2

func (this *LoadSource) Description() string

描述

func (*LoadSource) Execute added in v0.1.2

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

执行

func (*LoadSource) Form added in v0.1.2

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

表单信息

func (*LoadSource) Name added in v0.1.2

func (this *LoadSource) Name() string

名称

func (*LoadSource) Thresholds added in v0.1.2

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

阈值

func (*LoadSource) Variables added in v0.1.2

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

变量

type MemorySource added in v0.1.2

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

内存使用量

func NewMemorySource added in v0.1.2

func NewMemorySource() *MemorySource

获取新对象

func (*MemorySource) Charts added in v0.1.2

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

图表

func (*MemorySource) Code added in v0.1.2

func (this *MemorySource) Code() string

代号

func (*MemorySource) Description added in v0.1.2

func (this *MemorySource) Description() string

描述

func (*MemorySource) Execute added in v0.1.2

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

执行

func (*MemorySource) Form added in v0.1.2

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

表单信息

func (*MemorySource) Name added in v0.1.2

func (this *MemorySource) Name() string

名称

func (*MemorySource) Thresholds added in v0.1.2

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

阈值

func (*MemorySource) Variables added in v0.1.2

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

变量

type MySQLSource added in v0.1.2

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"`
}

MySQL SQL

func NewMySQLSource added in v0.1.2

func NewMySQLSource() *MySQLSource

获取新对象

func (*MySQLSource) Charts added in v0.1.2

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

图表

func (*MySQLSource) Code added in v0.1.2

func (this *MySQLSource) Code() string

代号

func (*MySQLSource) Description added in v0.1.2

func (this *MySQLSource) Description() string

描述

func (*MySQLSource) Execute added in v0.1.2

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

执行

func (*MySQLSource) Form added in v0.1.2

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

表单信息

func (*MySQLSource) Name added in v0.1.2

func (this *MySQLSource) Name() string

名称

func (*MySQLSource) Presentation added in v0.1.2

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

显示信息

func (*MySQLSource) Thresholds added in v0.1.2

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

阈值

func (*MySQLSource) Variables added in v0.1.2

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

变量

type NetworkSource added in v0.1.2

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

网络带宽等信息

func NewNetworkSource added in v0.1.2

func NewNetworkSource() *NetworkSource

获取新对象

func (*NetworkSource) Charts added in v0.1.2

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

图表

func (*NetworkSource) Code added in v0.1.2

func (this *NetworkSource) Code() string

代号

func (*NetworkSource) Description added in v0.1.2

func (this *NetworkSource) Description() string

描述

func (*NetworkSource) Execute added in v0.1.2

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

执行

func (*NetworkSource) Form added in v0.1.2

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

表单信息

func (*NetworkSource) Name added in v0.1.2

func (this *NetworkSource) Name() string

名称

func (*NetworkSource) Thresholds added in v0.1.2

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

阈值

func (*NetworkSource) Variables added in v0.1.2

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

变量

type NginxStatusSource added in v0.1.2

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

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

Nginx Status数据源

func NewNginxStatusSource added in v0.1.2

func NewNginxStatusSource() *NginxStatusSource

获取新对象

func (*NginxStatusSource) Charts added in v0.1.2

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

图表

func (*NginxStatusSource) Code added in v0.1.2

func (this *NginxStatusSource) Code() string

代号

func (*NginxStatusSource) Description added in v0.1.2

func (this *NginxStatusSource) Description() string

描述

func (*NginxStatusSource) Execute added in v0.1.2

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

执行

func (*NginxStatusSource) Form added in v0.1.2

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

选项表单

func (*NginxStatusSource) Name added in v0.1.2

func (this *NginxStatusSource) Name() string

名称

func (*NginxStatusSource) Presentation added in v0.1.2

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

显示信息

func (*NginxStatusSource) Thresholds added in v0.1.2

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

阈值

func (*NginxStatusSource) Validate added in v0.1.2

func (this *NginxStatusSource) Validate() error

校验

func (*NginxStatusSource) Variables added in v0.1.2

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

变量

type PingSource added in v0.1.2

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

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

Ping

func NewPingSource added in v0.1.2

func NewPingSource() *PingSource

获取新对象

func (*PingSource) Charts added in v0.1.2

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

图表

func (*PingSource) Code added in v0.1.2

func (this *PingSource) Code() string

代号

func (*PingSource) Description added in v0.1.2

func (this *PingSource) Description() string

描述

func (*PingSource) Execute added in v0.1.2

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

执行

func (*PingSource) Form added in v0.1.2

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

表单信息

func (*PingSource) Name added in v0.1.2

func (this *PingSource) Name() string

名称

func (*PingSource) Presentation added in v0.1.2

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

显示信息

func (*PingSource) Thresholds added in v0.1.2

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

阈值

func (*PingSource) Variables added in v0.1.2

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

变量

type PostgreSQLSource added in v0.1.5

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"`
}

Postgre SQL

func NewPostgreSQLSource added in v0.1.5

func NewPostgreSQLSource() *PostgreSQLSource

获取新对象

func (*PostgreSQLSource) Charts added in v0.1.5

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

图表

func (*PostgreSQLSource) Code added in v0.1.5

func (this *PostgreSQLSource) Code() string

代号

func (*PostgreSQLSource) Description added in v0.1.5

func (this *PostgreSQLSource) Description() string

描述

func (*PostgreSQLSource) Execute added in v0.1.5

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

执行

func (*PostgreSQLSource) Form added in v0.1.5

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

表单信息

func (*PostgreSQLSource) Name added in v0.1.5

func (this *PostgreSQLSource) Name() string

名称

func (*PostgreSQLSource) Presentation added in v0.1.5

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

显示信息

func (*PostgreSQLSource) Thresholds added in v0.1.5

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

阈值

func (*PostgreSQLSource) Variables added in v0.1.5

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

变量

type ProcessesSource added in v0.1.2

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

进程数

func NewProcessesSource added in v0.1.2

func NewProcessesSource() *ProcessesSource

获取新对象

func (*ProcessesSource) Charts added in v0.1.2

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

图表

func (*ProcessesSource) Code added in v0.1.2

func (this *ProcessesSource) Code() string

代号

func (*ProcessesSource) Description added in v0.1.2

func (this *ProcessesSource) Description() string

描述

func (*ProcessesSource) Execute added in v0.1.2

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

执行

func (*ProcessesSource) Form added in v0.1.2

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

表单信息

func (*ProcessesSource) Name added in v0.1.2

func (this *ProcessesSource) Name() string

名称

func (*ProcessesSource) Presentation added in v0.1.2

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

显示信息

func (*ProcessesSource) Thresholds added in v0.1.2

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

阈值

func (*ProcessesSource) Variables added in v0.1.2

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 added in v0.1.2

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 added in v0.1.2

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

显示界面

func (*ScriptSource) Validate

func (this *ScriptSource) Validate() error

校验

type SocketConnectivitySource added in v0.1.2

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

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

Socket连通性

func NewSocketConnectivitySource added in v0.1.2

func NewSocketConnectivitySource() *SocketConnectivitySource

获取新对象

func (*SocketConnectivitySource) Charts added in v0.1.2

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

图表

func (*SocketConnectivitySource) Code added in v0.1.2

func (this *SocketConnectivitySource) Code() string

代号

func (*SocketConnectivitySource) Description added in v0.1.2

func (this *SocketConnectivitySource) Description() string

描述

func (*SocketConnectivitySource) Execute added in v0.1.2

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

执行

func (*SocketConnectivitySource) Form added in v0.1.2

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

表单信息

func (*SocketConnectivitySource) Name added in v0.1.2

func (this *SocketConnectivitySource) Name() string

名称

func (*SocketConnectivitySource) Presentation added in v0.1.2

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

显示信息

func (*SocketConnectivitySource) Thresholds added in v0.1.2

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

阈值

func (*SocketConnectivitySource) Variables added in v0.1.2

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

变量

type Source added in v0.1.2

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

数据源基础定义

func (*Source) Charts added in v0.1.2

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

图表

func (*Source) Code added in v0.1.2

func (this *Source) Code() string

代号

func (*Source) DataFormatCode added in v0.1.2

func (this *Source) DataFormatCode() SourceDataFormat

获得数据格式

func (*Source) Description added in v0.1.2

func (this *Source) Description() string

描述

func (*Source) Platforms added in v0.1.2

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

支持的平台

func (*Source) Presentation added in v0.1.2

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

显示信息

func (*Source) Thresholds added in v0.1.2

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

阈值

func (*Source) Validate added in v0.1.2

func (this *Source) Validate() error

校验

func (*Source) Variables added in v0.1.2

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

数据变量定义

type SourceCategory added in v0.1.2

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
}

数据源接口定义

func FindDataSourceInstance

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

查找单个数据源实例

type SourceVariable added in v0.1.2

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) Next

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

取得下次运行时间

func (*TaskConfig) Validate

func (this *TaskConfig) Validate() error

校验

type TeaWebSource added in v0.1.2

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

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

TeaWeb相关数据源

func NewTeaWebSource added in v0.1.2

func NewTeaWebSource() *TeaWebSource

获取新对象

func (*TeaWebSource) Charts added in v0.1.2

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

图表

func (*TeaWebSource) Code added in v0.1.2

func (this *TeaWebSource) Code() string

代号

func (*TeaWebSource) Description added in v0.1.2

func (this *TeaWebSource) Description() string

描述

func (*TeaWebSource) Execute added in v0.1.2

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

执行

func (*TeaWebSource) Form added in v0.1.2

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

表单信息

func (*TeaWebSource) Name added in v0.1.2

func (this *TeaWebSource) Name() string

名称

func (*TeaWebSource) Presentation added in v0.1.2

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

显示信息

func (*TeaWebSource) Thresholds added in v0.1.2

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

阈值

func (*TeaWebSource) Variables added in v0.1.2

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 added in v0.1.2

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 added in v0.1.2

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

运算符定义

type URLConnectivitySource added in v0.1.2

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

	Timeout int    `yaml:"timeout" json:"timeout"` // 连接超时
	URL     string `yaml:"url" json:"url"`
	Method  string `yaml:"method" json:"method"`
}

URL连通性

func NewURLConnectivitySource added in v0.1.2

func NewURLConnectivitySource() *URLConnectivitySource

获取新对象

func (*URLConnectivitySource) Charts added in v0.1.2

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

图表

func (*URLConnectivitySource) Code added in v0.1.2

func (this *URLConnectivitySource) Code() string

代号

func (*URLConnectivitySource) Description added in v0.1.2

func (this *URLConnectivitySource) Description() string

描述

func (*URLConnectivitySource) Execute added in v0.1.2

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

执行

func (*URLConnectivitySource) Form added in v0.1.2

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

表单信息

func (*URLConnectivitySource) Name added in v0.1.2

func (this *URLConnectivitySource) Name() string

名称

func (*URLConnectivitySource) Presentation added in v0.1.2

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

显示信息

func (*URLConnectivitySource) Thresholds added in v0.1.2

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

阈值

func (*URLConnectivitySource) Variables added in v0.1.2

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

变量

type Value

type Value struct {
	Id          primitive.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"`     // Master时间戳
	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"`
		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) 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"` // 请求方法
	// 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 added in v0.1.2

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

选项表单

func (*WebHookSource) Name

func (this *WebHookSource) Name() string

名称

func (*WebHookSource) Presentation added in v0.1.2

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