proto

package
v0.0.0-...-0786b7d Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2021 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_AGENT_API_PORT       = "9000"
	DEFAULT_QAN_API_PORT         = "9001"
	DEFAULT_PROM_CONFIG_API_PORT = "9003"
	DEFAULT_METRICS_API_PORT     = "9004"
)
View Source
const (
	LOG_EMERGENCY byte = iota // not used
	LOG_ALERT                 // not used
	LOG_CRITICAL              // not used
	LOG_ERROR
	LOG_WARNING
	LOG_NOTICE
	LOG_INFO
	LOG_DEBUG
)

http://en.wikipedia.org/wiki/Syslog#Severity_levels

View Source
const MAX_DATA_SIZE = 1024 * 1024 * 5

In go-mysql/event/query_class.go MAX_EXAMPLE_BYTES=1024*10 (10 KiB) and default top query limit is 200 which = ~2M. Then add overhead for JSON and a single data msg should not exceed 5 MiB which very liberal because the real-world avg is about 300 KiB/msg for QAN (30 KiB/msg for MM).

View Source
const VERSION = "1.0"

Variables

View Source
var HostTypes = []string{"os", "mysql"}
View Source
var LogLevelName []string = []string{
	"emergency",
	"alert",
	"critical",
	"error",
	"warning",
	"notice",
	"info",
	"debug",
}
View Source
var LogLevelNumber map[string]byte = map[string]byte{
	"emergency": LOG_EMERGENCY,
	"alert":     LOG_ALERT,
	"critical":  LOG_CRITICAL,
	"error":     LOG_ERROR,
	"warning":   LOG_WARNING,
	"notice":    LOG_NOTICE,
	"info":      LOG_INFO,
	"debug":     LOG_DEBUG,
}

Functions

func ErrorResponse

func ErrorResponse(w http.ResponseWriter, err error)

func JSONResponse

func JSONResponse(w http.ResponseWriter, statusCode int, v interface{})

func WriteAccessControlHeaders

func WriteAccessControlHeaders(w http.ResponseWriter)

Types

type Agent

type Agent struct {
	UUID       string
	ParentUUID string
	Hostname   string
	Version    string
	Created    time.Time
	Deleted    time.Time
	Links      map[string]string `json:",omitempty"`
}

type AgentConfig

type AgentConfig struct {
	Service string // agent service (data, log, qan, etc.)
	UUID    string // of MySQL instance if Service = qan
	Set     string // config/config.go as set explicitly in the file
	Running string // ^ as the agent is running it with default applied
	Updated time.Time
}

type AuthResponse

type AuthResponse struct {
	Code  uint   // standard HTTP status (http://httpstatus.es/)
	Error string // empty if auth ok (Code=200)
}

type Cmd

type Cmd struct {
	Id        string `json:",omitempty"` // set by API
	Ts        time.Time
	User      string
	AgentUUID string
	Service   string
	Cmd       string
	Data      []byte `json:",omitempty"`
}

Sent by API to agent

func (*Cmd) Reply

func (cmd *Cmd) Reply(data interface{}, errs ...error) *Reply

func (*Cmd) String

func (cmd *Cmd) String() string

type Data

type Data struct {
	// Agent sets:
	ProtocolVersion string
	Created         time.Time // when Data was spooled (UTC)
	Hostname        string    // OS instance name the agent is running on
	Service         string    // which tool
	ContentType     string    // of Data ("application/json")
	ContentEncoding string    // of Data ("gzip" or empty)
	Data            []byte    // encoded tool data
}

Data from a tool

func (*Data) GetData

func (d *Data) GetData() ([]byte, error)

type DataSpoolLimits

type DataSpoolLimits struct {
	MaxAge   uint   // seconds
	MaxSize  uint64 // bytes
	MaxFiles uint
}

type Endpoint

type Endpoint struct {
	Targets []string
	Labels  map[string]string
}

type Error

type Error struct {
	Error string
}

type ExplainQuery

type ExplainQuery struct {
	UUID    string
	Db      string
	Query   string
	Convert bool // convert if not SELECT and MySQL <= 5.5 or >= 5.6 but no privs
}

type ExplainResult

type ExplainResult struct {
	Classic []*ExplainRow
	JSON    string // since MySQL 5.6.5
}

type ExplainRow

type ExplainRow struct {
	Id           NullInt64
	SelectType   NullString
	Table        NullString
	Partitions   NullString // split by comma; since MySQL 5.1
	CreateTable  NullString // @todo
	Type         NullString
	PossibleKeys NullString // split by comma
	Key          NullString
	KeyLen       NullString // https://jira.percona.com/browse/PCT-863
	Ref          NullString
	Rows         NullInt64
	Filtered     NullFloat64 // as of 5.7.3
	Extra        NullString  // split by semicolon
}

type Exporter

type Exporter struct {
	Name         string   `yaml:"name"`
	Alias        string   `yaml:"alias,omitempty"`
	Port         string   `yaml:"port"`
	Args         []string `yaml:"args"`
	InstanceUUID string   `yaml:"instance_uuid,omitempty"`
}

type Host

type Host struct {
	Alias   string
	Address string
}

type Instance

type Instance struct {
	Subsystem  string // Subsystem.Name
	ParentUUID string
	Id         uint   // internal ID for joining data tables
	UUID       string // primary ID, for accessing API
	Name       string // secondary ID, for human readability
	DSN        string // type-specific DSN, if any
	Distro     string
	Version    string
	Created    time.Time
	Deleted    time.Time
	Links      map[string]string `json:",omitempty"`
}

type JsonGzipSerializer

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

func NewJsonGzipSerializer

func NewJsonGzipSerializer() *JsonGzipSerializer

func (*JsonGzipSerializer) Concurrent

func (s *JsonGzipSerializer) Concurrent() bool

func (*JsonGzipSerializer) Encoding

func (s *JsonGzipSerializer) Encoding() string

func (*JsonGzipSerializer) ToBytes

func (s *JsonGzipSerializer) ToBytes(data interface{}) ([]byte, error)

type JsonSerializer

type JsonSerializer struct {
}

func NewJsonSerializer

func NewJsonSerializer() *JsonSerializer

func (*JsonSerializer) Concurrent

func (s *JsonSerializer) Concurrent() bool

func (*JsonSerializer) Encoding

func (s *JsonSerializer) Encoding() string

func (*JsonSerializer) ToBytes

func (j *JsonSerializer) ToBytes(data interface{}) ([]byte, error)
type Links struct {
	Links map[string]string
}

type LogEntry

type LogEntry struct {
	Ts      time.Time
	Level   byte
	Service string
	Msg     string
	Offline bool `json:"-"`
}

func (*LogEntry) String

func (e *LogEntry) String() string

type NullFloat64

type NullFloat64 struct {
	sql.NullFloat64
}

func (NullFloat64) Equal

func (n NullFloat64) Equal(u NullFloat64) bool

func (NullFloat64) MarshalJSON

func (n NullFloat64) MarshalJSON() (b []byte, err error)

func (*NullFloat64) UnmarshalJSON

func (n *NullFloat64) UnmarshalJSON(b []byte) error

type NullInt64

type NullInt64 struct {
	sql.NullInt64
}

func (NullInt64) Equal

func (n NullInt64) Equal(u NullInt64) bool

func (*NullInt64) MarshalJSON

func (n *NullInt64) MarshalJSON() (b []byte, err error)

func (*NullInt64) UnmarshalJSON

func (n *NullInt64) UnmarshalJSON(b []byte) error

type NullString

type NullString struct {
	sql.NullString
}

func (NullString) Equal

func (n NullString) Equal(u NullString) bool

func (*NullString) MarshalJSON

func (n *NullString) MarshalJSON() (b []byte, err error)

func (*NullString) UnmarshalJSON

func (n *NullString) UnmarshalJSON(b []byte) error

type NullTime

type NullTime struct {
	time.Time
}

func (*NullTime) Scan

func (n *NullTime) Scan(src interface{}) error

type Reply

type Reply struct {
	Id    string // set by API
	Cmd   string // original Cmd.Cmd
	Error string // success if empty
	Data  []byte `json:",omitempty"`
}

Sent by agent in response to every command

func (*Reply) String

func (reply *Reply) String() string

type Response

type Response struct {
	Code  uint   // standard HTTP status (http://httpstatus.es/)
	Error string // empty if ok (Code=200)
}

type Serializer

type Serializer interface {
	ToBytes(data interface{}) ([]byte, error)
	Encoding() string
	Concurrent() bool
}

type ServiceData

type ServiceData struct {
	Name   string
	Config []byte `json:",omitempty"` // cloud-tools/<service>/config.go
}

Data for StartService and StopService command replies

type ShowIndexRow

type ShowIndexRow struct {
	Table        string
	NonUnique    bool
	KeyName      string
	SeqInIndex   int
	ColumnName   string
	Collation    NullString
	Cardinality  NullInt64
	SubPart      NullInt64
	Packed       NullString
	Null         NullString
	IndexType    string
	Comment      NullString
	IndexComment NullString
	Visible      NullString
}

ShowIndexRow describes one row from `SHOW INDEX FROM %s` query. # mysql -e 'SHOW INDEX FROM mysql.user\G' *************************** 1. row ***************************

     Table: user
Non_unique: 0
  Key_name: PRIMARY

Seq_in_index: 1

Column_name: Host
  Collation: A
Cardinality: 2
   Sub_part: NULL
     Packed: NULL
       Null:
 Index_type: BTREE
    Comment:

Index_comment:

Visible: YES

*************************** 2. row ***************************

     Table: user
Non_unique: 0
  Key_name: PRIMARY

Seq_in_index: 2

Column_name: User
  Collation: A
Cardinality: 5
   Sub_part: NULL
     Packed: NULL
       Null:
 Index_type: BTREE
    Comment:

Index_comment:

Visible: YES

# mysql -e 'DESCRIBE INFORMATION_SCHEMA.STATISTICS' +---------------+------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------------+------------------+------+-----+---------+-------+ | TABLE_CATALOG | varchar(64) | NO | | NULL | | | TABLE_SCHEMA | varchar(64) | NO | | NULL | | | TABLE_NAME | varchar(64) | NO | | NULL | | | NON_UNIQUE | int(1) | NO | | 0 | | | INDEX_SCHEMA | varchar(64) | NO | | NULL | | | INDEX_NAME | varchar(64) | YES | | NULL | | | SEQ_IN_INDEX | int(10) unsigned | NO | | NULL | | | COLUMN_NAME | varchar(64) | YES | | NULL | | | COLLATION | varchar(1) | YES | | NULL | | | CARDINALITY | bigint(21) | YES | | NULL | | | SUB_PART | bigint(21) | YES | | NULL | | | PACKED | binary(0) | YES | | NULL | | | NULLABLE | varchar(3) | NO | | | | | INDEX_TYPE | varchar(11) | NO | | | | | COMMENT | varchar(8) | NO | | | | | INDEX_COMMENT | varchar(2048) | NO | | NULL | | | IS_VISIBLE | varchar(3) | NO | | | | +---------------+------------------+------+-----+---------+-------+

type ShowTableStatus

type ShowTableStatus struct {
	Name          string
	Engine        string
	Version       string
	RowFormat     string
	Rows          NullInt64
	AvgRowLength  NullInt64
	DataLength    NullInt64
	MaxDataLength NullInt64
	IndexLength   NullInt64
	DataFree      NullInt64
	AutoIncrement NullInt64
	CreateTime    NullTime
	UpdateTime    NullTime
	CheckTime     NullTime
	Collation     NullString
	Checksum      NullString
	CreateOptions NullString
	Comment       NullString
}

type Subsystem

type Subsystem struct {
	Id       uint
	ParentId uint
	Name     string // os, agent,  mysql
	Label    string // OS, Agent, MySQL
}

type Table

type Table struct {
	Db    string
	Table string
}

type TableInfo

type TableInfo struct {
	Create string                    `json:",omitempty"`
	Index  map[string][]ShowIndexRow `json:",omitempty"`
	Status *ShowTableStatus          `json:",omitempty"`
	Errors []string                  `json:",omitempty"`
}

type TableInfoQuery

type TableInfoQuery struct {
	UUID   string
	Create []Table // SHOW CREATE TABLE Db.Table
	Index  []Table // SHOW INDEXES FROM Db.Table
	Status []Table // SHOW TABLE STATUS FROM Db LIKE 'Table'
}

type TableInfoResult

type TableInfoResult map[string]*TableInfo

type Version

type Version struct {
	Installed string
	Running   string
	Revision  string
}

Reply from agent to Version command. The two can differ is agent self-update but hasn't be restarted yet.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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