probe

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package probe implements the ways Revere can measure the outside world.

Index

Constants

View Source
const (
	ProbesDir = "probes"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Checker

type Checker interface {
	Check() []Reading
}

Checker is used by Polling to actually check the thing being monitored.

type Details

type Details interface {
	// Text returns a human-readable description of these details. The
	// description may be multiple lines, though it should not end with a line
	// break.
	Text() string
}

Details encodes probe-type-specific details from a reading.

type GraphiteThreshold

type GraphiteThreshold struct {
	*Polling
	// contains filtered or unexported fields
}

GraphiteThreshold implements a probe that assigns states based on whether a Graphite metric is above or below various constant values.

func (*GraphiteThreshold) Check

func (gt *GraphiteThreshold) Check() []Reading

type GraphiteThresholdDBModel

type GraphiteThresholdDBModel struct {
	ResourceID int64
	Expression string

	Thresholds GraphiteThresholdThresholdsDBModel
	TriggerIf  string

	CheckPeriodMilli int64

	TimeToAuditMilli        int64
	RecentTimeToIgnoreMilli int64
	AuditFunction           string
}

GraphiteThresholdDBModel defines the JSON serialization format for saving Graphite threshold probes' settings in the database.

type GraphiteThresholdProbe

type GraphiteThresholdProbe struct {
	GraphiteThresholdType

	URL               string
	ResourceID        db.ResourceID
	Expression        string
	Thresholds        ThresholdsModel
	AuditFunction     string
	CheckPeriod       int64
	CheckPeriodType   string
	TriggerIf         string
	AuditPeriod       int64
	AuditPeriodType   string
	IgnoredPeriod     int64
	IgnoredPeriodType string
}

func (GraphiteThresholdProbe) HasResource

func (g GraphiteThresholdProbe) HasResource(id db.ResourceID) bool

func (GraphiteThresholdProbe) SerializeForDB

func (g GraphiteThresholdProbe) SerializeForDB() (string, error)

func (GraphiteThresholdProbe) SerializeForFrontend

func (g GraphiteThresholdProbe) SerializeForFrontend() map[string]string

func (GraphiteThresholdProbe) Type

func (g GraphiteThresholdProbe) Type() VMType

func (GraphiteThresholdProbe) Validate

func (g GraphiteThresholdProbe) Validate() (errs []string)

type GraphiteThresholdThresholdsDBModel

type GraphiteThresholdThresholdsDBModel struct {
	Warning  *float64
	Error    *float64
	Critical *float64
}

GraphiteThresholdThresholdsDBModel defines the JSON serialization format for saving Graphite threshold probes' threshold settings in the database.

type GraphiteThresholdType

type GraphiteThresholdType struct{}

func (GraphiteThresholdType) AcceptedResourceTypes

func (GraphiteThresholdType) AcceptedResourceTypes() []db.ResourceType

func (GraphiteThresholdType) Id

func (GraphiteThresholdType) Name

func (GraphiteThresholdType) Scripts

func (gt GraphiteThresholdType) Scripts() map[string][]string

func (GraphiteThresholdType) Templates

func (GraphiteThresholdType) Templates() map[string]string

type Polling

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

Polling helps implement probes that check conditions at regular intervals. Embed a pointer to this struct in a struct that implements Checker to get such a polling probe without having to deal with the polling loop.

func NewPolling

func NewPolling(period time.Duration, checker Checker, readingsSink chan<- []Reading) (*Polling, error)

func (*Polling) Start

func (p *Polling) Start()

func (*Polling) Stop

func (p *Polling) Stop()

type Probe

type Probe interface {
	Start()
	Stop()
}

Probe defines a common functional abstraction for all probes.

TODO(eefi): Pull in the probe concept explanation text from the Revere product overview design doc. Also document all the individual methods.

TODO(eefi): Incorporate the web side and also document that.

func New

func New(tx *db.Tx, typeID db.ProbeType, config types.JSONText, readingsSink chan<- []Reading) (Probe, error)

New makes a Probe of the given type and settings. The Probe will send its readings to the provided channel.

type Reading

type Reading struct {
	Subprobe string
	State    state.State
	Recorded time.Time
	Details  Details
}

Reading is a reading from a particular subprobe taken at a specific time.

type ThresholdsModel

type ThresholdsModel struct {
	Warning  *float64
	Error    *float64
	Critical *float64
}

type VM

type VM interface {
	VMType
	HasResource(db.ResourceID) bool
	SerializeForDB() (string, error)
	SerializeForFrontend() map[string]string
	Type() VMType
	Validate() []string
}

func Blank

func Blank(id db.ProbeType) (VM, error)

func Default

func Default() (VM, error)

func LoadFromDB

func LoadFromDB(id db.ProbeType, probeJson string, tx *db.Tx) (VM, error)

func LoadFromParams

func LoadFromParams(id db.ProbeType, probeParams string) (VM, error)

type VMType

type VMType interface {
	Id() db.ProbeType
	Name() string

	Templates() map[string]string
	Scripts() map[string][]string
	AcceptedResourceTypes() []db.ResourceType
	// contains filtered or unexported methods
}

ProbeVMType and ProbeVM define a common display abstraction for all probes.

func AllTypes

func AllTypes() (pts []VMType)

Jump to

Keyboard shortcuts

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