config

package
v0.0.0-...-3645f34 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewContext

func NewContext(ctx context.Context, name string, module *Module) context.Context

NewContext returns a new Context containing the given module and name.

Types

type Argument

type Argument struct {
	Condition BoolString `yaml:"set_if,omitempty"`
	Value     LazyArray  `yaml:"value,omitempty"`
	Order     int        `yaml:"order,omitempty"`
	Key       string     `yaml:"key,omitempty"`
	Required  BoolString `yaml:"required,omitempty"`
	RepeatKey BoolString `yaml:"repeat_key,omitempty"`
	SkipKey   BoolString `yaml:"skip_key,omitempty"`
	Separator string     `yaml:"separator,omitempty"`
}

Argument defines the condition and representation of a commandline argument to a module command

func (*Argument) MarshalIcinga

func (a *Argument) MarshalIcinga(name string) ([]byte, error)

MarshalIcinga renders the argument in the Icinga config syntax format

func (*Argument) UnmarshalYAML

func (a *Argument) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML populates the instace fields from the given data node

type BoolString

type BoolString string

BooleanString is a string type, which can be unmarshaled from a native bool value

func (*BoolString) UnmarshalYAML

func (b *BoolString) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML populates the instace from the given data node

type Config

type Config struct {
	Modules map[string]Module `yaml:"modules,omitempty"`
}

Config defines the configuration root node

func (*Config) MarshalYAML

func (c *Config) MarshalYAML() ([]byte, error)

YAML renders the instance as YAML representation

type LazyArray

type LazyArray []string

LazyArray is an array instance, which can be declared using a single-item notation

func (LazyArray) MarshalIcinga

func (s LazyArray) MarshalIcinga(name string) ([]byte, error)

MarshalIcinga renders the array in the Icinga config syntax format

func (LazyArray) String

func (s LazyArray) String() string

String create a newline-delimited string of the instance items

func (*LazyArray) UnmarshalYAML

func (s *LazyArray) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML populates the instace from the given data node

type Module

type Module struct {
	Command     string               `yaml:"command,omitempty"`
	Timeout     NumberDuration       `yaml:"timeout,omitempty"`
	Arguments   map[string]Argument  `yaml:"arguments,omitempty"`
	Variables   map[string]LazyArray `yaml:"variables,omitempty"`
	Environment map[string]string    `yaml:"environment,omitempty"`
}

Module defines a reusable monitoring execution plan

func FromContext

func FromContext(ctx context.Context) (string, *Module, bool)

FromContext returns the Module (+ name) value stored in ctx, if any.

func (*Module) MarshalIcinga

func (m *Module) MarshalIcinga(name string) ([]byte, error)

MarshalIcinga renders the module in the Icinga config syntax format

type NumberDuration

type NumberDuration time.Duration

NumberDuration is a time.Duration implementation which can optionally be declared without any time scale (defaulting to seconds)

func (NumberDuration) String

func (n NumberDuration) String() string

String renders the duration instance in seconds

func (*NumberDuration) UnmarshalYAML

func (n *NumberDuration) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML populates the instace from the given data node

type SafeConfig

type SafeConfig struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

SafeConfig is thread-safe Config instance provider

func NewSafeConfig

func NewSafeConfig(namespace string, reg prometheus.Registerer) *SafeConfig

NewSafeConfig creates a new SafeConfig instance

func (*SafeConfig) ProvideConfig

func (sc *SafeConfig) ProvideConfig(visitor func(*Config))

ProvideConfig is a thread-safe visitor implementation, to gain access to the internal config instance.

func (*SafeConfig) ReloadConfig

func (sc *SafeConfig) ReloadConfig(confFile string, logger log.Logger) (err error)

ReloadConfig reads the configuration from the given path and updates its internal config instance with the parsed result

func (*SafeConfig) UpdateConfig

func (sc *SafeConfig) UpdateConfig(c *Config)

UpdateConfig replaces the internal config instance with the given one (thread-safe)

Jump to

Keyboard shortcuts

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