snmp

package
v0.0.0-...-c5e60ee Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const DeviceReachableGetNextOid = "1.0"

DeviceReachableGetNextOid is used in getNext call to check if the device is reachable GETNEXT 1.0 should be able to fetch the first available SNMP OID. There is no need to handle top node other than iso(1) since it the only valid SNMP tree starting point. Other top nodes like ccitt(0) and joint(2) do not pertain to SNMP. Source: https://docstore.mik.ua/orelly/networking_2ndEd/snmp/ch02_03.htm

View Source
const DeviceSysDescrOid = "1.3.6.1.2.1.1.1.0"

DeviceSysDescrOid is the OID for the device system description

View Source
const DeviceSysNameOid = "1.3.6.1.2.1.1.5.0"

DeviceSysNameOid is the OID for the device system name

View Source
const DeviceSysObjectIDOid = "1.3.6.1.2.1.1.2.0"

DeviceSysObjectIDOid is the OID for the device system object ID

View Source
const DeviceSysUptimeOid = "1.3.6.1.2.1.1.3.0"

DeviceSysUptimeOid is the OID for the device system uptime

Variables

View Source
var ErrNoConfigGiven = errors.New("no config given for snmp_listener")

ErrNoConfigGiven is returned when the SNMP listener config was not found

Functions

This section is empty.

Types

type Authentication

type Authentication struct {
	Version         string `mapstructure:"snmp_version"`
	Timeout         int    `mapstructure:"timeout"`
	Retries         int    `mapstructure:"retries"`
	Community       string `mapstructure:"community_string"`
	User            string `mapstructure:"user"`
	AuthKey         string `mapstructure:"authKey"`
	AuthProtocol    string `mapstructure:"authProtocol"`
	PrivKey         string `mapstructure:"privKey"`
	PrivProtocol    string `mapstructure:"privProtocol"`
	ContextEngineID string `mapstructure:"context_engine_id"`
	ContextName     string `mapstructure:"context_name"`
}

Authentication holds SNMP authentication data

func (*Authentication) BuildSNMPParams

func (a *Authentication) BuildSNMPParams(deviceIP string, port uint16) (*gosnmp.GoSNMP, error)

BuildSNMPParams returns a valid GoSNMP struct to start making queries

type Config

type Config struct {
	ADIdentifier            string
	AuthKey                 string
	AuthProtocol            string
	Authentications         []Authentication
	Community               string
	ContextEngineID         string
	ContextName             string
	Loader                  string
	MinCollectionInterval   uint
	Namespace               string
	Network                 string
	OidBatchSize            int
	Port                    uint16
	PrivKey                 string
	PrivProtocol            string
	Retries                 int
	Tags                    []string
	Timeout                 int
	User                    string
	Version                 string
	CollectDeviceMetadata   bool
	CollectTopology         bool
	CollectVPN              bool
	IgnoredIPAddresses      map[string]bool
	UseDeviceIDAsHostname   bool
	UseRemoteConfigProfiles bool
	PingConfig              snmpintegration.PingConfig

	// InterfaceConfigs is a map of IP to a list of snmpintegration.InterfaceConfig
	InterfaceConfigs map[string][]snmpintegration.InterfaceConfig
}

Config holds configuration for a particular subnet

func (*Config) Digest

func (c *Config) Digest(address string) string

Digest returns an hash value representing the data stored in this configuration, minus the network address

func (*Config) IsIPIgnored

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

IsIPIgnored checks the given IP against IgnoredIPAddresses

func (*Config) LegacyDigest

func (c *Config) LegacyDigest(address string) string

LegacyDigest returns an hash value representing the data stored in this configuration, minus the network address and authentications TODO: Remove support for legacy format when Agent reaches version 7.76+: see https://github.com/DataDog/datadog-agent/pull/39459

type ListenerConfig

type ListenerConfig struct {
	Workers                 int                        `mapstructure:"workers"`
	DiscoveryInterval       int                        `mapstructure:"discovery_interval"`
	AllowedFailures         int                        `mapstructure:"discovery_allowed_failures"`
	Loader                  string                     `mapstructure:"loader"`
	CollectDeviceMetadata   bool                       `mapstructure:"collect_device_metadata"`
	CollectTopology         bool                       `mapstructure:"collect_topology"`
	CollectVPN              bool                       `mapstructure:"collect_vpn"`
	MinCollectionInterval   uint                       `mapstructure:"min_collection_interval"`
	Namespace               string                     `mapstructure:"namespace"`
	UseDeviceISAsHostname   bool                       `mapstructure:"use_device_id_as_hostname"`
	PingConfig              snmpintegration.PingConfig `mapstructure:"ping"`
	Deduplicate             bool                       `mapstructure:"use_deduplication"`
	UseRemoteConfigProfiles bool                       `mapstructure:"use_remote_config_profiles"`
	OidBatchSize            int                        `mapstructure:"oid_batch_size"`
	Timeout                 int                        `mapstructure:"timeout"`
	Retries                 int                        `mapstructure:"retries"`

	// legacy
	AllowedFailuresLegacy int `mapstructure:"allowed_failures"`

	Configs []Config

	// DON'T USE. This is only used to read the raw array from datadog.yaml
	UnmarshalledConfigs []UnmarshalledConfig `mapstructure:"configs"`
}

ListenerConfig holds global configuration for SNMP discovery

func NewListenerConfig

func NewListenerConfig() (ListenerConfig, error)

NewListenerConfig parses configuration and returns a built ListenerConfig

type UnmarshalledConfig

type UnmarshalledConfig struct {
	ADIdentifier          string                                       `mapstructure:"ad_identifier"`
	AuthKey               string                                       `mapstructure:"authKey"`
	AuthProtocol          string                                       `mapstructure:"authProtocol"`
	Authentications       []Authentication                             `mapstructure:"authentications"`
	CollectDeviceMetadata *bool                                        `mapstructure:"collect_device_metadata"`
	CollectTopology       *bool                                        `mapstructure:"collect_topology"`
	CollectVPN            *bool                                        `mapstructure:"collect_vpn"`
	Community             string                                       `mapstructure:"community_string"`
	ContextEngineID       string                                       `mapstructure:"context_engine_id"`
	ContextName           string                                       `mapstructure:"context_name"`
	IgnoredIPAddresses    []string                                     `mapstructure:"ignored_ip_addresses"`
	InterfaceConfigs      map[string][]snmpintegration.InterfaceConfig `mapstructure:"interface_configs"`
	Loader                string                                       `mapstructure:"loader"`
	MinCollectionInterval uint                                         `mapstructure:"min_collection_interval"`
	Namespace             string                                       `mapstructure:"namespace"`
	Network               string                                       `mapstructure:"network_address"`
	OidBatchSize          int                                          `mapstructure:"oid_batch_size"`
	PingConfig            snmpintegration.PingConfig                   `mapstructure:"ping"`
	Port                  uint16                                       `mapstructure:"port"`
	PrivKey               string                                       `mapstructure:"privKey"`
	PrivProtocol          string                                       `mapstructure:"privProtocol"`
	Retries               int                                          `mapstructure:"retries"`
	Tags                  []string                                     `mapstructure:"tags"`
	Timeout               int                                          `mapstructure:"timeout"`
	UseDeviceIDAsHostname *bool                                        `mapstructure:"use_device_id_as_hostname"`
	User                  string                                       `mapstructure:"user"`
	Version               string                                       `mapstructure:"snmp_version"`

	// Legacy
	NetworkLegacy      string `mapstructure:"network"`
	VersionLegacy      string `mapstructure:"version"`
	CommunityLegacy    string `mapstructure:"community"`
	AuthKeyLegacy      string `mapstructure:"authentication_key"`
	AuthProtocolLegacy string `mapstructure:"authentication_protocol"`
	PrivKeyLegacy      string `mapstructure:"privacy_key"`
	PrivProtocolLegacy string `mapstructure:"privacy_protocol"`
}

UnmarshalledConfig is used to read each item of the array in datadog.yaml

Directories

Path Synopsis
Package devicededuper provides a deduplication mechanism for SNMP devices based on the device info It is used to deduplicate devices which have multiple IPs
Package devicededuper provides a deduplication mechanism for SNMP devices based on the device info It is used to deduplicate devices which have multiple IPs
Package gosnmplib provides helpers to go with gosnmp.
Package gosnmplib provides helpers to go with gosnmp.
Package snmpparse extracts SNMP configurations from agent config data.
Package snmpparse extracts SNMP configurations from agent config data.

Jump to

Keyboard shortcuts

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