Documentation ¶
Index ¶
- Variables
- func BytesIfaceToASCII(b interface{}) (string, error)
- func GetAuthProtocol(s string) (gosnmp.SnmpV3AuthProtocol, error)
- func GetPrivProtocol(s string) (gosnmp.SnmpV3PrivProtocol, error)
- func GetSNMPVersion(s string) (gosnmp.SnmpVersion, error)
- func GetSecurityFlags(s string) (gosnmp.SnmpV3MsgFlags, error)
- func TagOrPanic(tag string) *sdk.Tag
- type Client
- type SnmpTargetConfiguration
- type SnmpV3Security
- type SnmpV3SecurityAuthentication
- type SnmpV3SecurityPrivacy
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidAuthProtocol = errors.New("unsupported SNMP auth protocol specified") ErrInvalidPrivProtocol = errors.New("unsupported SNMP privacy protocol specified") ErrInvalidSNMPVersion = errors.New("invalid SNMP version specified") ErrInvalidMessageFlag = errors.New("invalid security message flag specified") )
Errors for utility functions, largely around parsing SNMP configurations.
var (
ErrNonV3SecurityParams = errors.New("cannot define security parameters for SNMP versions other than v3")
)
Errors relating to SNMP plugin client creation and usage.
Functions ¶
func BytesIfaceToASCII ¶
BytesIfaceToASCII converts an interface, which should resolve to a byte array, to a (printable) ASCII string, if possible. This is needed since there is no differentiation between strings and byte arrays in the SNMP protocol.
If a call to this function fails, the caller should just keep the raw byte array.
This function makes no attempt to support extended (8-bit) ASCII.
func GetAuthProtocol ¶
func GetAuthProtocol(s string) (gosnmp.SnmpV3AuthProtocol, error)
GetAuthProtocol gets the SNMP v3 authentication protocol constant corresponding to the given string.
func GetPrivProtocol ¶
func GetPrivProtocol(s string) (gosnmp.SnmpV3PrivProtocol, error)
GetPrivProtocol gets the SNMP v3 privacy protocol constant corresponding to the given string.
func GetSNMPVersion ¶
func GetSNMPVersion(s string) (gosnmp.SnmpVersion, error)
GetSNMPVersion gets the version of SNMP corresponding to the given string.
func GetSecurityFlags ¶
func GetSecurityFlags(s string) (gosnmp.SnmpV3MsgFlags, error)
GetSecurityFlags gets the SNMP v3 security message flags constant corresponding to the given string.
func TagOrPanic ¶
TagOrPanic is a utility function which creates a new SDK Tag or it panics.
This is useful when you know the format of the tag is correct ahead of time and you which skip the error check.
Types ¶
type Client ¶
Client is a wrapper around a GoSNMP struct which adds some utility functions around it. Notably, it enables lazy connecting to the client, so the SNMP agent does not need to be reachable at plugin startup.
func NewClient ¶
func NewClient(cfg *SnmpTargetConfiguration) (*Client, error)
NewClient creates a new instance of an SNMP Client for the given SNMP target configuration. The SNMP target configuration is defined in the dynamic configuration block for the plugin.
func (*Client) GetSupportedDevices ¶
GetSupportedDevices gets all the OIDs for devices found on the target. This may not always be the full set of devices that a MIB defines.
This returns a map of OIDs to empty struct. This map should be used during device creation to filter the MIB to only register those devices that a target supports. It is returned as a map to make OID lookups easier than iterating over a slice. Presence in the map means the device is supported, absence means it is not.
type SnmpTargetConfiguration ¶
type SnmpTargetConfiguration struct { MIB string `yaml:"mib,omitempty"` Version string `yaml:"version,omitempty"` Agent string `yaml:"agent,omitempty"` Community string `yaml:"community,omitempty"` Timeout time.Duration `yaml:"timeout,omitempty"` Retries int `yaml:"retries,omitempty"` Security *SnmpV3Security `yaml:"security,omitempty"` }
SnmpTargetConfiguration defines the configuration for individual SNMP servers, which are defined in the plugin config's dynamicRegistration block.
func LoadTargetConfiguration ¶
func LoadTargetConfiguration(raw map[string]interface{}) (*SnmpTargetConfiguration, error)
LoadTargetConfiguration loads a map of data, which should be read in from the plugin config's dynamicRegistration block, into an SnmpTargetConfiguration struct.
type SnmpV3Security ¶
type SnmpV3Security struct { Level string `yaml:"level,omitempty"` Context string `yaml:"context,omitempty"` Username string `yaml:"username,omitempty"` Authentication *SnmpV3SecurityAuthentication `yaml:"authentication,omitempty"` Privacy *SnmpV3SecurityPrivacy `yaml:"privacy,omitempty"` }
SnmpV3Security defines the security configuration for the SNMP connection. Only v3 of the SNMP protocol supports these security parameters.
type SnmpV3SecurityAuthentication ¶
type SnmpV3SecurityAuthentication struct { Protocol string `yaml:"protocol,omitempty"` Passphrase string `yaml:"passphrase,omitempty"` }
SnmpV3SecurityAuthentication defines the authentication parameters for SNMP v3 security, when auth is enabled.
type SnmpV3SecurityPrivacy ¶
type SnmpV3SecurityPrivacy struct { Protocol string `yaml:"protocol,omitempty"` Passphrase string `yaml:"passphrase,omitempty"` }
SnmpV3SecurityPrivacy defines the privacy parameters for SNMP v3 security, when privacy is enabled.