qan

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: May 27, 2014 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ByQueryTime

type ByQueryTime []*mysqlLog.QueryClass

func (ByQueryTime) Len

func (a ByQueryTime) Len() int

func (ByQueryTime) Less

func (a ByQueryTime) Less(i, j int) bool

func (ByQueryTime) Swap

func (a ByQueryTime) Swap(i, j int)

type Config

type Config struct {
	proto.ServiceInstance
	// Manager
	Start             []mysql.Query
	Stop              []mysql.Query
	MaxWorkers        int
	Interval          uint  // minutes, "How often to report"
	MaxSlowLogSize    int64 // bytes, 0 = no max
	RemoveOldSlowLogs bool  // after rotating for MaxSlowLogSize
	// Worker
	ExampleQueries bool // only fingerprints if false
	WorkerRunTime  uint // seconds
	// Report
	ReportLimit uint
}

type FileIntervalIter

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

Implements IntervalIter:

func NewFileIntervalIter

func NewFileIntervalIter(logger *pct.Logger, filename FilenameFunc, tickChan chan time.Time) *FileIntervalIter

func (*FileIntervalIter) IntervalChan

func (i *FileIntervalIter) IntervalChan() chan *Interval

func (*FileIntervalIter) Start

func (i *FileIntervalIter) Start()

func (*FileIntervalIter) Stop

func (i *FileIntervalIter) Stop()

type FileIntervalIterFactory

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

func NewFileIntervalIterFactory

func NewFileIntervalIterFactory(logChan chan *proto.LogEntry) *FileIntervalIterFactory

func (*FileIntervalIterFactory) Make

func (f *FileIntervalIterFactory) Make(filename FilenameFunc, tickChan chan time.Time) IntervalIter

type FilenameFunc

type FilenameFunc func() (string, error)

Returns slow_query_log_file, or error:

type Interval

type Interval struct {
	Number      int
	Filename    string    // slow_query_log_file
	StartTime   time.Time // UTC
	StopTime    time.Time // UTC
	StartOffset int64     // bytes @ StartTime
	EndOffset   int64     // bytes @ StopTime
}

A slice of the MySQL slow log:

func (*Interval) String added in v1.0.1

func (i *Interval) String() string

type IntervalIter

type IntervalIter interface {
	Start()
	Stop()
	IntervalChan() chan *Interval
}

Used by Manager.run() to start a Worker:

type IntervalIterFactory

type IntervalIterFactory interface {
	Make(filename FilenameFunc, tickChan chan time.Time) IntervalIter
}

Used by Manager.Start() to create an IntervalIter that ticks at Config.Interval minutes:

type Job

type Job struct {
	Id             string
	SlowLogFile    string
	RunTime        time.Duration
	StartOffset    int64
	EndOffset      int64
	ExampleQueries bool
	// --
	ZeroRunTime bool // testing
}

func (*Job) String added in v1.0.1

func (j *Job) String() string

type Manager

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

func NewManager

func NewManager(logger *pct.Logger, mysqlFactory mysql.ConnectionFactory, clock ticker.Manager, iterFactory IntervalIterFactory, workerFactory WorkerFactory, spool data.Spooler, im *instance.Repo) *Manager

func (*Manager) GetConfig

func (m *Manager) GetConfig() ([]proto.AgentConfig, []error)

func (*Manager) Handle

func (m *Manager) Handle(cmd *proto.Cmd) *proto.Reply

func (*Manager) Start

func (m *Manager) Start() error

@goroutine[0]

func (*Manager) Status

func (m *Manager) Status() map[string]string

func (*Manager) Stop

func (m *Manager) Stop() error

type Report

type Report struct {
	proto.ServiceInstance
	StartTs     time.Time // UTC
	EndTs       time.Time // UTC
	SlowLogFile string    // not slow_query_log_file if rotated
	StartOffset int64     // parsing starts
	EndOffset   int64     // parsing stops, but...
	StopOffset  int64     // ...parsing didn't complete if stop < end
	RunTime     float64   // seconds
	Global      *mysqlLog.GlobalClass
	Class       []*mysqlLog.QueryClass
}

func MakeReport

func MakeReport(it proto.ServiceInstance, interval *Interval, result *Result, config Config) *Report

type Result

type Result struct {
	StopOffset int64
	RunTime    float64
	Error      string `json:",omitempty"`
	Global     *mysqlLog.GlobalClass
	Classes    []*mysqlLog.QueryClass
}

type SlowLogWorker

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

func NewSlowLogWorker

func NewSlowLogWorker(logger *pct.Logger, name string) *SlowLogWorker

func (*SlowLogWorker) Name

func (w *SlowLogWorker) Name() string

func (*SlowLogWorker) Run

func (w *SlowLogWorker) Run(job *Job) (*Result, error)

func (*SlowLogWorker) Status

func (w *SlowLogWorker) Status() string

type SlowLogWorkerFactory

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

func NewSlowLogWorkerFactory

func NewSlowLogWorkerFactory(logChan chan *proto.LogEntry) *SlowLogWorkerFactory

func (*SlowLogWorkerFactory) Make

func (f *SlowLogWorkerFactory) Make(name string) Worker

type Worker

type Worker interface {
	Name() string
	Status() string
	Run(job *Job) (*Result, error)
}

type WorkerFactory

type WorkerFactory interface {
	Make(name string) Worker
}

Jump to

Keyboard shortcuts

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