config

package
v0.0.0-...-1c2acb4 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package config implements the configuration type for the traps server and a component that provides it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsEnabled

func IsEnabled(conf config.Component) bool

IsEnabled returns whether SNMP trap collection is enabled in the Agent configuration.

Types

type Component

type Component interface {
	Get() *TrapsConfig
}

Component is the component type.

type TrapsConfig

type TrapsConfig struct {
	Enabled          bool     `mapstructure:"enabled" yaml:"enabled"`
	Port             uint16   `mapstructure:"port" yaml:"port"`
	Users            []UserV3 `mapstructure:"users" yaml:"users"`
	CommunityStrings []string `mapstructure:"community_strings" yaml:"community_strings"`
	BindHost         string   `mapstructure:"bind_host" yaml:"bind_host"`
	StopTimeout      int      `mapstructure:"stop_timeout" yaml:"stop_timeout"`
	Namespace        string   `mapstructure:"namespace" yaml:"namespace"`
	// contains filtered or unexported fields
}

TrapsConfig contains configuration for SNMP trap listeners. YAML field tags provided for test marshalling purposes.

func ReadConfig

func ReadConfig(host string, conf config.Component) (*TrapsConfig, error)

ReadConfig builds the traps configuration from the Agent configuration.

func (*TrapsConfig) Addr

func (c *TrapsConfig) Addr() string

Addr returns the host:port address to listen on.

func (*TrapsConfig) BuildSNMPParams

func (c *TrapsConfig) BuildSNMPParams(logger log.Component) (*gosnmp.GoSNMP, error)

BuildSNMPParams returns a valid GoSNMP params structure from configuration.

func (*TrapsConfig) GetPacketChannelSize

func (c *TrapsConfig) GetPacketChannelSize() int

GetPacketChannelSize returns the default size for the packets channel

func (*TrapsConfig) SetDefaults

func (c *TrapsConfig) SetDefaults(host string, namespace string) error

SetDefaults sets all unset values to default values, and returns an error if any fields are invalid.

type UserV3

type UserV3 struct {
	Username       string `mapstructure:"user" yaml:"user"`
	UsernameLegacy string `mapstructure:"username" yaml:"username"`
	AuthKey        string `mapstructure:"authKey" yaml:"authKey"`
	AuthProtocol   string `mapstructure:"authProtocol" yaml:"authProtocol"`
	PrivKey        string `mapstructure:"privKey" yaml:"privKey"`
	PrivProtocol   string `mapstructure:"privProtocol" yaml:"privProtocol"`
}

UserV3 contains the definition of one SNMPv3 user with its username and its auth parameters.

Directories

Path Synopsis
Package configimpl implements the config service.
Package configimpl implements the config service.

Jump to

Keyboard shortcuts

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