snmp

package
v1.17.0-rc0 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientConfig

type ClientConfig struct {
	// Timeout to wait for a response.
	Timeout internal.Duration `toml:"timeout"`
	Retries int               `toml:"retries"`
	// Values: 1, 2, 3
	Version uint8 `toml:"version"`

	// Parameters for Version 1 & 2
	Community string `toml:"community"`

	// Parameters for Version 2 & 3
	MaxRepetitions uint8 `toml:"max_repetitions"`

	// Parameters for Version 3
	ContextName string `toml:"context_name"`
	// Values: "noAuthNoPriv", "authNoPriv", "authPriv"
	SecLevel string `toml:"sec_level"`
	SecName  string `toml:"sec_name"`
	// Values: "MD5", "SHA", "". Default: ""
	AuthProtocol string `toml:"auth_protocol"`
	AuthPassword string `toml:"auth_password"`
	// Values: "DES", "AES", "". Default: ""
	PrivProtocol string `toml:"priv_protocol"`
	PrivPassword string `toml:"priv_password"`
	EngineID     string `toml:"-"`
	EngineBoots  uint32 `toml:"-"`
	EngineTime   uint32 `toml:"-"`
}

type GosnmpWrapper

type GosnmpWrapper struct {
	*gosnmp.GoSNMP
}

GosnmpWrapper wraps a *gosnmp.GoSNMP object so we can use it as a snmpConnection.

func NewWrapper

func NewWrapper(s ClientConfig) (GosnmpWrapper, error)

func (GosnmpWrapper) Get

func (gsw GosnmpWrapper) Get(oids []string) (*gosnmp.SnmpPacket, error)

Get wraps GoSNMP.GET(). If any error is encountered, it will just once reconnect and try again.

func (GosnmpWrapper) Host

func (gsw GosnmpWrapper) Host() string

Host returns the value of GoSNMP.Target.

func (*GosnmpWrapper) SetAgent

func (gs *GosnmpWrapper) SetAgent(agent string) error

SetAgent takes a url (scheme://host:port) and sets the wrapped GoSNMP struct's corresponding fields. This shouldn't be called after using the wrapped GoSNMP struct, for example after connecting.

func (GosnmpWrapper) Walk

func (gsw GosnmpWrapper) Walk(oid string, fn gosnmp.WalkFunc) error

Walk wraps GoSNMP.Walk() or GoSNMP.BulkWalk(), depending on whether the connection is using SNMPv1 or newer. Also, if any error is encountered, it will just once reconnect and try again.

Jump to

Keyboard shortcuts

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