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 ¶
const ( DefaultSendInterval = 10 * time.Minute MinimumSendInterval = DefaultSendInterval / 2 DefaultCheckInterval = MinimumSendInterval MinimumCheckInterval = 10 * time.Second MinimumTimeout = time.Second DefaultTimeout = 10 * MinimumTimeout MaximumParallel = 10 DefaultBuffer = 1000 NotifiarrEventType = "service_checks" )
Defaults.
Variables ¶
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", CheckTCP, CheckHTTP, CheckPROC) ErrBadTCP = fmt.Errorf("tcp checks must have an ip:port or host:port combo; the :port is required") )
Errors returned by this package.
Functions ¶
This section is empty.
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"` }
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.
type Config ¶
type Config struct { Interval cnfg.Duration `toml:"interval" xml:"interval"` Parallel uint `toml:"parallel" xml:"parallel"` Disabled bool `toml:"disabled" xml:"disabled"` LogFile string `toml:"log_file" xml:"log_file"` Apps *apps.Apps `toml:"-"` Notifiarr *notifiarr.Config `toml:"-"` *logs.Logger `json:"-"` // log file writer // contains filtered or unexported fields }
Config for this 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) RunAllChecksSendResult ¶ added in v0.1.14
func (*Config) RunChecks ¶
RunChecks runs checks that are due. Passing true, runs them even if they're not due. Returns true if a service state changed.
func (*Config) SendResults ¶
SendResults sends a set of Results to Notifiarr.
type ProcInfo ¶ added in v0.1.4
ProcInfo is derived from a pid.
func GetAllProcesses ¶ added in v0.1.4
GetAllProcesses returns all running process on the host.
type Results ¶
type Results struct { Type string `json:"eventType"` What string `json:"what"` Interval float64 `json:"interval"` Svcs []*CheckResult `json:"services"` }
Results is sent to Notifiarr.
type Service ¶
type Service struct { Name string `toml:"name" xml:"name"` // Radarr Type CheckType `toml:"type" xml:"type"` // http Value string `toml:"check" xml:"check"` // http://some.url Expect string `toml:"expect" xml:"expect"` // 200 Timeout cnfg.Duration `toml:"timeout" xml:"timeout"` // 10s Interval cnfg.Duration `toml:"interval" xml:"interval"` // 1m // contains filtered or unexported fields }
Service is a thing we check and report results for.