Help us shape the future of Go! Take the 2026 Go Developer Survey

monitor

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Monitor

type Monitor struct {
	Store store.Interface

	// CacheTTL - how long the computed stats are cached (0 disables the cache).
	// The cache is dropped whenever a check produces a new result.
	CacheTTL time.Duration
	// contains filtered or unexported fields
}

Monitor - main service which track the hosts liveness

func (*Monitor) ResponseTime

func (m *Monitor) ResponseTime(ctx context.Context, id string) ([]time.Time, []float64, error)

ResponseTime - returns the average response time per day

func (*Monitor) Run

func (m *Monitor) Run(ctx context.Context, cfg *types.Cfg) error

Run - applies the configuration: creates a watcher for every new host, updates the existing ones (restarting only those whose configuration changed) and removes the watchers for hosts that are not in the configuration anymore. The ctx bounds the lifetime of the monitor and is captured on the first call only.

func (*Monitor) Snapshot

func (m *Monitor) Snapshot(id string) (Snapshot, error)

Snapshot - returns the current state of the host

func (*Monitor) Snapshots

func (m *Monitor) Snapshots() []Snapshot

Snapshots - returns the current state of every host, ordered as in the configuration

func (*Monitor) Stats

func (m *Monitor) Stats(ctx context.Context) (*types.Stats, error)

Stats - returns the stats of all hosts grouped by groups

func (*Monitor) StatsByID

func (m *Monitor) StatsByID(ctx context.Context, id string, dayReport bool) (*types.Stats, error)

StatsByID - returns the stats of a host by id

func (*Monitor) Stop

func (m *Monitor) Stop()

Stop - stops every watcher, waits for them to finish and sends the shutdown notification.

type Snapshot

type Snapshot struct {
	Host         *types.Host
	Status       types.StatusType
	LastCheck    time.Time
	LastResponse *types.HttpResponse
}

Snapshot - the current state of a monitored host

Jump to

Keyboard shortcuts

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