result

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2021 License: GPL-2.0 Imports: 3 Imported by: 14

Documentation

Overview

result tries to

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func WorstState

func WorstState(states ...int) int

Determines the worst state from a list of states

Helps combining an overall states, only based on a few numbers for various checks.

Order of preference: Critical, Unknown, Warning, Ok

Example
state := result.WorstState(check.Unknown, check.Critical, check.OK)
fmt.Println(state)
Output:

2

Types

type Overall

type Overall struct {
	OKs       int
	Warnings  int
	Criticals int
	Unknowns  int
	Summary   string
	Outputs   []string
}

func (*Overall) Add

func (o *Overall) Add(state int, output string)
Example
overall := Overall{}
overall.Add(check.OK, "One element is good")
overall.Add(check.Critical, "The other is critical")

fmt.Println(overall)
Output:

{1 0 1 0  [[OK] One element is good [CRITICAL] The other is critical]}

func (*Overall) AddCritical

func (o *Overall) AddCritical(output string)

func (*Overall) AddOK

func (o *Overall) AddOK(output string)

func (*Overall) AddUnknown

func (o *Overall) AddUnknown(output string)

func (*Overall) AddWarning

func (o *Overall) AddWarning(output string)

func (*Overall) GetOutput

func (o *Overall) GetOutput() string
Example
overall := Overall{}
overall.Add(check.OK, "One element is good")
overall.Add(check.Critical, "The other is critical")

fmt.Println(overall.GetOutput())
Output:

states: critical=1 ok=1
[OK] One element is good
[CRITICAL] The other is critical

func (*Overall) GetStatus

func (o *Overall) GetStatus() int
Example
overall := Overall{}
overall.Add(check.OK, "One element is good")
overall.Add(check.Critical, "The other is critical")

fmt.Println(overall.GetStatus())
Output:

2

func (*Overall) GetSummary

func (o *Overall) GetSummary() string

Jump to

Keyboard shortcuts

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