Documentation
¶
Overview ¶
result tries to
Index ¶
- func WorstState(states ...int) int
- type Overall
- func (o *Overall) Add(state int, output string)
- func (o *Overall) AddCritical(output string)
- func (o *Overall) AddOK(output string)
- func (o *Overall) AddSubcheck(subcheck PartialResult)
- func (o *Overall) AddUnknown(output string)
- func (o *Overall) AddWarning(output string)
- func (o *Overall) GetOutput() string
- func (o *Overall) GetStatus() int
- func (o *Overall) GetSummary() string
- type PartialResult
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WorstState ¶
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
Types ¶
type Overall ¶
type Overall struct {
OKs int
Warnings int
Criticals int
Unknowns int
Summary string
Outputs []string // Deprecate this in a future version
// contains filtered or unexported fields
}
So, this is the idea: A check plugin has a single Overall (singleton) Each partial thing which is tested, gets it's own subcheck The results of these may be relevant to the overall status in the end or not, e.g. if a plugin trieds two different methods for something and one suffices, but one fails, the whole check might be OK and only the subcheck Warning or Critical.
Example (WithSubchecks) ¶
var overall Overall
example_perfdata := perfdata.Perfdata{Label: "pd_test", Value: 5, Uom: "s"}
pd_list := perfdata.PerfdataList{}
pd_list.Add(&example_perfdata)
subcheck := PartialResult{
State: check.OK,
Output: "Subcheck1 Test",
Perfdata: pd_list,
}
overall.AddSubcheck(subcheck)
overall.AddOK("bla")
fmt.Println(overall.GetOutput())
Output: states: ok=1 ok=1 [OK] bla \_ [OK] Subcheck1 Test|pd_test=5s
func (*Overall) Add ¶
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 ¶
Deprecate this in a future version
func (*Overall) AddSubcheck ¶ added in v0.4.0
func (o *Overall) AddSubcheck(subcheck PartialResult)
func (*Overall) AddUnknown ¶
Deprecate this in a future version
func (*Overall) AddWarning ¶
Deprecate this in a future version
func (*Overall) GetOutput ¶
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
type PartialResult ¶ added in v0.4.0
type PartialResult struct {
State int
Output string
Perfdata perfdata.PerfdataList
// contains filtered or unexported fields
}
func (*PartialResult) AddSubcheck ¶ added in v0.4.0
func (o *PartialResult) AddSubcheck(subcheck PartialResult)
func (*PartialResult) String ¶ added in v0.4.0
func (s *PartialResult) String() string