common

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 14, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	INSTANCE   = "instance"
	DEVICE     = "device"
	FSTYPE     = "fstype"
	MOUNTPOINT = "mountpoint"

	INSTANT_METRIC_PATH     = "/api/v1/query"
	VECTOR_METRIC_QUERY_KEY = "query"

	RANGE_METRIC_PATH = "/api/v1/query_range"
	RANGE_START       = "start"
	RANGE_END         = "end"
	RANGE_STEP        = "step"

	BVAR_METRIC_PATH = "/vars"
	RAFT_STATUS_PATH = "/raft_stat"

	CONF_VALUE = "conf_value"

	CURVEBS_VERSION = "curve_version"

	ETCD_CLUSTER_VERSION_NAME  = "etcd_cluster_version"
	ETCD_SERVER_IS_LEADER_NAME = "etcd_server_is_leader"
	ETCD_CLUSTER_VERSION       = "cluster_version"

	WRITE_IOPS = "write_iops"
	WRITE_RATE = "write_rate"
	READ_IOPS  = "read_iops"
	READ_REAT  = "read_rate"

	WRITE_QPS = "write_qps"
	WRITE_BPS = "write_bps"
	READ_QPS  = "read_qps"
	READ_BPS  = "read_bps"
)
View Source
const (
	// disk info
	NODE_DISK_INFO                  = "node_disk_info"
	NODE_DISK_READ_COMPLETED_TOTAL  = "node_disk_reads_completed_total"
	NODE_DISK_WRITE_COMPLETED_TOTAL = "node_disk_writes_completed_total"
	NODE_DISK_READ_BYTES_TOTAL      = "node_disk_read_bytes_total"
	NODE_DISK_WRITTEN_BYTES_TOTAL   = "node_disk_written_bytes_total"

	// filesystem
	NODE_FILESYSTEM_SIZE_TOTAL = "node_filesystem_size_bytes"
	NODE_FILESYSTEM_SIZE_AVAIL = "node_filesystem_avail_bytes"

	// disk
	NODE_DISK_ROTATION_RATE      = "node_disk_ata_rotation_rate_rpm"
	NODE_DISK_WRITE_CACHE_ENABLE = "node_disk_ata_write_cache_enabled"
	SSD_TYPE                     = "SSD"
	HDD_TYPE                     = "HDD"

	// disk modle
	MODLE = "model"
)
View Source
const (
	// node info
	NODE_UNAME_INFO      = "node_uname_info"
	NODE_UNAME_NODE_NAME = "nodename"
	NODE_UNAME_MACHINE   = "machine"
	NODE_UNAME_RELEASE   = "release"
	NODE_UNAME_SYSNAME   = "sysname"
	NODE_UNAME_VERSION   = "version"

	// cpu info
	NODE_CPU_INFO        = "node_cpu_info"
	NODE_CPU_MODLE       = "model_name"
	NODE_CPU_UTILIZATION = "node_cpu_seconds_total"
	NODE_CPU_IDLE        = "idle"

	// memory info
	NODE_MEMORY_TOTAL_BYTES = "node_memory_MemTotal_bytes"

	// network info
	NODE_NETWORK_DEVICE_FILTER        = "tap.*|veth.*|br.*|docker.*|virbr*|lo*"
	NODE_NETWORK_RECEIVE_BYTES_TOTAL  = "node_network_receive_bytes_total"
	NODE_NETWORK_TRANSMIT_BYTES_TOTAL = "node_network_transmit_bytes_total"
)

Variables

This section is empty.

Functions

func GetBvarConfMetricValue

func GetBvarConfMetricValue(metric string) string

func GetBvarMetric

func GetBvarMetric(addrs []string, name string, results *chan MetricResult)

func GetDiskFileSystemInfo

func GetDiskFileSystemInfo(instance string) (interface{}, error)

@return ap[instance]map[device]FileSystemInfo

func GetDiskPerformance

func GetDiskPerformance(instance string, start, end, interval uint64) (interface{}, error)

@return map[string][]Performance, key: device, value: performance at different timestamp

func GetDiskType

func GetDiskType(instance string) (interface{}, error)

@return map[instance]map[device]type

func GetDiskWriteCacheEnableFlag

func GetDiskWriteCacheEnableFlag(instance string) (interface{}, error)

@return map[instance]map[device]writeCacheEnable

func GetHostCPUInfo

func GetHostCPUInfo(instance string) (interface{}, error)

func GetHostCPUUtilization

func GetHostCPUUtilization(instance string, start, end, interval uint64) (interface{}, error)

func GetHostInfo

func GetHostInfo(instance string) (interface{}, error)

func GetHostMemUtilization

func GetHostMemUtilization(instance string, start, end, interval uint64) (interface{}, error)

func GetHostMemoryInfo

func GetHostMemoryInfo(instance string) (interface{}, error)

func GetNetWorkTraffic

func GetNetWorkTraffic(instance string, start, end, interval uint64) (interface{}, error)

* return: reveive, transmit, error * map[string][]RangeMetricItem: key: network device, value: performance in different timestamp

func GetNodeCPUUtilizationName

func GetNodeCPUUtilizationName(instance string, interval uint64) string

func GetNodeDiskPerformanceName

func GetNodeDiskPerformanceName(typeName, instance string, interval uint64) string

func GetNodeMemUtilizationName

func GetNodeMemUtilizationName(instance string) string

func GetNodeNetWorkReveiveName

func GetNodeNetWorkReveiveName(typeName, instance string, interval uint64) string

func GetRaftStatusMetric

func GetRaftStatusMetric(addrs []string, results *chan MetricResult)

func GetUtilization

func GetUtilization(name string, start, end, interval uint64) (map[string][]RangeMetricItem, error)

func ListDiskInfo

func ListDiskInfo(instance string) (interface{}, error)

@return map[instance][]map[key]value

func ParseBvarMetric

func ParseBvarMetric(value string) (*map[string]string, error)

func ParseMatrixMetric

func ParseMatrixMetric(info *QueryResponseOfMatrix, key string) map[string][]RangeMetricItem

func ParseRaftStatusMetric

func ParseRaftStatusMetric(addr string, value string) ([]map[string]string, error)

[8589934645] peer_id: 10.166.24.22:8200:0\r\n state: LEADER\r\n readonly: 0\r\n term: 19\r\n conf_index: 11244429\r\n peers: 10.166.24.22:8200:0 10.166.24.27:8218:0 10.166.24.29:8206:0\r\n changing_conf: NO stage: STAGE_NONE\r\n election_timer: timeout(1000ms) STOPPED\r\n vote_timer: timeout(1000ms) STOPPED\r\n stepdown_timer: timeout(1000ms) SCHEDULING(in 577ms)\r\n snapshot_timer: timeout(1800000ms) SCHEDULING(in 277280ms)\r\n storage: [11243647, 11245778]\n disk_index: 11245778\n known_applied_index: 11245778\n last_log_id: (index=11245778,term=19)\n state_machine: Idle\n last_committed_index: 11245778r\n last_snapshot_index: 11244429 last_snapshot_term: 19 snapshot_status: IDLE replicator_82304458296217@10.166.24.27:8218:0: next_index=11245779 flying_append_entries_size=0 idle hc=17738777 ac=206514 ic=0 replicator_80702435493905@10.166.24.29:8206:0: next_index=11245779 flying_append_entries_size=0 idle hc=17738818 ac=206282 ic=0 \r\n\r\n [8589934712] peer_id: 10.166.24.22:8200:0 state: FOLLOWER readonly: 0 term: 16 conf_index: 15368827 peers: 10.166.24.22:8200:0 10.166.24.29:8212:0 10.166.24.30:8219:0 leader: 10.166.24.29:8212:0 last_msg_to_now: 48 election_timer: timeout(1000ms) SCHEDULING(in 719ms) vote_timer: timeout(1000ms) STOPPED stepdown_timer: timeout(1000ms) STOPPED snapshot_timer: timeout(1800000ms) SCHEDULING(in 422640ms) storage: [15367732, 15370070] disk_index: 15370070 known_applied_index: 15370070 last_log_id: (index=15370070,term=16) state_machine: Idle last_committed_index: 15370070 last_snapshot_index: 15368827 last_snapshot_term: 16 snapshot_status: IDLE

func ParseVectorMetric

func ParseVectorMetric(info *QueryResponseOfVector, isValue bool) map[string]map[string]string

@return map[string]map[string]string, key: instance, value.key: meticKey or "value"

func QueryInstantMetric

func QueryInstantMetric(name string, results *chan MetricResult)

func QueryRangeMetric

func QueryRangeMetric(name string, results *chan MetricResult)

Types

type CPUInfo

type CPUInfo struct {
	TotalNum uint32            `json:"totalNum"`
	Models   map[string]uint32 `json:"cpuModles"`
}

type FileSystemInfo

type FileSystemInfo struct {
	Device     string
	FsType     string
	MountPoint string
	SpaceTotal uint64
	SpaceAvail uint64
}

type HostInfo

type HostInfo struct {
	HostName string `json:"hostname"`
	IP       string `json:"ip"`
	Machine  string `json:"machine"`
	Release  string `json:"kernel-release"`
	Version  string `json:"kernel-version"`
	System   string `json:"operating-system"`
}

type MetricResult

type MetricResult common.QueryResult

type NetworkTraffic

type NetworkTraffic struct {
	Receive  map[string][]RangeMetricItem
	Transmit map[string][]RangeMetricItem
}

type Performance

type Performance struct {
	Timestamp float64 `json:"timestamp" binding:"required"`
	WriteIOPS string  `json:"writeIOPS" binding:"required"`
	WriteBPS  string  `json:"writeBPS" binding:"required"`
	ReadIOPS  string  `json:"readIOPS" binding:"required"`
	ReadBPS   string  `json:"readBPS" binding:"required"`
}

func GetPerformance

func GetPerformance(name string, start, end, interval uint64) ([]Performance, error)

type QueryResponseOfMatrix

type QueryResponseOfMatrix struct {
	Status string `json:"status"`
	Data   struct {
		ResultType string `json:"resultType"`
		Result     []struct {
			Metric map[string]string `json:"metric"`
			Values [][]interface{}   `json:"values"`
		} `json:"result"`
	} `json:"data"`
}

type QueryResponseOfVector

type QueryResponseOfVector struct {
	Status string `json:"status"`
	Data   struct {
		ResultType string `json:"resultType"`
		Result     []struct {
			Metric map[string]string `json:"metric"`
			Value  []interface{}     `json:"value"`
		} `json:"result"`
	} `json:"data"`
}

prometheus http api resonse data struct

{
  "status": "success" | "error",
  "data": <data>,

  // Only set if status is "error". The data field may still hold additional data.
  "errorType": "<string>",
  "error": "<string>"
}

data struct: https://prometheus.io/docs/prometheus/latest/querying/api/#expression-query-result-formats

type RangeMetricItem

type RangeMetricItem struct {
	Timestamp float64 `json:"timestamp"`
	Value     string  `json:"value"`
}

type ServiceStatus

type ServiceStatus struct {
	Address string `json:"address"`
	Version string `json:"version"`
	Leader  bool   `json:"leader"`
	Online  bool   `json:"online"`
}

type Space

type Space struct {
	Total uint64
	Used  uint64
}

type SpaceTrend

type SpaceTrend struct {
	Timestamp float64 `json:"timestamp"`
	Total     uint64  `json:"total"`
	Used      uint64  `json:"alloc"`
}

type UserPerformance

type UserPerformance struct {
	Timestamp float64 `json:"timestamp" binding:"required"`
	WriteQPS  string  `json:"writeQPS" binding:"required"`
	WriteBPS  string  `json:"writeBPS" binding:"required"`
	ReadQPS   string  `json:"readQPS" binding:"required"`
	ReadBPS   string  `json:"readBPS" binding:"required"`
}

func GetUserPerformance

func GetUserPerformance(name string, start, end, interval uint64) ([]UserPerformance, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL