Documentation ¶
Index ¶
- Constants
- Variables
- func ParseTags(name string) map[string]string
- type Action
- type ActionResult
- type AgentPostMetricRequest
- type AlarmMessage
- type AlarmResults
- type AlarmTask
- type AlarmTasks
- type Chart
- type ChartElement
- type Client
- type Counter
- type ErrorResp
- type GetPluginResp
- type Group
- type HeartBeat
- type Host
- type InnerError
- type Interface
- type MessageType
- type MetricConfig
- type Node
- type Options
- type Panel
- type Plugin
- type Product
- type Query
- type QueryParams
- type Result
- type Script
- type SnmpConfig
- type Strategy
- type StrategyEvent
- type StrategyResult
- type Switch
- func (this *Switch) BuildInterfaceIndex() error
- func (this *Switch) CollectIfaceSpeed() error
- func (this *Switch) CollectInterfaceName() error
- func (this *Switch) CollectPerformanceData(oid string)
- func (this *Switch) CollectTraffic()
- func (this *Switch) Do(buf1 chan<- *TimeSeriesData, buf2 chan<- *MetricConfig)
- func (this *Switch) IsLegalPrefix(name string) bool
- type SyncPluginRequest
- type SyncPluginResponse
- type TimeSeriesData
- func (tsd *TimeSeriesData) AddTags(tags map[string]string)
- func (tsd *TimeSeriesData) Decode(data []byte) error
- func (tsd *TimeSeriesData) Encode() []byte
- func (tsd *TimeSeriesData) GetMetric() string
- func (tsd *TimeSeriesData) PK() string
- func (tsd *TimeSeriesData) RemoveTag(tagk string)
- func (tsd TimeSeriesData) String() string
- func (tsd *TimeSeriesData) Tags2String() string
- func (m *TimeSeriesData) Validate() bool
- type TimeSeriesDataStore
- type TimeSeriesDataV4
- type Trigger
- type TriggerEvent
- type TriggerResult
- type TriggerResultSet
- type User
- type UserGroup
Constants ¶
View Source
const ( ACTION_ALARM = iota ACTION_RESTORE )
View Source
const ( ACTION_NOTIFY = iota + 1 ACTION_RUN )
View Source
const ( ALAR_MESS_INSPECTOR_HEARTBEAT tcp.PacketType = iota + 1 ALAR_MESS_INSPECTOR_TASK_REQUEST ALAR_MESS_INSPECTOR_TASKS ALAR_MESS_INSPECTOR_RESULT )
报警服务消息类型定义
View Source
const ( EVENT_NEW = iota + 1 EVENT_AWARE EVENT_CLOSED EVENT_NODATA EVENT_UNKNOW )
View Source
const ( // Agent MsgAgentRegister tcp.PacketType = iota MsgAgentSendMetricInfo MsgAgentSendTimeSeriesData MsgAgentGetPluginsList MsgAgentRequestSyncPlugins MsgAgentSendHeartbeat // CFC MsgCFCSendPluginsList MsgCFCSendPlugin MsgCFCSendReconnect // Repeater MsgRepeaterPostTimeSeriesData )
View Source
const ( PRIORITY_HIGH_LEVEL = iota + 1 PRIORITY_MIDDLE_LEVEL PRIORITY_LOW_LEVEL )
View Source
const ( H3C_CPU_OID = ".1.3.6.1.4.1.25506.2.6.1.1.1.1.6" H3C_MEM_OID = ".1.3.6.1.4.1.25506.2.6.1.1.1.1.8" CISCO_CPU_OID = ".1.3.6.1.4.1.9.9.109.1.1.1.1.7" CISCO_MEM_OID = ".1.3.6.1.4.1.9.9.109.1.1.1.1.12" HUAWEI_MEM_OID = ".1.3.6.1.4.1.2011.5.25.31.1.1.1.1.7" HUAWEI_CPU_OID = ".1.3.6.1.4.1.2011.5.25.31.1.1.1.1.5" )
View Source
const ( USER = iota ADMIN )
Variables ¶
View Source
var ( ErrPluginPathIsBlank = errors.New("plugin path is blank") ErrPluginIntervalIsZero = errors.New("plugin interval is zore") )
View Source
var AlarmMessageTypeText map[tcp.PacketType]string = map[tcp.PacketType]string{ ALAR_MESS_INSPECTOR_HEARTBEAT: "inspector heartbeat", ALAR_MESS_INSPECTOR_TASK_REQUEST: "inspector task request", ALAR_MESS_INSPECTOR_TASKS: "inspector tasks", ALAR_MESS_INSPECTOR_RESULT: "inspector result", }
报警服务消息类型可读映射
View Source
var DEFAULT_TIME, _ = time.Parse(time.RFC3339, "1980-01-01T00:00:00+00:00")
View Source
var MsgTextMap map[tcp.PacketType]string = map[tcp.PacketType]string{ MsgAgentRegister: "MsgAgentRegister", MsgAgentSendMetricInfo: "MsgAgentSendMetricInfo", MsgAgentSendTimeSeriesData: "MsgAgentSendTimeSeriesData", MsgAgentGetPluginsList: "MsgAgentGetPluginList", MsgAgentRequestSyncPlugins: "MsgAgentRequestSyncPlugins", MsgAgentSendHeartbeat: "MsgAgentSendHeartbeat", MsgCFCSendPluginsList: "MsgCFCSendPluginsList", MsgCFCSendPlugin: "MsgCFCSendPlugin", MsgCFCSendReconnect: "MsgCFCSendReconnect", MsgRepeaterPostTimeSeriesData: "MsgRepeaterPostTimeSeriesData", }
Functions ¶
Types ¶
type Action ¶
type Action struct { ID int `json:"-"` StrategyID int `json:"strategy_id" db:"strategy_id"` Type int `json:"type"` Kind int `json:"kind"` ScriptID int `json:"script_id" db:"script_id"` FilePath string `json:"file_path" db:"file_path"` AlarmSubject string `json:"alarm_subject" db:"alarm_subject"` AlarmTemplate string `json:"alarm_template" db:"alarm_template"` RestoreSubject string `json:"restore_subject" db:"restore_subject"` RestoreTemplate string `json:"restore_template" db:"restore_template"` BeginTime string `json:"begin_time" db:"begin_time"` EndTime string `json:"end_time" db:"end_time"` TimePeriod int `json:"time_period" db:"time_period"` }
type ActionResult ¶
type ActionResult struct { StrategyEventID int64 `json:"strategy_event_id"` Count int `json:"count"` ActionID int `json:"action_id"` ActionType int `json:"action_type"` ActionKind int `json:"action_kind"` ScriptID int `json:"script_id"` UserID int `json:"user_id"` Username string `json:"username"` Phone string `json:"phone"` Mail string `json:"mail"` Weixin string `json:"weixin"` Subject string `json:"subject"` Content string `json:"content"` Success bool `json:"success"` Response string `json:"response"` FilePath string `json:"file_path"` }
func NewActionResult ¶
func NewActionResult( strategy_event_id int64, count, action_id, action_type, action_kind, script_id, user_id int, user_name, phone, mail, weixin, subject, content, response string, success bool) *ActionResult
type AgentPostMetricRequest ¶
type AgentPostMetricRequest struct { HostID string `json:"host_id"` Metrics []TimeSeriesData `json:"metrics"` // cpu.idle/ip=10.10.32.10,cpu=1 }
func (*AgentPostMetricRequest) Encode ¶
func (this *AgentPostMetricRequest) Encode() []byte
type AlarmResults ¶
type AlarmResults struct {
Results []*StrategyResult
}
type AlarmTask ¶
type AlarmTasks ¶
type AlarmTasks struct {
Tasks []*AlarmTask
}
func (*AlarmTasks) Decode ¶
func (this *AlarmTasks) Decode(data []byte) error
func (*AlarmTasks) Encode ¶
func (this *AlarmTasks) Encode() []byte
type Chart ¶
type Chart struct { ID int `json:"id"` Name string `json:"name"` UserID int `json:"-"` Size int `json:"size"` ReferCount int `json:"refer_count"` Thumbnail string `json:"thumbnail"` CreateAt time.Time `json:"create_at"` UpdateAt time.Time `json:"update_at"` Elements []*ChartElement `json:"elements"` }
type ChartElement ¶
type ChartElement struct { ID int `json:"id"` ChartID int `json:"-"` Name string `json:"name"` Metric string `json:"metric"` Tags string `json:"tags"` }
func (ChartElement) TableName ¶
func (ChartElement) TableName() string
type ErrorResp ¶
type ErrorResp struct {
Error InnerError `json:"error"`
}
type GetPluginResp ¶
type GetPluginResp struct { HostID string `json:"host_id"` // 当agent通过proxy连接,需要通过hostid来查找映射表 Plugins []Plugin `json:"plugins"` }
func (*GetPluginResp) Decode ¶
func (this *GetPluginResp) Decode(data []byte) error
func (*GetPluginResp) Encode ¶
func (this *GetPluginResp) Encode() []byte
type HeartBeat ¶
func NewHeartBeat ¶
type Host ¶
type Host struct { ID string `json:"id"` IP string `json:"ip"` Hostname string `json:"hostname"` AgentVersion string `json:"agent_version" db:"agent_version"` Status string `json:"status"` CreateAt time.Time `json:"create_at" db:"create_at"` UpdateAt time.Time `json:"update_at" db:"update_at"` Uptime float64 `json:"uptime" db:"uptime"` IdlePct float64 `json:"idle_pct" db:"idle_pct"` MuteTime time.Time `json:"-" db:"mute_time"` }
type InnerError ¶
type Interface ¶
type Interface struct { Index string `json:"index"` Name string `json:"name"` OperStatus uint64 `json:"oper_starus"` InBytes Counter `json:"in_bytes"` OutBytes Counter `json:"out_bytes"` InDiscards Counter `json:"in_discards"` OutDiscards Counter `json:"out_discards"` InErrors Counter `json:"in_errors"` OutErrors Counter `json:"out_errors"` Speed uint64 `json:"speed"` }
type MessageType ¶
type MessageType byte
const ( MESS_POST_HOST_CONFIG MessageType = iota MESS_POST_METRIC MESS_POST_TSD MESS_GET_HOST_PLUGIN_LIST MESS_GET_HOST_PLUGIN_LIST_RESP MESS_GET_ALL_PLUGIN_MD5 MESS_GET_ALL_PLUGIN_MD5_RESP MESS_PULL_PLUGIN MESS_POST_HOST_ALIVE )
消息类型定义
type MetricConfig ¶
type MetricConfig struct { HostID string `json:"host_id"` SeriesData TimeSeriesData `json:"time_series_data"` }
func (*MetricConfig) Decode ¶
func (tsd *MetricConfig) Decode(data []byte) error
func (*MetricConfig) Encode ¶
func (tsd *MetricConfig) Encode() []byte
type Node ¶
type Node struct { IP string `json:"ip"` Hostname string `json:"hostname"` Update time.Time `json:"update"` }
func (Node) MarshalJSON ¶
type Panel ¶
type Plugin ¶
type Plugin struct { // plugin 在数据库中的id号 ID int `json:"id"` // plugin 名称 Name string `json:"name"` // plugin 在磁盘上的路径 Path string `json:"path"` // 校验和,用于插件同步比对 Checksum string `json:"checksum"` // 执行参数 Args string `json:"args"` // 执行间隔 Interval int `json:"interval"` // 执行超时时间 Timeout int `json:"timeout"` }
type QueryParams ¶
type QueryParams struct { Start interface{} `json:"start"` End interface{} `json:"end,omitempty"` Queries []Query `json:"queries,omitempty"` NoAnnotations bool `json:"no_annotations,omitempty"` GlobalAnnotations bool `json:"global_annotations,omitempty"` MsResolution bool `json:"ms,omitempty"` ShowTSUIDs bool `json:"show_tsuids,omitempty"` ShowSummary bool `json:"show_summary,omitempty"` ShowQuery bool `json:"show_query,omitempty"` Delete bool `json:"delete,omitempty"` }
func NewQueryParams ¶
func NewQueryParams(start, end string, rawTags string, aggregator string, metric string) *QueryParams
type SnmpConfig ¶
type Strategy ¶
type Strategy struct { ID int `json:"id"` ProductID int `json:"product_id" db:"product_id"` Name string `json:"name"` Priority int `json:"priority"` AlarmCount int `json:"alarm_count" db:"alarm_count"` Cycle int `json:"cycle" ` Expression string `json:"expression"` Description string `json:"description"` UserID int `json:"user_id" db:"user_id"` Enable bool `json:"enable"` }
type StrategyEvent ¶
type StrategyEvent struct { ID int64 `json:"id" db:"id"` ProductID int `json:"product_id" db:"product_id"` StrategyID int `json:"strategy_id" db:"strategy_id"` StrategyName string `json:"strategy_name" db:"strategy_name"` Priority int `json:"priority"` Cycle int `json:"cycle"` AlarmCount int `json:"alarm_count" db:"alarm_count"` Expression string `json:"expression"` CreateTime time.Time `json:"create_time" db:"create_time"` UpdateTime time.Time `json:"update_time" db:"update_time"` AwareEndTime time.Time `json:"aware_end_time" db:"aware_end_time"` Count int `json:"count"` Status int `json:"status"` HostID string `json:"host_id" db:"host_id"` HostName string `json:"host_name" db:"host_name"` IP string `json:"ip"` ErrorMessage string `json:"error_message"` }
type StrategyResult ¶
type StrategyResult struct { TaskID string `json:"taskid"` Priority int `json:"priority"` TriggerResultSets map[string]*TriggerResultSet `json:"trigger_resultset"` ErrorMessage string `json:"error_message"` Triggered bool `json:"triggered"` CreateTime time.Time `json:"create_time"` }
func NewStrategyResult ¶
func NewStrategyResult(task_id string, priority int, trigger_results map[string]*TriggerResultSet, error_message string, triggered bool, create_time time.Time) *StrategyResult
func (*StrategyResult) Decode ¶
func (this *StrategyResult) Decode(data []byte) error
func (*StrategyResult) Encode ¶
func (this *StrategyResult) Encode() []byte
type Switch ¶
type Switch struct { ID string `json:"id"` IP string `json:"ip"` Hostname string `json:"hostname"` Vendor string `json:"vendor"` AgentVersion string `json:"agent_version"` CollectInterval int `json:"collect_interval"` LegalPrefix []string `json:"legal_prefix"` //采集数据成功更新 LastUpdate time.Time `json:"last_update"` Snmp SnmpConfig `json:"snmp"` Interfaces map[string]*Interface `json:"interfaces"` Cpu map[string]uint64 Mem map[string]uint64 }
func (*Switch) BuildInterfaceIndex ¶
func (*Switch) CollectIfaceSpeed ¶
func (*Switch) CollectInterfaceName ¶
func (*Switch) CollectPerformanceData ¶
func (*Switch) CollectTraffic ¶
func (this *Switch) CollectTraffic()
func (*Switch) Do ¶
func (this *Switch) Do(buf1 chan<- *TimeSeriesData, buf2 chan<- *MetricConfig)
func (*Switch) IsLegalPrefix ¶
type SyncPluginRequest ¶
func (*SyncPluginRequest) Decode ¶
func (spr *SyncPluginRequest) Decode(data []byte) error
func (*SyncPluginRequest) Encode ¶
func (spr *SyncPluginRequest) Encode() []byte
type SyncPluginResponse ¶
func (*SyncPluginResponse) Decode ¶
func (sp *SyncPluginResponse) Decode(data []byte) error
func (*SyncPluginResponse) Encode ¶
func (sp *SyncPluginResponse) Encode() []byte
type TimeSeriesData ¶
type TimeSeriesData struct { Metric string `json:"metric"` //sys.cpu.idle DataType string `json:"data_type"` //COUNTER,GAUGE,DERIVE Value float64 `json:"value"` //99.00 Timestamp int64 `json:"timestamp"` //unix timestamp Cycle int `json:"cycle,omitempty"` Tags map[string]string `json:"tags"` //{"product":"app01", "group":"dev02"} }
func (*TimeSeriesData) AddTags ¶
func (tsd *TimeSeriesData) AddTags(tags map[string]string)
func (*TimeSeriesData) Decode ¶
func (tsd *TimeSeriesData) Decode(data []byte) error
func (*TimeSeriesData) Encode ¶
func (tsd *TimeSeriesData) Encode() []byte
func (*TimeSeriesData) GetMetric ¶
func (tsd *TimeSeriesData) GetMetric() string
func (*TimeSeriesData) PK ¶
func (tsd *TimeSeriesData) PK() string
func (*TimeSeriesData) RemoveTag ¶
func (tsd *TimeSeriesData) RemoveTag(tagk string)
func (TimeSeriesData) String ¶
func (tsd TimeSeriesData) String() string
func (*TimeSeriesData) Tags2String ¶
func (tsd *TimeSeriesData) Tags2String() string
func (*TimeSeriesData) Validate ¶
func (m *TimeSeriesData) Validate() bool
type TimeSeriesDataStore ¶
type TimeSeriesDataStore struct {
// contains filtered or unexported fields
}
func NewTimeSeriesDataStore ¶
func NewTimeSeriesDataStore() *TimeSeriesDataStore
func (*TimeSeriesDataStore) Add ¶
func (ts *TimeSeriesDataStore) Add(t TimeSeriesData)
func (*TimeSeriesDataStore) Get ¶
func (ts *TimeSeriesDataStore) Get(pk string) (tsd TimeSeriesData, exist bool)
func (*TimeSeriesDataStore) GetAll ¶
func (ts *TimeSeriesDataStore) GetAll() []TimeSeriesData
func (*TimeSeriesDataStore) Remove ¶
func (ts *TimeSeriesDataStore) Remove(pk string)
type TimeSeriesDataV4 ¶
type TimeSeriesDataV4 struct { PerformanceIndex map[string]float64 `json:"performance_index"` Host string `json:"host"` AppName string `json:"app_name"` Domain string `json:"domain"` }
func (*TimeSeriesDataV4) ToV5 ¶
func (tsdv4 *TimeSeriesDataV4) ToV5() []*TimeSeriesData
type Trigger ¶
type Trigger struct { ID int64 `form:"id" json:"-" ` StrategyID int `form:"strategy_id" json:"strategy_id"` Metric string `form:"metric" json:"metric"` Tags string `form:"tags" json:"tags"` Number int `form:"number" json:"number"` Index string `form:"index" json:"index"` Method string `form:"method" json:"method" ` Symbol string `form:"symbol" json:"symbol" ` Threshold float64 `form:"threshold" json:"threshold" ` Description string `form:"description" json:"description"` }
type TriggerEvent ¶
type TriggerEvent struct { StrategyEventID int64 `json:"strategy_event_id" db:"strategy_event_id"` Index string `json:"index" db:"index"` Metric string `json:"metric" db:"metric"` Tags string `json:"tags"` Number int `json:"number"` AggregateTags string `json:"aggregate_tags" db:"aggregate_tags"` CurrentThreshold float64 `json:"current_threshold" db:"current_threshold"` Method string `json:"method"` Symbol string `json:"symbol"` Threshold float64 `json:"threshold"` Triggered bool `json:"triggered"` TriggerChanged bool `json:"-"` }
func NewTriggerEvent ¶
func (*TriggerEvent) String ¶
func (this *TriggerEvent) String() string
type TriggerResult ¶
type TriggerResult struct { Index string Tags string AggregateTags string CurrentThreshold float64 Triggered bool }
func NewTriggerResult ¶
type TriggerResultSet ¶
type TriggerResultSet struct { TriggerResults []*TriggerResult Triggered bool }
Click to show internal directories.
Click to hide internal directories.