Documentation ¶
Overview ¶
Package snmpparse extracts SNMP configurations from agent config data.
Index ¶
Constants ¶
const ( // DefaultPort is the standard SNMP port DefaultPort = 161 // DefaultCommunityString is the default on most v2 implementations DefaultCommunityString = "public" )
Variables ¶
var AuthOpts = NewOptions(OptPairs[gosnmp.SnmpV3AuthProtocol]{ {"", gosnmp.NoAuth}, {"MD5", gosnmp.MD5}, {"SHA", gosnmp.SHA}, {"SHA224", gosnmp.SHA224}, {"SHA256", gosnmp.SHA256}, {"SHA384", gosnmp.SHA384}, {"SHA512", gosnmp.SHA512}, })
AuthOpts maps string names to gosnmp auth protocols
var LevelOpts = NewOptions(OptPairs[gosnmp.SnmpV3MsgFlags]{ {"noAuthNoPriv", gosnmp.NoAuthNoPriv}, {"authNoPriv", gosnmp.AuthNoPriv}, {"authPriv", gosnmp.AuthPriv}, })
LevelOpts maps string names to gosnmp auth levels
var PrivOpts = NewOptions(OptPairs[gosnmp.SnmpV3PrivProtocol]{ {"", gosnmp.NoPriv}, {"DES", gosnmp.DES}, {"AES", gosnmp.AES}, {"AES192", gosnmp.AES192}, {"AES192C", gosnmp.AES192C}, {"AES256", gosnmp.AES256}, {"AES256C", gosnmp.AES256C}, })
PrivOpts maps string names to gosnmp privacy protocols
var VersionOpts = NewOptions(OptPairs[gosnmp.SnmpVersion]{ {"1", gosnmp.Version1}, {"2c", gosnmp.Version2c}, {"3", gosnmp.Version3}, })
VersionOpts maps string names to gosnmp versions
Functions ¶
func NewSNMP ¶
func NewSNMP(conf *SNMPConfig, logger log.Component) (*gosnmp.GoSNMP, error)
NewSNMP validates an SNMPConfig and builds a GoSNMP from it.
func SetDefault ¶
func SetDefault(sc *SNMPConfig)
SetDefault sets the standard default config values
Types ¶
type Options ¶
Options represents an ordered map of case-insensitive choices. This is particularly useful for generating sensible error messages and command-line documentation.
func NewOptions ¶
NewOptions creates a new Options object from a slice of pairs. We don't just create one directly from a map because map iteration order is random.
func (Options[T]) GetOpt ¶
GetOpt returns the key that matches choice, case-insensitively. The key is found case-insensitively; the returned value will be the key as defined in the original list.
type SNMPConfig ¶
type SNMPConfig struct { // General IPAddress string `yaml:"ip_address"` Port uint16 `yaml:"port"` Version string `yaml:"snmp_version"` Timeout int `yaml:"timeout"` Retries int `yaml:"retries"` // v1 &2 CommunityString string `yaml:"community_string"` // v3 Username string `yaml:"user"` AuthProtocol string `yaml:"authProtocol"` AuthKey string `yaml:"authKey"` PrivProtocol string `yaml:"privProtocol"` PrivKey string `yaml:"privKey"` Context string `yaml:"context_name"` // network NetAddress string `yaml:"network_address"` // These are omitted from the yaml because we don't let users configure // them, but there are cases where we use them (e.g. the snmpwalk command) SecurityLevel string `yaml:"-"` UseUnconnectedUDPSocket bool `yaml:"-"` }
SNMPConfig is a generic container for configuration data specific to the SNMP integration.
func GetConfigCheckSnmp ¶
func GetConfigCheckSnmp(conf config.Component) ([]SNMPConfig, error)
GetConfigCheckSnmp returns each SNMPConfig for all running config checks, by querying the local agent. If the agent isn't running or is unreachable, this will fail.
func GetIPConfig ¶
func GetIPConfig(ipAddress string, SnmpConfigList []SNMPConfig) SNMPConfig
GetIPConfig finds the SNMPConfig for a specific IP address. If the IP is explicitly configured, that will be returned; if it isn't, but it is part of a configured subnet, then the subnet config will be returned. If there are no matches, this will return an empty SNMPConfig.
func ParseConfigSnmp ¶
func ParseConfigSnmp(c integration.Config) []SNMPConfig
ParseConfigSnmp extracts all SNMPConfigs from an autodiscovery config. Any loading errors are logged but not returned.