Documentation ¶
Index ¶
- Variables
- type ArgumentError
- type AuthProtocol
- type Counter32
- type Counter64
- type EndOfMibView
- type ErrorStatus
- type Gauge32
- type Integer
- type Ipaddress
- type MessageError
- type NoSucheInstance
- type NoSucheObject
- type Null
- type OctetString
- type Oid
- func (v *Oid) AppendSubIds(subs []int) (*Oid, error)
- func (v *Oid) BigInt() (*big.Int, error)
- func (v *Oid) Compare(o *Oid) int
- func (v *Oid) Contains(o *Oid) bool
- func (v *Oid) Equal(o *Oid) bool
- func (v *Oid) Marshal() ([]byte, error)
- func (v *Oid) String() string
- func (v *Oid) Type() string
- func (v *Oid) Unmarshal(b []byte) (rest []byte, err error)
- type Oids
- type Opaque
- type Pdu
- type PduType
- type PduV1
- func (pdu *PduV1) AppendVarBind(oid *Oid, variable Variable)
- func (pdu *PduV1) ErrorIndex() int
- func (pdu *PduV1) ErrorStatus() ErrorStatus
- func (pdu *PduV1) Marshal() (b []byte, err error)
- func (pdu *PduV1) PduType() PduType
- func (pdu *PduV1) RequestId() int
- func (pdu *PduV1) SetErrorIndex(i int)
- func (pdu *PduV1) SetErrorStatus(i ErrorStatus)
- func (pdu *PduV1) SetMaxRepetitions(i int)
- func (pdu *PduV1) SetNonrepeaters(i int)
- func (pdu *PduV1) SetRequestId(i int)
- func (pdu *PduV1) String() string
- func (pdu *PduV1) Unmarshal(b []byte) (rest []byte, err error)
- func (pdu *PduV1) VarBinds() VarBinds
- type PrivProtocol
- type SNMP
- func (s *SNMP) Close()
- func (s *SNMP) GetBulkRequest(oids Oids, nonRepeaters, maxRepetitions int) (result Pdu, err error)
- func (s *SNMP) GetBulkWalk(oids Oids, nonRepeaters, maxRepetitions int) (result Pdu, err error)
- func (s *SNMP) GetNextRequest(oids Oids) (result Pdu, err error)
- func (s *SNMP) GetRequest(oids Oids) (result Pdu, err error)
- func (s *SNMP) InformRequest(varBinds VarBinds) error
- func (s *SNMP) Open() (err error)
- func (s *SNMP) String() string
- func (s *SNMP) V1Trap(varPduV1 TrapPduV1) (err error)
- func (s *SNMP) V2Trap(varBinds VarBinds) error
- func (s *SNMP) V2TrapWithBootsTime(varBinds VarBinds, eBoots, eTime int) error
- type SNMPArguments
- type SNMPVersion
- type ScopedPdu
- type SecurityEntry
- type SecurityLevel
- type ServerArguments
- type StdLogger
- type TimeTicks
- type TrapListener
- type TrapPduV1
- type TrapRequest
- type TrapServer
- type VarBind
- type VarBinds
- type Variable
Constants ¶
This section is empty.
Variables ¶
var ( OidSysUpTime = MustNewOid("1.3.6.1.2.1.1.3.0") OidSnmpTrap = MustNewOid("1.3.6.1.6.3.1.1.4.1.0") OidSnmpTrapEnterprise = MustNewOid("1.3.6.1.6.3.1.1.4.3.0") )
var UnsupportedOperation error = errors.New("Unsupported operation")
Functions ¶
This section is empty.
Types ¶
type ArgumentError ¶
type ArgumentError struct { Value interface{} // Argument that has a problem Message string // Error message }
An ArgumentError suggests that the arguments are wrong
func (*ArgumentError) Error ¶
func (e *ArgumentError) Error() string
type AuthProtocol ¶
type AuthProtocol string
const ( Md5 AuthProtocol = "MD5" Sha AuthProtocol = "SHA" )
type EndOfMibView ¶
type EndOfMibView struct {
Null
}
func NewEndOfMibView ¶
func NewEndOfMibView() *EndOfMibView
func (*EndOfMibView) Marshal ¶
func (v *EndOfMibView) Marshal() ([]byte, error)
func (*EndOfMibView) Type ¶
func (v *EndOfMibView) Type() string
type ErrorStatus ¶
type ErrorStatus int
const ( NoError ErrorStatus = iota TooBig NoSuchName BadValue ReadOnly GenError NoAccess WrongType WrongLength WrongEncoding WrongValue NoCreation InconsistentValue CommitFailed UndoFailed AuthorizationError NotWritable InconsistentName )
func (ErrorStatus) String ¶
func (e ErrorStatus) String() string
type MessageError ¶
type MessageError struct { Cause error // Cause of the error Message string // Error message Detail string // Detail of the error for debugging }
A MessageError suggests that the received message is wrong or is not obtained
func (*MessageError) Error ¶
func (e *MessageError) Error() string
type NoSucheInstance ¶
type NoSucheInstance struct {
Null
}
func NewNoSucheInstance ¶
func NewNoSucheInstance() *NoSucheInstance
func (*NoSucheInstance) Marshal ¶
func (v *NoSucheInstance) Marshal() ([]byte, error)
func (*NoSucheInstance) Type ¶
func (v *NoSucheInstance) Type() string
type NoSucheObject ¶
type NoSucheObject struct {
Null
}
func NewNoSucheObject ¶
func NewNoSucheObject() *NoSucheObject
func (*NoSucheObject) Marshal ¶
func (v *NoSucheObject) Marshal() ([]byte, error)
func (*NoSucheObject) Type ¶
func (v *NoSucheObject) Type() string
type OctetString ¶
type OctetString struct {
Value []byte
}
func NewOctetString ¶
func NewOctetString(b []byte) *OctetString
func (*OctetString) Marshal ¶
func (v *OctetString) Marshal() ([]byte, error)
func (*OctetString) String ¶
func (v *OctetString) String() string
func (*OctetString) Type ¶
func (v *OctetString) Type() string
type Oid ¶
type Oid struct {
Value asn1.ObjectIdentifier
}
func MustNewOid ¶
MustNewOid is like NewOid but panics if argument cannot be parsed
func (*Oid) AppendSubIds ¶
Returns Oid with additional sub-ids
func (*Oid) Compare ¶
Returns 0 this OID is equal to the specified OID, -1 this OID is lexicographically less than the specified OID, 1 this OID is lexicographically greater than the specified OID
type Opaque ¶
type Opaque struct {
OctetString
}
type Pdu ¶
type Pdu interface { PduType() PduType RequestId() int SetRequestId(int) ErrorStatus() ErrorStatus SetErrorStatus(ErrorStatus) ErrorIndex() int SetErrorIndex(int) SetNonrepeaters(int) SetMaxRepetitions(int) AppendVarBind(*Oid, Variable) VarBinds() VarBinds Marshal() ([]byte, error) Unmarshal([]byte) (rest []byte, err error) String() string }
The protocol data unit of SNMP
func NewPdu ¶
func NewPdu(ver SNMPVersion, t PduType) (pdu Pdu)
func NewPduWithOids ¶
func NewPduWithOids(ver SNMPVersion, t PduType, oids Oids) (pdu Pdu)
func NewPduWithVarBinds ¶
func NewPduWithVarBinds(ver SNMPVersion, t PduType, varBinds VarBinds) (pdu Pdu)
type PduV1 ¶
type PduV1 struct {
// contains filtered or unexported fields
}
The PduV1 is used by SNMP V1 and V2c, other than the SNMP V1 Trap
func (*PduV1) AppendVarBind ¶
func (*PduV1) ErrorIndex ¶
func (*PduV1) ErrorStatus ¶
func (pdu *PduV1) ErrorStatus() ErrorStatus
func (*PduV1) SetErrorIndex ¶
func (*PduV1) SetErrorStatus ¶
func (pdu *PduV1) SetErrorStatus(i ErrorStatus)
func (*PduV1) SetMaxRepetitions ¶
func (*PduV1) SetNonrepeaters ¶
func (*PduV1) SetRequestId ¶
type PrivProtocol ¶
type PrivProtocol string
const ( Des PrivProtocol = "DES" Aes PrivProtocol = "AES" )
type SNMP ¶
type SNMP struct {
// contains filtered or unexported fields
}
SNMP Object provides functions for the SNMP Client
func (*SNMP) GetBulkRequest ¶
func (*SNMP) GetBulkWalk ¶
This method inquire about OID subtrees by repeatedly using GetBulkRequest. Returned PDU contains the varbind list of all subtrees. however, if the ErrorStatus of PDU is not the NoError, return only the last query result.
func (*SNMP) InformRequest ¶
type SNMPArguments ¶
type SNMPArguments struct { Version SNMPVersion // SNMP version to use Network string // See net.Dial parameter (The default is `udp`) Address string // See net.Dial parameter Timeout time.Duration // Request timeout (The default is 5sec) Retries uint // Number of retries (The default is `0`) MessageMaxSize int // Maximum size of an SNMP message (The default is `1400`) Community string // Community (V1 or V2c specific) UserName string // Security name (V3 specific) SecurityLevel SecurityLevel // Security level (V3 specific) AuthPassword string // Authentication protocol pass phrase (V3 specific) AuthProtocol AuthProtocol // Authentication protocol (V3 specific) PrivPassword string // Privacy protocol pass phrase (V3 specific) PrivProtocol PrivProtocol // Privacy protocol (V3 specific) SecurityEngineId string // Security engine ID (V3 specific) ContextEngineId string // Context engine ID (V3 specific) ContextName string // Context name (V3 specific) // contains filtered or unexported fields }
An argument for creating a SNMP Object
func (*SNMPArguments) String ¶
func (a *SNMPArguments) String() string
type SNMPVersion ¶
type SNMPVersion int
const ( V1 SNMPVersion = 0 V2c SNMPVersion = 1 V3 SNMPVersion = 3 )
func (SNMPVersion) String ¶
func (s SNMPVersion) String() string
type ScopedPdu ¶
The ScopedPdu is used by SNMP V3. Includes the PduV1, and contains a SNMP context parameter
type SecurityEntry ¶
type SecurityEntry struct { Version SNMPVersion // SNMP version to use (V2c or V3) Community string // Community (V2c specific) UserName string // Security name (V3 specific) SecurityLevel SecurityLevel // Security level (V3 specific) AuthPassword string // Authentication protocol pass phrase (V3 specific) AuthProtocol AuthProtocol // Authentication protocol (V3 specific) PrivPassword string // Privacy protocol pass phrase (V3 specific) PrivProtocol PrivProtocol // Privacy protocol (V3 specific) SecurityEngineId string // Security engine ID (V3 Trap specific) }
SecurityEntry is used for authentication of the received SNMP message
func (*SecurityEntry) String ¶
func (a *SecurityEntry) String() string
type SecurityLevel ¶
type SecurityLevel int
const ( NoAuthNoPriv SecurityLevel = iota AuthNoPriv AuthPriv )
func (SecurityLevel) String ¶
func (s SecurityLevel) String() string
type ServerArguments ¶
type ServerArguments struct { Network string // "udp", "udp4", "udp6" (The default is `udp`) LocalAddr string // See net.Dial parameter WriteTimeout time.Duration // Timeout for writing a response (The default is 5sec) MessageMaxSize int // Maximum size of a SNMP message (The default is 2048) }
An argument for creating a Server Object
func (*ServerArguments) String ¶
func (a *ServerArguments) String() string
type StdLogger ¶
type StdLogger interface { Print(v ...interface{}) Printf(format string, v ...interface{}) }
type TrapListener ¶
type TrapListener interface {
OnTRAP(trap *TrapRequest)
}
TrapListener defines method that need to be implemented by Trap listeners. If OnTRAP panics, the server (caller of OnTRAP) assumes that affect of the panic is temporary and recovers by the panic and logs trace to the error log.
type TrapRequest ¶
type TrapRequest struct { // The received PDU Pdu Pdu // The source address of trap Source net.Addr // Error is an optional field used to indicate // errors which may occur during the decoding // of the received packet Error error }
TrapRequest is representing trap request that is send from the network element.
type TrapServer ¶
type TrapServer struct { // Error Logger which will be used for logging of default errors ErrorLog StdLogger // contains filtered or unexported fields }
A TrapServer defines parameters for running of TRAP daemon that listens for incoming trap messages.
func NewTrapServer ¶
func NewTrapServer(args ServerArguments) (*TrapServer, error)
NewTrapServer returns a new Server and is using server arguments for configuration.
func (*TrapServer) AddSecurity ¶
func (s *TrapServer) AddSecurity(entry *SecurityEntry) error
func (*TrapServer) DeleteSecurity ¶
func (s *TrapServer) DeleteSecurity(entry *SecurityEntry) error
func (*TrapServer) Serve ¶
func (s *TrapServer) Serve(listener TrapListener) error
Serve starts the SNMP trap receiver. Serve blocks, the caller should call Close when finished, to shut it down.
type VarBind ¶
func NewVarBind ¶
type VarBinds ¶
type VarBinds []*VarBind
func (VarBinds) MatchBaseOids ¶
Gets a VarBind list that matches the prefix
type Variable ¶
type Variable interface { // Return a BigInt representation of this Variable if such a representation exists BigInt() (*big.Int, error) // Return a string representation of this Variable String() string // Return a string of type Type() string Marshal() ([]byte, error) Unmarshal([]byte) (rest []byte, err error) }