Documentation ¶
Index ¶
- Constants
- func NewBaseConfigEngine(ctx context.Context) define.ConfigEngine
- func NewGlobalHeartBeatEvent(bt *MonitorBeater) define.Event
- type BaseConfigEngine
- func (ce *BaseConfigEngine) CleanTaskConfigList() error
- func (ce *BaseConfigEngine) FillConfig(taskMetaConfig define.TaskMetaConfig, ucfgConfig *ucfg.Config, absPath string) (*configs.ChildTaskMetaConfig, error)
- func (ce *BaseConfigEngine) GetBasicMetaConfig(ucfgConfig *ucfg.Config) (define.TaskMetaConfig, error)
- func (ce *BaseConfigEngine) GetChildTask(file os.DirEntry, basePath string) (*configs.ChildTaskMetaConfig, error)
- func (ce *BaseConfigEngine) GetChildTasks() error
- func (ce *BaseConfigEngine) GetGlobalConfig() define.Config
- func (ce *BaseConfigEngine) GetTaskConfigList() []define.TaskConfig
- func (ce *BaseConfigEngine) GetTaskNum() int
- func (ce *BaseConfigEngine) GetTasksFromDir(dirPath string) error
- func (ce *BaseConfigEngine) GetWrongTaskNum() int
- func (ce *BaseConfigEngine) HasChildPath() bool
- func (ce *BaseConfigEngine) Init(cfg *common.Config, bt define.Beater) error
- func (ce *BaseConfigEngine) ParseToUcfg(buf []byte) (*ucfg.Config, error)
- func (ce *BaseConfigEngine) ReInit(cfg *common.Config) error
- func (ce *BaseConfigEngine) RefreshHeartBeat() error
- func (ce *BaseConfigEngine) SendHeartBeat() error
- type BeatEvent
- type ChildTaskHeartbeatEvent
- type Event
- type GlobalHeartBeatEvent
- type HeartBeatEvent
- type MonitorBeater
- func (bt *MonitorBeater) GetConfig() define.Config
- func (bt *MonitorBeater) GetEventChan() chan define.Event
- func (bt *MonitorBeater) GetKeywordScheduler() define.Scheduler
- func (bt *MonitorBeater) GetListenScheduler() define.Scheduler
- func (bt *MonitorBeater) GetScheduler() define.Scheduler
- func (bt *MonitorBeater) GetTasks() []define.Task
- func (s MonitorBeater) IncrErrorCount() int32
- func (s MonitorBeater) IncrFailCount() int32
- func (s MonitorBeater) IncrSuccessCount() int32
- func (bt *MonitorBeater) IsMonitorBeat() bool
- func (bt *MonitorBeater) ParseConfig(cfg *common.Config) error
- func (bt *MonitorBeater) PostRun() error
- func (bt *MonitorBeater) PreRun() error
- func (bt *MonitorBeater) PublishEvent(event define.Event)
- func (bt *MonitorBeater) PublishHeartBeat(now time.Time)
- func (bt *MonitorBeater) Reload(cfg *common.Config)
- func (bt *MonitorBeater) Run() error
- func (bt *MonitorBeater) Stop()
Constants ¶
const (
CMDBLevelKey = "bk_cmdb_level"
)
Variables ¶
This section is empty.
Functions ¶
func NewBaseConfigEngine ¶
func NewBaseConfigEngine(ctx context.Context) define.ConfigEngine
NewBaseConfigEngine 获取configEngine
func NewGlobalHeartBeatEvent ¶
func NewGlobalHeartBeatEvent(bt *MonitorBeater) define.Event
Types ¶
type BaseConfigEngine ¶
type BaseConfigEngine struct {
// contains filtered or unexported fields
}
BaseConfigEngine 配置引擎,负责配置管理及心跳上报
func (*BaseConfigEngine) CleanTaskConfigList ¶
func (ce *BaseConfigEngine) CleanTaskConfigList() error
CleanTaskConfigList 校验任务,将校验通过的任务存入tasks中,不通过的存入wrongTasks
func (*BaseConfigEngine) FillConfig ¶
func (ce *BaseConfigEngine) FillConfig(taskMetaConfig define.TaskMetaConfig, ucfgConfig *ucfg.Config, absPath string) (*configs.ChildTaskMetaConfig, error)
FillConfig 将yaml文件中的参数填充到空的metaconfig中
func (*BaseConfigEngine) GetBasicMetaConfig ¶
func (ce *BaseConfigEngine) GetBasicMetaConfig(ucfgConfig *ucfg.Config) (define.TaskMetaConfig, error)
GetBasicMetaConfig 根据配置信息获取到基础的MetaConfig,作为后面对yaml文件反序列化的载体
func (*BaseConfigEngine) GetChildTask ¶
func (ce *BaseConfigEngine) GetChildTask(file os.DirEntry, basePath string) (*configs.ChildTaskMetaConfig, error)
GetChildTask 通过文件信息获取子任务
func (*BaseConfigEngine) GetChildTasks ¶
func (ce *BaseConfigEngine) GetChildTasks() error
GetChildTasks 获取全部子任务的方案
func (*BaseConfigEngine) GetGlobalConfig ¶
func (ce *BaseConfigEngine) GetGlobalConfig() define.Config
GetGlobalConfig 获取全局配置信息
func (*BaseConfigEngine) GetTaskConfigList ¶
func (ce *BaseConfigEngine) GetTaskConfigList() []define.TaskConfig
GetTaskConfigList 获取可执行任务集合
func (*BaseConfigEngine) GetTaskNum ¶
func (ce *BaseConfigEngine) GetTaskNum() int
GetTaskNum 获取配置正确的任务数
func (*BaseConfigEngine) GetTasksFromDir ¶
func (ce *BaseConfigEngine) GetTasksFromDir(dirPath string) error
GetTasksFromDir 从文件夹中提取任务,使用递归逻辑处理多层文件夹
func (*BaseConfigEngine) GetWrongTaskNum ¶
func (ce *BaseConfigEngine) GetWrongTaskNum() int
GetWrongTaskNum 获取配置出错的任务数
func (*BaseConfigEngine) HasChildPath ¶
func (ce *BaseConfigEngine) HasChildPath() bool
HasChildPath 判断是否有子任务路径
func (*BaseConfigEngine) ParseToUcfg ¶
func (ce *BaseConfigEngine) ParseToUcfg(buf []byte) (*ucfg.Config, error)
ParseToUcfg 通过输入的字符串解析出一个ucfg.Config对象,用来进一步转换出指定的TaskConfig
func (*BaseConfigEngine) ReInit ¶
func (ce *BaseConfigEngine) ReInit(cfg *common.Config) error
ReInit 重载配置
func (*BaseConfigEngine) RefreshHeartBeat ¶
func (ce *BaseConfigEngine) RefreshHeartBeat() error
RefreshHeartBeat 更新心跳数据,包括一个全局心跳数据和一列任务心跳数据 目前只更新全局心跳数据
func (*BaseConfigEngine) SendHeartBeat ¶
func (ce *BaseConfigEngine) SendHeartBeat() error
SendHeartBeat 发送心跳数据,包括一个全局心跳数据和一列任务心跳数据 目前只发送全局心跳数据
type BeatEvent ¶
type BeatEvent struct { *Event // contains filtered or unexported fields }
BeatEvent :
func NewBeatEvent ¶
func NewBeatEvent(bt *MonitorBeater, event define.Event) *BeatEvent
NewBeatEvent :
type ChildTaskHeartbeatEvent ¶
type ChildTaskHeartbeatEvent struct { DataID int32 Version string Name string TaskID int32 ConfigErrorCode int Path string }
ChildTaskHeartbeatEvent :
func (*ChildTaskHeartbeatEvent) AsMapStr ¶
func (c *ChildTaskHeartbeatEvent) AsMapStr() common.MapStr
AsMapStr :
func (ChildTaskHeartbeatEvent) GetType ¶
func (c ChildTaskHeartbeatEvent) GetType() string
GetType :
func (*ChildTaskHeartbeatEvent) IgnoreCMDBLevel ¶
func (c *ChildTaskHeartbeatEvent) IgnoreCMDBLevel() bool
IgnoreCMDBLevel :
type GlobalHeartBeatEvent ¶
type GlobalHeartBeatEvent struct { DataID int32 Status int Uptime int Version string Tasks int32 ConfigLoadAt int64 Published int32 Errors int32 ConfigErrorCode int ErrorTasks int }
GlobalHeartBeatEvent 全局心跳
func (*GlobalHeartBeatEvent) AsMapStr ¶
func (g *GlobalHeartBeatEvent) AsMapStr() common.MapStr
AsMapStr :
func (*GlobalHeartBeatEvent) GetType ¶
func (g *GlobalHeartBeatEvent) GetType() string
func (*GlobalHeartBeatEvent) IgnoreCMDBLevel ¶
func (g *GlobalHeartBeatEvent) IgnoreCMDBLevel() bool
IgnoreCMDBLevel :
type HeartBeatEvent ¶
type HeartBeatEvent struct { *Event BizID int32 DataID int32 Status int32 Time time.Time IP string Version string Uptime time.Duration Reload int32 ReloadTime time.Time LoadedTasks int32 RunningTasks int32 Success int32 Fail int32 Error int32 }
HeartBeatEvent :
func NewHeartBeatEvent ¶
func NewHeartBeatEvent(bt *MonitorBeater) *HeartBeatEvent
NewHeartBeatEvent :
type MonitorBeater ¶
type MonitorBeater struct { EventChan chan define.Event HookPreRun utils.HookManager HookPostRun utils.HookManager HookPreReload utils.HookManager HookPostReload utils.HookManager // contains filtered or unexported fields }
MonitorBeater 采集器主程序对象
func New ¶
func New(cfg *common.Config, name, version string) (*MonitorBeater, error)
New : new a beater
func (*MonitorBeater) GetEventChan ¶
func (bt *MonitorBeater) GetEventChan() chan define.Event
GetEventChan :
func (*MonitorBeater) GetKeywordScheduler ¶
func (bt *MonitorBeater) GetKeywordScheduler() define.Scheduler
GetKeywordScheduler :
func (*MonitorBeater) GetListenScheduler ¶
func (bt *MonitorBeater) GetListenScheduler() define.Scheduler
GetListenScheduler :
func (*MonitorBeater) GetScheduler ¶
func (bt *MonitorBeater) GetScheduler() define.Scheduler
GetScheduler :
func (MonitorBeater) IncrErrorCount ¶
func (s MonitorBeater) IncrErrorCount() int32
IncrErrorCount 出错计数
func (MonitorBeater) IncrFailCount ¶
func (s MonitorBeater) IncrFailCount() int32
IncrFailCount 失败计数
func (MonitorBeater) IncrSuccessCount ¶
func (s MonitorBeater) IncrSuccessCount() int32
IncrSuccessCount 成功计数
func (*MonitorBeater) IsMonitorBeat ¶
func (bt *MonitorBeater) IsMonitorBeat() bool
func (*MonitorBeater) ParseConfig ¶
func (bt *MonitorBeater) ParseConfig(cfg *common.Config) error
ParseConfig 读取配置
func (*MonitorBeater) PublishEvent ¶
func (bt *MonitorBeater) PublishEvent(event define.Event)
PublishEvent : publish event
func (*MonitorBeater) PublishHeartBeat ¶
func (bt *MonitorBeater) PublishHeartBeat(now time.Time)
PublishHeartBeat : publish heartbeat event
func (*MonitorBeater) Reload ¶
func (bt *MonitorBeater) Reload(cfg *common.Config)
Reload : reload conf