auditplan

package
v1.2204.0-pre3 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2022 License: MPL-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeDefault         = "default"
	TypeMySQLSlowLog    = "mysql_slow_log"
	TypeMySQLMybatis    = "mysql_mybatis"
	TypeMySQLSchemaMeta = "mysql_schema_meta"
	TypeOracleTopSQL    = "oracle_top_sql"
	TypeAllAppExtract   = "all_app_extract"
)
View Source
const (
	InstanceTypeAll    = ""
	InstanceTypeMySQL  = "mysql"
	InstanceTypeOracle = "Oracle"
)

Variables

View Source
var ErrAuditPlanExisted = errors.New(errors.DataExist, fmt.Errorf("audit plan existed"))
View Source
var ErrAuditPlanNotExist = errors.New(errors.DataNotExist, fmt.Errorf("audit plan not exist"))
View Source
var MetaMap = map[string]Meta{}
View Source
var Metas = []Meta{
	{
		Type:         TypeDefault,
		Desc:         "自定义",
		InstanceType: InstanceTypeAll,
	},
	{
		Type:         TypeMySQLSlowLog,
		Desc:         "慢日志",
		InstanceType: InstanceTypeMySQL,
	},
	{
		Type:         TypeMySQLMybatis,
		Desc:         "Mybatis 扫描",
		InstanceType: InstanceTypeMySQL,
	},
	{
		Type:         TypeMySQLSchemaMeta,
		Desc:         "库表元数据",
		InstanceType: InstanceTypeMySQL,
		Params: []*params.Param{
			&params.Param{
				Key:   paramKeyCollectIntervalMinute,
				Desc:  "采集周期(分钟)",
				Value: "60",
				Type:  params.ParamTypeInt,
			},
			&params.Param{
				Key:   "collect_view",
				Desc:  "是否采集视图信息",
				Value: "0",
				Type:  params.ParamTypeBool,
			},
		},
	},
	{
		Type:         TypeOracleTopSQL,
		Desc:         "Oracle TOP SQL",
		InstanceType: InstanceTypeOracle,
		Params: []*params.Param{
			{
				Key:   paramKeyCollectIntervalMinute,
				Desc:  "采集周期(分钟)",
				Value: "60",
				Type:  params.ParamTypeInt,
			},
			{
				Key:   "top_n",
				Desc:  "Top N",
				Value: "3",
				Type:  params.ParamTypeInt,
			},
			{
				Key:   "order_by_column",
				Desc:  "V$SQLAREA中的排序字段",
				Value: oracle.DynPerformanceViewSQLAreaColumnElapsedTime,
				Type:  params.ParamTypeString,
			},
		},
	},
	{
		Type:         TypeAllAppExtract,
		Desc:         "应用程序SQL抓取",
		InstanceType: InstanceTypeAll,
	},
}

Functions

func InitManager

func InitManager(s *model.Storage) chan struct{}

Types

type DefaultTask added in v1.2202.0

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

func NewDefaultTask added in v1.2202.0

func NewDefaultTask(entry *logrus.Entry, ap *model.AuditPlan) *DefaultTask

func (*DefaultTask) Audit added in v1.2202.0

func (at *DefaultTask) Audit() (*model.AuditPlanReportV2, error)

func (DefaultTask) FullSyncSQLs added in v1.2202.0

func (at DefaultTask) FullSyncSQLs(sqls []*SQL) error

func (DefaultTask) GetSQLs added in v1.2202.0

func (at DefaultTask) GetSQLs(args map[string]interface{}) ([]Head, []map[string]string, uint64, error)

func (DefaultTask) PartialSyncSQLs added in v1.2202.0

func (at DefaultTask) PartialSyncSQLs(sqls []*SQL) error

func (DefaultTask) Start added in v1.2202.0

func (at DefaultTask) Start() error

func (DefaultTask) Stop added in v1.2202.0

func (at DefaultTask) Stop() error
type Head struct {
	Name string
	Desc string
	Type string
}

type Manager

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

Manager is the struct managing the persistent AuditPlans. It is *goroutine-safe*, since all exported methods are protected by a lock.

All audit plan operations except select should go through Manager.

func GetManager

func GetManager() *Manager

func (*Manager) Audit added in v1.2202.0

func (mgr *Manager) Audit(apName string) (*model.AuditPlanReportV2, error)

func (*Manager) GetSQLs added in v1.2202.0

func (mgr *Manager) GetSQLs(apName string, args map[string]interface{}) ([]Head, []map[string]string, uint64, error)

func (*Manager) SyncTask added in v1.2202.0

func (mgr *Manager) SyncTask(apName string) error

func (*Manager) UploadSQLs added in v1.2202.0

func (mgr *Manager) UploadSQLs(apName string, sqls []*SQL, isPartialSync bool) error

type Meta added in v1.2201.0

type Meta struct {
	Type         string        `json:"audit_plan_type"`
	Desc         string        `json:"audit_plan_type_desc"`
	InstanceType string        `json:"instance_type"`
	Params       params.Params `json:"audit_plan_params,omitempty"`
}

func GetMeta added in v1.2201.0

func GetMeta(typ string) (Meta, error)

type OracleTopSQLTask added in v1.2202.0

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

OracleTopSQLTask implement the Task interface.

OracleTopSQLTask is a loop task which collect Top SQL from oracle instance.

func NewOracleTopSQLTask added in v1.2202.0

func NewOracleTopSQLTask(entry *logrus.Entry, ap *model.AuditPlan) *OracleTopSQLTask

func (*OracleTopSQLTask) Audit added in v1.2202.0

func (OracleTopSQLTask) FullSyncSQLs added in v1.2202.0

func (at OracleTopSQLTask) FullSyncSQLs(sqls []*SQL) error

func (*OracleTopSQLTask) GetSQLs added in v1.2202.0

func (at *OracleTopSQLTask) GetSQLs(args map[string]interface{}) ([]Head, []map[string]string, uint64, error)

func (OracleTopSQLTask) PartialSyncSQLs added in v1.2202.0

func (at OracleTopSQLTask) PartialSyncSQLs(sqls []*SQL) error

func (OracleTopSQLTask) Start added in v1.2202.0

func (at OracleTopSQLTask) Start() error

func (OracleTopSQLTask) Stop added in v1.2202.0

func (at OracleTopSQLTask) Stop() error

type SQL added in v1.2202.0

type SQL struct {
	SQLContent  string
	Fingerprint string
	Info        map[string]interface{}
}

type SchemaMetaTask added in v1.2202.0

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

func NewSchemaMetaTask added in v1.2202.0

func NewSchemaMetaTask(entry *logrus.Entry, ap *model.AuditPlan) *SchemaMetaTask

func (*SchemaMetaTask) Audit added in v1.2202.0

func (at *SchemaMetaTask) Audit() (*model.AuditPlanReportV2, error)

func (SchemaMetaTask) FullSyncSQLs added in v1.2202.0

func (at SchemaMetaTask) FullSyncSQLs(sqls []*SQL) error

func (*SchemaMetaTask) GetSQLs added in v1.2202.0

func (at *SchemaMetaTask) GetSQLs(args map[string]interface{}) ([]Head, []map[string]string, uint64, error)

func (SchemaMetaTask) PartialSyncSQLs added in v1.2202.0

func (at SchemaMetaTask) PartialSyncSQLs(sqls []*SQL) error

func (SchemaMetaTask) Start added in v1.2202.0

func (at SchemaMetaTask) Start() error

func (SchemaMetaTask) Stop added in v1.2202.0

func (at SchemaMetaTask) Stop() error

type Task added in v1.2202.0

type Task interface {
	Start() error
	Stop() error
	Audit() (*model.AuditPlanReportV2, error)
	FullSyncSQLs([]*SQL) error
	PartialSyncSQLs([]*SQL) error
	GetSQLs(map[string]interface{}) ([]Head, []map[string]string, uint64, error)
}

func NewTask added in v1.2202.0

func NewTask(entry *logrus.Entry, ap *model.AuditPlan) Task

Jump to

Keyboard shortcuts

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