shared

package
v0.1.11 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2019 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
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

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 added in v0.1.5

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 LoadPersistentStore

func LoadPersistentStore(identifier string, v interface{}) (rerr error)

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

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

func SavePersistentStore

func SavePersistentStore(identifier string, v interface{}) (rerr error)

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

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

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.

func NewPlugin

func NewPlugin() Plugin

NewPlugin instantiates a new BasePlugin, which should be inherited by user-defined plugin types

type PluginCommand added in v0.1.2

type PluginCommand interface {
	Command
	Plugin() Plugin
}

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

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

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'.

Jump to

Keyboard shortcuts

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