Documentation
¶
Index ¶
- Constants
- Variables
- func AlarmPack(t AlarmMessageType, m AlarmMessage) []byte
- func Pack(t MessageType, m Message) []byte
- func ParseTags(name string) map[string]string
- type Action
- type ActionResult
- type ActionUser
- type ActionUserGroup
- type AlarmMessage
- type AlarmMessageType
- type AlarmTask
- type Chart
- type ChartElement
- type Client
- type Counter
- type ErrorResp
- type GetPluginResp
- type GetTasksResp
- type Group
- type HeartBeat
- type Host
- type InnerError
- type Interface
- type Message
- type MessageType
- type MetricConfig
- type Node
- type NodePool
- type Options
- type Panel
- type Plugin
- type PostMetric
- type Query
- type QueryParams
- type Result
- type SnmpConfig
- type Strategy
- type StrategyEvent
- type StrategyGroup
- type StrategyHost
- 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 Template
- type TemplateHost
- type TemplateStrategy
- type TimeSeriesData
- type Trigger
- type TriggerEvent
- type TriggerResult
- type TriggerResultSet
- type User
- type UserGroup
Constants ¶
View Source
const ( SEND_MAIL = iota + 1 SEND_SMS SEND_WECHAT SEND_CALL SEND_ACTION )
View Source
const ( ACTION_ALARM = iota + 1 ACTION_RESTORE )
View Source
const ( EVENT_NEW = iota + 1 EVENT_AWARE EVENT_CLOSED )
View Source
const ( PRIORITY_HIGH_LEVEL = iota + 1 PRIORITY_MIDDLE_LEVEL PRIORITY_LOW_LEVEL )
View Source
const ( USER = iota ADMIN )
Variables ¶
View Source
var AlarmMessageTypeText map[AlarmMessageType]string = map[AlarmMessageType]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 MessageTypeText map[MessageType]string = map[MessageType]string{ MESS_POST_HOST_CONFIG: "post host config", MESS_POST_METRIC: "post metric", MESS_POST_TSD: "post time series data", MESS_GET_HOST_PLUGIN_LIST: "get host plugin list", MESS_GET_HOST_PLUGIN_LIST_RESP: "get host plugin list response", MESS_GET_ALL_PLUGIN_MD5: "get all plugin md5 list", MESS_GET_ALL_PLUGIN_MD5_RESP: "get all plugin md5 list response", MESS_PULL_PLUGIN: "pull plugin file", MESS_POST_HOST_ALIVE: "post host alive", }
消息类型可读映射
View Source
var STRATEGY_PRIORITY_MAPPING = map[int]string{1: "严重", 2: "较严重", 3: "注意"}
View Source
var STRATEGY_STATUS_MAPPING = map[int]string{1: "活跃报警", 2: "已知悉报警", 3: "已关闭报警"}
Functions ¶
func AlarmPack ¶
func AlarmPack(t AlarmMessageType, m AlarmMessage) []byte
func Pack ¶
func Pack(t MessageType, m Message) []byte
Types ¶
type Action ¶
type Action struct {
ID int `json:"-"`
StrategyID int `form:"strategy_id" json:"strategy_id" binding:"required"`
Type int `form:"type" json:"type" binding:"required"`
FilePath string `form:"file_path" json:"file_path"`
AlarmSubject string `form:"alarm_subject" json:"alarm_subject"`
RestoreSubject string `form:"restore_subject" json:"restore_subject"`
AlarmTemplate string `form:"alarm_template" json:"alarm_template"`
RestoreTemplate string `form:"restore_template" json:"restore_template"`
SendType int `form:"send_type" json:"send_type" binding:"require"`
}
type ActionResult ¶
type ActionResult struct {
StrategyEventID int64 `json:"strategy_event_id"`
ActionID int `json:"action_id"`
ActionType int `json:"action_type"`
ActionSendType int `json:"action_send_type"`
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"`
}
type ActionUser ¶
func (ActionUser) TableName ¶
func (ActionUser) TableName() string
type ActionUserGroup ¶
type ActionUserGroup struct {
ID int `json:"-"`
ActionID int `json:"-"`
UserGroupID int `form:"user_group_id" json:"user_group_id"`
}
func (ActionUserGroup) TableName ¶
func (ActionUserGroup) TableName() string
type AlarmMessageType ¶
type AlarmMessageType byte
const ( ALAR_MESS_INSPECTOR_HEARTBEAT AlarmMessageType = iota + 1 ALAR_MESS_INSPECTOR_TASK_REQUEST ALAR_MESS_INSPECTOR_TASKS ALAR_MESS_INSPECTOR_RESULT )
报警服务消息类型定义
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 ¶
func (*GetPluginResp) Decode ¶
func (this *GetPluginResp) Decode(data []byte) error
func (*GetPluginResp) Encode ¶
func (this *GetPluginResp) Encode() []byte
type GetTasksResp ¶
type GetTasksResp struct {
AlarmTasks []*AlarmTask
}
func (*GetTasksResp) Decode ¶
func (this *GetTasksResp) Decode(data []byte) error
func (*GetTasksResp) Encode ¶
func (this *GetTasksResp) Encode() []byte
type HeartBeat ¶
func NewHeartBeat ¶
type Host ¶
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 (this *MetricConfig) Decode(data []byte) error
func (*MetricConfig) Encode ¶
func (this *MetricConfig) Encode() []byte
type NodePool ¶
func NewNodePool ¶
func NewNodePool() *NodePool
type Panel ¶
type Plugin ¶
type PostMetric ¶
type PostMetric struct {
HostID string `json:"host_id"`
Metrics []TimeSeriesData `json:"metrics"` // cpu.idle/ip=10.10.32.10,cpu=1
}
func (*PostMetric) Encode ¶
func (this *PostMetric) Encode() []byte
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"`
Name string `form:"name" json:"name" binding:"required"`
Priority int `form:"priority" json:"priority" binding:"required"`
Pid int `form:"pid" json:"pid"`
AlarmCount int `form:"alarm_count" json:"alarm_count" binding:"required"`
Cycle int `form:"cycle" json:"cycle" binding:"required"`
Expression string `form:"expression" json:"expression" binding:"required"`
Description string `form:"description" json:"description"`
UserID int `json:"user_id"`
Enable bool `json:"enable"`
}
type StrategyEvent ¶
type StrategyEvent struct {
ID int64 `json:"id"`
StrategyID int `json:"strategy_id"`
StrategyName string `json:"strategy_name"`
Priority int `json:"priority"`
Cycle int `json:"cycle"`
AlarmCount int `json:"alarm_count"`
Expression string `json:"expression"`
CreateTime time.Time `json:"create_time"`
UpdateTime time.Time `json:"update_time"`
Count int `json:"count"`
Status int `json:"status"`
HostID string `json:"host_id"`
HostCname string `json:"host_cname"`
HostName string `json:"host_name"`
IP string `json:"ip"`
SN string `json:"sn"`
ProcessUser string `json:"process_user"`
ProcessComments string `json:"process_comments"`
ProcessTime time.Time `json:"process_time"`
}
func NewStrategyEvent ¶
func (StrategyEvent) MarshalJSON ¶
func (s StrategyEvent) MarshalJSON() ([]byte, error)
func (StrategyEvent) TableName ¶
func (StrategyEvent) TableName() string
type StrategyGroup ¶
type StrategyGroup struct {
ID int64 `json:"-"`
StrategyID int `json:"-"`
GroupID int `json:"group_id"`
}
func (StrategyGroup) TableName ¶
func (StrategyGroup) TableName() string
type StrategyHost ¶
type StrategyHost struct {
ID int64 `json:"-"`
StrategyID int `json:"-"`
HostID string `json:"host_id"`
}
func (StrategyHost) TableName ¶
func (StrategyHost) TableName() string
type StrategyResult ¶
type StrategyResult struct {
TaskID string
Priority int
TriggerResultSets map[string]*TriggerResultSet
ErrorMessage string
Triggered bool
CreateTime time.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"`
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"`
}
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 Template ¶
type Template struct {
STRATEGY TemplateStrategy
HOST TemplateHost
}
type TemplateHost ¶
type TemplateStrategy ¶
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"`
Tags map[string]string `json:"tags"` //{"product":"app01", "group":"dev02"}
}
func (*TimeSeriesData) Decode ¶
func (this *TimeSeriesData) Decode(data []byte) error
func (*TimeSeriesData) Encode ¶
func (this *TimeSeriesData) Encode() []byte
func (*TimeSeriesData) GetMetric ¶
func (this *TimeSeriesData) GetMetric() string
func (*TimeSeriesData) PK ¶
func (this *TimeSeriesData) PK() string
func (TimeSeriesData) String ¶
func (this TimeSeriesData) String() string
func (*TimeSeriesData) Tags2String ¶
func (this *TimeSeriesData) Tags2String() string
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" `
Name string `form:"name" json:"name"`
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"`
Index string `json:"index"`
Metric string `json:"metric"`
Tags string `json:"tags"`
Number int `json:"number"`
AggregateTags string `json:"aggregate_tags"`
CurrentThreshold float64 `json:"current_threshold"`
Method string `json:"method"`
Symbol string `json:"symbol"`
Threshold float64 `json:"threshold"`
Triggered bool `json:"triggered"`
}
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.