monitor

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package monitor implements monitoring logics.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRegistered    = errors.New("monitor has already been registered")
	ErrNotRegistered = errors.New("monitor has not been registered")
	ErrStarted       = errors.New("monitor has already been started")
)

Errors for monitors.

Functions

func Register

func Register(m *Monitor) error

Register registers a monitor.

func Unregister

func Unregister(m *Monitor) error

Unregister removes a monitor from the registry. The monitor should have stopped.

Types

type Monitor

type Monitor struct {
	// contains filtered or unexported fields
}

Monitor is a unit of monitoring.

It consists of a (configured) probe, zero or one filter, and one or more actions. goma will invoke Prover.Probe periodically at given interval.

func FindMonitor

func FindMonitor(id int) *Monitor

FindMonitor looks up a monitor in the registry. If not found, nil is returned.

func ListMonitors

func ListMonitors() []*Monitor

ListMonitors returns a list of monitors ordered by ID (ascending).

func NewMonitor

func NewMonitor(
	name string,
	p probes.Prober,
	f filters.Filter,
	a []actions.Actor,
	interval, timeout time.Duration,
	min, max float64) *Monitor

NewMonitor creates and initializes a monitor.

name can be any descriptive string for the monitor. p and a should not be nil. f may be nil. interval is the interval between probes. timeout is the maximum duration for a probe to run. min and max defines the range for normal probe results.

func (*Monitor) Failing

func (m *Monitor) Failing() bool

Failing returns true if the monitor is detecting a failure.

func (*Monitor) ID

func (m *Monitor) ID() int

ID returns the monitor ID.

ID is valid only after registration.

func (*Monitor) Name

func (m *Monitor) Name() string

Name returns the name of the monitor.

func (*Monitor) Running

func (m *Monitor) Running() bool

Running returns true if the monitor is running.

func (*Monitor) Start

func (m *Monitor) Start() error

Start starts monitoring. If already started, this returns a non-nil error.

func (*Monitor) Stop

func (m *Monitor) Stop()

Stop stops monitoring.

func (*Monitor) String

func (m *Monitor) String() string

String is the same as Name.

Jump to

Keyboard shortcuts

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