checkconfig

package
v0.0.0-...-7983b3b Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultBulkMaxRepetitions = uint32(10)

DefaultBulkMaxRepetitions is the default max rep Using too high max repetitions might lead to tooBig SNMP error messages. - Java SNMP and gosnmp (gosnmp.defaultMaxRepetitions) uses 50 - snmp-net uses 10

Variables

This section is empty.

Functions

func GetProfileForSysObjectID

func GetProfileForSysObjectID(profiles profileDefinitionMap, sysObjectID string) (string, error)

GetProfileForSysObjectID return a profile for a sys object id

func SetConfdPathAndCleanProfiles

func SetConfdPathAndCleanProfiles()

SetConfdPathAndCleanProfiles is used for testing only

func ValidateEnrichMetricTags

func ValidateEnrichMetricTags(metricTags []MetricTagConfig) []string

ValidateEnrichMetricTags validates and enrich metric tags

Types

type Boolean

type Boolean bool

Boolean can unmarshal yaml string or bool value

func (*Boolean) UnmarshalYAML

func (b *Boolean) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML unmarshalls Boolean

type CheckConfig

type CheckConfig struct {
	Name                  string
	IPAddress             string
	Port                  uint16
	CommunityString       string
	SnmpVersion           string
	Timeout               int
	Retries               int
	User                  string
	AuthProtocol          string
	AuthKey               string
	PrivProtocol          string
	PrivKey               string
	ContextName           string
	OidConfig             OidConfig
	Metrics               []MetricsConfig
	MetricTags            []MetricTagConfig
	OidBatchSize          int
	BulkMaxRepetitions    uint32
	Profiles              profileDefinitionMap
	ProfileTags           []string
	Profile               string
	ProfileDef            *profileDefinition
	ExtraTags             []string
	InstanceTags          []string
	CollectDeviceMetadata bool
	UseDeviceIDAsHostname bool
	DeviceID              string
	DeviceIDTags          []string
	ResolvedSubnetName    string
	Namespace             string
	AutodetectProfile     bool
	MinCollectionInterval time.Duration

	Network                  string
	DiscoveryWorkers         int
	Workers                  int
	DiscoveryInterval        int
	IgnoredIPAddresses       map[string]bool
	DiscoveryAllowedFailures int
}

CheckConfig holds config needed for an integration instance to run

func NewCheckConfig

func NewCheckConfig(rawInstance integration.Data, rawInitConfig integration.Data) (*CheckConfig, error)

NewCheckConfig builds a new check config

func (*CheckConfig) Copy

func (c *CheckConfig) Copy() *CheckConfig

Copy makes a copy of CheckConfig

func (*CheckConfig) CopyWithNewIP

func (c *CheckConfig) CopyWithNewIP(ipAddress string) *CheckConfig

CopyWithNewIP makes a copy of CheckConfig with new IP

func (*CheckConfig) DeviceDigest

func (c *CheckConfig) DeviceDigest(address string) DeviceDigest

DeviceDigest returns a hash value representing the minimal configs used to connect to the device. DeviceDigest is used for device discovery.

func (*CheckConfig) GetNetworkTags

func (c *CheckConfig) GetNetworkTags() []string

GetNetworkTags returns network tags network tags are not part of the static tags since we don't want the deviceID to change if the network/subnet changes e.g. 10.0.0.0/29 to 10.0.0.0/30

func (*CheckConfig) GetStaticTags

func (c *CheckConfig) GetStaticTags() []string

GetStaticTags return static tags built from configuration

func (*CheckConfig) IsDiscovery

func (c *CheckConfig) IsDiscovery() bool

IsDiscovery return weather it's a network/autodiscovery config or not

func (*CheckConfig) IsIPIgnored

func (c *CheckConfig) IsIPIgnored(ip net.IP) bool

IsIPIgnored checks the given IP against ignoredIPAddresses

func (*CheckConfig) RefreshWithProfile

func (c *CheckConfig) RefreshWithProfile(profile string) error

RefreshWithProfile refreshes config based on profile

func (*CheckConfig) ToString

func (c *CheckConfig) ToString() string

ToString used for logging CheckConfig without sensitive information

func (*CheckConfig) UpdateDeviceIDAndTags

func (c *CheckConfig) UpdateDeviceIDAndTags()

UpdateDeviceIDAndTags updates DeviceID and DeviceIDTags

type DeviceDigest

type DeviceDigest string

DeviceDigest is the digest of a minimal config used for autodiscovery

type InitConfig

type InitConfig struct {
	Profiles              profileConfigMap `yaml:"profiles"`
	GlobalMetrics         []MetricsConfig  `yaml:"global_metrics"`
	OidBatchSize          Number           `yaml:"oid_batch_size"`
	BulkMaxRepetitions    Number           `yaml:"bulk_max_repetitions"`
	CollectDeviceMetadata Boolean          `yaml:"collect_device_metadata"`
	UseDeviceIDAsHostname Boolean          `yaml:"use_device_id_as_hostname"`
	MinCollectionInterval int              `yaml:"min_collection_interval"`
	Namespace             string           `yaml:"namespace"`
}

InitConfig is used to deserialize integration init config

type InstanceConfig

type InstanceConfig struct {
	Name                  string            `yaml:"name"`
	IPAddress             string            `yaml:"ip_address"`
	Port                  Number            `yaml:"port"`
	CommunityString       string            `yaml:"community_string"`
	SnmpVersion           string            `yaml:"snmp_version"`
	Timeout               Number            `yaml:"timeout"`
	Retries               Number            `yaml:"retries"`
	User                  string            `yaml:"user"`
	AuthProtocol          string            `yaml:"authProtocol"`
	AuthKey               string            `yaml:"authKey"`
	PrivProtocol          string            `yaml:"privProtocol"`
	PrivKey               string            `yaml:"privKey"`
	ContextName           string            `yaml:"context_name"`
	Metrics               []MetricsConfig   `yaml:"metrics"`     // SNMP metrics definition
	MetricTags            []MetricTagConfig `yaml:"metric_tags"` // SNMP metric tags definition
	Profile               string            `yaml:"profile"`
	UseGlobalMetrics      bool              `yaml:"use_global_metrics"`
	CollectDeviceMetadata *Boolean          `yaml:"collect_device_metadata"`
	UseDeviceIDAsHostname *Boolean          `yaml:"use_device_id_as_hostname"`

	// ExtraTags is a workaround to pass tags from snmp listener to snmp integration via AD template
	// (see cmd/agent/dist/conf.d/snmp.d/auto_conf.yaml) that only works with strings.
	// TODO: deprecated extra tags in favour of using autodiscovery listener Service.GetTags()
	ExtraTags string `yaml:"extra_tags"` // comma separated tags

	// Tags are just static tags from the instance that is common to all integrations.
	// Normally, the Agent will enrich metrics with the metrics with those tags.
	// See https://github.com/DataDog/datadog-agent/blob/1e8321ff089d04ccce3987b84f8b75630d7a18c0/pkg/collector/corechecks/checkbase.go#L131-L139
	// But we need to deserialize here since we need them for NDM metadata.
	Tags []string `yaml:"tags"` // used for device metadata

	// The oid_batch_size indicates how many OIDs are retrieved in a single Get or GetBulk call
	OidBatchSize Number `yaml:"oid_batch_size"`
	// The bulk_max_repetitions config indicates how many rows of the table are to be retrieved in a single GetBulk call
	BulkMaxRepetitions Number `yaml:"bulk_max_repetitions"`

	MinCollectionInterval int `yaml:"min_collection_interval"`
	// To accept min collection interval from snmp_listener, we need to accept it as string.
	// Using extra_min_collection_interval, we can accept both string and integer value.
	ExtraMinCollectionInterval Number `yaml:"extra_min_collection_interval"`

	Network                  string   `yaml:"network_address"`
	IgnoredIPAddresses       []string `yaml:"ignored_ip_addresses"`
	DiscoveryInterval        int      `yaml:"discovery_interval"`
	DiscoveryAllowedFailures int      `yaml:"discovery_allowed_failures"`
	DiscoveryWorkers         int      `yaml:"discovery_workers"`
	Workers                  int      `yaml:"workers"`
	Namespace                string   `yaml:"namespace"`
}

InstanceConfig is used to deserialize integration instance config

type MetricIndexTransform

type MetricIndexTransform struct {
	Start uint `yaml:"start"`
	End   uint `yaml:"end"`
}

MetricIndexTransform holds configs for metric index transform

type MetricTagConfig

type MetricTagConfig struct {
	Tag string `yaml:"tag"`

	// Table config
	Index  uint         `yaml:"index"`
	Column SymbolConfig `yaml:"column"`

	// Symbol config
	OID  string `yaml:"OID"`
	Name string `yaml:"symbol"`

	IndexTransform []MetricIndexTransform `yaml:"index_transform"`

	Mapping map[string]string `yaml:"mapping"`

	// Regex
	Match string            `yaml:"match"`
	Tags  map[string]string `yaml:"tags"`
	// contains filtered or unexported fields
}

MetricTagConfig holds metric tag info

func (*MetricTagConfig) GetTags

func (mtc *MetricTagConfig) GetTags(value string) []string

GetTags returns tags based on MetricTagConfig and a value

type MetricTagConfigList

type MetricTagConfigList []MetricTagConfig

MetricTagConfigList holds configs for a list of metric tags

func (*MetricTagConfigList) UnmarshalYAML

func (a *MetricTagConfigList) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML unmarshalls MetricTagConfigList

type MetricsConfig

type MetricsConfig struct {
	// Symbol configs
	Symbol SymbolConfig `yaml:"symbol"`

	// Legacy Symbol configs syntax
	OID  string `yaml:"OID"`
	Name string `yaml:"name"`

	// Table configs
	Symbols []SymbolConfig `yaml:"symbols"`

	MetricTags MetricTagConfigList `yaml:"metric_tags"`

	ForcedType string              `yaml:"forced_type"`
	Options    MetricsConfigOption `yaml:"options"`
}

MetricsConfig holds configs for a metric

func (*MetricsConfig) GetSymbolTags

func (m *MetricsConfig) GetSymbolTags() []string

GetSymbolTags returns symbol tags

func (*MetricsConfig) GetTags

func (m *MetricsConfig) GetTags(fullIndex string, values *valuestore.ResultValueStore) []string

GetTags retrieve tags using the metric config and values

func (*MetricsConfig) IsColumn

func (m *MetricsConfig) IsColumn() bool

IsColumn returns true if the metrics config define columns metrics

func (*MetricsConfig) IsScalar

func (m *MetricsConfig) IsScalar() bool

IsScalar returns true if the metrics config define scalar metrics

type MetricsConfigOption

type MetricsConfigOption struct {
	Placement    uint   `yaml:"placement"`
	MetricSuffix string `yaml:"metric_suffix"`
}

MetricsConfigOption holds config for metrics options

type Number

type Number int

Number can unmarshal yaml string or integer

func (*Number) UnmarshalYAML

func (n *Number) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML unmarshalls Number

type OidConfig

type OidConfig struct {
	// ScalarOids are all scalar oids to fetch
	ScalarOids []string
	// ColumnOids are all column oids to fetch
	ColumnOids []string
}

OidConfig holds configs for OIDs to fetch

type StringArray

type StringArray []string

StringArray is list of string with a yaml un-marshaller that support both array and string. See test file for example usage. Credit: https://github.com/go-yaml/yaml/issues/100#issuecomment-324964723

func (*StringArray) UnmarshalYAML

func (a *StringArray) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML unmarshalls StringArray

type SymbolConfig

type SymbolConfig struct {
	OID          string `yaml:"OID"`
	Name         string `yaml:"name"`
	ExtractValue string `yaml:"extract_value"`

	ExtractValuePattern *regexp.Regexp
}

SymbolConfig holds info for a single symbol/oid

Jump to

Keyboard shortcuts

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