Documentation ¶
Index ¶
- Variables
- func Register(name string, constructorFn func(Config, *log.Logger) (Checker, error))
- type Checker
- type Command
- type CommandConfig
- type Config
- type Container
- type ContainerStats
- type CurrentMetrics
- type DockerStats
- type DockerStatsConfig
- type Failure
- type Host
- type MetricInfo
- type MetricQuery
- type PortConfig
- type Postgres
- type RemoteCommand
- type RemoteCommandConfig
- type RemoteDocker
- type RemoteDockerConfig
- type SCollector
- type SCollectorConfig
- type SSHAuthOptions
- type SSHAuthenticator
- type TCP
- type TCPConfig
- type TestCase
- type TestReport
- type TestReportConfig
- type Testsuite
- type WebPinger
- type WebPingerConfig
Constants ¶
This section is empty.
Variables ¶
View Source
var CommandMetrics = map[string]MetricInfo{
"execution_time": {
Unit: "ms",
},
}
View Source
var DockerStatsMetrics = map[string]MetricInfo{}
View Source
var GlobalSCollector map[Host]CurrentMetrics = make(map[Host]CurrentMetrics)
View Source
var NewCommand = func(config Config, logger *log.Logger) (Checker, error) { var commandConfig CommandConfig err := json.Unmarshal([]byte(config.Config), &commandConfig) if err != nil { return nil, err } if commandConfig.Command == "" { return nil, errors.New("command: command to run cannot be blank") } if commandConfig.Shell == "" { commandConfig.Shell = "sh" } if commandConfig.OutputType != "" && commandConfig.OutputType != "number" { return nil, errors.New("command: invalid output type") } if commandConfig.OutputType == "number" { CommandMetrics["output"] = MetricInfo{ Unit: "unit", } } return Checker(&Command{ commandConfig.Command, commandConfig.Shell, commandConfig.OutputType, logger}), nil }
View Source
var NewDockerRemoteDocker = func(config Config, logger *log.Logger) (Checker, error) { var remoteDockerConfig RemoteDockerConfig err := json.Unmarshal([]byte(config.Config), &remoteDockerConfig) if err != nil { return nil, err } tool := utils.StringDefault(remoteDockerConfig.Tool, "nc") if !utils.FindStringInArray(tool, []string{"nc", "socat"}) { return nil, errors.New("checks: unknown tool in remote docker config") } if remoteDockerConfig.User == "" { return nil, errors.New("remote-docker: user cannot be blank") } if remoteDockerConfig.Host == "" { return nil, errors.New("remote-docker: host cannot be blank") } return Checker(&RemoteDocker{ User: remoteDockerConfig.User, Password: remoteDockerConfig.Password, Host: remoteDockerConfig.Host, Key: remoteDockerConfig.Key, Tool: tool, log: logger, }), nil }
View Source
var NewDockerStats = func(config Config, logger *log.Logger) (Checker, error) { var commandConfig DockerStatsConfig err := json.Unmarshal([]byte(config.Config), &commandConfig) if err != nil { return nil, err } return Checker(&DockerStats{logger}), nil }
View Source
var NewPostgres = func(config Config, logger *log.Logger) (Checker, error) { postgres := new(Postgres) err := json.Unmarshal([]byte(config.Config), postgres) if err != nil { return nil, err } if postgres.ConnectionURL == "" { return nil, errors.New("postgres: connection url cannot be blank") } if len(postgres.MetricQueries) == 0 { return nil, errors.New("postgres: no metrics to query") } postgres.log = logger return Checker(postgres), nil }
View Source
var NewRemoteCommand = func(config Config, logger *log.Logger) (Checker, error) { var commandConfig RemoteCommandConfig err := json.Unmarshal([]byte(config.Config), &commandConfig) if err != nil { return nil, err } if commandConfig.Command == "" { return nil, errors.New("remote-command: command to run cannot be blank") } if commandConfig.OutputType != "" && commandConfig.OutputType != "number" { return nil, errors.New("remote-command: invalid output type") } if commandConfig.OutputType == "number" { RemoteCommandMetrics["output"] = MetricInfo{ Unit: "unit", } } return Checker(&RemoteCommand{ commandConfig.Command, commandConfig.OutputType, commandConfig.SSHAuthOptions, logger}), nil }
View Source
var NewSCollector = func(config Config, logger *log.Logger) (Checker, error) { var sCollectorConfig SCollectorConfig err := json.Unmarshal([]byte(config.Config), &sCollectorConfig) if err != nil { return nil, err } if sCollectorConfig.Host == "" { return nil, errors.New("scollector: host to collect stats via scollector cannot be blank") } return Checker(&SCollector{sCollectorConfig.Host}), nil }
View Source
var NewTCP = func(config Config, logger *log.Logger) (Checker, error) { var tcpConfig TCPConfig err := json.Unmarshal([]byte(config.Config), &tcpConfig) if err != nil { return nil, err } if tcpConfig.Host == "" { return nil, errors.New("tcp: host to connect to cannot be blank") } if tcpConfig.Port == 0 { return nil, errors.New("tcp: port to connect to cannot be zero") } return Checker(&TCP{tcpConfig.Host, tcpConfig.Port, logger}), nil }
View Source
var NewTestReport = func(config Config, logger *log.Logger) (Checker, error) { var testReportConfig TestReportConfig err := json.Unmarshal([]byte(config.Config), &testReportConfig) if err != nil { return nil, err } if testReportConfig.Command == "" { return nil, errors.New("command: command to run cannot be blank") } if testReportConfig.Shell == "" { testReportConfig.Shell = "sh" } return Checker(&TestReport{ testReportConfig.Command, testReportConfig.Shell, logger}), nil }
View Source
var NewWebPinger = func(config Config, logger *log.Logger) (Checker, error) { var webPingerConfig WebPingerConfig err := json.Unmarshal([]byte(config.Config), &webPingerConfig) if err != nil { return nil, err } if webPingerConfig.Address == "" { return nil, errors.New("web-ping: address to ping cannot be blank") } return Checker(&WebPinger{config, webPingerConfig, logger}), nil }
View Source
var RemoteCommandMetrics = map[string]MetricInfo{
"execution_time": {
Unit: "ms",
},
}
View Source
var TCPMetrics = map[string]MetricInfo{
"latency": {
Unit: "ms",
},
}
View Source
var TestReportMetrics = map[string]MetricInfo{
"execution_time": {
Unit: "ms",
},
}
View Source
var WebPingerMetrics = map[string]MetricInfo{
"latency": {
Unit: "ms",
},
}
Functions ¶
Types ¶
type Checker ¶
type Checker interface { Check() (data.CheckResponse, error) MetricInfo(string) MetricInfo MessageContext() string }
The Checker implements a type of status check / mechanism of data collection which may be used for triggering alerts
type Command ¶
type Command struct { Command string Shell string OutputType string // contains filtered or unexported fields }
func (*Command) MessageContext ¶
func (*Command) MetricInfo ¶
func (c *Command) MetricInfo(metric string) MetricInfo
type CommandConfig ¶
type Config ¶
type Config struct { ID string `json:"id"` Name string `json:"name"` Type string `json:"type"` SendAlerts []string `json:"send_alerts"` Backoff backoffs.Config `json:"backoff"` Config json.RawMessage `json:"config"` Assertions []assertions.Config `json:"assertions"` Enabled *bool `json:"enabled,omitempty"` VerboseLogging *bool `json:"verbose_logging,omitempty"` }
type ContainerStats ¶
type ContainerStats struct { Read string `json:"read"` Network struct { RxDropped int `json:"rx_dropped"` RxBytes int `json:"rx_bytes"` RxErrors int `json:"rx_errors"` TxPackets int `json:"tx_packets"` TxDropped int `json:"tx_dropped"` RxPackets int `json:"rx_packets"` TxErrors int `json:"tx_errors"` TxBytes int `json:"tx_bytes"` } `json:"network"` MemoryStats struct { Stats struct { TotalRss int `json:"total_rss"` } `json:"stats"` MaxUsage int `json:"max_usage"` Usage int `json:"usage"` Failcnt int `json:"failcnt"` Limit int `json:"limit"` } `json:"memory_stats"` CpuStats struct { CpuUsage struct { PercpuUsage []int `json:"percpu_usage"` UsageInUsermode int `json:"usage_in_usermode"` TotalUsage int `json:"total_usage"` UsageInKernelmode int `json:"usage_in_kernelmode"` } `json:"cpu_usage"` SystemCpuUsage int `json:"system_cpu_usage"` } `json:"cpu_stats"` }
type CurrentMetrics ¶
type DockerStats ¶
type DockerStats struct {
// contains filtered or unexported fields
}
func (*DockerStats) Check ¶
func (c *DockerStats) Check() (data.CheckResponse, error)
func (*DockerStats) MessageContext ¶
func (c *DockerStats) MessageContext() string
func (*DockerStats) MetricInfo ¶
func (c *DockerStats) MetricInfo(metric string) MetricInfo
type DockerStatsConfig ¶
type DockerStatsConfig struct { }
type MetricInfo ¶
type MetricInfo struct {
Unit string
}
type MetricQuery ¶
type Postgres ¶
type Postgres struct { ConnectionURL string `json:"connection_url"` MetricQueries []MetricQuery `json:"metric_queries"` // contains filtered or unexported fields }
func (*Postgres) MessageContext ¶
func (*Postgres) MetricInfo ¶
func (p *Postgres) MetricInfo(metric string) MetricInfo
type RemoteCommand ¶
type RemoteCommand struct { Command string OutputType string SSHAuthOptions SSHAuthOptions // contains filtered or unexported fields }
func (*RemoteCommand) Check ¶
func (c *RemoteCommand) Check() (data.CheckResponse, error)
func (*RemoteCommand) MessageContext ¶
func (c *RemoteCommand) MessageContext() string
func (*RemoteCommand) MetricInfo ¶
func (c *RemoteCommand) MetricInfo(metric string) MetricInfo
type RemoteCommandConfig ¶
type RemoteCommandConfig struct { Command string `json:"command"` OutputType string `json:"output_type"` SSHAuthOptions SSHAuthOptions `json:"ssh_auth_options"` }
type RemoteDocker ¶
type RemoteDocker struct { User string Password string Host string Key string Tool string // contains filtered or unexported fields }
func (*RemoteDocker) Check ¶
func (r *RemoteDocker) Check() (data.CheckResponse, error)
func (*RemoteDocker) MessageContext ¶
func (r *RemoteDocker) MessageContext() string
func (*RemoteDocker) MetricInfo ¶
func (r *RemoteDocker) MetricInfo(metric string) MetricInfo
type RemoteDockerConfig ¶
type SCollector ¶
type SCollector struct {
Host string
}
func (*SCollector) Check ¶
func (sc *SCollector) Check() (data.CheckResponse, error)
func (*SCollector) MessageContext ¶
func (sc *SCollector) MessageContext() string
func (*SCollector) MetricInfo ¶
func (sc *SCollector) MetricInfo(metric string) MetricInfo
type SCollectorConfig ¶
type SCollectorConfig struct {
Host string `json:"host"`
}
type SSHAuthOptions ¶
type SSHAuthenticator ¶
type SSHAuthenticator struct {
// contains filtered or unexported fields
}
func NewSSHAuthenticator ¶
func NewSSHAuthenticator(logger *log.Logger, options SSHAuthOptions) *SSHAuthenticator
func (*SSHAuthenticator) Cleanup ¶
func (s *SSHAuthenticator) Cleanup() error
type TCP ¶
func (*TCP) MessageContext ¶
func (*TCP) MetricInfo ¶
func (t *TCP) MetricInfo(metric string) MetricInfo
type TestReport ¶ added in v0.2.2
func (*TestReport) Check ¶ added in v0.2.2
func (c *TestReport) Check() (data.CheckResponse, error)
func (*TestReport) MessageContext ¶ added in v0.2.2
func (c *TestReport) MessageContext() string
func (*TestReport) MetricInfo ¶ added in v0.2.2
func (c *TestReport) MetricInfo(metric string) MetricInfo
type TestReportConfig ¶ added in v0.2.2
type WebPinger ¶
type WebPinger struct { Config Config WebPingerConfig WebPingerConfig // contains filtered or unexported fields }
func (*WebPinger) MessageContext ¶
func (*WebPinger) MetricInfo ¶
func (wp *WebPinger) MetricInfo(metric string) MetricInfo
type WebPingerConfig ¶
Click to show internal directories.
Click to hide internal directories.