Documentation
¶
Index ¶
- func LoadPersistentStore(identifier string, v interface{}) error
- func NagopherRangeVar(s kingpin.Settings, target *nagopher.Range)
- 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{}) error
- type BasePlugin
- func (p *BasePlugin) DefineFlags(kp KingpinInterface, useDefaultRanges bool)
- func (p *BasePlugin) ExecuteCheck(check *nagopher.Check)
- func (p *BasePlugin) ExecutePersistentCheck(check *nagopher.Check, uniqueKey string, store interface{})
- func (p *BasePlugin) Probe(warnings *nagopher.WarningCollection) (metrics []nagopher.Metric, _ error)
- type BasePluginResource
- type KingpinInterface
- type Plugin
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 NagopherRangeVar ¶
NagopherRangeVar 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 BasePlugin ¶
BasePlugin represents a generic plugin from which all other plugin types should originate.
func (*BasePlugin) DefineFlags ¶
func (p *BasePlugin) DefineFlags(kp KingpinInterface, useDefaultRanges bool)
DefineFlags defines common flags which should be provided by all plugins. It will also define flags for the default ranges, unless p.useDefaultRanges is set to false.
func (*BasePlugin) ExecuteCheck ¶
func (p *BasePlugin) ExecuteCheck(check *nagopher.Check)
ExecuteCheck is a helper method which creates a new nagopher 'Runtime', executes a check and exits
func (*BasePlugin) ExecutePersistentCheck ¶
func (p *BasePlugin) ExecutePersistentCheck(check *nagopher.Check, uniqueKey string, store interface{})
ExecutePersistentCheck is a helper method which extends Execute() with flock (based on given unique key, which should be chosen wisely) and a persistent store, which is also named by the unique key passed. This is especially useful when used with contexts like 'DeltaContext', which compare the current measurement against a previously measurement.
func (*BasePlugin) Probe ¶
func (p *BasePlugin) Probe(warnings *nagopher.WarningCollection) (metrics []nagopher.Metric, _ error)
Probe represents the method executing the actual check/metrics logic and should be overridden by each plugin for returning metrics. It also supports adding warnings through the passed 'WarningCollection' or returning an error in case metric collection goes wrong.
type BasePluginResource ¶
type BasePluginResource struct {
*nagopher.BaseResource
// contains filtered or unexported fields
}
BasePluginResource presents a generic nagopher 'BaseResource' linked to a plugin.
func NewPluginResource ¶
func NewPluginResource(plugin Plugin) *BasePluginResource
NewPluginResource instantiates 'BasePluginResource' and links it with the given plugin.
func (*BasePluginResource) Probe ¶
func (pr *BasePluginResource) Probe(warnings *nagopher.WarningCollection) ([]nagopher.Metric, error)
Probe is an override for 'BaseResource.Probe(...)', which is being called by nagopher for collecting metrics. This method should never be overridden by any of the plugins, as it will just pass all arguments to 'Plugin.Probe()', where the plugins should define their actual check/metrics logic.
type KingpinInterface ¶
type KingpinInterface interface {
Arg(name, help string) *kingpin.ArgClause
Flag(name, help string) *kingpin.FlagClause
}
KingpinInterface 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 Plugin ¶
type Plugin interface {
DefineFlags(kp KingpinInterface)
Execute()
Probe(*nagopher.WarningCollection) ([]nagopher.Metric, error)
}
Plugin represents a interface for all plugin types.