check

package
v0.0.0-...-0a8b275 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ExecCommand = exec.Command

Functions

func Check

func Check(r Checker, objs []interface{}) error

Check returns a result list

func ObjectPathClaimingDir

func ObjectPathClaimingDir(p string, objs []interface{}) string

ObjectPathClaimingDir returns the first object using the directory

func Register

func Register(c Checker)

func RunnerWithCustomCheckPaths

func RunnerWithCustomCheckPaths(paths ...string) funcopt.O

RunnerWithCustomCheckPaths adds paths where additionnal check driver are installed.

func RunnerWithObjects

func RunnerWithObjects(objs ...interface{}) funcopt.O

RunnerWithObjects sets the list of objects the checkers can use to correlate a check instance to an object.

func UnRegisterAll

func UnRegisterAll()

UnRegisterAll unregister all registered checkers

Types

type Checker

type Checker interface {
	Check(objs []interface{}) (*ResultSet, error)
}

Checker exposes what can be done with a check

type Result

type Result struct {
	DriverGroup string `json:"type"`
	DriverName  string `json:"driver"`
	Path        string `json:"path"`
	Instance    string `json:"instance"`
	Unit        string `json:"unit"`
	Value       int64  `json:"value"`
}

Result is the structure eventually collected for aggregation.

type ResultSet

type ResultSet struct {
	Data []Result
}

ResultSet holds the list of all evaluated check instances.

func NewResultSet

func NewResultSet() *ResultSet

NewResultSet allocates and returns a ResultSet.

func (*ResultSet) Add

func (t *ResultSet) Add(rs *ResultSet)

Add appends another ResultSet to this ResultSet

func (*ResultSet) Len

func (t *ResultSet) Len() int

Len returns the number of results in the set.

func (ResultSet) MarshalJSON

func (t ResultSet) MarshalJSON() ([]byte, error)

MarshalJSON turns this ResultSet into a byte slice.

func (*ResultSet) Push

func (t *ResultSet) Push(r Result)

Push adds a Result to this ResultSet.

func (ResultSet) Render

func (t ResultSet) Render() string

Render returns a human friendly string representation of the type.

func (*ResultSet) UnmarshalJSON

func (t *ResultSet) UnmarshalJSON(b []byte) error

UnmarshalJSON parses a byte slice and loads this ResultSet.

type Runner

type Runner struct {
	// contains filtered or unexported fields
}

Runner collects results and format the output.

func NewRunner

func NewRunner(opts ...funcopt.O) *Runner

func (Runner) Do

func (r Runner) Do(opts ...funcopt.O) *ResultSet

Do runs the check drivers, aggregates results and format the output.

type T

type T struct {
	Name string
}

T is the check type

func (T) String

func (r T) String() string

Directories

Path Synopsis
helpers

Jump to

Keyboard shortcuts

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