Documentation ¶
Index ¶
- Constants
- Variables
- func GetErrorCodeByError(err error) int
- func RecordLog(template string, kvs []LogKV)
- func RecordLogf(template string, args ...interface{})
- func SetLogConfig(c LogConfig)
- type Beater
- type CPUStat
- type CompareFlag
- type CompositeConfig
- type CompositeParam
- type Config
- type ConfigEngine
- type Event
- type FdStat
- type IOStat
- type LogConfig
- type LogKV
- type MemStat
- type MetricsReaderFunc
- type NamedCode
- type ProcStat
- type Scheduler
- type Status
- type Tag
- type Tags
- type Task
- type TaskConfig
- type TaskMetaConfig
Constants ¶
View Source
const ( BeaterStatusUnknown = -2 BeaterStatusError = -1 BeaterStatusReady = 0 BeaterStatusRunning = 1 BeaterStatusTerminating = 2 BeaterStatusTerminated = 3 // GatherStatus GatherStatusUnknown = -1 GatherStatusOK = 0 GatherStatusError = 1 )
BeaterStatus
View Source
const ( NameGatherUp = "bkm_gather_up" LabelUpCode = "bkm_up_code" LabelUpCodeName = "bkm_up_code_name" NameMetricBeatUp = "bkm_metricbeat_endpoint_up" NameMetricBeatScrapeDuration = "bkm_metricbeat_scrape_duration_seconds" NameMetricBeatScrapeSize = "bkm_metricbeat_scrape_size_bytes" NameMetricBeatScrapeLine = "bkm_metricbeat_scrape_line" NameMetricBeatHandleDuration = "bkm_metricbeat_handle_duration_seconds" NameKubeEventReceiveEvents = "bkm_kubeevent_receive_events" NameKubeEventReportEvents = "bkm_kubeevent_report_events" )
View Source
const ( DefaultTimeout = 3 * time.Second // 默认任务超时 DefaultPeriod = 10 * time.Second // 默认任务执行间隔 DefaultTaskConcurrencyLimitPerInstance = 100000 // 默认任务单实例并发限制 DefaultTaskConcurrencyLimitPerTask = 1000 // 默认单个任务并发限制 )
View Source
const ( ModuleGlobalHeartBeat = "global_heartbeat" ModuleChildHeartBeat = "child_heartbeat" ModuleStatus = "status" ModuleStatic = "static" ModuleHTTP = "http" ModuleMetricbeat = "metricbeat" ModulePing = "ping" ModuleScript = "script" ModuleTCP = "tcp" ModuleUDP = "udp" ModuleKeyword = "keyword" ModuleTrap = "snmptrap" ModuleBasereport = "basereport" ModuleExceptionbeat = "exceptionbeat" ModuleKubeevent = "kubeevent" ModuleProcessbeat = "processbeat" ModuleProcConf = "procconf" ModuleProcCustom = "proccustom" ModuleProcSync = "procsync" ModuleProcStatus = "procstatus" ModuleProcBin = "procbin" ModuleLoginLog = "loginlog" ModuleProcSnapshot = "procsnapshot" ModuleSocketSnapshot = "socketsnapshot" ModuleShellHistory = "shellhistory" ModuleRpmPackage = "rpmpackage" )
所有模块的module名引用
View Source
const (
UTCTimeFormat = "2006-01-02 15:04:05"
)
Variables ¶
View Source
var ( CodeOK = newNamedCode(0, "Ok") CodeUnknown = newNamedCode(1, "Unknown") CodeCanceled = newNamedCode(2, "Canceled") CodeTimeout = newNamedCode(3, "Timeout") CodeWriteTempFileFailed = newNamedCode(1501, "WriteTempFileFailed") CodeConnTimeout = newNamedCode(1001, "ConnTimeout") CodeConnFailed = newNamedCode(1000, "ConnFailed") CodeConnRefused = newNamedCode(2501, "ConnRefused") CodeInvalidPromFormat = newNamedCode(2502, "InvalidPromFormat") CodeScriptRunFailed = newNamedCode(2301, "ScriptRunFailed") CodeScriptNoOutput = newNamedCode(2303, "ScriptNoOutput") CodeScriptTimeout = newNamedCode(2304, "ScriptRunTimeout") CodeRequestFailed = newNamedCode(1100, "RequestFailed") CodeRequestTimeout = newNamedCode(1101, "RequestTimeout") CodeResponseFailed = newNamedCode(1200, "ResponseFailed") CodeResponseNotMatch = newNamedCode(1202, "ResponseNotMatch") CodeIPNotFound = newNamedCode(1211, "IPNotFound") CodeInvalidURL = newNamedCode(1213, "InvalidURL") CodeDNSResolveFailed = newNamedCode(1004, "DNSResolveFailed") CodeInvalidIP = newNamedCode(2102, "InvalidIP") CodeBadRequestParams = newNamedCode(1103, "BadRequestParams") )
View Source
var ( ErrNotConfigured = errors.New("get not configured error") ErrTaskNotFound = errors.New("task not found") ErrType = errors.New("type error") ErrTypeConvert = errors.New("get error when try to convert type") ErrWrongTargetType = errors.New("wrong target type") // 目标类型不是ip也不是domain ErrNoChildPath = errors.New("bkmonitorbeat.include not configured") ErrGetChildTasks = errors.New("get child tasks error") ErrUnpackCfg = errors.New("unpack cfg error") ErrCleanGlobalFail = errors.New("clean global config failed") ErrGetTaskFailed = errors.New("get task item by filename failed") ErrNoName = errors.New("task name not found") ErrNoVersion = errors.New("task version not found") ErrorNoTask = errors.New("no task found") ErrNoScriptOutput = errors.New("script no output") )
View Source
var ErrCodeMap = map[error]int{
ErrNotConfigured: 100,
ErrTaskNotFound: 103,
ErrType: 106,
ErrNoChildPath: 111,
ErrGetChildTasks: 112,
ErrUnpackCfg: 113,
ErrCleanGlobalFail: 114,
ErrGetTaskFailed: 121,
ErrNoName: 122,
ErrNoVersion: 123,
ErrTypeConvert: 131,
ErrWrongTargetType: 138,
}
View Source
var GlobalPidStore = newPidStore()
GlobalPidStore 全局pid信息
View Source
var GlobalWatcher host.Watcher
Functions ¶
func RecordLogf ¶
func RecordLogf(template string, args ...interface{})
func SetLogConfig ¶
func SetLogConfig(c LogConfig)
Types ¶
type Beater ¶
type Beater interface { Run() error Stop() Reload(*common.Config) GetEventChan() chan Event GetConfig() Config GetScheduler() Scheduler }
Beater : Beater
type CompareFlag ¶
type CompareFlag int
CompareFlag 比较结果标志位
var ( Upper CompareFlag = 1 Lower CompareFlag = 2 Equal CompareFlag = 3 )
标志位枚举
type Config ¶
type Config interface { GetTaskConfigListByType(string) []TaskConfig GetGatherUpDataID() int32 Clean() error }
Config : task config
type ConfigEngine ¶
type ConfigEngine interface { Init(cfg *common.Config, bt Beater) error ReInit(cfg *common.Config) error GetTaskConfigList() []TaskConfig GetTaskNum() int GetWrongTaskNum() int CleanTaskConfigList() error RefreshHeartBeat() error SendHeartBeat() error GetGlobalConfig() Config HasChildPath() bool }
ConfigEngine 配置引擎的接口
type MetricsReaderFunc ¶
func (MetricsReaderFunc) MarshalJSON ¶
func (m MetricsReaderFunc) MarshalJSON() ([]byte, error)
type Scheduler ¶
type Scheduler interface { Add(Task) Start(context.Context) error IsDaemon() bool Count() int Stop() Wait() GetStatus() Status Reload(context.Context, Config, []Task) error }
Scheduler : scheduler to run task
type Status ¶
type Status int
Status :
type Tags ¶
type Tags []Tag
Tags 全部Tag集合,实现了sort.Interface接口,可排序
func (Tags) CompareString ¶
func (t Tags) CompareString(a, b string) CompareFlag
CompareString 比较两个字符串大小 1.大于 2.小于 3.等于
type Task ¶
type Task interface { GetTaskID() int32 GetStatus() Status SetConfig(TaskConfig) GetConfig() TaskConfig SetGlobalConfig(Config) GetGlobalConfig() Config Reload() Wait() Stop() Run(ctx context.Context, e chan<- Event) }
Task : task for scheduler
type TaskConfig ¶
type TaskConfig interface { GetBizID() int32 GetIdent() string InitIdent() error SetIdent(ident string) GetTimeout() time.Duration GetAvailableDuration() time.Duration GetDataID() int32 GetTaskID() int32 GetPeriod() time.Duration GetType() string GetLabels() []map[string]string Clean() error }
TaskConfig : task config
type TaskMetaConfig ¶
type TaskMetaConfig interface { GetTaskConfigList() []TaskConfig Clean() error }
TaskMetaConfig : task config
Click to show internal directories.
Click to hide internal directories.