Documentation
¶
Index ¶
- Constants
- func DurationString(duration time.Duration) string
- func FormatBinarySize(size float64) string
- func LoadPersistentStore(identifier string, v interface{}) (rerr error)
- func NagopherBoundsVar(s kingpin.Settings, target *nagopher.OptionalBounds)
- func RegexpSubMatchMap(r *regexp.Regexp, str string) (map[string]string, bool)
- func RetryDuring(timeout time.Duration, delay time.Duration, function func() error) (err error)
- func Round(value float64, precision float64) float64
- func SavePersistentStore(identifier string, v interface{}) (rerr error)
- type Command
- type KingpinNode
- type Module
- type ModuleCommand
- type ModuleCommands
- type Plugin
- type PluginCommand
- type PluginCommands
- type PluginResource
- type PluginSummarizer
Constants ¶
const MetaNcPlugin = "nc#plugin"
MetaNcPlugin contains the metadata key for storing the plugin instance.
Variables ¶
This section is empty.
Functions ¶
func DurationString ¶ added in v0.1.4
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 ¶ added in v0.1.5
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 LoadPersistentStore ¶
LoadPersistentStore loads a persistent shm-based store, which can represent any structure/type as long as it can be unmarshalled by the builtin 'json.Unmarshal' function. Please note that this function should only be called when protected by a flock, as several processes operating the same store can lead to data loss.
func NagopherBoundsVar ¶ added in v0.1.11
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 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 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.
func SavePersistentStore ¶
SavePersistentStore stores a persistent shm-based store, which can represent any structure/type as long as it can be marshalled by the builtin 'json.Marshal' function. Please note that this function should only be called when protected by a flock, as several processes operating the same store can lead to data loss.
Types ¶
type Command ¶ added in v0.1.11
Command is a generic interface, which provides common methods for ModuleCommand and PluginCommand
type KingpinNode ¶ added in v0.1.11
type KingpinNode interface {
Arg(name, help string) *kingpin.ArgClause
Flag(name, help string) *kingpin.FlagClause
}
KingpinNode is a generic interface for kingpin, which is implemented by both "kingpin.Application" and "kingpin.CmdClause". This allows us to define a single "DefineFlags" method in the "Plugin" interface, which can handle both top-level and command-level flags.
type Module ¶ added in v0.1.6
type Module interface {
DefineFlags(KingpinNode)
Execute(Plugin)
GetModuleCommand() ModuleCommand
}
Module collects several plugin commands underneath a module command and offers the possibility to define CLI flags
func NewBaseModule ¶ added in v0.1.11
func NewBaseModule() Module
NewBaseModule instantiates a new BaseModule, which should be inherited by user-defined module types
type ModuleCommand ¶ added in v0.1.2
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 ¶ added in v0.1.11
func NewModuleCommand(name string, description string, module Module, pluginCommands ...PluginCommand) ModuleCommand
NewModuleCommand instantiates a new ModuleCommand with the given options
type ModuleCommands ¶ added in v0.1.2
type ModuleCommands []ModuleCommand
ModuleCommands represents a slice of ModuleCommand instances and offers a lookup method by name
func (ModuleCommands) GetByName ¶ added in v0.1.2
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 Plugin ¶
type Plugin interface {
DefineFlags(kp KingpinNode)
DefineDefaultFlags(kp KingpinNode)
DefineDefaultThresholds(kp KingpinNode)
Execute()
ExecuteCheck(check nagopher.Check)
ExecutePersistentCheck(check nagopher.Check, uniqueKey string, store interface{})
Probe(nagopher.WarningCollection) ([]nagopher.Metric, error)
WarningThreshold() nagopher.OptionalBounds
CriticalThreshold() nagopher.OptionalBounds
}
Plugin represents a interface for all plugin types.
type PluginCommand ¶ added in v0.1.2
PluginCommand is a single plugin command of a module, which executes a specific check
func NewPluginCommand ¶ added in v0.1.11
func NewPluginCommand(name string, description string, plugin Plugin) PluginCommand
NewPluginCommand instantiates a new PluginCommand with the given options
type PluginCommands ¶ added in v0.1.2
type PluginCommands []PluginCommand
PluginCommands represents a slice of PluginCommand instances and offers a lookup method by name
func (PluginCommands) GetByName ¶ added in v0.1.2
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 PluginResource ¶ added in v0.1.11
PluginResource represents a resource tied to a plugin
func NewPluginResource ¶
func NewPluginResource(plugin Plugin) PluginResource
NewPluginResource instantiates 'pluginResource' and links it with the given plugin.
type PluginSummarizer ¶ added in v0.1.11
type PluginSummarizer interface {
nagopher.Summarizer
Plugin() Plugin
}
PluginSummarizer represents a summarizer tied to a plugin
func NewPluginSummarizer ¶ added in v0.1.11
func NewPluginSummarizer(plugin Plugin) PluginSummarizer
NewPluginSummarizer instantiates 'pluginSummarizer'.