session

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: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NewSession = NewGosnmpSession

NewSession returns a new session Can be replaced in tests to use a mock session

Functions

func FetchSysObjectID

func FetchSysObjectID(session Session) (string, error)

FetchSysObjectID fetches the sys object id from the device

Types

type GosnmpSession

type GosnmpSession struct {
	// contains filtered or unexported fields
}

GosnmpSession is used to connect to a snmp device

func (*GosnmpSession) Close

func (s *GosnmpSession) Close() error

Close is used to close the connection

func (*GosnmpSession) Connect

func (s *GosnmpSession) Connect() error

Connect is used to create a new connection

func (*GosnmpSession) Get

func (s *GosnmpSession) Get(oids []string) (result *gosnmp.SnmpPacket, err error)

Get will send a SNMPGET command

func (*GosnmpSession) GetBulk

func (s *GosnmpSession) GetBulk(oids []string, bulkMaxRepetitions uint32) (result *gosnmp.SnmpPacket, err error)

GetBulk will send a SNMP BULKGET command

func (*GosnmpSession) GetNext

func (s *GosnmpSession) GetNext(oids []string) (result *gosnmp.SnmpPacket, err error)

GetNext will send a SNMP GETNEXT command

func (*GosnmpSession) GetVersion

func (s *GosnmpSession) GetVersion() gosnmp.SnmpVersion

GetVersion returns the snmp version used

type MockSession

type MockSession struct {
	mock.Mock
	ConnectErr error
	CloseErr   error
	Version    gosnmp.SnmpVersion
}

MockSession mocks a connection session

func CreateMockSession

func CreateMockSession() *MockSession

CreateMockSession creates a mock session

func (*MockSession) Close

func (s *MockSession) Close() error

Close is used to close the connection

func (*MockSession) Configure

func (s *MockSession) Configure(config checkconfig.CheckConfig) error

Configure configures the session

func (*MockSession) Connect

func (s *MockSession) Connect() error

Connect is used to create a new connection

func (*MockSession) Get

func (s *MockSession) Get(oids []string) (result *gosnmp.SnmpPacket, err error)

Get will send a SNMPGET command

func (*MockSession) GetBulk

func (s *MockSession) GetBulk(oids []string, bulkMaxRepetitions uint32) (result *gosnmp.SnmpPacket, err error)

GetBulk will send a SNMP BULKGET command

func (*MockSession) GetNext

func (s *MockSession) GetNext(oids []string) (result *gosnmp.SnmpPacket, err error)

GetNext will send a SNMP GETNEXT command

func (*MockSession) GetVersion

func (s *MockSession) GetVersion() gosnmp.SnmpVersion

GetVersion returns the snmp version used

type Session

type Session interface {
	Connect() error
	Close() error
	Get(oids []string) (result *gosnmp.SnmpPacket, err error)
	GetBulk(oids []string, bulkMaxRepetitions uint32) (result *gosnmp.SnmpPacket, err error)
	GetNext(oids []string) (result *gosnmp.SnmpPacket, err error)
	GetVersion() gosnmp.SnmpVersion
}

Session interface for connecting to a snmp device

func NewGosnmpSession

func NewGosnmpSession(config *checkconfig.CheckConfig) (Session, error)

NewGosnmpSession creates a new session

func NewMockSession

func NewMockSession() Session

NewMockSession creates a mock session

Jump to

Keyboard shortcuts

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