Documentation ¶
Index ¶
- func DurationString(duration time.Duration) string
- func FormatBinarySize(size float64) string
- func NagopherBoundsVar(s kingpin.Settings, target *nagopher.OptionalBounds)
- func NewInvalidMetricTypeResult(context Context, metric nagopher.Metric, resource nagopher.Resource) nagopher.Result
- func RegexpSubMatchMap(r *regexp.Regexp, str string) (map[string]string, bool)
- func RegisterModules(modules ...Module) map[string]Module
- func RetryDuring(timeout time.Duration, delay time.Duration, function func() error) (err error)
- func Round(value float64, precision float64) float64
- type Command
- type Context
- type ContextOpt
- type KingpinNode
- type Module
- type ModuleCommand
- type ModuleCommands
- type ModuleOpt
- type Plugin
- type PluginCommand
- type PluginCommands
- type PluginOpt
- type Resource
- type ResourceOpt
- type Summarizer
- type SummarizerOpt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DurationString ¶
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 ¶
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 ¶
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 ¶
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 ¶
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.
Types ¶
type Command ¶
Command is a generic interface, which provides common methods for ModuleCommand and PluginCommand
type Context ¶ added in v0.1.14
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
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 ¶
ModuleDescription is a functional option for NewModule(), which sets the module description
func ModulePlugin ¶
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
type PluginCommand ¶
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 ¶
PluginDefaultFlags is a functional option for NewPlugin(), which toggles the definition of default flags
func PluginDefaultThresholds ¶
PluginDefaultThresholds is a functional option for NewPlugin(), which toggles the definition of default thresholds
func PluginDescription ¶
PluginDescription is a functional option for NewPlugin(), which sets the module description
func PluginForceVerbose ¶ added in v0.1.14
PluginForceVerbose is a functional option for NewPlugin(), which toggles forcing verbose check output
type Resource ¶
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()