nagocheck

package
v0.1.18 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2019 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DurationString

func DurationString(duration time.Duration) string

DurationString outputs a time.Duration variable in the same way as time.Duration.String() with additional support for days instead of just hours, minutes and seconds.

func FormatBinarySize

func FormatBinarySize(size float64) string

FormatBinarySize expects a size given in bytes and returns a formatted string with a precision of two with the most appropriate unit, which can either be B, K, M, G or T.

func NagopherBoundsVar

func NagopherBoundsVar(s kingpin.Settings, target *nagopher.OptionalBounds)

NagopherBoundsVar is a helper method for defining kingpin flags which should be parsed as a Nagopher range specifier.

func NewInvalidMetricTypeResult added in v0.1.14

func NewInvalidMetricTypeResult(context Context, metric nagopher.Metric, resource nagopher.Resource) nagopher.Result

NewInvalidMetricTypeResult returns a new Nagopher result in case a custom context tries to convert the generic Metric interface pointer into a specific type and is unable to do so. An example from Nagopher itself (which does not use this helper method though, obviously) would be a ScalarContext which strictly requires a NumericMetric to properly evaluate the context.

func RegexpSubMatchMap

func RegexpSubMatchMap(r *regexp.Regexp, str string) (map[string]string, bool)

RegexpSubMatchMap is a utility function which matches a string against a regular expression and returns a map of the type 'map[string]string', which contains all named capture groups.

func RegisterModules

func RegisterModules(modules ...Module) map[string]Module

RegisterModules returns a map of modules with their name as the respective key. Additionally, all plugins contained by these modules are being registered to their respective module using Plugin.setModule()

func RetryDuring

func RetryDuring(timeout time.Duration, delay time.Duration, function func() error) (err error)

RetryDuring retries a given function until it no longer returns an error or the timeout value was reached. The delay parameter specifies the delay between each unsuccessful attempt.

func Round

func Round(value float64, precision float64) float64

Round is a utility function which allows rounding a float64 to a given precision

Types

type Command

type Command interface {
	Name() string
	Description() string
}

Command is a generic interface, which provides common methods for ModuleCommand and PluginCommand

type Context added in v0.1.14

type Context interface {
	nagopher.Context
	Plugin() Plugin
}

Context provides a base type for nagocheck contexts, which embeds nagopher.Context

func NewContext added in v0.1.14

func NewContext(plugin Plugin, parentContext nagopher.Context, options ...ContextOpt) Context

NewContext instantiates baseContext with the given functional options

func NewHiddenScalarContext added in v0.1.14

func NewHiddenScalarContext(plugin Plugin, name string, warningThreshold *nagopher.Bounds, criticalThreshold *nagopher.Bounds) Context

NewHiddenScalarContext is a subclass of the standard ScalarContext provided by nagopher. It behaves exactly the same in terms of representation and evaluation, however it is being suppressed in performance data.

type ContextOpt added in v0.1.14

type ContextOpt func(*baseContext)

ContextOpt is a type alias for functional options used by NewContext()

type KingpinNode

type KingpinNode interface {
	Arg(name, help string) *kingpin.ArgClause
	Flag(name, help string) *kingpin.FlagClause
}

KingpinNode is a unified interface for kingpin, which allows using Arg() and Flag() at root- and command-level

type Module

type Module interface {
	Name() string
	Description() string
	Plugins() map[string]Plugin

	DefineCommand() KingpinNode
	DefineFlags(node KingpinNode)
	RegisterPlugin(plugin Plugin)
	ExecutePlugin(plugin Plugin) error
	GetPluginByName(pluginName string) (Plugin, error)
}

Module consists out of several plugins and offers methods for executing them

func NewModule

func NewModule(name string, options ...ModuleOpt) Module

NewModule instantiates baseModule with the given functional options

type ModuleCommand

type ModuleCommand interface {
	Command
	Module() Module
	PluginCommands() PluginCommands
}

ModuleCommand is an interface, which provides a set of plugin commands underneath a given module

func NewModuleCommand

func NewModuleCommand(name string, description string, module Module, pluginCommands ...PluginCommand) ModuleCommand

NewModuleCommand instantiates a new ModuleCommand with the given options

type ModuleCommands

type ModuleCommands []ModuleCommand

ModuleCommands represents a slice of ModuleCommand instances and offers a lookup method by name

func (ModuleCommands) GetByName

func (c ModuleCommands) GetByName(name string) (ModuleCommand, error)

GetByName searches through a ModuleCommands slice and returns a module with the given name or an error, if not found

type ModuleOpt

type ModuleOpt func(*baseModule)

ModuleOpt is a type alias for functional options used by NewModule()

func ModuleDescription

func ModuleDescription(description string) ModuleOpt

ModuleDescription is a functional option for NewModule(), which sets the module description

func ModulePlugin

func ModulePlugin(plugin Plugin) ModuleOpt

ModulePlugin is a functional option for NewModule(), which registers a plugin using Module.RegisterPlugin()

type Plugin

type Plugin interface {
	Name() string
	Description() string
	Module() Module
	DefineFlags(node KingpinNode)
	DefineCheck() nagopher.Check

	VerboseOutput() bool
	WarningThreshold() nagopher.OptionalBounds
	CriticalThreshold() nagopher.OptionalBounds
	// contains filtered or unexported methods
}

Plugin represents a single check including its CLI arguments

func NewPlugin

func NewPlugin(name string, options ...PluginOpt) Plugin

NewPlugin instantiates basePlugin with the given functional options

type PluginCommand

type PluginCommand interface {
	Command
	Plugin() Plugin
}

PluginCommand is a single plugin command of a module, which executes a specific check

func NewPluginCommand

func NewPluginCommand(name string, description string, plugin Plugin) PluginCommand

NewPluginCommand instantiates a new PluginCommand with the given options

type PluginCommands

type PluginCommands []PluginCommand

PluginCommands represents a slice of PluginCommand instances and offers a lookup method by name

func (PluginCommands) GetByName

func (c PluginCommands) GetByName(name string) (PluginCommand, error)

GetByName searches through a PluginCommands slice and returns a module with the given name or an error, if not found

type PluginOpt

type PluginOpt func(*basePlugin)

PluginOpt is a type alias for functional options used by NewPlugin()

func PluginDefaultFlags

func PluginDefaultFlags(enabled bool) PluginOpt

PluginDefaultFlags is a functional option for NewPlugin(), which toggles the definition of default flags

func PluginDefaultThresholds

func PluginDefaultThresholds(enabled bool) PluginOpt

PluginDefaultThresholds is a functional option for NewPlugin(), which toggles the definition of default thresholds

func PluginDescription

func PluginDescription(description string) PluginOpt

PluginDescription is a functional option for NewPlugin(), which sets the module description

func PluginForceVerbose added in v0.1.14

func PluginForceVerbose(enabled bool) PluginOpt

PluginForceVerbose is a functional option for NewPlugin(), which toggles forcing verbose check output

type Resource

type Resource interface {
	nagopher.Resource
	Plugin() Plugin
}

Resource provides a base type for nagocheck resources, which embeds nagopher.Resource

func NewResource

func NewResource(plugin Plugin, options ...ResourceOpt) Resource

NewResource instantiates baseResource with the given functional options

type ResourceOpt

type ResourceOpt func(*baseResource)

ResourceOpt is a type alias for functional options used by NewSummarizer()

func ResourcePersistence

func ResourcePersistence(uniqueKey string, dataStore interface{}) ResourceOpt

ResourcePersistence is a functional option for NewResource(), which enables resource persistence with the given key

type Summarizer

type Summarizer interface {
	nagopher.Summarizer
	Plugin() Plugin
}

Summarizer provides a base type for nagocheck summarizers, which embeds nagopher.Summarizer

func NewSummarizer

func NewSummarizer(plugin Plugin, options ...SummarizerOpt) Summarizer

NewSummarizer instantiates baseSummarizer with the given functional options

type SummarizerOpt

type SummarizerOpt func(*baseSummarizer)

SummarizerOpt is a type alias for functional options used by NewSummarizer()

Jump to

Keyboard shortcuts

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