services

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2021 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
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

View Source
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.

View Source
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")
)

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

type CheckType

type CheckType string

CheckType locks us into a few specific types of checks.

const (
	CheckHTTP CheckType = "http"
	CheckTCP  CheckType = "tcp"
	CheckPING CheckType = "ping"
	CheckPROC CheckType = "process"
)

These are our supported Check Types.

type Config

type Config struct {
	Interval     cnfg.Duration     `toml:"interval" xml:"interval"`
	Parallel     uint              `toml:"parallel" xml:"parallel"`
	Disabled     bool              `toml:"disabled" xml:"disabled"`
	Apps         *apps.Apps        `toml:"-"`
	Notify       *notifiarr.Config `toml:"-"`
	*logs.Logger `json:"-"`        // log file writer
	// contains filtered or unexported fields
}

Config for this plugin.

func (*Config) GetResults

func (c *Config) GetResults() []*CheckResult

func (*Config) RunChecks

func (c *Config) RunChecks(forceAll bool) bool

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

func (c *Config) SendResults(url string, results *Results)

SendResults sends a set of Results to Notifiarr.

func (*Config) Start

func (c *Config) Start(services []*Service) error

func (*Config) Stop

func (c *Config) Stop()

type ProcInfo added in v0.1.4

type ProcInfo struct {
	CmdLine string
	Created time.Time
	PID     int32
}

ProcInfo is derived from a pid.

func GetAllProcesses added in v0.1.4

func GetAllProcesses() ([]*ProcInfo, error)

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.

Jump to

Keyboard shortcuts

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