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
- type CadastreWebHandler
- type Configuration
- type Count
- type Counts
- type DataStore
- type Event
- type Fetcher
- type FileStore
- func (me *FileStore) Initialize() error
- func (me *FileStore) Persist(identifier string, value *Snapshot) error
- func (me *FileStore) RetrieveCounts(identifier string, datestamp time.Time) (*Counts, error)
- func (me *FileStore) RetrieveSnapshot(identifier string, timestamp time.Time) (*Snapshot, error)
- type Server
- type ServerGroup
- type Snapshot
- type WebUI
Constants ¶
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 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.
type FileStore ¶
type FileStore struct { DataDirectory string RetentionPeriod time.Duration // contains filtered or unexported fields }
func (*FileStore) Initialize ¶
func (*FileStore) RetrieveCounts ¶
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 ¶
A collection of events that represent a complete point-in-time view of the MySQL process list.