pmm

package
v0.0.0-...-77276c9 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2020 License: AGPL-3.0 Imports: 46 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ServerInfoTemplate = `` /* 228-byte string literal not displayed */

	DefaultServerInfoTemplate = `{{template "ServerInfo" .}}
`
)
View Source
const (
	DefaultListTemplate = `` /* 268-byte string literal not displayed */

)

each non-empty field value must end with newline

View Source
const (
	NameRegex = `^[-\w:\.]{2,60}$`
)

Variables

View Source
var (
	// you can use `-ldflags -X github.com/percona/pmm-client/pmm.Version=`
	// to set build version number
	Version = "1.17.4"

	// you can use `-ldflags -X github.com/percona/pmm-client/pmm.RootDir=`
	// to set root filesystem for pmm-admin
	RootDir = ""

	PMMBaseDir   = RootDir + "/usr/local/percona/pmm-client"
	AgentBaseDir = RootDir + "/usr/local/percona/qan-agent"

	ConfigFile  = fmt.Sprintf("%s/pmm.yml", PMMBaseDir)
	SSLCertFile = fmt.Sprintf("%s/server.crt", PMMBaseDir)
	SSLKeyFile  = fmt.Sprintf("%s/server.key", PMMBaseDir)

	ErrDuplicate = errors.New("there is already one instance with this name under monitoring.")
	ErrNoService = errors.New("no service found.")
)
View Source
var (
	NewService func(i service.Interface, c *service.Config) (service.Service, error) = service.New
)

Functions

func CheckBinaries

func CheckBinaries() string

CheckBinaries check if all PMM Client binaries are at their paths

func CheckMonitoredDBServices

func CheckMonitoredDBServices() []string

CheckMonitoredDBServices finds out what DB instances are monitored.

func FileExists

func FileExists(file string) bool

FileExists check if file exists.

func GetLocalServices

func GetLocalServices() (services []string)

GetLocalServices finds any local PMM services

func GetServiceDirAndExtension

func GetServiceDirAndExtension() (dir, extension string)

GetServiceDirAndExtension returns dir and extension used to create system service

Types

type API

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

func NewAPI

func NewAPI(insecureFlag bool, timeout time.Duration, debug bool) *API

func (*API) Delete

func (a *API) Delete(url string) (*http.Response, []byte, error)

func (*API) Error

func (a *API) Error(method, url string, gotStatusCode, expectedStatusCode int, content []byte) error

func (*API) Get

func (a *API) Get(url string) (*http.Response, []byte, error)

func (*API) Hostname

func (a *API) Hostname() string

func (*API) NewClient

func (a *API) NewClient() *http.Client

NewClient creates new *http.Client tailored for this API

func (*API) Ping

func (a *API) Ping(url string) error

func (*API) Post

func (a *API) Post(url string, data []byte) (*http.Response, []byte, error)

func (*API) Put

func (a *API) Put(url string, data []byte) (*http.Response, []byte, error)

func (*API) URL

func (a *API) URL(paths ...string) string

type Admin

type Admin struct {
	ServiceName string
	ServicePort int
	Args        []string // Args defines additional arguments to pass through to *_exporter or qan-agent
	Config      *Config
	Verbose     bool
	SkipAdmin   bool
	Format      string
	// contains filtered or unexported fields
}

Admin main class.

func (*Admin) AddAnnotation

func (a *Admin) AddAnnotation(ctx context.Context, text string, tags string) error

AddAnnotation posts annotation to managed.

func (*Admin) AddExternalInstances

func (a *Admin) AddExternalInstances(ctx context.Context, name string, targets []ExternalTarget, checkReachability bool) error

AddExternalInstances adds targets to existing scrape job.

func (*Admin) AddExternalMetrics

func (a *Admin) AddExternalMetrics(ctx context.Context, ext *ExternalMetrics, checkReachability bool) error

AddExternalMetrics adds external Prometheus scrape job and targets.

func (*Admin) AddExternalService

func (a *Admin) AddExternalService(ctx context.Context, ext *ExternalMetrics, force bool) error

func (*Admin) AddMetrics

func (a *Admin) AddMetrics(ctx context.Context, m plugin.Metrics, force bool, disableSSL bool) (*plugin.Info, error)

AddMetrics add metrics service to monitoring.

func (*Admin) AddQueries

func (a *Admin) AddQueries(ctx context.Context, q plugin.Queries) (*plugin.Info, error)

AddQueries add instance to Query Analytics.

func (*Admin) CheckInstallation

func (a *Admin) CheckInstallation() (orphanedServices, missingServices []string)

CheckInstallation check for broken installation.

func (*Admin) CheckNetwork

func (a *Admin) CheckNetwork() error

CheckNetwork check connectivity between client and server.

func (*Admin) CheckVersion

func (a *Admin) CheckVersion(ctx context.Context) (fatal bool, err error)

CheckVersion check server and client versions and returns boolean and error; boolean is true if error is fatal.

func (*Admin) CollectSummary

func (a *Admin) CollectSummary() error

CollectSummary get output of system and pmm utilites.

func (*Admin) List

func (a *Admin) List() error

List prints to stdout all services from Consul.

func (*Admin) ListExternalMetrics

func (a *Admin) ListExternalMetrics(ctx context.Context) ([]ExternalMetrics, error)

ListExternalMetrics returns external Prometheus exporters.

func (*Admin) LoadConfig

func (a *Admin) LoadConfig() error

LoadConfig read PMM client config file.

func (*Admin) PrintInfo

func (a *Admin) PrintInfo()

PrintInfo print PMM client info.

func (*Admin) PurgeMetrics

func (a *Admin) PurgeMetrics(svcType string) error

PurgeMetrics purge metrics data on the server by its metric type and name.

func (*Admin) RemoveAllMonitoring

func (a *Admin) RemoveAllMonitoring(ignoreErrors bool) (uint16, error)

RemoveAllMonitoring remove all the monitoring services.

func (*Admin) RemoveExternalInstances

func (a *Admin) RemoveExternalInstances(ctx context.Context, name string, targets []string) error

RemoveExternalInstances removes targets from existing scrape job.

func (*Admin) RemoveExternalMetrics

func (a *Admin) RemoveExternalMetrics(ctx context.Context, name string) error

RemoveExternalMetrics removes external Prometheus scrape job and targets.

func (*Admin) RemoveMetrics

func (a *Admin) RemoveMetrics(name string) error

RemoveMetrics remove metrics service from monitoring.

func (*Admin) RemoveQueries

func (a *Admin) RemoveQueries(name string) error

RemoveQueries remove instance from QAN.

func (*Admin) RepairInstallation

func (a *Admin) RepairInstallation() error

RepairInstallation repair installation.

func (*Admin) ServerInfo

func (a *Admin) ServerInfo() error

ServerInfo print server info.

func (*Admin) SetAPI

func (a *Admin) SetAPI() error

SetAPI setups QAN, Consul, Prometheus, pmm-managed clients and verifies connections.

func (*Admin) SetConfig

func (a *Admin) SetConfig(cf Config, flagForce bool) error

SetConfig configure PMM client, check connectivity and write the config.

func (*Admin) ShowPasswords

func (a *Admin) ShowPasswords()

ShowPasswords display passwords from config file.

func (*Admin) StartStopAllMonitoring

func (a *Admin) StartStopAllMonitoring(action string) (numOfAffected, numOfAll int, err error)

StartStopAllMonitoring start/stop all metric services.

func (*Admin) StartStopMonitoring

func (a *Admin) StartStopMonitoring(action, svcType string) (affected bool, err error)

StartStopMonitoring start/stop system service by its metric type and name.

func (*Admin) Uninstall

func (a *Admin) Uninstall() uint16

Uninstall remove all monitoring services with the best effort.

type Collector

type Collector struct {
	CollectorDescription string
	ExecCommand          []string
	OutputFileName       string
}

Collector parameters and description.

func (*Collector) CollectData

func (c *Collector) CollectData() error

CollectData runs a command and collects output into a file.

type Config

type Config struct {
	ServerAddress     string `yaml:"server_address"`
	ClientAddress     string `yaml:"client_address"`
	BindAddress       string `yaml:"bind_address"`
	ClientName        string `yaml:"client_name"`
	MySQLPassword     string `yaml:"mysql_password,omitempty"`
	ServerUser        string `yaml:"server_user,omitempty"`
	ServerPassword    string `yaml:"server_password,omitempty"`
	ServerSSL         bool   `yaml:"server_ssl,omitempty"`
	ServerInsecureSSL bool   `yaml:"server_insecure_ssl,omitempty"`
}

Config pmm.yml config file.

type Errors

type Errors []error

func (Errors) Error

func (e Errors) Error() string

type ExternalLabelPair

type ExternalLabelPair struct {
	Name  string
	Value string
}

type ExternalMetrics

type ExternalMetrics struct {
	JobName        string
	ScrapeInterval time.Duration // nanoseconds in JSON
	ScrapeTimeout  time.Duration // nanoseconds in JSON
	MetricsPath    string
	Scheme         string
	Targets        []ExternalTarget
}

ExternalMetrics represents external Prometheus exporter configuration: job and targets. Field names are used for JSON output, so do not rename them. JSON output uses Prometheus and pmm-managed API terms; TUI uses terms aligned with other commands.

type ExternalTarget

type ExternalTarget struct {
	Target string
	Labels []ExternalLabelPair
	Health string
}

type List

type List struct {
	Version string
	ServerInfo
	Platform         string
	Err              string
	Services         []ServiceStatus
	ExternalErr      string
	ExternalServices []ExternalMetrics
}

func (*List) ExternalTable

func (l *List) ExternalTable() string

ExternalTable formats *List.ExternalServices as table and returns result as string.

func (*List) Format

func (l *List) Format(format string) string

Format formats *List with provided format template and returns result as string.

func (*List) Table

func (l *List) Table() string

Table formats *List.Services as table and returns result as string.

type ServerInfo

type ServerInfo struct {
	ServerAddress     string
	ServerSecurity    string
	ClientName        string
	ClientAddress     string
	ClientBindAddress string
}

type ServiceStatus

type ServiceStatus struct {
	Type     string
	Name     string
	Port     string
	Running  bool
	DSN      string
	Options  string
	SSL      string
	Password string
}

Service status description.

Jump to

Keyboard shortcuts

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