Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Evaluation ¶
type Evaluation struct { ID int64 `json:"id" storm:"id,increment"` CheckHostID string `json:"check_host_id" storm:"index"` CheckID string `json:"check_id" storm:"index"` HostID string `json:"host_id"` History States `json:"history"` State State `json:"state"` Start time.Time `json:"start"` End time.Time `json:"end"` Hosts map[string]State `json:"hosts"` Results []checks.CheckResult `json:"-"` }
Evaluation describes the current state of a check.
func LatestEvaluation ¶
func LatestEvaluation(db database.Reader, result *checks.CheckResult) (*Evaluation, error)
LatestEvaluation retrieves the latest evaluation if any.
func NewEvaluation ¶
func NewEvaluation(clock time.Time, result *checks.CheckResult) *Evaluation
NewEvaluation returns a new evaluation.
func (*Evaluation) Final ¶
func (e *Evaluation) Final() bool
Final returns true if the evaluation is for a check and not for a host-part of a check.
type Evaluator ¶
type Evaluator struct {
// contains filtered or unexported fields
}
Evaluator will evaluate check results from all nodes on the leader node.
func NewEvaluator ¶
func NewEvaluator(db database.ReadWriter) *Evaluator
NewEvaluator will instantiate a new Evaluator listening to cluster changes, and evaluating results as they arrive.
func (*Evaluator) Evaluate ¶
func (e *Evaluator) Evaluate(checkResult *checks.CheckResult) (*Evaluation, error)
Evaluate will evaluate a CheckResult and return an Evaluation including current state.
type State ¶
type State int
State denotes the current state of a Check.
func (State) ColorString ¶
ColorString will return a colorized string representing the state. It will be suitable for printing in an ANSI terminal.
func (State) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (State) MarshalText ¶
MarshalText implements encoding.TextMarshaler.
func (*State) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
func (*State) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.
type States ¶
type States []State
States can hold multiple states.
func (*States) Add ¶
Add a new state to a States object. The newest state will always be available at position 0. This type is not meant to be read directly thou.
func (*States) ColorString ¶
ColorString will return a nicely colored array.
func (*States) Reduce ¶
Reduce reduces the slice of states to a single state according to a very simple algorithm:
- If there's no states stored, return StateUnknown.
- If any state is StateUnknown, return StateUnknown.
- If no state is StateUnknown, and there is a majority that majority is returned.
- If none of 1-3 is satisfied, StateUnknown will we returned.
type Summary ¶
type Summary struct { sync.RWMutex ID string `storm:"id"` Checks int `json:"checks"` States map[State]int `json:"states"` // contains filtered or unexported fields }
Summary is a summary of all checks.
func NewSummary ¶
NewSummary will return a new Summary.
func (*Summary) AddEvaluation ¶
func (s *Summary) AddEvaluation(eval *Evaluation) error
AddEvaluation will add a new evaluation to the summary.
func (*Summary) PostApply ¶
PostApply implements database.Listener. We listen for added and deleted checks.
func (*Summary) RemoveCheck ¶
RemoveCheck will remove the check identifier by id from summary.