perfdata

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2022 License: GPL-2.0 Imports: 4 Imported by: 11

Documentation

Index

Examples

Constants

View Source
const ValidUom = "us|ms|s|tb|gb|mb|kb|b|%|c"

ValidUom lists all valid units allowed by spec and Icinga 2

Also see:

Variables

This section is empty.

Functions

func FormatLabel

func FormatLabel(label string) string

FormatLabel returns a sane perfdata label

All groups of invalid characters will be replaced by a single underscore.

func FormatNumeric

func FormatNumeric(value interface{}) string

FormatNumeric returns a string representation of various possible numerics

This supports most internal types of Go and all fmt.Stringer interfaces.

func IsValidUom

func IsValidUom(uom string) bool

IsValidUom compares the given unit against ValidUom

Types

type Perfdata

type Perfdata struct {
	Label string
	Value interface{}
	Uom   string
	Warn  *check.Threshold
	Crit  *check.Threshold
	Min   interface{}
	Max   interface{}
}

Perfdata represents all properties of performance data for Icinga

Implements fmt.Stringer to return the plaintext format for a plugin output.

Also see https://www.monitoring-plugins.org/doc/guidelines.html#AEN201

Example
perf := Perfdata{
	Label: "test",
	Value: 10.1,
	Uom:   "%",
	Warn:  &check.Threshold{Upper: 80},
	Crit:  &check.Threshold{Upper: 90},
	Min:   0, Max: 100}

fmt.Println(perf)
Output:

test=10.1%;80;90;0;100

func (Perfdata) String

func (p Perfdata) String() (s string)

String returns the proper format for the plugin output

type PerfdataList

type PerfdataList []*Perfdata

PerfdataList can store multiple perfdata and brings a simple fmt.Stringer interface

Example
list := PerfdataList{}
list.Add(&Perfdata{Label: "test1", Value: 23})
list.Add(&Perfdata{Label: "test2", Value: 42})

fmt.Println(list)
Output:

test1=23 test2=42

func (*PerfdataList) Add

func (l *PerfdataList) Add(p *Perfdata)

Add a Perfdata to the list

func (PerfdataList) String

func (l PerfdataList) String() (s string)

String returns string representations of all Perfdata

Jump to

Keyboard shortcuts

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