check

package
v3.0.0-rc49 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultOutput is the listing of the check results.
	DefaultOutput = "tab=TYPE:type,DRIVER:driver,INSTANCE:instance,OBJECT:path,VALUE:value_text"

	// DefaultSort orders the results by type, the instances of a type
	// together.
	DefaultSort = "TYPE,INSTANCE"
)

Variables

View Source
var ExecCommand = exec.CommandContext

Functions

func Check

func Check(ctx context.Context, r Checker, objs []interface{}) error

Check returns a result list

func ObjectPathClaimingDir

func ObjectPathClaimingDir(ctx context.Context, p string, objs []interface{}) string

ObjectPathClaimingDir returns the first object using the directory: the object whose head it is, or else the object of a provisioned resource whose head it is.

func ObjectPathWithResource

func ObjectPathWithResource(ctx context.Context, objs []interface{}, match func(resource.Driver) bool) string

ObjectPathWithResource returns the first object having a resource match selects, and empty when none has one.

func Register

func Register(c Checker)

func RunnerWithCustomCheckPaths

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

RunnerWithCustomCheckPaths adds paths where additional 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

func ValueText

func ValueText(value int64, unit string) string

ValueText returns the value with its unit, as a reader reads it: sizes in binary units as the other listings show them, speeds in Mb/s or Gb/s, and a value of a unit not known followed by its unit.

Types

type Checker

type Checker interface {
	Check(ctx context.Context, objs []interface{}) (*ResultSet, error)
}

Checker exposes what can be done with a check

type DeviceIndex

type DeviceIndex map[string]string

DeviceIndex is the object each device used or exposed by a disk or a fs resource belongs to, by device path, its links resolved, as /dev/mapper/<name> and the /dev/dm-<n> it leads to.

A checker reporting devices builds it once per check: asking every resource for its devices for each device reported would run their tools as many times.

func DeviceIndexOf

func DeviceIndexOf(ctx context.Context, objs []interface{}) DeviceIndex

DeviceIndexOf returns the device index of the objects, built once for the checkers of a run.

func NewDeviceIndex

func NewDeviceIndex(ctx context.Context, objs []interface{}) DeviceIndex

NewDeviceIndex returns the index of the devices of the disk and fs resources of the objects. The devices of the other resources, as a container, are not the ones a node device is attributed by.

func (DeviceIndex) Path

func (t DeviceIndex) Path(devs ...string) string

Path returns the object of the first of the devices it knows, and empty when it knows none.

type Line

type Line struct {
	Result
	ValueText string `json:"value_text"`
}

Line is a check result as a listing shows it: the result, its value and its unit kept apart, and the value as a reader reads it, unit included.

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

	// Failed names the checkers that failed during the run, timed out
	// or erred: their results are partial or missing, so the run does
	// not tell the state of their checks.
	Failed []string
}

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) IsPartial

func (t *ResultSet) IsPartial() bool

IsPartial is true when a checker failed during the run, so the results miss some of the checks the node has.

func (*ResultSet) Len

func (t *ResultSet) Len() int

Len returns the number of results in the set.

func (ResultSet) Lines

func (t ResultSet) Lines() []Line

Lines returns the results as a listing shows them.

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) 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(ctx context.Context, 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
checkexec
Package checkexec runs the commands the check drivers read their values from.
Package checkexec runs the commands the check drivers read their values from.

Jump to

Keyboard shortcuts

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