This is a creation in Article, where the information may have evolved or changed.
Open-falcon-hbs
tags (space delimited): Go Falcon
Key Features
Handling agent heartbeat requests, populating the host table
IP whitelist issued by all agents
Issued to implement the plug-in information
Issued monitoring port, process
Cache monitoring Policy
Module structure
Memory Data Map Structure
Hostmap:
(hostname, hostId int)
Hostgroupsmap:
(hostId, groupsId []int)
Groupplugins:
(groupId, pluginsPath []string)
Grouptemplates:
(groupId, templatesID []int)
Templatecache:
(templateId, Template)
type Template struct { Id int `json:"id"` Name string `json:"name"` ParentId int `json:"parentId"` ActionId int `json:"actionId"` Creator string `json:"creator"`}
type Strategy struct { Id int `json:"id"` Metric string `json:"metric"` Tags map[string]string `json:"tags"` Func string `json:"func"` // e.g. max(#3) all(#3) Operator string `json:"operator"` // e.g. < != RightValue float64 `json:"rightValue"` // critical value MaxStep int `json:"maxStep"` Priority int `json:"priority"` Note string `json:"note"` Tpl *Template `json:"tpl"`}
Hosttemplates:
(hostID, templatesID []int)
Expressioncache:
(expressionId, [] Expression)
type Expression struct { Id int `json:"id"` Metric string `json:"metric"` Tags map[string]string `json:"tags"` Func string `json:"func"` // e.g. max(#3) all(#3) Operator string `json:"operator"` // e.g. < != RightValue float64 `json:"rightValue"` // critical value MaxStep int `json:"maxStep"` Priority int `json:"priority"` Note string `json:"note"` ActionId int `json:"actionId"`}
type Host struct { Id int Name string}
DB and Cache
rows, err = DB.Query(sql)if err != nil { log.Println("ERROR:", err) return err}…defer DB.Close()for rows.Next(){ … err = rows.Scan(&id, &hostname) if err != nil { log.Println("ERROR:", err) continue } …}
Plugins update request contains hostname and checksum (checksum initially empty), HBS reads the plug-in path information from the PORTALDB after receiving the request, and after sorting the path takes MD5 to form checksum, Checksum compared to the agent request, the same return null does not make the plugins update, otherwise return the plug-in information, Agent received after the update plug-in and regular execution of plug-ins.
How RPC is implemented
RPC services can be established through HTTP,TCP and JSON Sever and CLIENT;HBS RPC service side through the implementation of JSON, can register multiple clients, implement the relevant interface for agent and Judge Call.