Documentation
      ¶
    
    
  
    
  
    Index ¶
- Constants
 - func AllActions() []maps.Map
 - func AllDataSources() []maps.Map
 - func AllSourceDataFormats() []maps.Map
 - func AllThresholdOperators() []maps.Map
 - func DecodeSource(data []byte, format SourceDataFormat) (value interface{}, err error)
 - func FindAction(code string) maps.Map
 - func FindDataSource(code string) maps.Map
 - func FindSourceDataFormat(dataFormat SourceDataFormat) maps.Map
 - func FindThresholdOperator(op string) maps.Map
 - type ActionInterface
 - type AgentConfig
 - func (this *AgentConfig) AddApp(app *AppConfig)
 - func (this *AgentConfig) AddApps(apps []*AppConfig)
 - func (this *AgentConfig) AddGroup(groupId string)
 - func (this *AgentConfig) Delete() error
 - func (this *AgentConfig) EncodeYAML() ([]byte, error)
 - func (this *AgentConfig) Filename() string
 - func (this *AgentConfig) FindApp(appId string) *AppConfig
 - func (this *AgentConfig) FindItem(itemId string) (appConfig *AppConfig, item *Item)
 - func (this *AgentConfig) FindSystemApps() []*AppConfig
 - func (this *AgentConfig) FindTask(taskId string) (appConfig *AppConfig, taskConfig *TaskConfig)
 - func (this *AgentConfig) IsLocal() bool
 - func (this *AgentConfig) RemoveApp(appId string)
 - func (this *AgentConfig) RemoveGroup(groupId string)
 - func (this *AgentConfig) ResetSystemApps()
 - func (this *AgentConfig) Save() error
 - func (this *AgentConfig) Validate() error
 
- type AgentList
 - type AppConfig
 - func (this *AppConfig) AddItem(item *Item)
 - func (this *AppConfig) AddTask(task *TaskConfig)
 - func (this *AppConfig) FindBootingTasks() []*TaskConfig
 - func (this *AppConfig) FindItem(itemId string) *Item
 - func (this *AppConfig) FindManualTasks() []*TaskConfig
 - func (this *AppConfig) FindSchedulingTasks() []*TaskConfig
 - func (this *AppConfig) FindTask(taskId string) *TaskConfig
 - func (this *AppConfig) RemoveItem(itemId string)
 - func (this *AppConfig) RemoveTask(taskId string)
 - func (this *AppConfig) Validate() error
 
- type Board
 - type BoardChart
 - type FileSource
 - func (this *FileSource) Code() string
 - func (this *FileSource) DataFormatCode() SourceDataFormat
 - func (this *FileSource) Description() string
 - func (this *FileSource) Execute(params map[string]string) (value interface{}, err error)
 - func (this *FileSource) Name() string
 - func (this *FileSource) Summary() maps.Map
 - func (this *FileSource) Validate() error
 
- type Group
 - type GroupConfig
 - func (this *GroupConfig) AddGroup(group *Group)
 - func (this *GroupConfig) FindAllGroups() []*Group
 - func (this *GroupConfig) FindGroup(groupId string) *Group
 - func (this *GroupConfig) Move(fromIndex int, toIndex int)
 - func (this *GroupConfig) RemoveGroup(groupId string)
 - func (this *GroupConfig) Save() error
 
- type Item
 - func (this *Item) AddChart(chart *widgets.Chart)
 - func (this *Item) AddThreshold(t *Threshold)
 - func (this *Item) FindChart(chartId string) *widgets.Chart
 - func (this *Item) IntervalDuration() time.Duration
 - func (this *Item) RemoveChart(chartId string)
 - func (this *Item) Source() SourceInterface
 - func (this *Item) TestValue(value interface{}) (level notices.NoticeLevel, message string)
 - func (this *Item) Validate() error
 
- type ScheduleConfig
 - func (this *ScheduleConfig) AddDayRanges(r ...*ScheduleRangeConfig)
 - func (this *ScheduleConfig) AddHourRanges(r ...*ScheduleRangeConfig)
 - func (this *ScheduleConfig) AddMinuteRanges(r ...*ScheduleRangeConfig)
 - func (this *ScheduleConfig) AddMonthRanges(r ...*ScheduleRangeConfig)
 - func (this *ScheduleConfig) AddSecondRanges(r ...*ScheduleRangeConfig)
 - func (this *ScheduleConfig) AddWeekDayRanges(r ...*ScheduleRangeConfig)
 - func (this *ScheduleConfig) AddYearRanges(r ...*ScheduleRangeConfig)
 - func (this *ScheduleConfig) Next(now time.Time) (t time.Time, ok bool)
 - func (this *ScheduleConfig) ShouldRun(t time.Time) bool
 - func (this *ScheduleConfig) Summary() string
 - func (this *ScheduleConfig) Validate() error
 
- type ScheduleRangeConfig
 - type ScheduleRangeList
 - type ScriptAction
 - func (this *ScriptAction) AddEnv(name, value string)
 - func (this *ScriptAction) Code() string
 - func (this *ScriptAction) Description() string
 - func (this *ScriptAction) FormattedScript() string
 - func (this *ScriptAction) Generate(id string) (path string, err error)
 - func (this *ScriptAction) Name() string
 - func (this *ScriptAction) Run(params map[string]string) (result string, err error)
 - func (this *ScriptAction) Summary() maps.Map
 - func (this *ScriptAction) Validate() error
 
- type ScriptSource
 - func (this *ScriptSource) AddEnv(name, value string)
 - func (this *ScriptSource) Code() string
 - func (this *ScriptSource) DataFormatCode() SourceDataFormat
 - func (this *ScriptSource) Description() string
 - func (this *ScriptSource) Execute(params map[string]string) (value interface{}, err error)
 - func (this *ScriptSource) FormattedScript() string
 - func (this *ScriptSource) Generate(id string) (path string, err error)
 - func (this *ScriptSource) Name() string
 - func (this *ScriptSource) Summary() maps.Map
 - func (this *ScriptSource) Validate() error
 
- type SourceDataFormat
 - type SourceInterface
 - type TaskConfig
 - func (this *TaskConfig) AddEnv(name string, value string)
 - func (this *TaskConfig) AddSchedule(schedule *ScheduleConfig)
 - func (this *TaskConfig) FormattedScript() string
 - func (this *TaskConfig) Generate() (path string, err error)
 - func (this *TaskConfig) GenerateAgain() (path string, err error)
 - func (this *TaskConfig) Next(now time.Time) (next time.Time, ok bool)
 - func (this *TaskConfig) Validate() error
 
- type Threshold
 - type ThresholdOperator
 - type Value
 - type WebHookSource
 - func (this *WebHookSource) Code() string
 - func (this *WebHookSource) DataFormatCode() SourceDataFormat
 - func (this *WebHookSource) Description() string
 - func (this *WebHookSource) Execute(params map[string]string) (value interface{}, err error)
 - func (this *WebHookSource) Name() string
 - func (this *WebHookSource) Summary() maps.Map
 - func (this *WebHookSource) Validate() error
 
Constants ¶
      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" ThresholdOperatorNot = "not" ThresholdOperatorPrefix = "prefix" ThresholdOperatorSuffix = "suffix" ThresholdOperatorContains = "contains" ThresholdOperatorNotContains = "not contains" )
Variables ¶
This section is empty.
Functions ¶
func DecodeSource ¶
func DecodeSource(data []byte, format SourceDataFormat) (value interface{}, err error)
解码数据
func FindSourceDataFormat ¶
func FindSourceDataFormat(dataFormat SourceDataFormat) maps.Map
取得单个数据格式
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"`                         // 版本
	CountDisconnections int          `yaml:"countDisconnections" json:"countDisconnections"` // 错误次数
	GroupIds            []string     `yaml:"groupIds" json:"groupIds"`                       // 分组IDs
}
    Agent定义
func LocalAgentConfig ¶
func LocalAgentConfig() *AgentConfig
func (*AgentConfig) FindItem ¶
func (this *AgentConfig) FindItem(itemId string) (appConfig *AppConfig, item *Item)
查找监控项
func (*AgentConfig) FindSystemApps ¶
func (this *AgentConfig) FindSystemApps() []*AppConfig
取得系统App列表
func (*AgentConfig) FindTask ¶
func (this *AgentConfig) FindTask(taskId string) (appConfig *AppConfig, taskConfig *TaskConfig)
查找任务
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"`         // 名称
	IsSystem bool          `yaml:"isSystem" json:"isSystem"` // 是否为系统定义
}
    App定义
func (*AppConfig) FindBootingTasks ¶
func (this *AppConfig) FindBootingTasks() []*TaskConfig
Boot Tasks
func (*AppConfig) FindManualTasks ¶
func (this *AppConfig) FindManualTasks() []*TaskConfig
Manual Tasks
func (*AppConfig) FindSchedulingTasks ¶
func (this *AppConfig) FindSchedulingTasks() []*TaskConfig
Schedule Tasks
type Board ¶
type Board struct {
	Filename string        `yaml:"filename" json:"filename"`
	Charts   []*BoardChart `yaml:"charts" json:"charts"`
}
    看板
type BoardChart ¶
type BoardChart struct {
	AppId   string `yaml:"appId" json:"appId"`
	ItemId  string `yaml:"itemId" json:"itemId"`
	ChartId string `yaml:"chartId" json:"chartId"`
}
    看板图表定义
type FileSource ¶
type FileSource struct {
	Path       string           `yaml:"path" json:"path"`
	DataFormat SourceDataFormat `yaml:"dataFormat" json:"dataFormat"` // 数据格式
}
    数据文件
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 (*Group) AddNoticeReceiver ¶
func (this *Group) AddNoticeReceiver(level notices.NoticeLevel, receiver *notices.NoticeReceiver)
添加通知接收者
func (*Group) RemoveNoticeReceiver ¶
func (this *Group) RemoveNoticeReceiver(level notices.NoticeLevel, receiverId string)
删除通知接收者
type GroupConfig ¶
type GroupConfig struct {
	Filename string   `yaml:"filename" json:"filename"`
	Groups   []*Group `yaml:"groups" json:"groups"`
}
    分组配置
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"`               // 图表
	// contains filtered or unexported fields
}
    数据指标项
func (*Item) TestValue ¶
func (this *Item) TestValue(value interface{}) (level notices.NoticeLevel, message string)
检查某个值对应的通知级别
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 (*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)
添加年设置
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时间范围
type ScheduleRangeList ¶
type ScheduleRangeList struct {
	Every  bool
	Ranges []*ScheduleRangeConfig
}
    定时列表
func (*ScheduleRangeList) Convert ¶
func (this *ScheduleRangeList) Convert(ranges []*ScheduleRangeConfig)
转换
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.EnvVariable `yaml:"env" json:"env"`               // 环境变量设置
	Cwd        string                `yaml:"cwd" json:"cwd"`
}
    Script文件数据源
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) Validate ¶
func (this *ScriptAction) Validate() error
type ScriptSource ¶
type ScriptSource 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.EnvVariable `yaml:"env" json:"env"`               // 环境变量设置
	Cwd        string                `yaml:"cwd" json:"cwd"`
	DataFormat SourceDataFormat      `yaml:"dataFormat" json:"dataFormat"` // 数据格式
}
    Script文件数据源
func (*ScriptSource) DataFormatCode ¶
func (this *ScriptSource) DataFormatCode() SourceDataFormat
数据格式
func (*ScriptSource) Execute ¶
func (this *ScriptSource) Execute(params map[string]string) (value interface{}, err error)
执行
func (*ScriptSource) Generate ¶
func (this *ScriptSource) Generate(id string) (path string, err error)
保存到本地
type SourceInterface ¶
type SourceInterface interface {
	// 名称
	Name() string
	// 代号
	Code() string
	// 描述
	Description() string
	// 校验
	Validate() error
	// 执行
	Execute(params map[string]string) (value interface{}, err error)
	// 获得数据格式
	DataFormatCode() SourceDataFormat
	// 获取简要信息
	Summary() maps.Map
}
    数据源接口定义
func FindDataSourceInstance ¶
func FindDataSourceInstance(code string, options map[string]interface{}) SourceInterface
查找单个数据源实例
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.EnvVariable `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 (*TaskConfig) GenerateAgain ¶
func (this *TaskConfig) GenerateAgain() (path string, err error)
重新生成
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"`             // 动作配置
	// contains filtered or unexported fields
}
    阈值定义
func (*Threshold) Eval ¶
func (this *Threshold) Eval(value interface{}) string
执行数值运算,使用Javascript语法
func (*Threshold) RunActions ¶
执行动作
type Value ¶
type Value struct {
	Id          primitive.ObjectID  `bson:"_id" json:"id"`                  // 数据库存储的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"`     // 时间戳
	Value       interface{}         `bson:"value" json:"value"`             // 值,可以是个标量,或者一个组合的值
	Error       string              `bson:"error" json:"error"`             // 错误信息
	NoticeLevel notices.NoticeLevel `bson:"noticeLevel" json:"noticeLevel"` // 通知级别
	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"`
}
    应用指标值定义
type WebHookSource ¶
type WebHookSource struct {
	URL        string           `yaml:"url" json:"url"`
	Timeout    string           `yaml:"timeout" json:"timeout"`
	Method     string           `yaml:"method" json:"method"`         // 请求方法
	DataFormat SourceDataFormat `yaml:"dataFormat" json:"dataFormat"` // 数据格式
	// contains filtered or unexported fields
}
    WebHook
func (*WebHookSource) DataFormatCode ¶
func (this *WebHookSource) DataFormatCode() SourceDataFormat
数据格式
      
      Source Files
      ¶
    
   Click to show internal directories. 
   Click to hide internal directories.