Documentation ¶
Index ¶
- Constants
- Variables
- func AlertUpgradeMarshal(alterUpgrade AlertUpgrade) (string, error)
- func CleanExpireMask(now int64) error
- func CreateCollect(collectType, creator string, collect interface{}) error
- func DelById(id int64) error
- func DelEventCurOlder(ts int64, batch int) (int64, error)
- func DelEventOlder(ts int64, batch int) (int64, error)
- func DeleteCollectById(collectType, creator string, cid int64) error
- func EndpointBindingsForMail(endpoints []string) []string
- func EndpointDel(ids []int64) error
- func EndpointIdsByIdents(idents []string) ([]int64, error)
- func EndpointIdsByNodeIds(nodeIds []int64) ([]int64, error)
- func EndpointImport(endpoints []string) error
- func EndpointTotal(query, batch, field string) (int64, error)
- func EndpointUnderNodeTotal(leafids []int64, query, batch, field string) (int64, error)
- func EventAlertUpgradeMarshal(alertUpgrade AlertUpgrade) (string, error)
- func EventCnt(hashid uint64, stime, etime string, isUpgrade bool) (int64, error)
- func EventCurDel(hashid uint64) error
- func EventCurTotal(stime, etime int64, nodePath, query string, priorities, sendTypes []string) (int64, error)
- func EventTotal(stime, etime int64, nodePath, query, eventType string, ...) (int64, error)
- func GetCollectById(collectType string, cid int64) (interface{}, error)
- func GetCollectByName(collectType string, name string) (interface{}, error)
- func GetCollectByNid(collectType string, nids []int64) ([]interface{}, error)
- func GetFlagsByStatus(ss []string) []uint16
- func GetStatus(status string) int
- func GetStatusByFlag(flag uint16) []string
- func InitMySQL(names ...string)
- func InitNode()
- func InitRoot()
- func InviteAdd(token, creator string) error
- func LdapLogin(user, pass string) error
- func MaskconfDel(id int64) error
- func NodeEndpointBind(nid, eid int64) error
- func NodeEndpointUnbind(nid, eid int64) error
- func NodeIdsGetByEndpointId(endpointId int64) ([]int64, error)
- func NodeValid(name, path string) error
- func ParseEtime(etime int64) string
- func PassLogin(user, pass string) error
- func Paths(longPath string) []string
- func SaveEvent(event *Event) error
- func SaveEventCur(eventCur *EventCur) error
- func SaveEventCurStatus(hashid uint64, status string) error
- func SaveEventStatus(id int64, status string) error
- func SaveStraCommit(id int64, action, username, body string, session *xorm.Session) error
- func StatusConvert(s []string) []string
- func StraDel(id int64) error
- func TeamAdd(ident, name string, mgmt int, admins, members []int64) error
- func TeamNameGetsByIds(ids string) ([]string, error)
- func TeamTotal(query string) (int64, error)
- func UpdateClaimantsById(userId, id int64) error
- func UpdateClaimantsByNodePath(userId int64, nodePath string) error
- func UpdateEventCurPriority(hashid uint64, priority int) error
- func UpdateEventPriority(id int64, priority int) error
- func UserIdGetByTeamIds(teamIds []int64) ([]int64, error)
- func UserNameGetByIds(ids string) ([]string, error)
- func UserTotal(query string) (int64, error)
- type AlertUpgrade
- type Chart
- type Collect
- type CollectHist
- type Endpoint
- func EndpointGet(col string, val interface{}) (*Endpoint, error)
- func EndpointGets(query, batch, field string, limit, offset int) ([]Endpoint, error)
- func EndpointUnderLeafs(leafIds []int64) ([]Endpoint, error)
- func EndpointUnderNodeGets(leafids []int64, query, batch, field string, limit, offset int) ([]Endpoint, error)
- type EndpointBinding
- type Event
- type EventAlertUpgrade
- type EventCur
- type EventDetail
- type EventDetailPoint
- type EventSlice
- type Exp
- type Instance
- type Invite
- type LogCollect
- type Maskconf
- type MaskconfEndpoints
- type MySQLConf
- type Node
- func NodeByIds(ids []int64) ([]Node, error)
- func NodeGet(col string, val interface{}) (*Node, error)
- func NodeGets(where string, args ...interface{}) (nodes []Node, err error)
- func NodeGetsByPaths(paths []string) ([]Node, error)
- func NodeQueryPath(query string, limit int) (nodes []Node, err error)
- func NodesGetByIds(ids []int64) ([]Node, error)
- func TreeSearchByPath(query string) (nodes []Node, err error)
- func (n *Node) Bind(endpointIds []int64, delOld int) error
- func (n *Node) CreateChild(name string, leaf int, note string) (int64, error)
- func (n *Node) Del() error
- func (n *Node) LeafIds() ([]int64, error)
- func (n *Node) Pids() ([]int64, error)
- func (n *Node) Rename(name string) error
- func (n *Node) Unbind(hostIds []int64) error
- type NodeEndpoint
- type PluginCollect
- type PortCollect
- type ProcCollect
- type Screen
- type ScreenSubclass
- type Stra
- type StraLog
- type Tag
- type Team
- type TeamUser
- type TmpChart
- type User
Constants ¶
View Source
const ( FLAG_SEND = iota FLAG_CALLBACK FLAG_MASK FLAG_CONVERGE FLAG_NONEUSER FLAG_UPGRADE )
0 0 0 0 0 0 处理中 0 0 0 0 x 1 已发送 0 0 0 0 1 x 已回调 0 0 0 1 0 0 已屏蔽 0 0 1 0 0 0 被收敛 0 1 0 0 x 0 无接收人 1 0 0 0 x 0 升级发送
View Source
const ( STATUS_DOING = "doing" // 处理中 STATUS_SEND = "send" // 已发送 STATUS_NONEUSER = "none-user" // 无接收人 STATUS_CALLBACK = "callback" // 已回调 STATUS_MASK = "mask" // 已屏蔽 STATUS_CONVERGE = "converge" // 频率限制 STATUS_UPGRADE = "upgrade" // 升级报警 )
Variables ¶
View Source
var DB = map[string]*xorm.Engine{}
Functions ¶
func AlertUpgradeMarshal ¶
func AlertUpgradeMarshal(alterUpgrade AlertUpgrade) (string, error)
func CleanExpireMask ¶
func CreateCollect ¶
func DeleteCollectById ¶
func EndpointBindingsForMail ¶
EndpointBindingsForMail 用来发告警邮件的时候带上各个endpoint的挂载信息
func EndpointDel ¶
func EndpointIdsByIdents ¶
func EndpointIdsByNodeIds ¶
func EndpointImport ¶
func EndpointTotal ¶
func EndpointUnderNodeTotal ¶
func EventAlertUpgradeMarshal ¶
func EventAlertUpgradeMarshal(alertUpgrade AlertUpgrade) (string, error)
func EventCurDel ¶
func EventCurTotal ¶
func EventTotal ¶
func GetCollectById ¶
func GetCollectByName ¶
func GetCollectByNid ¶
func GetFlagsByStatus ¶
func GetStatusByFlag ¶
func MaskconfDel ¶
func NodeEndpointBind ¶
func NodeEndpointUnbind ¶
func NodeIdsGetByEndpointId ¶
func ParseEtime ¶
func SaveEventCur ¶
func SaveEventCurStatus ¶
func SaveEventStatus ¶
func SaveStraCommit ¶
func StatusConvert ¶
func TeamNameGetsByIds ¶
func UpdateClaimantsById ¶
func UpdateEventCurPriority ¶
func UpdateEventPriority ¶
func UserIdGetByTeamIds ¶
func UserNameGetByIds ¶
Types ¶
type AlertUpgrade ¶
type AlertUpgrade struct { Users []int64 `json:"users"` Groups []int64 `json:"groups"` Duration int `json:"duration"` Level int `json:"level"` }
func AlertUpgradeUnMarshal ¶
func AlertUpgradeUnMarshal(str string) (AlertUpgrade, error)
type Chart ¶
type Collect ¶
type Collect struct { sync.RWMutex Ports map[int]*PortCollect `json:"ports"` Procs map[string]*ProcCollect `json:"procs"` Logs map[string]*LogCollect `json:"logs"` Plugins map[string]*PluginCollect `json:"plugins"` }
func NewCollect ¶
func NewCollect() *Collect
func (*Collect) GetLogConfig ¶
func (c *Collect) GetLogConfig() map[string]*LogCollect
func (*Collect) GetPlugin ¶ added in v1.3.3
func (c *Collect) GetPlugin() map[string]*PluginCollect
func (*Collect) GetPorts ¶
func (c *Collect) GetPorts() map[int]*PortCollect
func (*Collect) GetProcs ¶
func (c *Collect) GetProcs() map[string]*ProcCollect
type CollectHist ¶
type Endpoint ¶
type Endpoint struct { Id int64 `json:"id"` Ident string `json:"ident"` Alias string `json:"alias"` }
func EndpointGet ¶
func EndpointGets ¶
func EndpointUnderLeafs ¶
func EndpointUnderNodeGets ¶
type EndpointBinding ¶
type EndpointBinding struct { Ident string `json:"ident"` Alias string `json:"alias"` Nodes []Node `json:"nodes"` }
func EndpointBindings ¶
func EndpointBindings(endpointIds []int64) ([]EndpointBinding, error)
type Event ¶
type Event struct { Id int64 `json:"id"` Sid int64 `json:"sid"` Sname string `json:"sname"` NodePath string `json:"node_path"` Endpoint string `json:"endpoint"` EndpointAlias string `json:"endpoint_alias"` Priority int `json:"priority"` EventType string `json:"event_type"` // alert|recovery Category int `json:"category"` Status uint16 `json:"status"` HashId uint64 `json:"hashid" xorm:"hashid"` Etime int64 `json:"etime"` Value string `json:"value"` Info string `json:"info"` Created time.Time `json:"created" xorm:"created"` Detail string `json:"detail"` Users string `json:"users"` Groups string `json:"groups"` Nid int64 `json:"nid"` NeedUpgrade int `json:"need_upgrade"` AlertUpgrade string `json:"alert_upgrade"` RecvUserIDs []int64 `json:"recv_user_ids" xorm:"-"` RecvUserObjs []User `json:"recv_user_objs" xorm:"-"` RealUpgrade bool `json:"real_upgrade" xorm:"-"` }
func (*Event) GetEventDetail ¶
func (e *Event) GetEventDetail() ([]EventDetail, error)
type EventAlertUpgrade ¶
type EventAlertUpgrade struct { Users string `json:"users"` Groups string `json:"groups"` Duration int `json:"duration"` Level int `json:"level"` }
func EventAlertUpgradeUnMarshal ¶
func EventAlertUpgradeUnMarshal(str string) (EventAlertUpgrade, error)
type EventCur ¶
type EventCur struct { Id int64 `json:"id"` Sid int64 `json:"sid"` Sname string `json:"sname"` NodePath string `json:"node_path"` Endpoint string `json:"endpoint"` EndpointAlias string `json:"endpoint_alias"` Priority int `json:"priority"` EventType string `json:"event_type"` // alert|recovery Category int `json:"category"` Status uint16 `json:"status"` HashId uint64 `json:"hashid" xorm:"hashid"` Etime int64 `json:"etime"` Value string `json:"value"` Info string `json:"info"` Created time.Time `json:"created" xorm:"created"` Detail string `json:"detail"` Users string `json:"users"` Groups string `json:"groups"` Nid int64 `json:"nid"` IgnoreAlert int `json:"ignore_alert"` Claimants string `json:"claimants"` NeedUpgrade int `json:"need_upgrade"` AlertUpgrade string `json:"alert_upgrade"` }
func EventCurGet ¶
func EventCurGets ¶
func (*EventCur) EventIgnore ¶
type EventDetail ¶
type EventDetail struct { Metric string `json:"metric"` Tags map[string]string `json:"tags"` Points []*EventDetailPoint `json:"points"` PredPoints []*EventDetailPoint `json:"pred_points,omitempty"` // 预测值, 预测值不为空时, 现场值对应的是实际值 }
type EventDetailPoint ¶
type EventSlice ¶
type EventSlice []*Event
func (EventSlice) Len ¶
func (e EventSlice) Len() int
func (EventSlice) Less ¶
func (e EventSlice) Less(i, j int) bool
func (EventSlice) Swap ¶
func (e EventSlice) Swap(i, j int)
type Instance ¶
type Instance struct { Id int64 `json:"id"` Module string `json:"module"` Identity string `json:"identity"` //ip 或者 机器名 RPCPort string `json:"rpc_port" xorm:"rpc_port"` HTTPPort string `json:"http_port" xorm:"http_port"` TS int64 `json:"ts" xorm:"ts"` Remark string `json:"remark"` Active bool `xorm:"-" json:"active"` }
func GetInstanceBy ¶
type LogCollect ¶
type LogCollect struct { Id int64 `json:"id"` Nid int64 `json:"nid"` CollectType string `json:"collect_type"` Name string `json:"name"` TagsStr string `xorm:"tags" json:"-"` Step int `json:"step"` Comment string `json:"comment"` Creator string `json:"creator"` Created time.Time `xorm:"updated" json:"created"` LastUpdator string `xorm:"last_updator" json:"last_updator"` LastUpdated time.Time `xorm:"updated" json:"last_updated"` Tags map[string]string `xorm:"-" json:"tags"` FilePath string `json:"file_path"` TimeFormat string `json:"time_format"` Pattern string `json:"pattern"` Func string `json:"func"` FuncType string `json:"func_type"` Unit string `json:"unit"` Degree int `json:"degree"` Zerofill int `xorm:"zero_fill" json:"zerofill"` Aggregate string `json:"aggregate"` LocalUpdated int64 `xorm:"-" json:"-"` TimeReg *regexp.Regexp `xorm:"-" json:"-"` PatternReg *regexp.Regexp `xorm:"-" json:"-"` ExcludeReg *regexp.Regexp `xorm:"-" json:"-"` TagRegs map[string]*regexp.Regexp `xorm:"-" json:"-"` ParseSucc bool `xorm:"-" json:"-"` }
func GetLogCollects ¶
func GetLogCollects() ([]*LogCollect, error)
func (*LogCollect) Decode ¶
func (l *LogCollect) Decode() error
func (*LogCollect) Encode ¶
func (l *LogCollect) Encode() error
func (*LogCollect) Update ¶
func (l *LogCollect) Update() error
type Maskconf ¶
type Maskconf struct { Id int64 `json:"id"` Nid int64 `json:"nid"` NodePath string `json:"node_path" xorm:"-"` Metric string `json:"metric"` Tags string `json:"tags"` Cause string `json:"cause"` User string `json:"user"` Btime int64 `json:"btime"` Etime int64 `json:"etime"` Endpoints []string `json:"endpoints" xorm:"-"` }
func MaskconfGet ¶
func MaskconfGetAll ¶
func MaskconfGets ¶
func (*Maskconf) FillEndpoints ¶
type MaskconfEndpoints ¶
type Node ¶
type Node struct { Id int64 `json:"id"` Pid int64 `json:"pid"` Name string `json:"name"` Path string `json:"path"` Leaf int `json:"leaf"` Note string `json:"note"` }
func NodeGetsByPaths ¶
func NodesGetByIds ¶
func TreeSearchByPath ¶
func (*Node) CreateChild ¶
type NodeEndpoint ¶
type NodeEndpoint struct { NodeId int64 `xorm:"'node_id'"` EndpointId int64 `xorm:"'endpoint_id'"` }
func NodeEndpointGetByEndpointIds ¶
func NodeEndpointGetByEndpointIds(endpointsIds []int64) ([]NodeEndpoint, error)
func NodeEndpointGetByNodeIds ¶
func NodeEndpointGetByNodeIds(nodeIds []int64) ([]NodeEndpoint, error)
func (NodeEndpoint) TableName ¶
func (NodeEndpoint) TableName() string
type PluginCollect ¶ added in v1.3.3
type PluginCollect struct { Id int64 `json:"id"` Nid int64 `json:"nid"` CollectType string `json:"collect_type"` Name string `json:"name"` Step int `json:"step"` FilePath string `json:"file_path"` Params string `json:"params"` Stdin string `json:"stdin"` Env string `json:"env"` Comment string `json:"comment"` Creator string `json:"creator"` Created time.Time `xorm:"updated" json:"created"` LastUpdator string `xorm:"last_updator" json:"last_updator"` LastUpdated time.Time `xorm:"updated" json:"last_updated"` }
func GetPluginCollects ¶ added in v1.4.0
func GetPluginCollects() ([]*PluginCollect, error)
func (*PluginCollect) Update ¶ added in v1.4.0
func (p *PluginCollect) Update() error
type PortCollect ¶
type PortCollect struct { Id int64 `json:"id"` Nid int64 `json:"nid"` CollectType string `json:"collect_type"` Name string `json:"name"` Tags string `json:"tags"` Step int `json:"step"` Comment string `json:"comment"` Creator string `json:"creator"` Created time.Time `xorm:"updated" json:"created"` LastUpdator string `xorm:"last_updator" json:"last_updator"` LastUpdated time.Time `xorm:"updated" json:"last_updated"` Port int `json:"port"` Timeout int `json:"timeout"` }
func GetPortCollects ¶
func GetPortCollects() ([]*PortCollect, error)
func (*PortCollect) Update ¶
func (p *PortCollect) Update() error
type ProcCollect ¶
type ProcCollect struct { Id int64 `json:"id"` Nid int64 `json:"nid"` CollectType string `json:"collect_type"` Name string `json:"name"` Tags string `json:"tags"` Step int `json:"step"` Comment string `json:"comment"` Creator string `json:"creator"` Created time.Time `xorm:"updated" json:"created"` LastUpdator string `xorm:"last_updator" json:"last_updator"` LastUpdated time.Time `xorm:"updated" json:"last_updated"` Target string `json:"target"` CollectMethod string `json:"collect_method"` }
func GetProcCollects ¶
func GetProcCollects() ([]*ProcCollect, error)
func (*ProcCollect) Update ¶
func (p *ProcCollect) Update() error
type Screen ¶
type Screen struct { Id int64 `json:"id"` NodeId int64 `json:"node_id"` Name string `json:"name"` LastUpdator string `json:"last_updator"` LastUpdated time.Time `xorm:"<-" json:"last_updated"` }
func ScreenGets ¶
type ScreenSubclass ¶
type ScreenSubclass struct { Id int64 `json:"id"` ScreenId int64 `json:"screen_id"` Name string `json:"name"` Weight int `json:"weight"` }
func ScreenSubclassGet ¶
func ScreenSubclassGet(col string, val interface{}) (*ScreenSubclass, error)
func ScreenSubclassGets ¶
func ScreenSubclassGets(screenId int64) ([]ScreenSubclass, error)
func (*ScreenSubclass) Add ¶
func (s *ScreenSubclass) Add() error
func (*ScreenSubclass) Del ¶
func (s *ScreenSubclass) Del() error
func (*ScreenSubclass) Update ¶
func (s *ScreenSubclass) Update(cols ...string) error
type Stra ¶
type Stra struct { Id int64 `json:"id"` Name string `json:"name"` Category int `json:"category"` //机器,非机器 Nid int64 `json:"nid"` //服务树节点id ExclNidStr string `xorm:"excl_nid" json:"-"` //排除的叶子节点 AlertDur int `json:"alert_dur"` //单位秒,持续异常10分钟则产生异常event RecoveryDur int `json:"recovery_dur"` //单位秒,持续正常2分钟则产生恢复event,0表示立即产生恢复event RecoveryNotify int `json:"recovery_notify"` //0 发送恢复通知 1不发送恢复通知 ExprsStr string `xorm:"exprs" json:"-"` //多个条件的监控实例需要相同,并且同时满足才产生event TagsStr string `xorm:"tags" json:"-"` //tag过滤条件 EnableStime string `json:"enable_stime"` //策略生效开始时间 EnableEtime string `json:"enable_etime"` //策略生效终止时间 支持23:00-02:00 EnableDaysOfWeekStr string `xorm:"enable_days_of_week" json:"-"` //策略生效日期 ConvergeStr string `xorm:"converge" json:"-"` //告警通知收敛,第1个值表示收敛周期,单位秒,第2个值表示周期内允许发送告警次数 Priority int `json:"priority"` Callback string `json:"callback"` NotifyGroupStr string `xorm:"notify_group" json:"-"` NotifyUserStr string `xorm:"notify_user" json:"-"` Creator string `json:"creator"` Created time.Time `xorm:"created" json:"created"` LastUpdator string `xorm:"last_updator" json:"last_updator"` LastUpdated time.Time `xorm:"<-" json:"last_updated"` NeedUpgrade int `xorm:"need_upgrade" json:"need_upgrade"` AlertUpgradeStr string `xorm:"alert_upgrade" json:"-"` ExclNid []int64 `xorm:"-" json:"excl_nid"` Exprs []Exp `xorm:"-" json:"exprs"` Tags []Tag `xorm:"-" json:"tags"` EnableDaysOfWeek []int `xorm:"-" json:"enable_days_of_week"` Converge []int `xorm:"-" json:"converge"` NotifyGroup []int `xorm:"-" json:"notify_group"` NotifyUser []int `xorm:"-" json:"notify_user"` LeafNids []int64 `xorm:"-" json:"leaf_nids"` //叶子节点id Endpoints []string `xorm:"-" json:"endpoints"` AlertUpgrade AlertUpgrade `xorm:"-" json:"alert_upgrade"` JudgeInstance string `xorm:"-" json:"judge_instance"` }
func EffectiveStrasList ¶
func (*Stra) HasPermssion ¶
type Team ¶
type Team struct { Id int64 `json:"id"` Ident string `json:"ident"` Name string `json:"name"` Mgmt int `json:"mgmt"` AdminObjs []User `json:"admin_objs" xorm:"-"` MemberObjs []User `json:"member_objs" xorm:"-"` }
func (*Team) CheckFields ¶
type TmpChart ¶
type TmpChart struct { Id int64 `json:"id"` Configs string `json:"configs"` Creator string `json:"creator"` }
func TmpChartGet ¶
type User ¶
type User struct { Id int64 `json:"id"` Username string `json:"username"` Password string `json:"-"` Dispname string `json:"dispname"` Phone string `json:"phone"` Email string `json:"email"` Im string `json:"im"` IsRoot int `json:"is_root"` }
func UserGetByIds ¶
func (*User) CheckFields ¶
func (u *User) CheckFields()
func (*User) CopyLdapAttr ¶ added in v1.0.2
func (u *User) CopyLdapAttr(sr *ldap.SearchResult)
Click to show internal directories.
Click to hide internal directories.