Documentation
¶
Index ¶
- type Bounds
- type BoundsOpt
- type Check
- type CheckResult
- type Context
- func NewBaseContext(name string, format string) Context
- func NewDeltaContext(name string, previousValue *float64, warningThreshold *Bounds, ...) Context
- func NewScalarContext(name string, warningThreshold *Bounds, criticalThreshold *Bounds) Context
- func NewStringInfoContext(name string) Context
- func NewStringMatchContext(name string, problemState State, expectedValues []string) Context
- type Metric
- type NumericMetric
- type OptionalBounds
- type OptionalContext
- type OptionalMetric
- type OptionalPerfData
- type OptionalResource
- type OptionalResult
- type OptionalState
- type PerfData
- type Resource
- type Result
- type ResultCollection
- type ResultOpt
- type Runtime
- type State
- type StringMetric
- type Summarizer
- type Warning
- type WarningCollection
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bounds ¶
type Bounds interface { fmt.Stringer ViolationHint() string ToNagiosRange() string Match(value float64) bool IsInverted() bool Lower() optional.Float64 Upper() optional.Float64 }
Bounds support matching float64 numbers against a given range, optionally inverting the result
func NewBoundsFromNagiosRange ¶
NewBoundsFromNagiosRange is a helper method, which constructs a new Bounds object from a Nagios range specifier
func OptionalBoundsPtr ¶
func OptionalBoundsPtr(optionalBounds OptionalBounds) *Bounds
OptionalBoundsPtr takes an optional bounds value and either returns a pointer to it or nil. It is the callers duty to properly handle such nil values!
type BoundsOpt ¶
type BoundsOpt func(*bounds)
BoundsOpt is a type alias for functional options used by NewBounds()
func InvertedBounds ¶
InvertedBounds is a functional option for NewBounds(), which inverts matching of the boundary (inside -> outside)
func LowerBound ¶
LowerBound is a functional option for NewBounds(), which sets the lower boundary
func NagiosRange ¶
NagiosRange is a functional option for NewBounds(), which parses a Nagios range specifier
func UpperBound ¶
UpperBound is a functional option for NewBounds(), which sets the upper boundary
type Check ¶
type Check interface { Run(warnings WarningCollection) SetMeta(key string, value interface{}) GetMeta(key string, defaultValue interface{}) interface{} AttachResources(resources ...Resource) AttachContexts(contexts ...Context) Name() string PerfData() []PerfData Contexts() []Context Resources() []Resource Results() ResultCollection State() State Summary() string VerboseSummary() []string }
Check collects metrics (results) and performance data, which are being associated to one or more given contexts. Metrics are being collected by executing one or more resources using Resource.Probe(). Additional metadata without a specific type can be added using Check.SetMeta() / Check.GetMeta(). Collected results can be queried by using Check.State(), Check.Summary() or Check.VerboseSummary(), which use the configured summarizer instance.
func NewCheck ¶
func NewCheck(name string, summarizer Summarizer) Check
NewCheck instantiates a new Check object with the given name and summarizer
type CheckResult ¶
CheckResult contains the results of a Check together with an exit code to indicate the check state
func NewCheckResult ¶
func NewCheckResult(exitCode int8, output string) CheckResult
NewCheckResult instantiates a new CheckResult with the given exit code and output string
type Context ¶
type Context interface { Name() string Describe(Metric) string Evaluate(Metric, Resource) Result Performance(Metric, Resource) (OptionalPerfData, error) }
Context provides methods for further processing a metric to generate results and/or performance data
func NewBaseContext ¶ added in v0.1.5
NewBaseContext instantiates a base Context which neither holds any information nor provides any kind of logic. It is meant to be used for developing custom Context types outside of nagopher.
func NewDeltaContext ¶
func NewDeltaContext(name string, previousValue *float64, warningThreshold *Bounds, criticalThreshold *Bounds) Context
NewDeltaContext creates a new scalar Context object, which operates the same way as a ScalarContext, but instead of using the current absolute metric value, it will be compared to a previous measurement. It is the callers duty to provide a pointer to the previous metric value or nil, if not available.
func NewScalarContext ¶
NewScalarContext creates a new scalar Context object, which handles metrics of the type NumericMetric and provides the ability to constraint these metric values to a given warning and/or critical threshold range
func NewStringInfoContext ¶
NewStringInfoContext instantiates a Context which only holds and returns a plain string without any further logic.
func NewStringMatchContext ¶
NewStringMatchContext instantiates a Context which holds a string, which is being compared to a whitelist of acceptable values during the evaluation phase. Should the value not be accepted, a problem state gets returned.
type Metric ¶
type Metric interface { ToNagiosValue() string Name() string ValueUnit() string ValueString() string ValueRange() OptionalBounds ContextName() string }
Metric stores a value of a given type associated to a specific context, optionally restrained into a specific range. It can be converted to the according representation of that value in context of Nagios plugins.
type NumericMetric ¶
NumericMetric represents a Metric storing float64 values
func MustNewNumericMetric ¶
func MustNewNumericMetric(name string, value float64, valueUnit string, valueRange *Bounds, contextName string) NumericMetric
MustNewNumericMetric calls MustNewNumericMetric and panics in case the creation of a metric instance fails
func NewNumericMetric ¶
func NewNumericMetric(name string, value float64, valueUnit string, valueRange *Bounds, contextName string) (NumericMetric, error)
NewNumericMetric instantiates a new NumericMetric with the given parameters.
type OptionalBounds ¶
type OptionalBounds struct {
// contains filtered or unexported fields
}
OptionalBounds is an optional Bounds.
func NewOptionalBounds ¶
func NewOptionalBounds(v Bounds) OptionalBounds
NewOptionalBounds creates an optional.OptionalBounds from a Bounds.
func (OptionalBounds) Get ¶
func (o OptionalBounds) Get() (Bounds, error)
Get returns the Bounds value or an error if not present.
func (OptionalBounds) If ¶
func (o OptionalBounds) If(fn func(Bounds))
If calls the function f with the value if the value is present.
func (OptionalBounds) OrElse ¶
func (o OptionalBounds) OrElse(v Bounds) Bounds
OrElse returns the Bounds value or a default value if the value is not present.
func (OptionalBounds) Present ¶
func (o OptionalBounds) Present() bool
Present returns whether or not the value is present.
type OptionalContext ¶
type OptionalContext struct {
// contains filtered or unexported fields
}
OptionalContext is an optional Context.
func NewOptionalContext ¶
func NewOptionalContext(v Context) OptionalContext
NewOptionalContext creates an optional.OptionalContext from a Context.
func (OptionalContext) Get ¶
func (o OptionalContext) Get() (Context, error)
Get returns the Context value or an error if not present.
func (OptionalContext) If ¶
func (o OptionalContext) If(fn func(Context))
If calls the function f with the value if the value is present.
func (OptionalContext) OrElse ¶
func (o OptionalContext) OrElse(v Context) Context
OrElse returns the Context value or a default value if the value is not present.
func (OptionalContext) Present ¶
func (o OptionalContext) Present() bool
Present returns whether or not the value is present.
type OptionalMetric ¶
type OptionalMetric struct {
// contains filtered or unexported fields
}
OptionalMetric is an optional Metric.
func NewOptionalMetric ¶
func NewOptionalMetric(v Metric) OptionalMetric
NewOptionalMetric creates an optional.OptionalMetric from a Metric.
func (OptionalMetric) Get ¶
func (o OptionalMetric) Get() (Metric, error)
Get returns the Metric value or an error if not present.
func (OptionalMetric) If ¶
func (o OptionalMetric) If(fn func(Metric))
If calls the function f with the value if the value is present.
func (OptionalMetric) OrElse ¶
func (o OptionalMetric) OrElse(v Metric) Metric
OrElse returns the Metric value or a default value if the value is not present.
func (OptionalMetric) Present ¶
func (o OptionalMetric) Present() bool
Present returns whether or not the value is present.
type OptionalPerfData ¶
type OptionalPerfData struct {
// contains filtered or unexported fields
}
OptionalPerfData is an optional PerfData.
func NewOptionalPerfData ¶
func NewOptionalPerfData(v PerfData) OptionalPerfData
NewOptionalPerfData creates an optional.OptionalPerfData from a PerfData.
func (OptionalPerfData) Get ¶
func (o OptionalPerfData) Get() (PerfData, error)
Get returns the PerfData value or an error if not present.
func (OptionalPerfData) If ¶
func (o OptionalPerfData) If(fn func(PerfData))
If calls the function f with the value if the value is present.
func (OptionalPerfData) OrElse ¶
func (o OptionalPerfData) OrElse(v PerfData) PerfData
OrElse returns the PerfData value or a default value if the value is not present.
func (OptionalPerfData) Present ¶
func (o OptionalPerfData) Present() bool
Present returns whether or not the value is present.
func (*OptionalPerfData) Set ¶
func (o *OptionalPerfData) Set(v PerfData)
Set sets the PerfData value.
type OptionalResource ¶
type OptionalResource struct {
// contains filtered or unexported fields
}
OptionalResource is an optional Resource.
func NewOptionalResource ¶
func NewOptionalResource(v Resource) OptionalResource
NewOptionalResource creates an optional.OptionalResource from a Resource.
func (OptionalResource) Get ¶
func (o OptionalResource) Get() (Resource, error)
Get returns the Resource value or an error if not present.
func (OptionalResource) If ¶
func (o OptionalResource) If(fn func(Resource))
If calls the function f with the value if the value is present.
func (OptionalResource) OrElse ¶
func (o OptionalResource) OrElse(v Resource) Resource
OrElse returns the Resource value or a default value if the value is not present.
func (OptionalResource) Present ¶
func (o OptionalResource) Present() bool
Present returns whether or not the value is present.
func (*OptionalResource) Set ¶
func (o *OptionalResource) Set(v Resource)
Set sets the Resource value.
type OptionalResult ¶
type OptionalResult struct {
// contains filtered or unexported fields
}
OptionalResult is an optional Result.
func NewOptionalResult ¶
func NewOptionalResult(v Result) OptionalResult
NewOptionalResult creates an optional.OptionalResult from a Result.
func (OptionalResult) Get ¶
func (o OptionalResult) Get() (Result, error)
Get returns the Result value or an error if not present.
func (OptionalResult) If ¶
func (o OptionalResult) If(fn func(Result))
If calls the function f with the value if the value is present.
func (OptionalResult) OrElse ¶
func (o OptionalResult) OrElse(v Result) Result
OrElse returns the Result value or a default value if the value is not present.
func (OptionalResult) Present ¶
func (o OptionalResult) Present() bool
Present returns whether or not the value is present.
type OptionalState ¶
type OptionalState struct {
// contains filtered or unexported fields
}
OptionalState is an optional State.
func NewOptionalState ¶
func NewOptionalState(v State) OptionalState
NewOptionalState creates an optional.OptionalState from a State.
func (OptionalState) Get ¶
func (o OptionalState) Get() (State, error)
Get returns the State value or an error if not present.
func (OptionalState) If ¶
func (o OptionalState) If(fn func(State))
If calls the function f with the value if the value is present.
func (OptionalState) OrElse ¶
func (o OptionalState) OrElse(v State) State
OrElse returns the State value or a default value if the value is not present.
func (OptionalState) Present ¶
func (o OptionalState) Present() bool
Present returns whether or not the value is present.
type PerfData ¶
PerfData holds a Metric instance and allows transformation into Nagios performance data
func NewNumericPerfData ¶
func NewNumericPerfData(name string, value float64, valueUnit string, valueRange *Bounds, warningThreshold *Bounds, criticalThreshold *Bounds) (PerfData, error)
NewNumericPerfData instantiates new PerfData. The parameters are being used to create a new NumericMetric instance, which is then passed along with the optional thresholds to NewPerfData().
type Resource ¶
type Resource interface { Setup(WarningCollection) error Probe(WarningCollection) ([]Metric, error) Teardown(WarningCollection) error }
Resource offers a method for collecting one or more metrics
type Result ¶
type Result interface { fmt.Stringer Hint() string State() OptionalState Metric() OptionalMetric Context() OptionalContext Resource() OptionalResource }
Result represents the output of a context, after the evaluation of an associated metric
type ResultCollection ¶
type ResultCollection interface { Add(results ...Result) Get() []Result Count() int MostSignificantResult() OptionalResult MostSignificantState() OptionalState GetByMetricName(name string) OptionalResult GetMetricByName(name string) OptionalMetric GetNumericMetricValue(name string) optional.Float64 GetStringMetricValue(name string) optional.String }
ResultCollection contains an arbitrary amount of Result instances and methods to sort them by relevance
func NewResultCollection ¶
func NewResultCollection() ResultCollection
NewResultCollection instantiates a new ResultCollection object without any items
type ResultOpt ¶
type ResultOpt func(*result)
ResultOpt is a type alias for functional options used by NewResult()
func ResultContext ¶
ResultContext is a functional option for NewResult(), which stores the responsible context of the result
func ResultHint ¶
ResultHint is a functional option for NewResult(), which stores the hint of the result
func ResultMetric ¶
ResultMetric is a functional option for NewResult(), which stores the responsible metric of the result
func ResultResource ¶
ResultResource is a functional option for NewResult(), which stores the responsible resource of the result
func ResultState ¶
ResultState is a functional option for NewResult(), which stores the state of the result
type Runtime ¶
type Runtime interface { Execute(Check) CheckResult ExecuteAndExit(check Check) }
Runtime executes a specific Check instance and prints or outputs the results according to the Nagios plugin specs
func NewRuntime ¶
NewRuntime instantiates a new Runtime, optionally enabling verbose output
type State ¶
State represents a Nagios plugin state, which consists of an exit code and description
func StateCritical ¶
func StateCritical() State
StateCritical returns an "CRITICAL" state according to Nagios plugin standards
func StateInfo ¶ added in v0.1.6
func StateInfo() State
StateInfo returns an "INFO" state, which is used for verbose output and otherwise behaves as StateOk()
func StateOk ¶
func StateOk() State
StateOk returns an "OK" state according to Nagios plugin standards
func StateUnknown ¶
func StateUnknown() State
StateUnknown returns an "UNKNOWN" state according to Nagios plugin standards
func StateWarning ¶
func StateWarning() State
StateWarning returns an "WARNING" state according to Nagios plugin standards
type StringMetric ¶
StringMetric represents a Metric storing string values
func MustNewStringMetric ¶
func MustNewStringMetric(name string, value string, contextName string) StringMetric
MustNewStringMetric calls NewStringMetric and panics in case the creation of a metric instance fails
func NewStringMetric ¶
func NewStringMetric(name string, value string, contextName string) (StringMetric, error)
NewStringMetric instantiates a new StringMetric with the given parameters.
type Summarizer ¶
type Summarizer interface { Ok(Check) string Problem(Check) string Verbose(Check) []string Empty() string }
Summarizer provides methods for displaying a human-readable
type Warning ¶
type Warning interface {
Warning() string
}
Warning represents a single warning cont
func NewWarning ¶
NewWarning instantiates a new warning, passing the format string and an arbitrary amount of arguments to fmt.Sprintf() for building the string.
type WarningCollection ¶
type WarningCollection interface { Add(warnings ...Warning) Get() []Warning GetWarningStrings() []string }
WarningCollection collects an arbitrary amount of warnings, which can happen during runtime execution.
func NewWarningCollection ¶
func NewWarningCollection() WarningCollection
NewWarningCollection instantiates a new WarningCollection without any items.
Source Files
¶
- bounds.go
- check.go
- context.go
- context_delta.go
- context_scalar.go
- context_string.go
- metric.go
- metric_numeric.go
- metric_string.go
- optional_bounds.go
- optional_context.go
- optional_metric.go
- optional_perfdata.go
- optional_resource.go
- optional_result.go
- optional_state.go
- perfdata.go
- resource.go
- result.go
- result_collection.go
- runtime.go
- state.go
- summarizer.go
- warning.go