cadastre

package module
v0.0.0-...-2717faf Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2015 License: MIT Imports: 24 Imported by: 1

README

cadastre

a ledger for what mysql is doing at any given moment

Documentation

Overview

Cadastre is a way to see what your MySQL servers were doing five minutes ago and what they're doing now. It will continuously poll the configured servers and save their process list state to a persistent data store, which can later be viewed by the web interface.

Index

Constants

View Source
const CadastreEncodedFavicon = "" /* 7848-byte string literal not displayed */

Variables

This section is empty.

Functions

This section is empty.

Types

type CadastreWebHandler

type CadastreWebHandler struct {
	Handler func(http.ResponseWriter, *http.Request) error
	Server  *WebUI
}

func CadastreHandler

func CadastreHandler(server *WebUI, handlerFunc func(http.ResponseWriter, *http.Request) error) *CadastreWebHandler

func (*CadastreWebHandler) ServeHTTP

func (me *CadastreWebHandler) ServeHTTP(response http.ResponseWriter, request *http.Request)

type Configuration

type Configuration struct {
	// The list of MySQL hosts to check. A host is defined by a unique, internal name,
	// a display name (something more suitable than the internal name or hostname), an optional
	// category to allow for logical UI grouping and a DSN used to figure out how to connect to
	// the MySQL host.
	Servers []Server

	// A list of MySQL hosts to check, grouped by category.  This list contains the same servers
	// as the "Servers" list.
	ServerGroups []ServerGroup

	// The interval to check each server.
	FetchInterval time.Duration

	// The storage engine used to persist the host information to.
	Storage DataStore

	// The address for the web server to listen on.
	ListenAddress string

	// Where to load templates from.
	TemplateDirectory string

	// Where to serve static assets from.
	StaticAssetDirectory string

	// Whether or not we're in debug mode.
	DebugMode bool
}

Provides the basic information needed to run Cadastre: what servers to check, how often to check them, and where to put the data.

func LoadConfigurationFromFile

func LoadConfigurationFromFile(configurationFile string) (*Configuration, error)

type Count

type Count struct {
	Timestamp   int64 `json:"x"`
	ThreadCount int64 `json:"y"`
}

Represents the number of threads running/executing/whatever at a given time.

type Counts

type Counts struct {
	Counts []Count `json:"counts"`
}

Represents a series of counts.

type DataStore

type DataStore interface {
	// Allows the storage engine time before serving requests to initialize itself, spin up any
	// background workers, etc.
	Initialize() error

	// Retrieve the snapshot for the given timestamp.  Returns nil if the snapshot for the given
	// timestamp can't be found, and an error if any errors were encountered.
	RetrieveSnapshot(identifier string, timestamp time.Time) (*Snapshot, error)

	// Retrieve the thread counts for snapshots taken within the given time period.  The time period
	// is calculated as anything on the same day as the given datestamp - only the date matters. Returns
	// nil if there are no counts for the given time period, and an error if any errors were encountered.
	RetrieveCounts(identifier string, datestamp time.Time) (*Counts, error)

	// Persists a snapshot for the given identifier to the underlying storage engine.
	Persist(identifier string, value *Snapshot) error
}

Defines the basic interface for the storage engine.

type Event

type Event struct {
	EventID      int64  `json:"id"`
	TimeElapsed  int64  `json:"timeElapsed"`
	Host         string `json:"host"`
	Database     string `json:"database"`
	User         string `json:"user"`
	Command      string `json:"command"`
	Status       string `json:"status"`
	SQL          string `json:"sql"`
	RowsSent     int64  `json:"rowsSent"`
	RowsExamined int64  `json:"rowsExamined"`
}

Defines a single event at a given point in time in the MySQL process list. It includes the query ID (event ID), how long the query has been running, who is running it and from where, the sttus of the query, the actual query itself, and metadata such as rows sent, examined and read, where applicable.

type Fetcher

type Fetcher struct {
	Configuration *Configuration
	// contains filtered or unexported fields
}

Represents the fetcher, which runs continuously, sucking up data from the specified hosts and persisting it to the storage engine for later retrieval.

func (*Fetcher) Start

func (me *Fetcher) Start() error

func (*Fetcher) Stop

func (me *Fetcher) Stop() error

type FileStore

type FileStore struct {
	DataDirectory string

	RetentionPeriod time.Duration
	// contains filtered or unexported fields
}

func (*FileStore) Initialize

func (me *FileStore) Initialize() error

func (*FileStore) Persist

func (me *FileStore) Persist(identifier string, value *Snapshot) error

func (*FileStore) RetrieveCounts

func (me *FileStore) RetrieveCounts(identifier string, datestamp time.Time) (*Counts, error)

func (*FileStore) RetrieveSnapshot

func (me *FileStore) RetrieveSnapshot(identifier string, timestamp time.Time) (*Snapshot, error)

type Server

type Server struct {
	// The name of the server to show in the UI.
	DisplayName string `json:"displayName"`

	// The internal name of the server, which should be unique.  This is used when
	// persisting and retrieiving snapshots for the host from the storage engine.
	InternalName string `json:"internalName"`

	// The name of the group this server belongs to.
	GroupName string `json:"-"`

	// The canonical data source name for the given server.  This includes hostname,
	// port, username, password, SSL options, etc.
	DataSourceName string `json:"-"`
}

Defines a MySQL server that can be checked.

type ServerGroup

type ServerGroup struct {
	// The name of the group.
	GroupName string `json:"groupName"`

	// The servers that make up the group.
	Servers []Server `json:"servers"`
}

Defines a logical grouping of MySQL servers - testing vs production, etc

type Snapshot

type Snapshot struct {
	Timestamp int64   `json:"timestamp"`
	Events    []Event `json:"events"`
}

A collection of events that represent a complete point-in-time view of the MySQL process list.

func NewSnapshotFromReader

func NewSnapshotFromReader(r io.Reader) (*Snapshot, error)

func (*Snapshot) GetCount

func (me *Snapshot) GetCount() Count

func (*Snapshot) TakeSnapshot

func (me *Snapshot) TakeSnapshot(server Server) error

func (*Snapshot) WriteTo

func (me *Snapshot) WriteTo(w io.Writer) error

type WebUI

type WebUI struct {
	Configuration *Configuration

	RequestsServed uint64
	RequestErrors  uint64
	CacheRequests  uint64
	CacheHits      uint64
	// contains filtered or unexported fields
}

func (*WebUI) StartListening

func (me *WebUI) StartListening() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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