Documentation ¶
Index ¶
Constants ¶
const ( TypeInteger = 0x02 TypeString = 0x04 TypeNull = 0x05 TypeOID = 0x06 TypeSequence = 0x30 TypeIpAddress = 0x40 TypeCounter = 0x41 TypeGauge = 0x42 TypeTimeTicks = 0x43 TypeCounter64 = 0x46 TypeNoSuchObject = 0x80 TypeNoSuchInstance = 0x81 TypeEndOfMIBView = 0x82 TypeGetRequest = 0xa0 TypeGetNextRequest = 0xa1 TypeGetResponse = 0xa2 TypeReport = 0xa8 )
const EndOfMIBView tag = TypeEndOfMIBView
const NoSuchInstance tag = TypeNoSuchInstance
const NoSuchObject tag = TypeNoSuchObject
const Null tag = 0x05
Null represents an SNMP NULL.
Variables ¶
var ( ErrDecodingType = errors.New("snmp: error decoding type") ErrUnknownType = errors.New("snmp: unknown type") )
var (
ErrorIncorrectType = errors.New("snmp: incorrect type")
)
Functions ¶
This section is empty.
Types ¶
type GetNextRequest ¶
type GetNextRequest struct {
PDU
}
GetNextRequest represents an SNMP GetNextRequest-PDU.
func (GetNextRequest) Encode ¶
func (s GetNextRequest) Encode() ([]byte, error)
Encode encodes a GetNextRequest with the proper header.
type GetRequest ¶
type GetRequest struct {
PDU
}
GetRequest represents an SNMP GetRequest-PDU.
func (GetRequest) Encode ¶
func (s GetRequest) Encode() ([]byte, error)
Encode encodes a GetRequest with the proper header.
type GetResponse ¶
type GetResponse struct {
PDU
}
GetResponse represents an SNMP GetResponse-PDU.
func (GetResponse) Encode ¶
func (s GetResponse) Encode() ([]byte, error)
Encode encodes a GetResponse with the proper header.
type ObjectIdentifier ¶
type ObjectIdentifier []uint
ObjectIdentifier represents an SNMP OID.
func MustParseOID ¶
func MustParseOID(str string) ObjectIdentifier
MustParseOID parses a string and returns an ObjectIdentifier. It panics if an error is encountered.
func ParseOID ¶
func ParseOID(str string) (ObjectIdentifier, error)
ParseOID parses and returns an ObjectIdentifier and an error.
func (ObjectIdentifier) Encode ¶
func (oid ObjectIdentifier) Encode() ([]byte, error)
Encode encodes an ObjectIdentifier with the proper header.
func (ObjectIdentifier) String ¶
func (oid ObjectIdentifier) String() string
String returns the string representation of an ObjectIdentifer. This value can be parsed into the original OID as well.
type PDU ¶
type PDU struct {
// contains filtered or unexported fields
}
PDU represents an SNMP PDU.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session represents an SNMP v3 session to a single device.
func (*Session) Get ¶
func (s *Session) Get(oid ObjectIdentifier) (*GetResponse, error)
func (*Session) GetNext ¶
func (s *Session) GetNext(oid ObjectIdentifier) (*GetResponse, error)
type SessionManager ¶
type SessionManager struct {
// contains filtered or unexported fields
}
A SessionManager listens on a UDP port and manages SNMP sessions.
func NewSessionManager ¶
func NewSessionManager() (*SessionManager, error)
NewSessionManager creates a new SessionManager and starts listening on a UDP port.
func (*SessionManager) NewSession ¶
func (s *SessionManager) NewSession(address, user, authPassphrase, privPassphrase string) (*Session, error)
NewSession creates a new SNMP v3 session using "authPriv" mode with SHA authentication and AES encryption.
type Varbind ¶
type Varbind struct { OID ObjectIdentifier // contains filtered or unexported fields }
Varbind represents a single variable binding.
func NewVarbind ¶
func NewVarbind(OID ObjectIdentifier, value DataType) Varbind
NewVarbind returns a new Varbind with the given OID and value.
func (Varbind) GetIntegerValue ¶
GetIntegerValue returns the integer value of a variable binding. An error is returned if the value is not an integer.
func (Varbind) GetStringValue ¶
GetStringValue returns the string value of a variable binding. An error is returned if the value is not a string.