healthcheck

package
v1.1.3 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (

	// Prometheus API
	PrometheusAvgBackupFailedRatioV1 = `` /* 366-byte string literal not displayed */

	PrometheusAvgBackupFailedRatioV2 = `` /* 374-byte string literal not displayed */

	PrometheusStatisticFailedRatioV1 = `
	1-(sum(mysqlupdbstat{instance=~"%s",type="dbupstatus"})/count(mysqlupdbstat{instance=~"%s",type="dbupstatus"}))
	`
	PrometheusStatisticFailedRatioV2 = `
	1-(sum(mysqlupdbstat{node_name=~"%s",type="dbupstatus"})/count(mysqlupdbstat{node_name=~"%s",type="dbupstatus"}))
	`
	PrometheusCPUUsageV1 = `` /* 582-byte string literal not displayed */

	PrometheusCPUUsageV2 = `` /* 620-byte string literal not displayed */

	PrometheusFileSystemV1 = `
		node_filesystem_files{instance=~"%s",fstype!~"rootfs|selinuxfs|autofs|rpc_pipefs|tmpfs"}
    `
	PrometheusFileSystemV2 = `
		node_filesystem_files{node_name=~"%s",fstype!~"rootfs|selinuxfs|autofs|rpc_pipefs|tmpfs"}
    `
	PrometheusIOUtilV1 = `` /* 138-byte string literal not displayed */

	PrometheusIOUtilV2 = `` /* 292-byte string literal not displayed */

	PrometheusDiskCapacityV1 = `` /* 233-byte string literal not displayed */

	PrometheusDiskCapacityV2 = `` /* 603-byte string literal not displayed */

	PrometheusConnectionUsageV1 = `` /* 367-byte string literal not displayed */

	PrometheusConnectionUsageV2 = `` /* 386-byte string literal not displayed */

	PrometheusAverageActiveSessionPercentsV1 = `` /* 350-byte string literal not displayed */

	PrometheusAverageActiveSessionPercentsV2 = `` /* 374-byte string literal not displayed */

	PrometheusCacheMissRatioV1 = `` /* 347-byte string literal not displayed */

	PrometheusCacheMissRatioV2 = `` /* 367-byte string literal not displayed */

	// query
	MonitorMySQLQuery = `` /* 980-byte string literal not displayed */

	MonitorClickhouseQuery = `` /* 1250-byte string literal not displayed */

)
View Source
const (
	SlowQueryNumLimit = 100
)

Variables

This section is empty.

Functions

func NewApplicationMySQLRepo added in v1.1.0

func NewApplicationMySQLRepo(operationInfo healthcheck.OperationInfo, conn *mysql.Conn) healthcheck.ApplicationMySQLRepo

NewApplicationMySQLRepo returns a new healthcheck.ApplicationMySQLRepo

func NewDASRepo added in v1.1.0

func NewDASRepo(db middleware.Pool) healthcheck.DASRepo

NewDASRepo returns healthcheck.DASRepo with given middleware.Pool

func NewDASRepoWithGlobal added in v1.1.0

func NewDASRepoWithGlobal() healthcheck.DASRepo

NewDASRepoWithGlobal returns healthcheck.DASRepo with global mysql pool

func NewDefaultEngine

func NewDefaultEngine(operationInfo healthcheck.OperationInfo,
	dasRepo healthcheck.DASRepo,
	applicationMySQLRepo healthcheck.ApplicationMySQLRepo,
	prometheusRepo healthcheck.PrometheusRepo,
	queryRepo healthcheck.QueryRepo) healthcheck.Engine

NewDefaultEngine returns a new healthcheck.DefaultEngine

func NewDefaultItemConfig

func NewDefaultItemConfig(itemName string, itemWeight int, lowWatermark float64, highWatermark float64, unit float64,
	scoreDeductionPerUnitHigh float64, maxScoreDeductionHigh float64, scoreDeductionPerUnitMedium float64, maxScoreDeductionMedium float64) healthcheck.ItemConfig

NewDefaultItemConfig returns new healthcheck.ItemConfig

func NewEmptyDefaultEngineConfig

func NewEmptyDefaultEngineConfig() healthcheck.EngineConfig

NewEmptyDefaultEngineConfig returns a new empty DefaultItemConfig

func NewEmptyDefaultItemConfig

func NewEmptyDefaultItemConfig() healthcheck.ItemConfig

NewEmptyDefaultItemConfig returns a new healthcheck.DefaultItemConfig with empty value

func NewEmptyOperationHistory added in v1.1.1

func NewEmptyOperationHistory() healthcheck.OperationHistory

NewEmptyOperationHistory returns healthcheck.OperationHistory with empty value

func NewEmptyPrometheusData added in v1.1.0

func NewEmptyPrometheusData() healthcheck.PrometheusData

func NewEmptyTable added in v1.1.0

func NewEmptyTable() healthcheck.Table

func NewFileSystem added in v1.1.0

func NewFileSystem(mountPoint, device string) healthcheck.FileSystem

func NewOperationHistory added in v1.1.1

func NewOperationHistory(id, mySQLServerID int, hostIP string, portNum int, startTime, endTime time.Time, step, status int, message string,
	delFlag int, createTime, lastUpdateTime time.Time) healthcheck.OperationHistory

NewOperationHistory returns healthcheck.OperationHistory

func NewOperationInfo

func NewOperationInfo(operationID int, user metadata.User, apps []metadata.App, mysqlServer metadata.MySQLServer, MonitorSystem metadata.MonitorSystem, startTime, endTime time.Time, step time.Duration) healthcheck.OperationInfo

NewOperationInfo returns a new healthcheck.OperationInfo

func NewPrometheusData added in v1.1.0

func NewPrometheusData(ts string, value float64) healthcheck.PrometheusData

func NewService

func NewService(repo healthcheck.DASRepo) healthcheck.Service

NewService returns a new *Service

func NewServiceWithDefault

func NewServiceWithDefault() healthcheck.Service

NewServiceWithDefault returns a new healthcheck.Service with default repository

func NewTable added in v1.1.0

func NewTable(db, name string, rows int, size float64) healthcheck.Table

Types

type ApplicationMySQLRepo added in v1.1.0

type ApplicationMySQLRepo struct {
	// contains filtered or unexported fields
}

func (*ApplicationMySQLRepo) Close added in v1.1.0

func (amr *ApplicationMySQLRepo) Close() error

Close closes the application mysql connection

func (*ApplicationMySQLRepo) GetDBName added in v1.1.0

func (amr *ApplicationMySQLRepo) GetDBName(tableNames []string) (string, error)

GetDBName gets the db name of given table names

func (*ApplicationMySQLRepo) GetLargeTables added in v1.1.0

func (amr *ApplicationMySQLRepo) GetLargeTables() ([]healthcheck.Table, error)

GetLargeTables gets the large tables

func (*ApplicationMySQLRepo) GetMySQLDirs added in v1.1.0

func (amr *ApplicationMySQLRepo) GetMySQLDirs() ([]string, error)

GetMySQLDirs gets the mysql directories

func (*ApplicationMySQLRepo) GetOperationInfo added in v1.1.0

func (amr *ApplicationMySQLRepo) GetOperationInfo() healthcheck.OperationInfo

GetOperationInfo returns the operation information

func (*ApplicationMySQLRepo) GetVariables added in v1.1.0

func (amr *ApplicationMySQLRepo) GetVariables(items []string) ([]healthcheck.Variable, error)

GetVariables gets db config with given items

type ClickhouseQueryRepo added in v1.1.0

type ClickhouseQueryRepo struct {
	// contains filtered or unexported fields
}

func NewClickhouseQueryRepo added in v1.1.0

func NewClickhouseQueryRepo(operationInfo healthcheck.OperationInfo, conn *clickhouse.Conn) *ClickhouseQueryRepo

NewClickhouseQueryRepo returns the new *ClickhouseQueryRepo

func (*ClickhouseQueryRepo) Close added in v1.1.0

func (cqr *ClickhouseQueryRepo) Close() error

Close closes the connection

func (*ClickhouseQueryRepo) GetOperationInfo added in v1.1.0

func (cqr *ClickhouseQueryRepo) GetOperationInfo() healthcheck.OperationInfo

GetOperationInfo returns the operation information

func (*ClickhouseQueryRepo) GetSlowQuery added in v1.1.0

func (cqr *ClickhouseQueryRepo) GetSlowQuery() ([]depquery.Query, error)

GetSlowQuery gets the slow query

type DASRepo added in v1.1.0

type DASRepo struct {
	Database middleware.Pool
}

DASRepo for health check

func (*DASRepo) Execute added in v1.1.0

func (dr *DASRepo) Execute(command string, args ...interface{}) (middleware.Result, error)

Execute executes given command and placeholders on the middleware

func (*DASRepo) GetHealthCheckHistories added in v1.1.1

func (dr *DASRepo) GetHealthCheckHistories(mysqlServerIDList []int, limit int) ([]healthcheck.OperationHistory, error)

GetOperationHistories gets operation histories from the middleware

func (*DASRepo) GetResultByOperationID added in v1.1.0

func (dr *DASRepo) GetResultByOperationID(operationID int) (healthcheck.Result, error)

GetResultByOperationID gets a Result by the operationID from the middleware

func (*DASRepo) InitOperation added in v1.1.0

func (dr *DASRepo) InitOperation(userID, mysqlServerID int, startTime, endTime time.Time, step time.Duration) (int, error)

InitOperation creates a testOperationInfo in the middleware

func (*DASRepo) IsRunning added in v1.1.0

func (dr *DASRepo) IsRunning(mysqlServerID int) (bool, error)

IsRunning gets status by the mysqlServerID from the middleware

func (*DASRepo) LoadEngineConfig added in v1.1.0

func (dr *DASRepo) LoadEngineConfig() (healthcheck.EngineConfig, error)

LoadEngineConfig loads engine config from the middleware

func (*DASRepo) SaveResult added in v1.1.0

func (dr *DASRepo) SaveResult(result healthcheck.Result) error

SaveResult saves the result in the middleware

func (*DASRepo) Transaction added in v1.1.0

func (dr *DASRepo) Transaction() (middleware.Transaction, error)

Transaction returns a middleware.Transaction that could execute multiple commands as a transaction

func (*DASRepo) UpdateAccuracyReviewByOperationID added in v1.1.0

func (dr *DASRepo) UpdateAccuracyReviewByOperationID(operationID int, review int) error

UpdateAccuracyReviewByOperationID updates the accuracyReview by the operationID in the middleware

func (*DASRepo) UpdateOperationStatus added in v1.1.0

func (dr *DASRepo) UpdateOperationStatus(operationID int, status int, message string) error

UpdateOperationStatus updates the status and message by the operationID in the middleware

type DefaultEngine

type DefaultEngine struct {
	// contains filtered or unexported fields
}

DefaultEngine work for health check module

func (*DefaultEngine) CheckAvgBackupFailedRatio added in v1.1.0

func (de *DefaultEngine) CheckAvgBackupFailedRatio() error

CheckAvgBackupFailedRatio checks the mysql backup information

func (*DefaultEngine) CheckStatisticFailedRatio added in v1.1.0

func (de *DefaultEngine) CheckStatisticFailedRatio() error

CheckStatisticFailedRatio checks the statistic of mysql

func (*DefaultEngine) GetOperationInfo added in v1.1.0

func (de *DefaultEngine) GetOperationInfo() healthcheck.OperationInfo

GetOperationInfo returns the operation information

func (*DefaultEngine) Run

func (de *DefaultEngine) Run()

Run runs healthcheck

type DefaultEngineConfig

type DefaultEngineConfig map[string]healthcheck.ItemConfig

DefaultEngineConfig is a map of DefaultItemConfig

func (DefaultEngineConfig) GetItemConfig added in v1.1.0

func (dec DefaultEngineConfig) GetItemConfig(item string) healthcheck.ItemConfig

GetItemConfig returns healthcheck.ItemConfig with given item name

func (DefaultEngineConfig) SetItemConfig added in v1.1.1

func (dec DefaultEngineConfig) SetItemConfig(item string, config healthcheck.ItemConfig)

SetItemConfig sets item config with given item and config

func (DefaultEngineConfig) Validate

func (dec DefaultEngineConfig) Validate() error

Validate validates if engine configuration is valid

type DefaultItemConfig

type DefaultItemConfig struct {
	ID                          int       `middleware:"id" json:"id"`
	ItemName                    string    `middleware:"item_name" json:"item_name"`
	ItemWeight                  int       `middleware:"item_weight" json:"item_weight"`
	LowWatermark                float64   `middleware:"low_watermark" json:"low_watermark"`
	HighWatermark               float64   `middleware:"high_watermark" json:"high_watermark"`
	Unit                        float64   `middleware:"unit" json:"unit"`
	ScoreDeductionPerUnitHigh   float64   `middleware:"score_deduction_per_unit_high" json:"score_deduction_per_unit_high"`
	MaxScoreDeductionHigh       float64   `middleware:"max_score_deduction_high" json:"max_score_deduction_high"`
	ScoreDeductionPerUnitMedium float64   `middleware:"score_deduction_per_unit_medium" json:"score_deduction_per_unit_medium"`
	MaxScoreDeductionMedium     float64   `middleware:"max_score_deduction_medium" json:"max_score_deduction_medium"`
	DelFlag                     int       `middleware:"del_flag" json:"del_flag"`
	CreateTime                  time.Time `middleware:"create_time" json:"create_time"`
	LastUpdateTime              time.Time `middleware:"last_update_time" json:"last_update_time"`
}

DefaultItemConfig include all data for a item

func (*DefaultItemConfig) GetCreateTime added in v1.1.0

func (dic *DefaultItemConfig) GetCreateTime() time.Time

GetCreateTime returns the create time

func (*DefaultItemConfig) GetDelFlag added in v1.1.0

func (dic *DefaultItemConfig) GetDelFlag() int

GetDelFlag returns the delete flag

func (*DefaultItemConfig) GetHighWatermark added in v1.1.0

func (dic *DefaultItemConfig) GetHighWatermark() float64

GetHighWatermark returns the high watermark

func (*DefaultItemConfig) GetID added in v1.1.0

func (dic *DefaultItemConfig) GetID() int

GetID returns the identity

func (*DefaultItemConfig) GetItemName added in v1.1.0

func (dic *DefaultItemConfig) GetItemName() string

GetItemName returns the item name

func (*DefaultItemConfig) GetItemWeight added in v1.1.0

func (dic *DefaultItemConfig) GetItemWeight() int

GetItemWeight returns the item weight

func (*DefaultItemConfig) GetLastUpdateTime added in v1.1.0

func (dic *DefaultItemConfig) GetLastUpdateTime() time.Time

GetLastUpdateTime returns the last update time

func (*DefaultItemConfig) GetLowWatermark added in v1.1.0

func (dic *DefaultItemConfig) GetLowWatermark() float64

GetLowWatermark returns the low watermark

func (*DefaultItemConfig) GetMaxScoreDeductionHigh added in v1.1.0

func (dic *DefaultItemConfig) GetMaxScoreDeductionHigh() float64

GetMaxScoreDeductionHigh returns the max score deduction high

func (*DefaultItemConfig) GetMaxScoreDeductionMedium added in v1.1.0

func (dic *DefaultItemConfig) GetMaxScoreDeductionMedium() float64

GetMaxScoreDeductionMedium returns the max score deduction medium

func (*DefaultItemConfig) GetScoreDeductionPerUnitHigh added in v1.1.0

func (dic *DefaultItemConfig) GetScoreDeductionPerUnitHigh() float64

GetScoreDeductionPerUnitHigh returns the score deduction per unit high

func (*DefaultItemConfig) GetScoreDeductionPerUnitMedium added in v1.1.0

func (dic *DefaultItemConfig) GetScoreDeductionPerUnitMedium() float64

GetScoreDeductionPerUnitMedium returns the score deduction per unit medium

func (*DefaultItemConfig) GetUnit added in v1.1.0

func (dic *DefaultItemConfig) GetUnit() float64

GetUnit returns the unit

type FileSystem added in v1.1.0

type FileSystem struct {
	MountPoint string `middleware:"mount_point" json:"mount_point"`
	Device     string `middleware:"device" json:"device"`
}

func (*FileSystem) GetDevice added in v1.1.0

func (fs *FileSystem) GetDevice() string

func (*FileSystem) GetMountPoint added in v1.1.0

func (fs *FileSystem) GetMountPoint() string

type GlobalVariable

type GlobalVariable struct {
	VariableName  string `middleware:"variable_name" json:"variable_name"`
	VariableValue string `middleware:"variable_value" json:"variable_value"`
}

GlobalVariable encapsulates k-v pairs for global variable

func NewEmptyGlobalVariable

func NewEmptyGlobalVariable() *GlobalVariable

NewEmptyGlobalVariable returns a new *GlobalVariables

func NewGlobalVariable

func NewGlobalVariable(name, value string) *GlobalVariable

NewGlobalVariable returns a *GlobalVariable

func (*GlobalVariable) GetName added in v1.1.0

func (gv *GlobalVariable) GetName() string

func (*GlobalVariable) GetValue added in v1.1.0

func (gv *GlobalVariable) GetValue() string

type MySQLQueryRepo added in v1.1.0

type MySQLQueryRepo struct {
	// contains filtered or unexported fields
}

func NewMySQLQueryRepo added in v1.1.0

func NewMySQLQueryRepo(operationInfo healthcheck.OperationInfo, conn *mysql.Conn) *MySQLQueryRepo

NewMySQLQueryRepo returns the new *MySQLQueryRepo

func (*MySQLQueryRepo) Close added in v1.1.0

func (mqr *MySQLQueryRepo) Close() error

Close closes the connection

func (*MySQLQueryRepo) GetOperationInfo added in v1.1.0

func (mqr *MySQLQueryRepo) GetOperationInfo() healthcheck.OperationInfo

GetOperationInfo returns the operation information

func (*MySQLQueryRepo) GetSlowQuery added in v1.1.0

func (mqr *MySQLQueryRepo) GetSlowQuery() ([]depquery.Query, error)

GetSlowQuery gets the slow query

type OperationHistory added in v1.1.1

type OperationHistory struct {
	ID             int       `middleware:"id" json:"id"`
	UserID         int       `middleware:"user_id" json:"user_id"`
	AccountName    string    `middleware:"account_name" json:"account_name"`
	MySQLServerID  int       `middleware:"mysql_server_id" json:"mysql_server_id"`
	HostIP         string    `middleware:"host_ip" json:"host_ip"`
	PortNum        int       `middleware:"port_num" json:"port_num"`
	StartTime      time.Time `middleware:"start_time" json:"start_time"`
	EndTime        time.Time `middleware:"end_time" json:"end_time"`
	Step           int       `middleware:"step" json:"step"`
	Status         int       `middleware:"status" json:"status"`
	Message        string    `middleware:"message" json:"message"`
	DelFlag        int       `middleware:"del_flag" json:"del_flag"`
	CreateTime     time.Time `middleware:"create_time" json:"create_time"`
	LastUpdateTime time.Time `middleware:"last_update_time" json:"last_update_time"`
}

func (*OperationHistory) GetAccountName added in v1.1.1

func (oh *OperationHistory) GetAccountName() string

GetAccountName returns the user account name

func (*OperationHistory) GetCreateTime added in v1.1.1

func (oh *OperationHistory) GetCreateTime() time.Time

GetCreateTime returns the create time

func (*OperationHistory) GetDelFlag added in v1.1.1

func (oh *OperationHistory) GetDelFlag() int

GetDelFlag returns the delete flag

func (*OperationHistory) GetEndTime added in v1.1.1

func (oh *OperationHistory) GetEndTime() time.Time

GetEndTime returns the end time

func (*OperationHistory) GetHostIP added in v1.1.1

func (oh *OperationHistory) GetHostIP() string

GetHostIP returns the host ip of mysql server

func (*OperationHistory) GetID added in v1.1.1

func (oh *OperationHistory) GetID() int

GetID returns the identity

func (*OperationHistory) GetLastUpdateTime added in v1.1.1

func (oh *OperationHistory) GetLastUpdateTime() time.Time

GetLastUpdateTime returns the last update time

func (*OperationHistory) GetMessage added in v1.1.1

func (oh *OperationHistory) GetMessage() string

GetMessage returns the message

func (*OperationHistory) GetMySQLServerID added in v1.1.1

func (oh *OperationHistory) GetMySQLServerID() int

GetMySQLServerID returns the mysql server id

func (*OperationHistory) GetPortNum added in v1.1.1

func (oh *OperationHistory) GetPortNum() int

GetPortNum returns the port number of mysql server

func (*OperationHistory) GetStartTime added in v1.1.1

func (oh *OperationHistory) GetStartTime() time.Time

GetStartTime returns the start time

func (*OperationHistory) GetStatus added in v1.1.1

func (oh *OperationHistory) GetStatus() int

GetStatus returns the status

func (*OperationHistory) GetStep added in v1.1.1

func (oh *OperationHistory) GetStep() int

GetStep returns the step, the unit is seconds

func (*OperationHistory) GetUserID added in v1.1.1

func (oh *OperationHistory) GetUserID() int

GetUserID returns the user id

type OperationInfo

type OperationInfo struct {
	// contains filtered or unexported fields
}

func (*OperationInfo) GetAppName added in v1.1.0

func (oi *OperationInfo) GetAppName() string

GetAppName returns the app name in string, it will concat all the app names with comma

func (*OperationInfo) GetApps added in v1.1.0

func (oi *OperationInfo) GetApps() []metadata.App

GetApps returns the apps

func (*OperationInfo) GetEndTime added in v1.1.0

func (oi *OperationInfo) GetEndTime() time.Time

GetEndTime returns the end time

func (*OperationInfo) GetMonitorSystem added in v1.1.0

func (oi *OperationInfo) GetMonitorSystem() metadata.MonitorSystem

GetMonitorSystem returns the monitor system

func (*OperationInfo) GetMySQLServer added in v1.1.0

func (oi *OperationInfo) GetMySQLServer() metadata.MySQLServer

GetMySQLServer returns the mysql server

func (*OperationInfo) GetOperationID added in v1.1.0

func (oi *OperationInfo) GetOperationID() int

GetOperationID returns the operation identity

func (*OperationInfo) GetStartTime added in v1.1.0

func (oi *OperationInfo) GetStartTime() time.Time

GetStartTime returns the start time

func (*OperationInfo) GetStep added in v1.1.0

func (oi *OperationInfo) GetStep() time.Duration

GetStep returns the step

func (*OperationInfo) GetUser added in v1.1.1

func (oi *OperationInfo) GetUser() metadata.User

GetUser returns the user

type PrometheusData added in v1.1.0

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

func (*PrometheusData) GetTimestamp added in v1.1.0

func (pd *PrometheusData) GetTimestamp() string

func (*PrometheusData) GetValue added in v1.1.0

func (pd *PrometheusData) GetValue() float64

type PrometheusRepo added in v1.1.0

type PrometheusRepo struct {
	// contains filtered or unexported fields
}

func NewPrometheusRepo added in v1.1.0

func NewPrometheusRepo(operationInfo healthcheck.OperationInfo, conn *prometheus.Conn) *PrometheusRepo

NewPrometheusRepo returns a new *PrometheusRepo

func (*PrometheusRepo) GetAverageActiveSessionPercents added in v1.1.0

func (pr *PrometheusRepo) GetAverageActiveSessionPercents() ([]healthcheck.PrometheusData, error)

GetAverageActiveSessionPercents gets the average active session percents

func (*PrometheusRepo) GetAvgBackupFailedRatio added in v1.1.0

func (pr *PrometheusRepo) GetAvgBackupFailedRatio() ([]healthcheck.PrometheusData, error)

GetAvgBackupFailedRatio gets the mysql backup information

func (*PrometheusRepo) GetCPUUsage added in v1.1.0

func (pr *PrometheusRepo) GetCPUUsage() ([]healthcheck.PrometheusData, error)

GetCPUUsage gets the cpu usage

func (*PrometheusRepo) GetCacheMissRatio added in v1.1.0

func (pr *PrometheusRepo) GetCacheMissRatio() ([]healthcheck.PrometheusData, error)

GetCacheMissRatio gets the cache miss ratio

func (*PrometheusRepo) GetConnectionUsage added in v1.1.0

func (pr *PrometheusRepo) GetConnectionUsage() ([]healthcheck.PrometheusData, error)

GetConnectionUsage gets the connection usage

func (*PrometheusRepo) GetDiskCapacityUsage added in v1.1.0

func (pr *PrometheusRepo) GetDiskCapacityUsage(mountPoints []string) ([]healthcheck.PrometheusData, error)

GetDiskCapacityUsage gets the disk capacity usage

func (*PrometheusRepo) GetFileSystems added in v1.1.0

func (pr *PrometheusRepo) GetFileSystems() ([]healthcheck.FileSystem, error)

GetFileSystems gets the file systems from the prometheus

func (*PrometheusRepo) GetIOUtil added in v1.1.0

func (pr *PrometheusRepo) GetIOUtil() ([]healthcheck.PrometheusData, error)

GetIOUtil gets the io util

func (*PrometheusRepo) GetOperationInfo added in v1.1.0

func (pr *PrometheusRepo) GetOperationInfo() healthcheck.OperationInfo

GetOperationInfo returns the operation information

func (*PrometheusRepo) GetStatisticFailedRatio added in v1.1.0

func (pr *PrometheusRepo) GetStatisticFailedRatio() ([]healthcheck.PrometheusData, error)

GetStatisticFailedRatio gets the statistic of mysql

type Result

type Result struct {
	healthcheck.DASRepo
	ID                                int       `middleware:"id" json:"id"`
	OperationID                       int       `middleware:"operation_id" json:"operation_id"`
	HostIP                            string    `middleware:"host_ip" json:"host_ip"`
	PortNum                           int       `middleware:"port_num" json:"port_num"`
	WeightedAverageScore              int       `middleware:"weighted_average_score" json:"weighted_average_score"`
	DBConfigScore                     int       `middleware:"db_config_score" json:"db_config_score"`
	DBConfigData                      string    `middleware:"db_config_data" json:"db_config_data"`
	DBConfigAdvice                    string    `middleware:"db_config_advice" json:"db_config_advice"`
	AvgBackupFailedRatioScore         int       `middleware:"avg_backup_failed_ratio_score" json:"avg_backup_failed_ratio_score"`
	AvgBackupFailedRatioData          string    `middleware:"avg_backup_failed_ratio_data" json:"avg_backup_failed_ratio_data"`
	AvgBackupFailedRatioHigh          string    `middleware:"avg_backup_failed_ratio_high" json:"avg_backup_failed_ratio_high"`
	StatisticFailedRatioScore         int       `middleware:"statistics_failed_ratio_score" json:"statistics_failed_ratio_score"`
	StatisticFailedRatioData          string    `middleware:"statistics_failed_ratio_data" json:"statistics_failed_ratio_data"`
	StatisticFailedRatioHigh          string    `middleware:"statistics_failed_ratio_high" json:"statistics_failed_ratio_high"`
	CPUUsageScore                     int       `middleware:"cpu_usage_score" json:"cpu_usage_score"`
	CPUUsageData                      string    `middleware:"cpu_usage_data" json:"cpu_usage_data"`
	CPUUsageHigh                      string    `middleware:"cpu_usage_high" json:"cpu_usage_high"`
	IOUtilScore                       int       `middleware:"io_util_score" json:"io_util_score"`
	IOUtilData                        string    `middleware:"io_util_data" json:"io_util_data"`
	IOUtilHigh                        string    `middleware:"io_util_high" json:"io_util_high"`
	DiskCapacityUsageScore            int       `middleware:"disk_capacity_usage_score" json:"disk_capacity_usage_score"`
	DiskCapacityUsageData             string    `middleware:"disk_capacity_usage_data" json:"disk_capacity_usage_data"`
	DiskCapacityUsageHigh             string    `middleware:"disk_capacity_usage_high" json:"disk_capacity_usage_high"`
	ConnectionUsageScore              int       `middleware:"connection_usage_score" json:"connection_usage_score"`
	ConnectionUsageData               string    `middleware:"connection_usage_data" json:"connection_usage_data"`
	ConnectionUsageHigh               string    `middleware:"connection_usage_high" json:"connection_usage_high"`
	AverageActiveSessionPercentsScore int       `middleware:"average_active_session_percents_score" json:"average_active_session_percents_score"`
	AverageActiveSessionPercentsData  string    `middleware:"average_active_session_percents_data" json:"average_active_session_percents_data"`
	AverageActiveSessionPercentsHigh  string    `middleware:"average_active_session_percents_high" json:"average_active_session_percents_high"`
	CacheMissRatioScore               int       `middleware:"cache_miss_ratio_score" json:"cache_miss_ratio_score"`
	CacheMissRatioData                string    `middleware:"cache_miss_ratio_data" json:"cache_miss_ratio_data"`
	CacheMissRatioHigh                string    `middleware:"cache_miss_ratio_high" json:"cache_miss_ratio_high"`
	TableRowsScore                    int       `middleware:"table_rows_score" json:"table_rows_score"`
	TableRowsData                     string    `middleware:"table_rows_data" json:"table_rows_data"`
	TableRowsHigh                     string    `middleware:"table_rows_high" json:"table_rows_high"`
	TableSizeScore                    int       `middleware:"table_size_score" json:"table_size_score"`
	TableSizeData                     string    `middleware:"table_size_data" json:"table_size_data"`
	TableSizeHigh                     string    `middleware:"table_size_high" json:"table_size_high"`
	SlowQueryScore                    int       `middleware:"slow_query_score" json:"slow_query_score"`
	SlowQueryData                     string    `middleware:"slow_query_data" json:"slow_query_data"`
	SlowQueryAdvice                   string    `middleware:"slow_query_advice" json:"slow_query_advice"`
	AccuracyReview                    int       `middleware:"accuracy_review" json:"accuracy_review"`
	DelFlag                           int       `middleware:"del_flag" json:"del_flag"`
	CreateTime                        time.Time `middleware:"create_time" json:"create_time"`
	LastUpdateTime                    time.Time `middleware:"last_update_time" json:"last_update_time"`
}

Result include all data needed in healthcheck

func NewEmptyResult

func NewEmptyResult() *Result

NewEmptyResult returns an empty *Result

func NewEmptyResultWithGlobal

func NewEmptyResultWithGlobal() *Result

NewEmptyResultWithGlobal return a new Result

func NewEmptyResultWithOperationIDAndHostInfo added in v1.1.1

func NewEmptyResultWithOperationIDAndHostInfo(operationID int, hostIP string, portNum int) *Result

NewEmptyResultWithOperationIDAndHostInfo returns an empty *Result but with operation identity and host information

func NewEmptyResultWithRepo

func NewEmptyResultWithRepo(repository healthcheck.DASRepo) *Result

NewEmptyResultWithRepo return a new Result

func NewResult

func NewResult(repo healthcheck.DASRepo, operationID int, hostIP string, portNum int, weightedAverageScore int, dbConfigScore int, dbConfigData string, dbConfigAdvice string,
	avgBackupFailedRatioScore int, avgBackupFailedRatioData string, avgBackupFailedRatioHigh string, statisticScore int, statisticData string, statisticHigh string,
	cpuUsageScore int, cpuUsageData string, cpuUsageHigh string, ioUtilScore int, ioUtilData string, ioUtilHigh string,
	diskCapacityUsageScore int, diskCapacityUsageData string, diskCapacityUsageHigh string,
	connectionUsageScore int, connectionUsageData string, connectionUsageHigh string,
	averageActiveSessionPercentsScore int, averageActiveSessionPercentsData string, averageActiveSessionPercentsHigh string,
	cacheMissRatioScore int, cacheMissRatioData string, cacheMissRatioHigh string,
	tableRowsScore int, tableRowsData string, tableRowsHigh string,
	tableSizeScore int, tableSizeData string, tableSizeHigh string,
	slowQueryScore int, slowQueryData string, slowQueryAdvice string) *Result

NewResult returns a new *Result

func NewResultWithDefault

func NewResultWithDefault(operationID int, hostIP string, portNum int, weightedAverageScore int, dbConfigScore int,
	avgBackupFailedRatioScore int, statisticFailedRatioScore int,
	cpuUsageScore int, ioUtilScore int, diskCapacityUsageScore int, connectionUsageScore int,
	averageActiveSessionPercentsScore int, cacheMissRatioScore int, tableRowsScore int, tableSizeScore int,
	slowQueryScore int, accuracyReview int) *Result

NewResultWithDefault returns a new *Result with default DASRepo

func (*Result) GetAccuracyReview added in v1.1.0

func (r *Result) GetAccuracyReview() int

GetAccuracyReview returns the AccuracyReview

func (*Result) GetAverageActiveSessionPercentsData added in v1.1.0

func (r *Result) GetAverageActiveSessionPercentsData() string

GetAverageActiveSessionPercentsData returns the AverageActiveSessionPercentsData

func (*Result) GetAverageActiveSessionPercentsHigh added in v1.1.0

func (r *Result) GetAverageActiveSessionPercentsHigh() string

GetAverageActiveSessionPercentsHigh returns the AverageActiveSessionPercentsHigh

func (*Result) GetAverageActiveSessionPercentsScore added in v1.1.0

func (r *Result) GetAverageActiveSessionPercentsScore() int

GetAverageActiveSessionPercentsScore returns the AverageActiveSessionPercentsScore

func (*Result) GetAvgBackupFailedRatioData added in v1.1.0

func (r *Result) GetAvgBackupFailedRatioData() string

GetAvgBackupFailedRatioData returns the AvgBackupFailedRatioData

func (*Result) GetAvgBackupFailedRatioHigh added in v1.1.0

func (r *Result) GetAvgBackupFailedRatioHigh() string

GetAvgBackupFailedRatioHigh returns the AvgBackupFailedRatioHigh

func (*Result) GetAvgBackupFailedRatioScore added in v1.1.0

func (r *Result) GetAvgBackupFailedRatioScore() int

GetAvgBackupFailedRatioScore returns the AvgBackupFailedRatioScore

func (*Result) GetCPUUsageData

func (r *Result) GetCPUUsageData() string

GetCPUUsageData returns the CPUUsageData

func (*Result) GetCPUUsageHigh

func (r *Result) GetCPUUsageHigh() string

GetCPUUsageHigh returns the CPUUsageHigh

func (*Result) GetCPUUsageScore

func (r *Result) GetCPUUsageScore() int

GetCPUUsageScore returns the CPUUsageScore

func (*Result) GetCacheMissRatioData

func (r *Result) GetCacheMissRatioData() string

GetCacheMissRatioData returns the CacheMissRatioData

func (*Result) GetCacheMissRatioHigh

func (r *Result) GetCacheMissRatioHigh() string

GetCacheMissRatioHigh returns the CacheMissRatioHigh

func (*Result) GetCacheMissRatioScore

func (r *Result) GetCacheMissRatioScore() int

GetCacheMissRatioScore returns the CacheMissRatioScore

func (*Result) GetConnectionUsageData

func (r *Result) GetConnectionUsageData() string

GetConnectionUsageData returns the ConnectionUsageData

func (*Result) GetConnectionUsageHigh

func (r *Result) GetConnectionUsageHigh() string

GetConnectionUsageHigh returns the ConnectionUsageHigh

func (*Result) GetConnectionUsageScore

func (r *Result) GetConnectionUsageScore() int

GetConnectionUsageScore returns the ConnectionUsageScore

func (*Result) GetCreateTime

func (r *Result) GetCreateTime() time.Time

GetCreateTime returns the create time

func (*Result) GetDBConfigAdvice

func (r *Result) GetDBConfigAdvice() string

GetDBConfigAdvice returns the DBConfigAdvice

func (*Result) GetDBConfigData

func (r *Result) GetDBConfigData() string

GetDBConfigData returns the DBConfigData

func (*Result) GetDBConfigScore

func (r *Result) GetDBConfigScore() int

GetDBConfigScore returns the DBConfigScore

func (*Result) GetDelFlag

func (r *Result) GetDelFlag() int

GetDelFlag returns the delete flag

func (*Result) GetDiskCapacityUsageData

func (r *Result) GetDiskCapacityUsageData() string

GetDiskCapacityUsageData returns the DiskCapacityUsageData

func (*Result) GetDiskCapacityUsageHigh

func (r *Result) GetDiskCapacityUsageHigh() string

GetDiskCapacityUsageHigh returns the DiskCapacityUsageHigh

func (*Result) GetDiskCapacityUsageScore

func (r *Result) GetDiskCapacityUsageScore() int

GetDiskCapacityUsageScore returns the DiskCapacityUsageScore

func (*Result) GetHostIP added in v1.1.1

func (r *Result) GetHostIP() string

Identity returns the host ip

func (*Result) GetIOUtilData

func (r *Result) GetIOUtilData() string

GetIOUtilData returns the IOUtilData

func (*Result) GetIOUtilHigh

func (r *Result) GetIOUtilHigh() string

GetIOUtilHigh returns the IOUtilHigh

func (*Result) GetIOUtilScore

func (r *Result) GetIOUtilScore() int

GetIOUtilScore returns the IOUtilScore

func (*Result) GetLastUpdateTime

func (r *Result) GetLastUpdateTime() time.Time

GetLastUpdateTime returns the last update time

func (*Result) GetOperationID

func (r *Result) GetOperationID() int

GetOperationID returns the OperationID

func (*Result) GetPortNum added in v1.1.1

func (r *Result) GetPortNum() int

Identity returns the port number

func (*Result) GetSlowQueryAdvice

func (r *Result) GetSlowQueryAdvice() string

GetSlowQueryAdvice returns the SlowQueryAdvice

func (*Result) GetSlowQueryData

func (r *Result) GetSlowQueryData() string

GetSlowQueryData returns the SlowQueryData

func (*Result) GetSlowQueryScore

func (r *Result) GetSlowQueryScore() int

GetSlowQueryScore returns the SlowQueryScore

func (*Result) GetStatisticFailedRatioData added in v1.1.0

func (r *Result) GetStatisticFailedRatioData() string

GetStatisticFailedRatioData returns the StatisticFailedRatioData

func (*Result) GetStatisticFailedRatioHigh added in v1.1.0

func (r *Result) GetStatisticFailedRatioHigh() string

GetStatisticFailedRatioHigh returns the StatisticFailedRatioHigh

func (*Result) GetStatisticFailedRatioScore added in v1.1.0

func (r *Result) GetStatisticFailedRatioScore() int

GetStatisticFailedRatioScore returns the StatisticFailedRatioScore

func (*Result) GetTableRowsData added in v1.1.0

func (r *Result) GetTableRowsData() string

GetTableRowsData returns the TableRowsData

func (*Result) GetTableRowsHigh added in v1.1.0

func (r *Result) GetTableRowsHigh() string

GetTableRowsHigh returns the TableRowsHigh

func (*Result) GetTableRowsScore added in v1.1.0

func (r *Result) GetTableRowsScore() int

GetTableRowsScore returns the TableRowsScore

func (*Result) GetTableSizeData

func (r *Result) GetTableSizeData() string

GetTableSizeData returns the TableSizeData

func (*Result) GetTableSizeHigh

func (r *Result) GetTableSizeHigh() string

GetTableSizeHigh returns the TableSizeHigh

func (*Result) GetTableSizeScore

func (r *Result) GetTableSizeScore() int

GetTableSizeScore returns the TableSizeScore

func (*Result) GetWeightedAverageScore

func (r *Result) GetWeightedAverageScore() int

GetWeightedAverageScore returns the WeightedAverageScore

func (*Result) Identity

func (r *Result) Identity() int

Identity returns the identity

func (*Result) MarshalJSON

func (r *Result) MarshalJSON() ([]byte, error)

MarshalJSON marshals health check to json string

func (*Result) MarshalJSONWithFields

func (r *Result) MarshalJSONWithFields(fields ...string) ([]byte, error)

MarshalJSONWithFields marshals only specified field of the health check to json string

func (*Result) Set

func (r *Result) Set(fields map[string]interface{}) error

Set sets health check with given fields, key is the field name and value is the relevant value of the key

func (*Result) String added in v1.1.0

func (r *Result) String() string

type Service

type Service struct {
	healthcheck.DASRepo
	OperationInfo      healthcheck.OperationInfo
	Engine             healthcheck.Engine
	Result             healthcheck.Result             `json:"result"`
	OperationHistories []healthcheck.OperationHistory `json:"operation_histories"`
}

Service of health check

func (*Service) Check

func (s *Service) Check(mysqlServerID int, startTime, endTime time.Time, step time.Duration, loginName string) (int, error)

Check performs healthcheck on the mysql server with given mysql server id, initiating is synchronous, actual running is asynchronous

func (*Service) CheckByHostInfo

func (s *Service) CheckByHostInfo(hostIP string, portNum int, startTime, endTime time.Time, step time.Duration, loginName string) (int, error)

CheckByHostInfo performs healthcheck on the mysql server with given mysql server id, initiating is synchronous, actual running is asynchronous

func (*Service) GetDASRepo added in v1.1.0

func (s *Service) GetDASRepo() healthcheck.DASRepo

GetDASRepo returns the das repository

func (*Service) GetEngine added in v1.1.0

func (s *Service) GetEngine() healthcheck.Engine

GetEngine returns the healthcheck engine

func (*Service) GetOperationHistories added in v1.1.1

func (s *Service) GetOperationHistories() []healthcheck.OperationHistory

GetOperationHistories returns the operation histories

func (*Service) GetOperationHistoriesByLoginName added in v1.1.1

func (s *Service) GetOperationHistoriesByLoginName(loginName string) error

GetOperationHistoriesByLoginName returns the operation histories by login name

func (*Service) GetOperationInfo added in v1.1.0

func (s *Service) GetOperationInfo() healthcheck.OperationInfo

GetOperationInfo returns the operation information

func (*Service) GetResult

func (s *Service) GetResult() healthcheck.Result

GetResult returns the healthcheck result

func (*Service) GetResultByOperationID

func (s *Service) GetResultByOperationID(id int) error

GetResultByOperationID gets the result of given operation id

func (*Service) Marshal added in v1.1.0

func (s *Service) Marshal() ([]byte, error)

Marshal marshals Service to json bytes

func (*Service) MarshalWithFields added in v1.1.0

func (s *Service) MarshalWithFields(fields ...string) ([]byte, error)

MarshalWithFields marshals only specified fields of the Service to json bytes

func (*Service) ReviewAccuracy added in v1.1.0

func (s *Service) ReviewAccuracy(id, review int) error

ReviewAccuracy updates accuracy review with given operation id

type Table added in v1.1.0

type Table struct {
	DBName    string  `middleware:"db_name" json:"db_name"`
	TableName string  `middleware:"table_name" json:"table_name"`
	TableRows int     `middleware:"table_rows" json:"table_rows"`
	TableSize float64 `middleware:"table_size" json:"table_size"`
}

func (*Table) GetName added in v1.1.0

func (t *Table) GetName() string

func (*Table) GetRows added in v1.1.0

func (t *Table) GetRows() int

func (*Table) GetSchema added in v1.1.0

func (t *Table) GetSchema() string

func (*Table) GetSize added in v1.1.0

func (t *Table) GetSize() float64

type Variable added in v1.1.0

type Variable struct {
	Name   string `middleware:"name" json:"name"`
	Value  string `middleware:"value" json:"value"`
	Advice string `middleware:"advice" json:"advice"`
}

func NewVariable added in v1.1.0

func NewVariable(variableName, currentValue, advice string) *Variable

Jump to

Keyboard shortcuts

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