Documentation ¶
Overview ¶
Package services provides service-checks to the notifiarr client application. This package spins up go routines to check http endpoints, running processes, tcp ports, etc. The configuration comes directly from the config file.
Index ¶
- Constants
- Variables
- func RemoveSecrets(appURL, message string) string
- type CheckResult
- type CheckState
- type CheckType
- type Config
- func (c *Config) GetResults() []*CheckResult
- func (c *Config) RunCheck(source website.EventType, name string) error
- func (c *Config) RunChecks(source website.EventType)
- func (c *Config) Running() bool
- func (c *Config) SendResults(results *Results)
- func (c *Config) Setup(services []*Service) error
- func (c *Config) Start(ctx context.Context)
- func (c *Config) Stop()
- type ProcInfo
- type Results
- type Service
Constants ¶
const ( DefaultSendInterval = 10 * time.Minute MinimumSendInterval = DefaultSendInterval / 2 DefaultCheckInterval = MinimumSendInterval MinimumCheckInterval = 10 * time.Second MinimumTimeout = time.Second DefaultTimeout = 10 * MinimumTimeout MaximumParallel = 10 DefaultBuffer = 1000 )
Services Defaults.
Variables ¶
var ( ErrPingExpect = fmt.Errorf("ping/icmp expect must contain three integers separated by two colons. ex: 3:2:500") ErrNoPingVal = fmt.Errorf("ping or icmp 'check' must not be empty") ErrPingCountZero = fmt.Errorf("none of the ping expect values may be set to 0") )
Custom errors.
var ( ErrProcExpect = fmt.Errorf("invalid process expect type") ErrNoProcVal = fmt.Errorf("process 'check' must not be empty") ErrCountZero = fmt.Errorf("process 'count' may not be used with 'running'") ErrBSDRestart = fmt.Errorf("process 'restart' check does not work on FreeBSD") // one day. )
Custom errors.
var ( ErrNoName = fmt.Errorf("service check is missing a unique name") ErrNoCheck = fmt.Errorf("service check is missing a check value") ErrInvalidType = fmt.Errorf("service check type must be one of %s, %s, %s, %s, %s", CheckTCP, CheckHTTP, CheckPROC, CheckPING, CheckICMP) ErrBadTCP = fmt.Errorf("tcp checks must have an ip:port or host:port combo; the :port is required") )
Errors returned by this Services package.
var ErrSvcsStopped = fmt.Errorf("service check routine stopped")
Functions ¶
func RemoveSecrets ¶ added in v0.2.1
RemoveSecrets removes secret token values in a message parsed from a url.
Types ¶
type CheckResult ¶
type CheckResult struct { Name string `json:"name"` // "Radarr" State CheckState `json:"state"` // 0 = OK, 1 = Warn, 2 = Crit, 3 = Unknown Output string `json:"output"` // metadata message Type CheckType `json:"type"` // http, tcp, ping Time time.Time `json:"time"` // when it was checked, rounded to Microseconds Since time.Time `json:"since"` // how long it has been in this state, rounded to Microseconds Interval float64 `json:"interval"` Check string `json:"-"` Expect string `json:"-"` IntervalDur time.Duration `json:"-"` }
CheckResult represents the status of a service.
type CheckState ¶
type CheckState uint
CheckState represents the current state of a service check.
const ( StateOK CheckState = iota StateWarning StateCritical StateUnknown )
Supported check states.
func (CheckState) String ¶
func (c CheckState) String() string
String turns a check status into a human string.
func (CheckState) Value ¶ added in v0.3.0
func (c CheckState) Value() uint
type Config ¶
type Config struct { Interval cnfg.Duration `toml:"interval" xml:"interval" json:"interval"` Parallel uint `toml:"parallel" xml:"parallel" json:"parallel"` Disabled bool `toml:"disabled" xml:"disabled" json:"disabled"` LogFile string `toml:"log_file" xml:"log_file" json:"logFile"` Apps *apps.Apps `toml:"-" json:"-"` Website *website.Server `toml:"-" json:"-"` Plugins *snapshot.Plugins `toml:"-" json:"-"` mnd.Logger `json:"-"` // log file writer // contains filtered or unexported fields }
Config for this Services plugin comes from a config file.
func (*Config) GetResults ¶
func (c *Config) GetResults() []*CheckResult
GetResults creates a copy of all the results and returns them.
func (*Config) SendResults ¶
SendResults sends a set of Results to Notifiarr.
type Results ¶
type Results struct { Type string `json:"eventType"` What website.EventType `json:"what"` Interval float64 `json:"interval"` Svcs []*CheckResult `json:"services"` }
Results is sent to website.
type Service ¶
type Service struct { Name string `toml:"name" xml:"name" json:"name"` // Radarr Type CheckType `toml:"type" xml:"type" json:"type"` // http Value string `toml:"check" xml:"check" json:"value"` // http://some.url Expect string `toml:"expect" xml:"expect" json:"expect"` // 200 Timeout cnfg.Duration `toml:"timeout" xml:"timeout" json:"timeout"` // 10s Interval cnfg.Duration `toml:"interval" xml:"interval" json:"interval"` // 1m // contains filtered or unexported fields }
Service is a thing we check and report results for.