common

package
v0.3.9-2 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2022 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	K8S_MODULE_DEPLOY    = K8sClusterModuleType("deploy")
	K8S_MODULE_POD       = K8sClusterModuleType("pod")
	K8S_MODULE_CONTAINER = K8sClusterModuleType("container")
	K8S_MODULE_NS        = K8sClusterModuleType("ns")
	K8S_MODULE_NODE      = K8sClusterModuleType("node")
	K8S_MODULE_DAEMONSET = K8sClusterModuleType("daemonset")
)
View Source
const (
	PERIOD             = 60
	UNIT_AVERAGE       = "Average"
	DEFAULT_STATISTICS = "Average,Minimum,Maximum"
	UNIT_PERCENT       = "Percent"
	UNIT_BPS           = "bps"
	UNIT_MBPS          = "Mbps"
	UNIT_BYTEPS        = "Bps"
	UNIT_CPS           = "cps"
	UNIT_COUNT         = "count"
	UNIT_MEM           = "byte"
	UNIT_MSEC          = "ms"
	UNIT_COUNT_SEC     = "count/s"
	UNIT_BYTES         = "byte"

	SERVER_METRIC_NAMESPACE = "QCE/CVM"
	REDIS_METRIC_NAMESPACE  = "QCE/REDIS"
	RDS_METRIC_NAMESPACE    = "QCE/CDB"

	//ESC监控指标
	INFLUXDB_FIELD_CPU_USAGE           = "vm_cpu.usage_active"
	INFLUXDB_FIELD_MEM_USAGE           = "vm_mem.used_percent"
	INFLUXDB_FIELD_DISK_USAGE          = "vm_disk.used_percent"
	INFLUXDB_FIELD_DISK_READ_BPS       = "vm_diskio.read_bps"
	INFLUXDB_FIELD_DISK_WRITE_BPS      = "vm_diskio.write_bps"
	INFLUXDB_FIELD_DISK_READ_IOPS      = "vm_diskio.read_iops"
	INFLUXDB_FIELD_DISK_WRITE_IOPS     = "vm_diskio.write_iops"
	INFLUXDB_FIELD_NET_BPS_RX          = "vm_netio.bps_recv"
	INFLUXDB_FIELD_NET_BPS_RX_INTERNET = INFLUXDB_FIELD_NET_BPS_RX + ",net_type=internet"
	INFLUXDB_FIELD_NET_BPS_RX_INTRANET = INFLUXDB_FIELD_NET_BPS_RX + ",net_type=intranet"
	INFLUXDB_FIELD_NET_BPS_TX          = "vm_netio.bps_sent"
	INFLUXDB_FIELD_NET_BPS_TX_INTERNET = INFLUXDB_FIELD_NET_BPS_TX + ",net_type=internet"
	INFLUXDB_FIELD_NET_BPS_TX_INTRANET = INFLUXDB_FIELD_NET_BPS_TX + ",net_type=intranet"
	INFLUXDB_FIELD_WANOUTTRAFFIC       = "vm_eipio.bps_out"
	INFLUXDB_FIELD_WANINTRAFFIC        = "vm_eipio.bps_in"
	INFLUXDB_FIELD_WANOUTPKG           = "vm_eipio.pps_out"
	INFLUXDB_FIELD_WANINPKG            = "vm_eipio.pps_in"

	//RDS监控指标
	INFLUXDB_FIELD_RDS_CPU_USAGE            = "rds_cpu.usage_active"
	INFLUXDB_FIELD_RDS_MEM_USAGE            = "rds_mem.used_percent"
	INFLUXDB_FIELD_RDS_NET_BPS_RX           = "rds_netio.bps_recv"
	INFLUXDB_FIELD_RDS_NET_BPS_RX_INTRANET  = INFLUXDB_FIELD_RDS_NET_BPS_RX + ",net_type=intranet"
	INFLUXDB_FIELD_RDS_NET_BPS_RX_MYSQL     = INFLUXDB_FIELD_RDS_NET_BPS_RX + ",server_type=mysql"
	INFLUXDB_FIELD_RDS_NET_BPS_RX_SQLSERVER = INFLUXDB_FIELD_RDS_NET_BPS_RX + ",server_type=sqlserver"
	INFLUXDB_FIELD_RDS_NET_BPS_TX           = "rds_netio.bps_sent"
	INFLUXDB_FIELD_RDS_NET_BPS_TX_INTRANET  = INFLUXDB_FIELD_RDS_NET_BPS_TX + ",net_type=intranet"
	INFLUXDB_FIELD_RDS_NET_BPS_TX_MYSQL     = INFLUXDB_FIELD_RDS_NET_BPS_TX + ",server_type=mysql"
	INFLUXDB_FIELD_RDS_NET_BPS_TX_SQLSERVER = INFLUXDB_FIELD_RDS_NET_BPS_TX + ",server_type=sqlserver"
	INFLUXDB_FIELD_RDS_DISK_USAGE           = "rds_disk.used_percent"
	INFLUXDB_FIELD_RDS_DISK_READ_BPS        = "rds_diskio.read_bps"
	INFLUXDB_FIELD_RDS_DISK_WRITE_BPS       = "rds_diskio.write_bps"
	INFLUXDB_FIELD_RDS_DISK_IO_PERSENT      = "rds_diskio.used_percent"
	INFLUXDB_FIELD_RDS_CONN_COUNT           = "rds_conn.used_count"
	INFLUXDB_FIELD_RDS_CONN_ACTIVE          = "rds_conn.active_count"
	INFLUXDB_FIELD_RDS_CONN_USAGE           = "rds_conn.used_percent"
	INFLUXDB_FIELD_RDS_CONN_FAILED          = "rds_conn.failed_count"

	INFLUXDB_FIELD_RDS_QPS              = "rds_qps.query_qps"
	INFLUXDB_FIELD_RDS_TPS              = "rds_tps.trans_qps"
	INFLUXDB_FIELD_RDS_INNODB_REDA_BPS  = "rds_innodb.read_bps"
	INFLUXDB_FIELD_RDS_INNODB_WRITE_BPS = "rds_innodb.write_bps"

	//REDIS监控指标
	INFLUXDB_FIELD_REDIS_CPU_USAGE      = "dcs_cpu.usage_active"
	INFLUXDB_FIELD_REDIS_MEM_USAGE      = "dcs_mem.used_percent"
	INFLUXDB_FIELD_REDIS_NET_BPS_RX     = "dcs_netio.bps_recv"
	INFLUXDB_FIELD_REDIS_NET_BPS_TX     = "dcs_netio.bps_sent"
	INFLUXDB_FIFLD_REDIS_CONN_USAGE     = "dcs_conn.used_percent"
	INFLUXDB_FIFLD_REDIS_OPT_SES        = "dcs_instantopt.opt_sec"
	INFLUXDB_FIFLD_REDIS_CACHE_KEYS     = "dcs_cachekeys.key_count"
	INFLUXDB_FIFLD_REDIS_CACHE_EXP_KEYS = INFLUXDB_FIFLD_REDIS_CACHE_KEYS + ",exp=expire"
	INFLUXDB_FIFLD_REDIS_DATA_MEM_USAGE = "dcs_datamem.used_byte"
	INFLUXDB_FIFLD_REDIS_SERVER_LOAD    = "dcs_cpu.server_load"
	INFLUXDB_FIFLD_REDIS_CONN_ERRORS    = "dcs_conn.errors"

	//对象存储OSS监控指标
	INFLUXDB_FIELD_OSS_NET_BPS_RX          = "oss_netio.bps_recv"
	INFLUXDB_FIELD_OSS_NET_BPS_RX_INTERNET = INFLUXDB_FIELD_OSS_NET_BPS_RX + ",net_type=internet"
	INFLUXDB_FIELD_OSS_NET_BPS_RX_INTRANET = INFLUXDB_FIELD_OSS_NET_BPS_RX + ",net_type=intranet"
	INFLUXDB_FIELD_OSS_NET_BPS_TX          = "oss_netio.bps_sent"
	INFLUXDB_FIELD_OSS_NET_BPS_TX_INTERNET = INFLUXDB_FIELD_OSS_NET_BPS_TX + ",net_type=internet"
	INFLUXDB_FIELD_OSS_NET_BPS_TX_INTRANET = INFLUXDB_FIELD_OSS_NET_BPS_TX + ",net_type=intranet"
	INFLUXDB_FIELD_OSS_LATECY              = "oss_latency.req_late"
	INFLUXDB_FIELD_OSS_LATECY_GET          = INFLUXDB_FIELD_OSS_LATECY + ",request=get"
	INFLUXDB_FIELD_OSS_LATECY_POST         = INFLUXDB_FIELD_OSS_LATECY + ",request=post"
	INFLUXDB_FIELD_OSS_REQ_COUNT           = "oss_req.req_count"
	INFLUXDB_FIELD_OSS_REQ_COUNT_GET       = INFLUXDB_FIELD_OSS_REQ_COUNT + ",request=get"
	INFLUXDB_FIELD_OSS_REQ_COUNT_POST      = INFLUXDB_FIELD_OSS_REQ_COUNT + ",request=post"
	INFLUXDB_FIELD_OSS_REQ_COUNT_5XX       = INFLUXDB_FIELD_OSS_REQ_COUNT + ",request=5xx"
	INFLUXDB_FIELD_OSS_REQ_COUNT_4XX       = INFLUXDB_FIELD_OSS_REQ_COUNT + ",request=4xx"

	//负载均衡监控指标
	INFLUXDB_FIELD_ELB_NET_BPS_RX      = "haproxy.bin"
	INFLUXDB_FIELD_ELB_NET_BPS_TX      = "haproxy.bout"
	INFLUXDB_FIELD_ELB_REQ_RATE        = "haproxy.req_rate,request=http"
	INFLUXDB_FIELD_ELB_CONN_RATE       = "haproxy.conn_rate,request=tcp"
	INFLUXDB_FIELD_ELB_DREQ_COUNT      = "haproxy.dreq,request=http"
	INFLUXDB_FIELD_ELB_DCONN_COUNT     = "haproxy.dcon,request=tcp"
	INFLUXDB_FIELD_ELB_HRSP_COUNT      = "haproxy.hrsp_Nxx"
	INFLUXDB_FIELD_ELB_HRSP_COUNT_2XX  = INFLUXDB_FIELD_ELB_HRSP_COUNT + ",request=2xx"
	INFLUXDB_FIELD_ELB_HRSP_COUNT_3XX  = INFLUXDB_FIELD_ELB_HRSP_COUNT + ",request=3xx"
	INFLUXDB_FIELD_ELB_HRSP_COUNT_4XX  = INFLUXDB_FIELD_ELB_HRSP_COUNT + ",request=4xx"
	INFLUXDB_FIELD_ELB_HRSP_COUNT_5XX  = INFLUXDB_FIELD_ELB_HRSP_COUNT + ",request=5xx"
	INFLUXDB_FIELD_ELB_CHC_STATUS      = "haproxy.check_status"
	INFLUXDB_FIELD_ELB_CHC_CODE        = "haproxy.check_code"
	INFLUXDB_FIELD_ELB_LAST_CHC        = "haproxy.last_chk"
	INFLUXDB_FIELD_ELB_SNAT_PORT       = "haproxy.used_snat_port"
	INFLUXDB_FIELD_ELB_SNAT_CONN_COUNT = "haproxy.snat_conn_count"

	INFLUXDB_FIELD_K8S_CLUSTER_CPU_USAGE       = "k8s_cluster.cpu_used_percent"
	INFLUXDB_FIELD_K8S_CLUSTER_MEM_USAGE       = "k8s_cluster.mem_used_percent"
	INFLUXDB_FIELD_K8S_CLUSTER_ALLOCATABLE_POD = "k8s_cluster.allocatable_pod"
	INFLUXDB_FIELD_K8S_CLUSTER_TOTAL_CPUCORE   = "k8s_cluster.total_cpu"
	INFLUXDB_FIELD_K8S_CLUSTER_CPU_ALLOCATED   = "k8s_cluster.cpu_allocated_percent"

	INFLUXDB_FIELD_K8S_DEPLOY_CPU_USAGE               = "k8s_deploy.cpu_used_percent"
	INFLUXDB_FIELD_K8S_DEPLOY_MEM_USAGE               = "k8s_deploy.mem_used_percent"
	INFLUXDB_FIELD_K8S_DEPLOY_RESTART_TOTAL           = "k8s_deploy.restart_total"
	INFLUXDB_FIELD_K8S_DEPLOY_NET_BPS_RX              = "k8s_deploy.bps_recv"
	INFLUXDB_FIELD_K8S_DEPLOY_NET_BPS_RX_INTERNET     = INFLUXDB_FIELD_NET_BPS_RX + ",net_type=internet"
	INFLUXDB_FIELD_K8S_DEPLOY_NET_BPS_RX_INTRANET     = INFLUXDB_FIELD_NET_BPS_RX + ",net_type=intranet"
	INFLUXDB_FIELD_K8S_DEPLOY_NET_BPS_TX              = "k8s_deploy.bps_sent"
	INFLUXDB_FIELD_K8S_DEPLOY_NET_BPS_TX_INTERNET     = INFLUXDB_FIELD_NET_BPS_TX + ",net_type=internet"
	INFLUXDB_FIELD_K8S_DEPLOY_NET_BPS_TX_INTRANET     = INFLUXDB_FIELD_NET_BPS_TX + ",net_type=intranet"
	INFLUXDB_FIELD_K8S_POD_OOM_CONTAINER_COUNT        = "k8s_deploy.pod_oom_total"
	INFLUXDB_FIELD_K8S_POD_RESTARTING_CONTAINER_COUNT = "k8s_deploy.pod_restarting_total"

	INFLUXDB_FIELD_K8S_POD_CPU_USAGE     = "k8s_pod.cpu_used_percent"
	INFLUXDB_FIELD_K8S_POD_MEM_USAGE     = "k8s_pod.mem_used_percent"
	INFLUXDB_FIELD_K8S_POD_RESTART_TOTAL = "k8s_pod.restart_total"

	INFLUXDB_FIELD_K8S_CONTAINER_CPU_USAGE  = "k8s_container.cpu_used_percent"
	INFLUXDB_FIELD_K8S_CONTAINER_MEM_USAGE  = "k8s_container.mem_used_percent"
	INFLUXDB_FIELD_K8S_CONTAINER_NET_BPS_RX = "k8s_container.net_bps_recv"
	INFLUXDB_FIELD_K8S_CONTAINER_NET_BPS_TX = "k8s_container.net_bps_sent"

	INFLUXDB_FIELD_K8S_NODE_CPU_USAGE           = "k8s_node.cpu_used_percent"
	INFLUXDB_FIELD_K8S_NODE_MEM_USAGE           = "k8s_node.mem_used_percent"
	INFLUXDB_FIELD_K8S_NODE_DISK_USAGE          = "k8s_node.disk_used_percent"
	INFLUXDB_FIELD_K8S_NODE_NET_BPS_RX          = "k8s_node.bps_recv"
	INFLUXDB_FIELD_K8S_NODE_NET_BPS_RX_INTERNET = INFLUXDB_FIELD_NET_BPS_RX + ",net_type=internet"
	INFLUXDB_FIELD_K8S_NODE_NET_BPS_RX_INTRANET = INFLUXDB_FIELD_NET_BPS_RX + ",net_type=intranet"
	INFLUXDB_FIELD_K8S_NODE_NET_BPS_TX          = "k8s_node.bps_sent"
	INFLUXDB_FIELD_K8S_NODE_NET_BPS_TX_INTERNET = INFLUXDB_FIELD_NET_BPS_TX + ",net_type=internet"
	INFLUXDB_FIELD_K8S_NODE_NET_BPS_TX_INTRANET = INFLUXDB_FIELD_NET_BPS_TX + ",net_type=intranet"
	INFLUXDB_FIELD_K8S_NODE_POD_RESTART_TOTAL   = "k8s_node.pod_restart_total"

	KEY_VMS   = "vms"
	KEY_CPUS  = "cpus"
	KEY_MEMS  = "mems"
	KEY_DISKS = "disks"
)
View Source
const (
	KEY_LIMIT  = "limit"
	KEY_ADMIN  = "admin"
	KEY_USABLE = "usable"
	DETAILS    = "details"
	KEY_SCOPE  = "scope"
)
View Source
const (
	TYPE_VIRTUALMACHINE = "VirtualMachine"
	TYPE_HOSTSYSTEM     = "HostSystem"
)

Variables

View Source
var AddTags = map[string]string{
	"source": "cloudmon",
}
View Source
var AlertRecordHistoryFields = []string{"res_num"}
View Source
var AlertRecordHistoryTags = map[string]string{
	"alert_name":     "alert_name",
	"alert_id":       "alert_id",
	"domain_id":      "domain_id",
	"project_domain": "project_domain",
	"tenant_id":      "tenant_id",
	"tenant":         "tenant",
	"res_type":       "res_type",
}
View Source
var CloudAccountFields = []string{"balance"}
View Source
var CloudAccountTags = map[string]string{
	"id":             "cloudaccount_id",
	"name":           "cloudaccount_name",
	"brand":          "brand",
	"domain_id":      "domain_id",
	"project_domain": "project_domain",
}
View Source
var ElbTags = map[string]string{
	"host":           "host",
	"host_id":        "host_id",
	"id":             "elb_id",
	"ips":            "elb_ip",
	"name":           "elb_name",
	"zone":           "zone",
	"zone_id":        "zone_id",
	"zone_ext_id":    "zone_ext_id",
	"os_type":        "os_type",
	"status":         "status",
	"region":         "region",
	"cloudregion":    "cloudregion",
	"cloudregion_id": "cloudregion_id",
	"tenant":         "tenant",
	"tenant_id":      "tenant_id",
	"brand":          "brand",
	"domain_id":      "domain_id",
	"project_domain": "project_domain",
}
View Source
var HostTags = map[string]string{
	"id":             "host_id",
	"ips":            "host_ip",
	"name":           "host",
	"zone":           "zone",
	"zone_id":        "zone_id",
	"zone_ext_id":    "zone_ext_id",
	"os_type":        "os_type",
	"status":         "status",
	"cloudregion":    "cloudregion",
	"cloudregion_id": "cloudregion_id",
	"region_ext_id":  "region_ext_id",
	"tenant":         "tenant",
	"tenant_id":      "tenant_id",
	"brand":          "brand",
	"domain_id":      "domain_id",
	"project_domain": "project_domain",
	"account":        "account",
	"account_id":     "account_id",
}
View Source
var InstanceProviders = "Aliyun,Azure,Aws,Qcloud,VMWare,Huawei,Openstack,Ucloud,ZStack"
View Source
var K8sTags = map[string]string{
	"id":             "id",
	"name":           "name",
	"zone":           "zone",
	"zone_id":        "zone_id",
	"zone_ext_id":    "zone_ext_id",
	"status":         "status",
	"cloudregion":    "cloudregion",
	"cloudregion_id": "cloudregion_id",
	"region_ext_id":  "region_ext_id",
	"tenant":         "tenant",
	"tenant_id":      "tenant_id",
	"brand":          "brand",
	"provider":       "provider",
	"domain_id":      "domain_id",
	"project_domain": "project_domain",
}
View Source
var OssTags = map[string]string{
	"host":           "host",
	"host_id":        "host_id",
	"id":             "oss_id",
	"ips":            "oss_ip",
	"name":           "oss_name",
	"zone":           "zone",
	"zone_id":        "zone_id",
	"zone_ext_id":    "zone_ext_id",
	"os_type":        "os_type",
	"status":         "status",
	"cloudregion":    "cloudregion",
	"cloudregion_id": "cloudregion_id",
	"region_ext_id":  "region_ext_id",
	"tenant":         "tenant",
	"tenant_id":      "tenant_id",
	"brand":          "brand",
	"domain_id":      "domain_id",
	"project_domain": "project_domain",
}
View Source
var OtherHostTag = map[string]string{
	"source":   "cloudmon",
	"res_type": "host",
	"is_vm":    "false",
}
View Source
var OtherTags = map[string]string{
	"source": "cloudmon",
}
View Source
var OtherVmTags = map[string]string{
	"source":   "cloudmon",
	"res_type": "guest",
	"is_vm":    "true",
}
View Source
var RdsTags = map[string]string{
	"host":           "host",
	"host_id":        "host_id",
	"id":             "rds_id",
	"ips":            "rds_ip",
	"name":           "rds_name",
	"zone":           "zone",
	"zone_id":        "zone_id",
	"zone_ext_id":    "zone_ext_id",
	"os_type":        "os_type",
	"status":         "status",
	"cloudregion":    "cloudregion",
	"cloudregion_id": "cloudregion_id",
	"region_ext_id":  "region_ext_id",
	"tenant":         "tenant",
	"tenant_id":      "tenant_id",
	"brand":          "brand",
	"domain_id":      "domain_id",
	"project_domain": "project_domain",
}
View Source
var RedisTags = map[string]string{
	"host":           "host",
	"host_id":        "host_id",
	"id":             "redis_id",
	"ips":            "redis_ip",
	"name":           "redis_name",
	"zone":           "zone",
	"zone_id":        "zone_id",
	"zone_ext_id":    "zone_ext_id",
	"os_type":        "os_type",
	"status":         "status",
	"cloudregion":    "cloudregion",
	"cloudregion_id": "cloudregion_id",
	"region_ext_id":  "region_ext_id",
	"tenant":         "tenant",
	"tenant_id":      "tenant_id",
	"brand":          "brand",
	"domain_id":      "domain_id",
	"project_domain": "project_domain",
}
View Source
var ServerPairs = []string{"vcpu_count", "vmem_size", "disk"}
View Source
var ServerTags = map[string]string{
	"host":             "host",
	"host_id":          "host_id",
	"id":               "vm_id",
	"ips":              "vm_ip",
	"name":             "vm_name",
	"zone":             "zone",
	"zone_id":          "zone_id",
	"zone_ext_id":      "zone_ext_id",
	"os_type":          "os_type",
	"status":           "status",
	"cloudregion":      "cloudregion",
	"cloudregion_id":   "cloudregion_id",
	"region_ext_id":    "region_ext_id",
	"tenant":           "tenant",
	"tenant_id":        "tenant_id",
	"brand":            "brand",
	"scaling_group_id": "vm_scaling_group_id",
	"domain_id":        "domain_id",
	"project_domain":   "project_domain",
	"account":          "account",
	"account_id":       "account_id",
}

server的key-value对应保存时的Tags和Pairs var ServerTags = []string{"host", "host_id", "vm_id", "vm_ip", "vm_name", "zone", "zone_id", "zone_ext_id",

"hypervisor", "os_type", "status", "region", "region_id", "region_ext_id", "tenant", "tenant_id", "brand", "name"}
View Source
var StorageTags = map[string]string{
	"id":             "storage_id",
	"name":           "storage_name",
	"zone":           "zone",
	"zone_id":        "zone_id",
	"zone_ext_id":    "zone_ext_id",
	"status":         "status",
	"cloudregion":    "cloudregion",
	"cloudregion_id": "cloudregion_id",
	"region_ext_id":  "region_ext_id",
	"brand":          "brand",
	"domain_id":      "domain_id",
	"project_domain": "project_domain",
}

Functions

func CollectRegionMetricAsync

func CollectRegionMetricAsync(asynCount int, region cloudprovider.ICloudRegion,
	servers []jsonutils.JSONObject, report ICloudReport) error

func CustomizeRunFunc

func CustomizeRunFunc(ctx context.Context, factory ICloudReportFactory, provider *SProvider,
	session *mcclient.ClientSession)

func FillVMCapacity

func FillVMCapacity(server *jsonutils.JSONDict) (influxdb.SMetricData, error)

组装server相关capability

func GetMeasurement

func GetMeasurement(action string, influxDbSpec string) (measurement string)

func JsonToMetric

func JsonToMetric(obj *jsonutils.JSONDict, name string, tags map[string]string, metrics []string) (influxdb.SMetricData, error)

func ListAllResources

func ListAllResources(manager modulebase.Manager, session *mcclient.ClientSession,
	query *jsonutils.JSONDict) ([]jsonutils.JSONObject, error)

func ListK8sClusterModuleResources

func ListK8sClusterModuleResources(typ K8sClusterModuleType, clusterId string, session *mcclient.ClientSession, query *jsonutils.JSONDict) ([]jsonutils.JSONObject, error)

func MakePullMetricRoutineAtZeroPoint

func MakePullMetricRoutineAtZeroPoint(ctx context.Context, factory ICloudReportFactory, provider *SProvider,
	closeChan chan struct{}, interval time.Duration, run runFunc)

func MakePullMetricRoutineWithDur

func MakePullMetricRoutineWithDur(ctx context.Context, factory ICloudReportFactory, provider *SProvider, closeChan chan struct{}, interval time.Duration, run runFunc)

func ParseTimeStr

func ParseTimeStr(startTime, endTime string) (since, util time.Time, err error)

func RegisterFactory

func RegisterFactory(factory ICloudReportFactory)

func RegisterK8sClusterHelper

func RegisterK8sClusterHelper(helper IK8sClusterMetricHelper)

func ReportCloudMetricOfoperatorType

func ReportCloudMetricOfoperatorType(operatorType string, session *mcclient.ClientSession,
	args *o.ReportOptions) error

func ReportConnectCloudproviderMetric

func ReportConnectCloudproviderMetric(ctx context.Context, provider jsonutils.JSONObject,
	closeChan chan struct{}) error

func ReportCustomizeCloudMetric

func ReportCustomizeCloudMetric(operatorType string, session *mcclient.ClientSession, args *o.ReportOptions) error

func SendMetrics

func SendMetrics(s *mcclient.ClientSession, metrics []influxdb.SMetricData, debug bool, database string) error

func SubstringAfter

func SubstringAfter(str, separator string) string

get substring from str after separator

func SubstringBefore

func SubstringBefore(str, separator string) string

get substring from str before separator

func SubstringBetween

func SubstringBetween(str, open, close string) string

get a substring from str between[open,close)

func TimeRangeFromArgs

func TimeRangeFromArgs(args *o.ReportOptions) (since, until time.Time, err error)

Types

type CloudReportBase

type CloudReportBase struct {
	SProvider *SProvider
	Session   *mcclient.ClientSession
	Args      *options.ReportOptions
	Operator  string
	Impl      ICloudReportK8s
}

func (*CloudReportBase) AddMetricTag

func (self *CloudReportBase) AddMetricTag(metric *influxdb.SMetricData, tags map[string]string)

func (*CloudReportBase) CollectRegionMetric

func (self *CloudReportBase) CollectRegionMetric(region cloudprovider.ICloudRegion,
	servers []jsonutils.JSONObject) error

func (*CloudReportBase) CollectRegionMetricOfK8sModules

func (self *CloudReportBase) CollectRegionMetricOfK8sModules(region cloudprovider.ICloudRegion,
	clusters []jsonutils.JSONObject) error

func (*CloudReportBase) GetAllCloudAccount

func (self *CloudReportBase) GetAllCloudAccount(manager modulebase.Manager) ([]jsonutils.JSONObject, error)

func (*CloudReportBase) GetAllHostOfThisProvider

func (self *CloudReportBase) GetAllHostOfThisProvider(manager modulebase.Manager) ([]jsonutils.JSONObject, error)

func (*CloudReportBase) GetAllRegionOfServers

func (self *CloudReportBase) GetAllRegionOfServers(servers []jsonutils.JSONObject,
	providerInstance cloudprovider.ICloudProvider) ([]cloudprovider.
	ICloudRegion, map[string][]jsonutils.JSONObject, error)

func (*CloudReportBase) GetAllStorage

func (self *CloudReportBase) GetAllStorage(manager modulebase.Manager) ([]jsonutils.JSONObject, error)

func (*CloudReportBase) GetAllserverOfThisProvider

func (self *CloudReportBase) GetAllserverOfThisProvider(manager modulebase.Manager, query *jsonutils.JSONDict) ([]jsonutils.JSONObject, error)

func (*CloudReportBase) GetResourceById

func (self *CloudReportBase) GetResourceById(id string, manager modulebase.Manager) (jsonutils.JSONObject, error)

func (*CloudReportBase) GetResourceByOperator

func (self *CloudReportBase) GetResourceByOperator() ([]jsonutils.JSONObject, error)

func (*CloudReportBase) InitProviderInstance

func (self *CloudReportBase) InitProviderInstance() (cloudprovider.ICloudProvider, error)

func (*CloudReportBase) ListAllResource

func (self *CloudReportBase) ListAllResource(manager modulebase.Manager,
	query jsonutils.JSONObject) ([]jsonutils.JSONObject, error)

func (*CloudReportBase) ListAllResources

func (self *CloudReportBase) ListAllResources(manager modulebase.Manager,
	query *jsonutils.JSONDict) ([]jsonutils.JSONObject, error)

func (*CloudReportBase) NewMetricFromJson

func (self *CloudReportBase) NewMetricFromJson(server jsonutils.JSONObject) (influxdb.SMetricData, error)

func (*CloudReportBase) Report

func (self *CloudReportBase) Report() error

type CommonReportFactory

type CommonReportFactory struct {
}

func (*CommonReportFactory) MyRoutineInteval

func (co *CommonReportFactory) MyRoutineInteval(monOptions options.CloudMonOptions) time.Duration

type DimensionId

type DimensionId struct {
	LocalId string
	ExtId   string
}

type ICloudReport

type ICloudReport interface {
	Report() error
	GetAllserverOfThisProvider(manager modulebase.Manager, query *jsonutils.JSONDict) ([]jsonutils.JSONObject, error)
	InitProviderInstance() (cloudprovider.ICloudProvider, error)
	GetAllRegionOfServers(servers []jsonutils.JSONObject, providerInstance cloudprovider.ICloudProvider) (
		[]cloudprovider.ICloudRegion, map[string][]jsonutils.JSONObject, error)
	CollectRegionMetric(region cloudprovider.ICloudRegion,
		servers []jsonutils.JSONObject) error
}

type ICloudReportFactory

type ICloudReportFactory interface {
	NewCloudReport(provider *SProvider, session *mcclient.ClientSession, args *options.ReportOptions,
		operatorType string) ICloudReport
	GetId() string
	MyRoutineInteval(monOptions options.CloudMonOptions) time.Duration
}

func GetCloudReportFactory

func GetCloudReportFactory(provider string) (ICloudReportFactory, error)

type ICloudReportK8s

type ICloudReportK8s interface {
	CollectRegionMetricOfK8sModules(region cloudprovider.ICloudRegion,
		clusters []jsonutils.JSONObject) error
	CollectK8sModuleMetric(region cloudprovider.ICloudRegion, cluster jsonutils.JSONObject,
		helper IK8sClusterModuleHelper) error
}

type IK8sClusterMetricHelper

type IK8sClusterMetricHelper interface {
	HelperBrand() string
	MyModuleHelper() map[K8sClusterModuleType]IK8sClusterModuleHelper
	RegisterModuleHelper(helper IK8sClusterModuleHelper)
}

func GetK8sClusterHelper

func GetK8sClusterHelper(brand string) (IK8sClusterMetricHelper, error)

type IK8sClusterModuleHelper

type IK8sClusterModuleHelper interface {
	MyModuleType() K8sClusterModuleType
	/**
	DimensionId.LocalId 由「,」分割表示多个组装后Dimension
	LocalId和ExtId 「,」分割长度需一致
	*/
	MyResDimensionId() DimensionId
	MyNamespaceAndMetrics() (string, map[string][]string)
	MyResourceFilterQuery(res jsonutils.JSONObject) jsonutils.JSONObject
}

type IRoutineFactory

type IRoutineFactory interface {
	MyRoutineFunc() RoutineFunc
}

type K8sClusterMetricBaseHelper

type K8sClusterMetricBaseHelper struct {
	ModuleHelper map[K8sClusterModuleType]IK8sClusterModuleHelper
}

func (*K8sClusterMetricBaseHelper) MyModuleHelper

func (*K8sClusterMetricBaseHelper) RegisterModuleHelper

func (h *K8sClusterMetricBaseHelper) RegisterModuleHelper(helper IK8sClusterModuleHelper)

type K8sClusterModuleQueryHelper

type K8sClusterModuleQueryHelper struct {
}

func (K8sClusterModuleQueryHelper) MyResourceFilterQuery

type K8sClusterModuleType

type K8sClusterModuleType string

type MonType

type MonType string
const (
	SERVER       MonType = "server"
	HOST         MonType = "host"
	REDIS        MonType = "redis"
	RDS          MonType = "rds"
	OSS          MonType = "oss"
	ELB          MonType = "elb"
	CLOUDACCOUNT MonType = "cloudaccount"
	STORAGE      MonType = "storage"
	ALERT_RECORD MonType = "alertRecord"

	PING_PROBE MonType = "ping_probe"
	USAGE      MonType = "usage"

	K8S        MonType = "k8s"
	K8S_DEPLOY         = MonType(K8S_MODULE_DEPLOY)
	K8S_POD            = MonType(K8S_MODULE_POD)
	K8S_NODE           = MonType(K8S_MODULE_NODE)

	ALL_RESOURCE MonType = "all"
)

type RoutineFunc

type RoutineFunc func(ctx context.Context, factory ICloudReportFactory, provider *SProvider, closeChan chan struct{},
	interval time.Duration, run runFunc)

type SProvider

type SProvider struct {
	compute.CloudproviderDetails
}

func (*SProvider) Validate

func (s *SProvider) Validate() error

Jump to

Keyboard shortcuts

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