checks

package
v0.0.0-...-efb87f3 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckHostID

func CheckHostID(checkID string, hostID string) string

CheckHostID returns a compound key constisting of a check id and a host id.

Types

type Check

type Check struct {
	database.Object `storm:"inline"`
	Name            string          `json:"name" validate:"required"`
	AgentID         string          `json:"agent" validate:"required"`
	Hosts           []string        `json:"hosts"`
	Interval        time.Duration   `json:"interval"`
	Arguments       json.RawMessage `json:"arguments"`
	Expressions     []string        `json:"expressions"`
	ContactGroups   []string        `json:"contactgroups"`
}

Check defines a check to be conducted by Gansoi.

func (*Check) Evaluate

func (c *Check) Evaluate(result plugins.AgentResult) error

Evaluate will evaluate the CheckResult based on a slice of expressions.

func (*Check) Validate

func (c *Check) Validate(_ database.Reader) error

Validate implements database.Validator.

type CheckResult

type CheckResult struct {
	ID          int64               `json:"id,omitempty" storm:"id,increment"`
	CheckHostID string              `json:"check_host_id,omitempty" storm:"index"`
	CheckID     string              `json:"check_id" storm:"index"`
	HostID      string              `json:"host_id"`
	Node        string              `json:"node_id,omitempty"`
	Error       string              `json:"error"`
	TimeStamp   time.Time           `json:"timestamp"`
	Results     plugins.AgentResult `json:"results"`
}

CheckResult describes the result of one or more checks after a single node has executed the check.

func RunCheck

func RunCheck(transport transports.Transport, check *Check) (checkResult *CheckResult)

RunCheck will run a check and return a CheckResult.

type MetaStore

type MetaStore struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

MetaStore will keep a list of checks to execute.

func (*MetaStore) Done

func (s *MetaStore) Done(meta *checkMeta)

Done must be called to signal that a check is done. After Done() the checkMeta can again be returned from Next().

func (*MetaStore) PostApply

func (s *MetaStore) PostApply(leader bool, command database.Command, data interface{})

PostApply implements database.Listener.

type Scheduler

type Scheduler struct {
	Results chan *CheckResult
	// contains filtered or unexported fields
}

Scheduler takes care of scheduling checks on the local node. For now it will spin four times each second.

func NewScheduler

func NewScheduler(db database.ReadWriteBroadcaster, nodeName string) *Scheduler

NewScheduler instantiates a new scheduler.

func (*Scheduler) Run

func (s *Scheduler) Run()

Run will start the event loop.

func (*Scheduler) Stop

func (s *Scheduler) Stop()

Stop will stop the event loop.

Jump to

Keyboard shortcuts

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