pmm

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2018 License: AGPL-3.0 Imports: 49 Imported by: 2

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 = "EXPERIMENTAL"

	// 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.")
	ErrOneLinux  = errors.New("there could be only one instance of linux metrics being monitored for this system.")
)
View Source
var (
	NewService func(i service.Interface, c *service.Config) (service.Service, error) = service.New
)

Functions

func CheckBinaries added in v1.0.4

func CheckBinaries() string

CheckBinaries check if all PMM Client binaries are at their paths

func FileExists

func FileExists(file string) bool

FileExists check if file exists.

func GetLocalServices added in v1.3.2

func GetLocalServices() (services []string)

GetLocalServices finds any local PMM services

func GetServiceDirAndExtension added in v1.3.2

func GetServiceDirAndExtension() (dir, extension string)

GetServiceDirAndExtension returns dir and extension used to create system service

func SanitizeDSN

func SanitizeDSN(dsn string) string

SanitizeDSN remove password from DSN

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 added in v1.3.2

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
	Format      string
	// contains filtered or unexported fields
}

Admin main class.

func (*Admin) AddExternalInstances added in v1.4.0

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

AddExternalInstances adds targets to existing scrape job.

func (*Admin) AddExternalMetrics added in v1.4.0

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

AddExternalMetrics adds external Prometheus scrape job and targets.

func (*Admin) AddExternalService added in v1.7.0

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

func (*Admin) AddLinuxMetrics added in v1.0.4

func (a *Admin) AddLinuxMetrics(force bool) error

AddLinuxMetrics add linux service to monitoring.

func (*Admin) AddMongoDBMetrics added in v1.0.4

func (a *Admin) AddMongoDBMetrics(uri, cluster string) error

AddMongoDBMetrics add mongodb metrics service to monitoring.

func (*Admin) AddMongoDBQueries added in v1.3.2

func (a *Admin) AddMongoDBQueries(buildInfo mgo.BuildInfo, uri string) error

AddMongoDBQueries add mongodb instance to Query Analytics.

func (*Admin) AddMySQLMetrics added in v1.0.4

func (a *Admin) AddMySQLMetrics(info map[string]string, mf MySQLFlags) error

AddMySQLMetrics add mysql metrics service to monitoring.

func (*Admin) AddMySQLQueries added in v1.0.4

func (a *Admin) AddMySQLQueries(info map[string]string) error

AddMySQLQueries add mysql instance to Query Analytics.

func (*Admin) AddProxySQLMetrics added in v1.0.5

func (a *Admin) AddProxySQLMetrics(dsn string) error

AddProxySQLMetrics add proxysql service to monitoring.

func (*Admin) CheckInstallation added in v1.0.5

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) DetectMongoDB added in v1.0.4

func (a *Admin) DetectMongoDB(uri string) (mgo.BuildInfo, error)

DetectMongoDB verifies MongoDB connection.

func (*Admin) DetectMySQL added in v1.0.4

func (a *Admin) DetectMySQL(mf MySQLFlags) (map[string]string, error)

DetectMySQL detect MySQL, create user if needed, return DSN and MySQL info strings.

func (*Admin) DetectProxySQL added in v1.0.5

func (a *Admin) DetectProxySQL(dsnString string) error

DetectProxySQL verify ProxySQL connection.

func (*Admin) List

func (a *Admin) List() error

List prints to stdout all services from Consul.

func (*Admin) ListExternalMetrics added in v1.4.0

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 added in v1.0.6

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

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

func (*Admin) RemoveAllMonitoring added in v1.0.4

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

RemoveAllMonitoring remove all the monitoring services.

func (*Admin) RemoveExternalInstances added in v1.4.0

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

RemoveExternalInstances removes targets from existing scrape job.

func (*Admin) RemoveExternalMetrics added in v1.4.0

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

RemoveExternalMetrics removes external Prometheus scrape job and targets.

func (*Admin) RemoveLinuxMetrics added in v1.0.4

func (a *Admin) RemoveLinuxMetrics() error

RemoveLinuxMetrics remove linux service from monitoring.

func (*Admin) RemoveMongoDBMetrics added in v1.0.4

func (a *Admin) RemoveMongoDBMetrics() error

RemoveMongoDBMetrics remove mongodb metrics service from monitoring.

func (*Admin) RemoveMongoDBQueries added in v1.3.2

func (a *Admin) RemoveMongoDBQueries() error

RemoveMongoDBQueries remove mongodb instance from QAN.

func (*Admin) RemoveMySQLMetrics added in v1.0.4

func (a *Admin) RemoveMySQLMetrics() error

RemoveMySQLMetrics remove mysql metrics service from monitoring.

func (*Admin) RemoveMySQLQueries added in v1.0.4

func (a *Admin) RemoveMySQLQueries() error

RemoveMySQLQueries remove mysql instance from QAN.

func (*Admin) RemoveProxySQLMetrics added in v1.0.5

func (a *Admin) RemoveProxySQLMetrics() error

RemoveProxySQLMetrics remove proxysql service from monitoring.

func (*Admin) RepairInstallation added in v1.0.5

func (a *Admin) RepairInstallation() error

RepairInstallation repair installation.

func (*Admin) ServerInfo added in v1.0.4

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 added in v1.0.7

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 added in v1.0.6

func (a *Admin) Uninstall() uint16

Uninstall remove all monitoring services with the best effort.

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 added in v1.1.2

type Errors []error

func (Errors) Error added in v1.1.2

func (e Errors) Error() string

type ExternalLabelPair added in v1.7.0

type ExternalLabelPair struct {
	Name  string
	Value string
}

type ExternalMetrics added in v1.4.0

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 added in v1.7.0

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

type List added in v1.4.0

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

func (*List) ExternalTable added in v1.4.0

func (l *List) ExternalTable() string

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

func (*List) Format added in v1.4.0

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

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

func (*List) Table added in v1.4.0

func (l *List) Table() string

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

type MySQLFlags

type MySQLFlags struct {
	DefaultsFile string
	User         string
	Password     string
	Host         string
	Port         string
	Socket       string

	QuerySource string

	CreateUser         bool
	CreateUserPassword string
	MaxUserConn        uint16
	Force              bool

	DisableTableStats      bool
	DisableTableStatsLimit uint16
	DisableUserStats       bool
	DisableBinlogStats     bool
	DisableProcesslist     bool
	DisableQueryExamples   bool
}

MySQLFlags MySQL specific flags.

type ServerInfo added in v1.4.0

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

type ServiceStatus added in v1.4.0

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

Service status description.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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