Documentation ¶
Index ¶
- Constants
- Variables
- func GetAvgCpuByHosts(ctx context.Context, hosts []*monitor.HostInfo) float64
- func GetAvgMemByHosts(ctx context.Context, hosts []*monitor.HostInfo) float64
- func Init()
- func PromQueryJsonPathWithRetFloat(ctx context.Context, query string, jsonPath string) float64
- func PromQueryJsonPathWithRetInt(ctx context.Context, query string, jsonPath string) int
- func UpdateHostUsage()
- func UpdateServiceList()
- func UpdateServiceStatistics()
- func UsageToStatus(usage int) string
- type BackendHostUsage
- type BuildVersion
- type MonitorServiceHeartbeat
- type ServiceInfo
- type ServiceInstance
Constants ¶
View Source
const ( AgentCpuMetrics = "sum by (agent_id)(elkeid_ac_agent_cpu{agent_id='%s'})" AgentMemoryMetrics = "sum by (agent_id)(elkeid_ac_agent_rss{agent_id='%s'})" AgentDiskMetrics = "sum by (agent_id)(elkeid_ac_agent_du{agent_id='%s'})" AgentNetUploadMetrics = "sum by (agent_id)(elkeid_ac_agent_tx_speed{agent_id='%s'})" AgentNetDownloadMetrics = "sum by (agent_id)(elkeid_ac_agent_rx_speed{agent_id='%s'})" AgentDiskReadMetrics = "sum by (agent_id)(elkeid_ac_agent_read_speed{agent_id='%s'})" AgentDiskWriteMetrics = "sum by (agent_id)(elkeid_ac_agent_write_speed{agent_id='%s'})" HostNameInfoMetrics = "node_uname_info{instance=~'%s:.*'}" HostCpuCountMetrics = "count(count(node_cpu_seconds_total{instance=~'%s:.*'}) by (cpu))" HostMemTotalMetrics = "node_memory_MemTotal_bytes{instance=~'%s:.*'}" HostCpuUsageMetrics = "" /* 126-byte string literal not displayed */ HostMemUsageMetrics = "1-(node_memory_MemAvailable_bytes{instance=~'%s:.*'}/node_memory_MemTotal_bytes{instance=~'%s:.*'})" HostDiskUsageMetrics = "" /* 160-byte string literal not displayed */ HostNetUploadMetrics = "sum(rate(node_network_transmit_bytes_total{instance=~'%s:.*'}[1m]))" HostNetDownloadMetrics = "sum(rate(node_network_receive_bytes_total{instance=~'%s:.*'}[1m]))" HostCpuAvgUsageMetrics = "sum(rate(node_cpu_seconds_total{mode!='idle'}[1m]))/sum(rate(node_cpu_seconds_total{}[1m]))" HostMemAvgUsageMetrics = "1-(sum(node_memory_MemAvailable_bytes{})/sum(node_memory_MemTotal_bytes{}))" HostDiskAvgUsageMetrics = "" /* 134-byte string literal not displayed */ )
View Source
const ( ServiceInstanceAlive = "alive" ServiceInstanceDead = "dead" )
View Source
const ( MonitorServiceUsageLow = "low" MonitorServiceUsageMiddle = "middle" MonitorServiceUsageHigh = "high" )
View Source
const (
MonitorServiceHeartbeatCollection = "monitor_service_heartbeat"
)
Variables ¶
View Source
var HostUsageList = make([]*BackendHostUsage, 0)
View Source
var HostUsageListLastUpdate = time.Time{}
View Source
var HostUsageListUpdateMutex = &sync.Mutex{}
View Source
var ServiceInfoList = make([]ServiceInfo, 0)
View Source
var ServiceInfoListLastUpdate = time.Time{}
View Source
var ServiceInfoListUpdateMutex = &sync.Mutex{}
View Source
var ServiceStatistics = serviceStatisticsData{}
View Source
var ServiceStatisticsLastUpdate = time.Time{}
View Source
var ServiceStatisticsUpdateMutex = &sync.Mutex{}
Functions ¶
func GetAvgCpuByHosts ¶
func GetAvgMemByHosts ¶
func UpdateHostUsage ¶
func UpdateHostUsage()
func UpdateServiceList ¶
func UpdateServiceList()
func UpdateServiceStatistics ¶
func UpdateServiceStatistics()
func UsageToStatus ¶
Types ¶
type BackendHostUsage ¶
type BackendHostUsage struct { ID string `json:"id"` HostName string `json:"host_name"` HostIP string `json:"host_ip"` ServiceList []string `json:"service_list"` Quota string `json:"quota"` CpuUsage float64 `json:"cpu_usage"` MemoryUsage float64 `json:"memory_usage"` DiskUsage float64 `json:"disk_usage"` NetUpload float64 `json:"net_upload"` NetDownload float64 `json:"net_download"` Detail string `json:"detail"` Status string `json:"status"` Info monitor.HostInfo `json:"-"` LoadScore float64 `json:"-"` }
func (*BackendHostUsage) UpdateBackendHostUsage ¶
func (u *BackendHostUsage) UpdateBackendHostUsage() []error
type BuildVersion ¶
type MonitorServiceHeartbeat ¶
type MonitorServiceHeartbeat struct { ServiceID string `json:"service_id" bson:"service_id"` ServiceName string `json:"service_name" bson:"service_name"` Instance string `json:"instance"` LastHeartbeat int64 `json:"last_heartbeat" bson:"last_heartbeat"` Status string `json:"status" bson:"status"` Version string `json:"version" bson:"version"` Commit string `json:"commit" bson:"commit"` Build string `json:"build" bson:"build"` CI string `json:"ci" bson:"ci"` UpdateAt time.Time `json:"update_at" bson:"update_at"` }
func GetHeartbeatFromServiceHeartbeat ¶
func GetHeartbeatFromServiceHeartbeat(ctx context.Context, info monitor.ServiceInfo) ([]MonitorServiceHeartbeat, error)
type ServiceInfo ¶
type ServiceInfo struct { ID string `json:"id"` Name string `json:"name"` Description string `json:"description"` Version string `json:"version"` CI string `json:"ci"` Commit string `json:"commit"` Build string `json:"build"` Quota string `json:"quota"` LastHeartbeat int64 `json:"last_heartbeat"` Alive int `json:"alive"` Sum int `json:"sum"` Instances []ServiceInstance `json:"instances"` }
Click to show internal directories.
Click to hide internal directories.