Documentation ¶
Index ¶
- Variables
- func ArgsValidate(args *Arguments) error
- func AsInt(value Variable) (int, error)
- func AsInt32(value Variable) (int32, error)
- func AsInt64(value Variable) (int64, error)
- func AsString(value Variable) (string, error)
- func AsUint(value Variable) (uint, error)
- func AsUint32(value Variable) (uint32, error)
- func AsUint64(value Variable) (uint64, error)
- func DecryptAES(src, key, privParam []byte, engineBoots, engineTime int32) (dst []byte, err error)
- func DecryptDES(src, key, privParam []byte) (dst []byte, err error)
- func EncryptAES(src, key []byte, engineBoots, engineTime int32, salt int64) (dst, privParam []byte, err error)
- func EncryptDES(src, key []byte, engineBoots, salt int32) (dst, privParam []byte, err error)
- func ParseIntsFromString(s string) ([]int, error)
- func ParseLine(ss []string, is_end bool) (*Oid, Variable, []string, error)
- func PasswordToKey(proto AuthProtocol, password string, engineId []byte) []byte
- func Read(reader io.Reader, cb func(oid Oid, value Variable) error) error
- func ReadHex(buf *bytes.Buffer, s string) error
- func SnmpCheckPdu(snmp *SNMP, pdu PDU) error
- func StripHexPrefix(s string) string
- func ToHexStr(a []byte, sep string) string
- func ToOidString(sub []int) string
- func ToSyntexString(t int) string
- type ArgumentError
- type Arguments
- type AuthProtocol
- type CompareFunc
- type Counter32
- func (v *Counter32) Bytes() []byte
- func (v *Counter32) ErrorMessage() string
- func (v *Counter32) Int() int64
- func (v *Counter32) IsError() bool
- func (v *Counter32) Marshal() ([]byte, error)
- func (v *Counter32) MarshalJSON() ([]byte, error)
- func (v *Counter32) String() string
- func (v *Counter32) Syntex() int
- func (v *Counter32) ToString() string
- func (v *Counter32) Uint() uint64
- func (v *Counter32) Unmarshal(b []byte) (rest []byte, err error)
- type Counter64
- func (v *Counter64) Bytes() []byte
- func (v *Counter64) ErrorMessage() string
- func (v *Counter64) Int() int64
- func (v *Counter64) IsError() bool
- func (v *Counter64) Marshal() ([]byte, error)
- func (v *Counter64) MarshalJSON() ([]byte, error)
- func (v *Counter64) String() string
- func (v *Counter64) Syntex() int
- func (v *Counter64) ToString() string
- func (v *Counter64) Uint() uint64
- func (v *Counter64) Unmarshal(b []byte) (rest []byte, err error)
- type EndOfMibView
- func (v *EndOfMibView) Bytes() []byte
- func (v *EndOfMibView) ErrorMessage() string
- func (v *EndOfMibView) IsError() bool
- func (v *EndOfMibView) Marshal() ([]byte, error)
- func (v *EndOfMibView) MarshalJSON() ([]byte, error)
- func (v *EndOfMibView) String() string
- func (v *EndOfMibView) Syntex() int
- func (v *EndOfMibView) Unmarshal(b []byte) (rest []byte, err error)
- type ErrorStatus
- type Gauge32
- type Integer
- func (v *Integer) Bytes() []byte
- func (v *Integer) ErrorMessage() string
- func (v *Integer) Int() int64
- func (v *Integer) IsError() bool
- func (v *Integer) Marshal() ([]byte, error)
- func (v *Integer) MarshalJSON() ([]byte, error)
- func (v *Integer) String() string
- func (v *Integer) Syntex() int
- func (v *Integer) ToString() string
- func (v *Integer) Uint() uint64
- func (v *Integer) Unmarshal(b []byte) (rest []byte, err error)
- type Ipaddress
- func (v *Ipaddress) Int() int64
- func (v *Ipaddress) Marshal() ([]byte, error)
- func (v *Ipaddress) MarshalJSON() ([]byte, error)
- func (v *Ipaddress) String() string
- func (v *Ipaddress) Syntex() int
- func (v *Ipaddress) ToString() string
- func (v *Ipaddress) Uint() uint64
- func (v *Ipaddress) Unmarshal(b []byte) (rest []byte, err error)
- type Item
- type Iterator
- func (iter Iterator) Equal(iter2 Iterator) bool
- func (iter Iterator) Item() interface{}
- func (iter Iterator) Limit() bool
- func (iter Iterator) Max() bool
- func (iter Iterator) Min() bool
- func (iter Iterator) NegativeLimit() bool
- func (iter Iterator) Next() Iterator
- func (iter Iterator) Prev() Iterator
- type Message
- type MessageProcessing
- type MessageV1
- func (msg *MessageV1) Marshal() (b []byte, err error)
- func (msg *MessageV1) PDU() PDU
- func (msg *MessageV1) PduBytes() []byte
- func (msg *MessageV1) SetPDU(pdu PDU)
- func (msg *MessageV1) SetPduBytes(b []byte)
- func (msg *MessageV1) String() string
- func (msg *MessageV1) Unmarshal(b []byte) (rest []byte, err error)
- func (msg *MessageV1) Version() SnmpVersion
- type MessageV3
- func (h *MessageV3) Authentication() bool
- func (msg *MessageV3) Marshal() (b []byte, err error)
- func (h *MessageV3) Privacy() bool
- func (h *MessageV3) Reportable() bool
- func (h *MessageV3) SetAuthentication(b bool)
- func (h *MessageV3) SetPrivacy(b bool)
- func (h *MessageV3) SetReportable(b bool)
- func (msg *MessageV3) String() string
- func (msg *MessageV3) Unmarshal(b []byte) (rest []byte, err error)
- type NoSucheInstance
- func (v *NoSucheInstance) Bytes() []byte
- func (v *NoSucheInstance) ErrorMessage() string
- func (v *NoSucheInstance) IsError() bool
- func (v *NoSucheInstance) Marshal() ([]byte, error)
- func (v *NoSucheInstance) MarshalJSON() ([]byte, error)
- func (v *NoSucheInstance) String() string
- func (v *NoSucheInstance) Syntex() int
- func (v *NoSucheInstance) Unmarshal(b []byte) (rest []byte, err error)
- type NoSucheObject
- func (v *NoSucheObject) Bytes() []byte
- func (v *NoSucheObject) ErrorMessage() string
- func (v *NoSucheObject) IsError() bool
- func (v *NoSucheObject) Marshal() ([]byte, error)
- func (v *NoSucheObject) MarshalJSON() ([]byte, error)
- func (v *NoSucheObject) String() string
- func (v *NoSucheObject) Syntex() int
- func (v *NoSucheObject) Unmarshal(b []byte) (rest []byte, err error)
- type Null
- func (v *Null) Bytes() []byte
- func (v *Null) ErrorMessage() string
- func (v *Null) Int() int64
- func (v *Null) IsError() bool
- func (v *Null) Marshal() ([]byte, error)
- func (v *Null) MarshalJSON() ([]byte, error)
- func (v *Null) String() string
- func (v *Null) Syntex() int
- func (v *Null) ToString() string
- func (v *Null) Uint() uint64
- func (v *Null) Unmarshal(b []byte) (rest []byte, err error)
- type OctetString
- func (v *OctetString) Bytes() []byte
- func (v *OctetString) ErrorMessage() string
- func (v *OctetString) Int() int64
- func (v *OctetString) IsError() bool
- func (v *OctetString) Marshal() ([]byte, error)
- func (v *OctetString) MarshalJSON() ([]byte, error)
- func (v *OctetString) String() string
- func (v *OctetString) Syntex() int
- func (v *OctetString) ToString() string
- func (v *OctetString) Uint() uint64
- func (v *OctetString) Unmarshal(b []byte) (rest []byte, err error)
- type Oid
- func (v *Oid) AppendSubIds(subs []int) Oid
- func (v *Oid) Bytes() []byte
- func (v *Oid) Compare(o *Oid) int
- func (v *Oid) Contains(o *Oid) bool
- func (v *Oid) Equal(o *Oid) bool
- func (v *Oid) ErrorMessage() string
- func (v *Oid) Int() int64
- func (v *Oid) IsError() bool
- func (v *Oid) Marshal() ([]byte, error)
- func (v *Oid) MarshalJSON() ([]byte, error)
- func (v *Oid) String() string
- func (v *Oid) Syntex() int
- func (v *Oid) ToString() string
- func (v *Oid) Uint() uint64
- func (v *Oid) Unmarshal(b []byte) (rest []byte, err error)
- type OidAndValue
- type Oids
- type Opaque
- type PDU
- type PduType
- type PduV1
- func (pdu *PduV1) AppendVariableBinding(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) VariableBindings() VariableBindings
- type PingResult
- type Pinger
- func (self *Pinger) Close()
- func (self *Pinger) GetChannel() <-chan *PingResult
- func (self *Pinger) Recv(timeout time.Duration) (net.Addr, SnmpVersion, error)
- func (self *Pinger) Send(id int, ra *net.UDPAddr, args *Arguments) error
- func (self *Pinger) SendV2(id int, ra *net.UDPAddr, version SnmpVersion, community string) error
- func (self *Pinger) SendV2With(id int, raddr string, version SnmpVersion, community string) error
- func (self *Pinger) SendV3(id int, raddr, username string) error
- type Pingers
- func (self *Pingers) Close()
- func (self *Pingers) GetChannel() <-chan *PingResult
- func (self *Pingers) Length() int
- func (self *Pingers) Listen(network, laddr string, version SnmpVersion, community string) error
- func (self *Pingers) ListenV3(network, laddr, userName string) error
- func (self *Pingers) Recv(timeout time.Duration) (net.Addr, SnmpVersion, error)
- func (self *Pingers) Send(idx int, raddr string) error
- func (self *Pingers) SendWith(idx int, raddr *net.UDPAddr) error
- type PrivProtocol
- type ResponseError
- 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(VariableBindings VariableBindings) error
- func (s *SNMP) Open() (err error)
- func (s *SNMP) SetRequest(variableBindings VariableBindings) (result PDU, err error)
- func (s *SNMP) String() string
- func (s *SNMP) V1Trap(enterprise Oid, agentAddress Ipaddress, genericTrap int, specificTrap int, ...) error
- func (s *SNMP) V2Trap(VariableBindings VariableBindings) error
- type ScopedPdu
- type Security
- type SecurityLevel
- type SnmpVersion
- type TimeTicks
- type Tree
- func (root *Tree) DeleteWithIterator(iter Iterator)
- func (root *Tree) DeleteWithKey(key Item) bool
- func (root *Tree) FindGE(key Item) Iterator
- func (root *Tree) FindLE(key Item) Iterator
- func (root *Tree) Get(key Item) Item
- func (root *Tree) Insert(item Item) bool
- func (root *Tree) Len() int
- func (root *Tree) Limit() Iterator
- func (root *Tree) Max() Iterator
- func (root *Tree) Min() Iterator
- func (root *Tree) NegativeLimit() Iterator
- type USM
- func (u *USM) CheckTimeliness(engineBoots, engineTime int64) error
- func (u *USM) GenerateRequestMessage(args *Arguments, sendMsg Message) (err error)
- func (u *USM) IsDiscover() bool
- func (u *USM) ProcessIncomingMessage(args *Arguments, recvMsg Message) (err error)
- func (u *USM) String() string
- func (u *USM) SynchronizeEngineBootsTime(engineBoots, engineTime int64)
- func (u *USM) UpdateEngineBootsTime() error
- type UdpServer
- func (self *UdpServer) Close() error
- func (self *UdpServer) GetIntPort() int
- func (self *UdpServer) GetNextValueByOid(mibs *Tree, oid Oid) (*Oid, Variable)
- func (self *UdpServer) GetPort() string
- func (self *UdpServer) GetValueByOid(mibs *Tree, oid Oid) Variable
- func (self *UdpServer) LoadFile(file string) error
- func (self *UdpServer) LoadFileTo(engineID, filename string, isReset bool) error
- func (self *UdpServer) LoadMibsFromString(mibs string) error
- func (self *UdpServer) LoadMibsIntoEngine(engineID string, rd io.Reader, isReset bool) error
- func (self *UdpServer) Pause() error
- func (self *UdpServer) ReloadMibsFromFile(file string) error
- func (self *UdpServer) ReloadMibsFromString(mibs string) error
- func (self *UdpServer) Restart() error
- func (self *UdpServer) Resume() error
- func (self *UdpServer) ReturnErrorIfOidNotExists(status bool) *UdpServer
- func (self *UdpServer) SetCommunity(community string)
- func (self *UdpServer) SetMiss(miss int)
- type Variable
- func NewCounter32FromString(s string) (Variable, error)
- func NewCounter64FromString(s string) (Variable, error)
- func NewGauge32FromString(s string) (Variable, error)
- func NewIPAddressFromString(s string) (Variable, error)
- func NewIntegerFromString(s string) (Variable, error)
- func NewOctetStringFromString(s string) (Variable, error)
- func NewOidFromString(s string) (Variable, error)
- func NewOpaqueFromString(s string) (Variable, error)
- func NewTimeticksFromString(s string) (Variable, error)
- func NewVariable(s string) (Variable, error)
- func ParseHexString(ss []string, is_end bool, vs string) (Variable, []string, error)
- func ParseString(ss []string, is_end bool, vs string) (Variable, []string, error)
- type VariableBinding
- type VariableBindings
Constants ¶
This section is empty.
Variables ¶
var ( OidSysUpTime = MustParseOidFromString("1.3.6.1.2.1.1.3.0") OidSnmpTrap = MustParseOidFromString("1.3.6.1.6.3.1.1.4.1.0") )
var ENDOFMIBVIEW = &EndOfMibView{Null{}}
var NOSUCHEINSTANCE = &NoSucheInstance{Null{}}
var NOSUCHEOBJECT = &NoSucheObject{Null{}}
var TimeoutError = errors.New("time out")
var UnsupportedOperation error = errors.New("Unsupported operation")
Functions ¶
func DecryptAES ¶ added in v1.1.0
func DecryptDES ¶ added in v1.1.0
func EncryptAES ¶ added in v1.1.0
func EncryptDES ¶ added in v1.1.0
func ParseIntsFromString ¶ added in v1.1.0
func PasswordToKey ¶ added in v1.1.0
func PasswordToKey(proto AuthProtocol, password string, engineId []byte) []byte
func SnmpCheckPdu ¶ added in v1.1.0
func StripHexPrefix ¶ added in v1.1.0
func ToOidString ¶ added in v1.1.0
func ToSyntexString ¶ added in v1.1.0
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 Arguments ¶ added in v1.1.0
type Arguments struct { Version SnmpVersion // SNMP version to use 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) AuthKey []byte PrivPassword string // Privacy protocol pass phrase (V3 specific) PrivProtocol PrivProtocol // Privacy protocol (V3 specific) PrivKey []byte SecurityEngineId string // Security engine ID (V3 specific) ContextEngineId string // Context engine ID (V3 specific) ContextName string // Context name (V3 specific) }
An argument for creating a SNMP Object
type AuthProtocol ¶
type AuthProtocol string
const ( Md5 AuthProtocol = "MD5" Sha AuthProtocol = "SHA" )
func ParseAuthProtocol ¶ added in v1.1.0
func ParseAuthProtocol(s string) (AuthProtocol, error)
type CompareFunc ¶ added in v1.1.0
CompareFunc returns 0 if a==b, <0 if a<b, >0 if a>b.
type Counter32 ¶
type Counter32 struct {
Value uint32
}
func NewCounter32 ¶
func (*Counter32) ErrorMessage ¶ added in v1.1.0
func (*Counter32) MarshalJSON ¶ added in v1.1.0
type Counter64 ¶
type Counter64 struct {
Value uint64
}
func NewCounter64 ¶
func (*Counter64) ErrorMessage ¶ added in v1.1.0
func (*Counter64) MarshalJSON ¶ added in v1.1.0
type EndOfMibView ¶
type EndOfMibView struct {
Null
}
func NewEndOfMibView ¶
func NewEndOfMibView() *EndOfMibView
func (*EndOfMibView) Bytes ¶ added in v1.1.0
func (v *EndOfMibView) Bytes() []byte
func (*EndOfMibView) ErrorMessage ¶ added in v1.1.0
func (v *EndOfMibView) ErrorMessage() string
func (*EndOfMibView) IsError ¶ added in v1.1.0
func (v *EndOfMibView) IsError() bool
func (*EndOfMibView) Marshal ¶
func (v *EndOfMibView) Marshal() ([]byte, error)
func (*EndOfMibView) MarshalJSON ¶ added in v1.1.0
func (v *EndOfMibView) MarshalJSON() ([]byte, error)
func (*EndOfMibView) String ¶ added in v1.1.0
func (v *EndOfMibView) String() string
func (*EndOfMibView) Syntex ¶ added in v1.1.0
func (v *EndOfMibView) Syntex() int
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 Gauge32 ¶
type Gauge32 struct {
Counter32
}
func NewGauge32 ¶
func (*Gauge32) MarshalJSON ¶ added in v1.1.0
type Integer ¶
type Integer struct {
Value int
}
func NewInteger ¶
func (*Integer) ErrorMessage ¶ added in v1.1.0
func (*Integer) MarshalJSON ¶ added in v1.1.0
type Ipaddress ¶
type Ipaddress struct {
OctetString
}
func NewIpaddress ¶
func (*Ipaddress) MarshalJSON ¶ added in v1.1.0
type Iterator ¶ added in v1.1.0
type Iterator struct {
// contains filtered or unexported fields
}
Iterator allows scanning tree elements in sort order.
Iterator invalidation rule is the same as C++ std::map<>'s. That is, if you delete the element that an iterator points to, the iterator becomes invalid. For other operation types, the iterator remains valid.
func (Iterator) Item ¶ added in v1.1.0
func (iter Iterator) Item() interface{}
Return the current element.
REQUIRES: !iter.Limit() && !iter.NegativeLimit()
func (Iterator) Limit ¶ added in v1.1.0
Check if the iterator points beyond the max element in the tree
func (Iterator) Max ¶ added in v1.1.0
Check if the iterator points to the maximum element in the tree
func (Iterator) Min ¶ added in v1.1.0
Check if the iterator points to the minimum element in the tree
func (Iterator) NegativeLimit ¶ added in v1.1.0
Check if the iterator points before the minumum element in the tree
type Message ¶ added in v1.1.0
type Message interface { Version() SnmpVersion PDU() PDU PduBytes() []byte SetPduBytes([]byte) Marshal() ([]byte, error) Unmarshal([]byte) ([]byte, error) String() string }
snmp messsage v1 or v2
+----------------------------------+ | version | community | pdu | +----------------------------------+
|<------------ ScopedPdu ---------->| +--------------------------------------------------------------------------------------------------------+
snmpv3 message | version | RequestID | MaxSize | Flag | security | Security | context | context | PDU |
| | | | | Model | parameters | engineId | name | | +--------------------------------------------------------------------------------------------------------+ +-----------------------------------+
ScopedPdu | context | context | PDU |
| engineId | name | | +-----------------------------------+
func NewMessage ¶ added in v1.1.0
func NewMessage(ver SnmpVersion, pdu PDU) (msg Message)
type MessageProcessing ¶ added in v1.1.0
type MessageProcessing interface { Security() Security PrepareOutgoingMessage(*SNMP, PDU) (Message, error) PrepareDataElements(*SNMP, Message, []byte) (PDU, error) }
func NewMessageProcessing ¶ added in v1.1.0
func NewMessageProcessing(ver SnmpVersion) (mp MessageProcessing)
type MessageV1 ¶ added in v1.1.0
type MessageV1 struct { Community []byte // contains filtered or unexported fields }
func (*MessageV1) SetPduBytes ¶ added in v1.1.0
func (*MessageV1) Version ¶ added in v1.1.0
func (msg *MessageV1) Version() SnmpVersion
type MessageV3 ¶ added in v1.1.0
type MessageV3 struct { MessageV1 // contains filtered or unexported fields }
|<------------ ScopedPdu ---------->| +--------------------------------------------------------------------------------------------------------+
snmpv3 message | version | RequestID | MaxSize | Flag | security | Security | context | context | PDU |
| | | | | Model | parameters | engineId | name | | +--------------------------------------------------------------------------------------------------------+ +-----------------------------------+
ScopedPdu | context | context | PDU |
| engineId | name | | +-----------------------------------+ SNMPv3 Packet Format ------------------------- /|\ | msgVersion | | |-----------------------| | | msgID | | |-----------------------| USM Security Parameters | | msgMaxSize | | |-----------------------| /------------------------------- | | msgFlags | / | msgAuthoritativeEngineID | scope of |-----------------------| / |-----------------------------|
authentication | msgSecurityModel | / | msgAuthoritativeEngineBoots |
| |-----------------------|/ |-----------------------------| | | | | msgAuthoritativeEngineTime | | | msgSecurityParameters | |-----------------------------| | | | | msgUserName | | |-----------------------|\ |-----------------------------| | /|\ | | \ | msgAuthenticationParameters | | | | | \ |-----------------------------| | | | | \ | msgPrivacyParameters | | scope of | scopedPDU | \------------------------------- | encryption | | | | | | | | | | | | | | \|/ \|/ | | -------------------------
func (*MessageV3) Authentication ¶ added in v1.1.0
func (h *MessageV3) Authentication() bool
func (*MessageV3) Reportable ¶ added in v1.1.0
func (h *MessageV3) Reportable() bool
func (*MessageV3) SetAuthentication ¶ added in v1.1.0
func (h *MessageV3) SetAuthentication(b bool)
func (*MessageV3) SetPrivacy ¶ added in v1.1.0
func (h *MessageV3) SetPrivacy(b bool)
func (*MessageV3) SetReportable ¶ added in v1.1.0
func (h *MessageV3) SetReportable(b bool)
type NoSucheInstance ¶
type NoSucheInstance struct {
Null
}
func NewNoSucheInstance ¶
func NewNoSucheInstance() *NoSucheInstance
func (*NoSucheInstance) Bytes ¶ added in v1.1.0
func (v *NoSucheInstance) Bytes() []byte
func (*NoSucheInstance) ErrorMessage ¶ added in v1.1.0
func (v *NoSucheInstance) ErrorMessage() string
func (*NoSucheInstance) IsError ¶ added in v1.1.0
func (v *NoSucheInstance) IsError() bool
func (*NoSucheInstance) Marshal ¶
func (v *NoSucheInstance) Marshal() ([]byte, error)
func (*NoSucheInstance) MarshalJSON ¶ added in v1.1.0
func (v *NoSucheInstance) MarshalJSON() ([]byte, error)
func (*NoSucheInstance) String ¶ added in v1.1.0
func (v *NoSucheInstance) String() string
func (*NoSucheInstance) Syntex ¶ added in v1.1.0
func (v *NoSucheInstance) Syntex() int
type NoSucheObject ¶
type NoSucheObject struct {
Null
}
func NewNoSucheObject ¶
func NewNoSucheObject() *NoSucheObject
func (*NoSucheObject) Bytes ¶ added in v1.1.0
func (v *NoSucheObject) Bytes() []byte
func (*NoSucheObject) ErrorMessage ¶ added in v1.1.0
func (v *NoSucheObject) ErrorMessage() string
func (*NoSucheObject) IsError ¶ added in v1.1.0
func (v *NoSucheObject) IsError() bool
func (*NoSucheObject) Marshal ¶
func (v *NoSucheObject) Marshal() ([]byte, error)
func (*NoSucheObject) MarshalJSON ¶ added in v1.1.0
func (v *NoSucheObject) MarshalJSON() ([]byte, error)
func (*NoSucheObject) String ¶ added in v1.1.0
func (v *NoSucheObject) String() string
func (*NoSucheObject) Syntex ¶ added in v1.1.0
func (v *NoSucheObject) Syntex() int
type Null ¶
type Null struct{}
func (*Null) ErrorMessage ¶ added in v1.1.0
func (*Null) MarshalJSON ¶ added in v1.1.0
type OctetString ¶
type OctetString struct {
Value []byte
}
func NewOctetString ¶
func NewOctetString(b []byte) *OctetString
func (*OctetString) Bytes ¶ added in v1.1.0
func (v *OctetString) Bytes() []byte
func (*OctetString) ErrorMessage ¶ added in v1.1.0
func (v *OctetString) ErrorMessage() string
func (*OctetString) Int ¶ added in v1.1.0
func (v *OctetString) Int() int64
func (*OctetString) IsError ¶ added in v1.1.0
func (v *OctetString) IsError() bool
func (*OctetString) Marshal ¶
func (v *OctetString) Marshal() ([]byte, error)
func (*OctetString) MarshalJSON ¶ added in v1.1.0
func (v *OctetString) MarshalJSON() ([]byte, error)
func (*OctetString) String ¶
func (v *OctetString) String() string
func (*OctetString) Syntex ¶ added in v1.1.0
func (v *OctetString) Syntex() int
func (*OctetString) ToString ¶ added in v1.1.0
func (v *OctetString) ToString() string
func (*OctetString) Uint ¶ added in v1.1.0
func (v *OctetString) Uint() uint64
type Oid ¶
type Oid struct {
Value []int
}
var EmptyOID Oid
func ConcatOidString ¶ added in v1.1.0
func MustParseOidFromString ¶ added in v1.1.0
MustNewOid is like NewOid but panics if argument cannot be parsed
func ParseOidFromString ¶ added in v1.1.0
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
func (*Oid) ErrorMessage ¶ added in v1.1.0
func (*Oid) MarshalJSON ¶ added in v1.1.0
type OidAndValue ¶ added in v1.1.0
type PDU ¶ added in v1.1.0
type PDU interface { PduType() PduType RequestId() int SetRequestId(int) ErrorStatus() ErrorStatus SetErrorStatus(ErrorStatus) ErrorIndex() int SetErrorIndex(int) SetNonrepeaters(int) SetMaxRepetitions(int) AppendVariableBinding(Oid, Variable) VariableBindings() VariableBindings Marshal() ([]byte, error) Unmarshal([]byte) (rest []byte, err error) String() string }
The protocol data unit of SNMP The PduV1 is used by SNMP V1 and V2c, other than the SNMP V1 Trap
trap pdu +------------+--------------+------------+----------------+---------------+-------------+---------------------+ | PDU Type | enterprise | agent addr | generic trap | specific trap | time stamp | variable bindings | +------------+--------------+------------+----------------+---------------+-------------+---------------------+
reponse pdu +------------+--------------+----------------+---------------+----------------------+ | PDU Type | request id | error status | error index | variable bindings | +------------+--------------+----------------+---------------+----------------------+
request pdu +------------+--------------+----------------+---------------+----------------------+ | PDU Type | request id | 0 | 0 | variable bindings | +------------+--------------+----------------+---------------+----------------------+
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, VariableBindings VariableBindings) (pdu PDU)
type PduV1 ¶
type PduV1 struct { Enterprise Oid AgentAddress Ipaddress GenericTrap int SpecificTrap int Timestamp int // contains filtered or unexported fields }
The PduV1 is used by SNMP V1 and V2c, other than the SNMP V1 Trap
func (*PduV1) AppendVariableBinding ¶ added in v1.1.0
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 ¶
func (*PduV1) VariableBindings ¶ added in v1.1.0
func (pdu *PduV1) VariableBindings() VariableBindings
type PingResult ¶ added in v1.1.0
type Pinger ¶ added in v1.1.0
type Pinger struct {
// contains filtered or unexported fields
}
func (*Pinger) GetChannel ¶ added in v1.1.0
func (self *Pinger) GetChannel() <-chan *PingResult
func (*Pinger) SendV2With ¶ added in v1.1.0
type Pingers ¶ added in v1.1.0
type Pingers struct {
// contains filtered or unexported fields
}
func NewPingers ¶ added in v1.1.0
func (*Pingers) GetChannel ¶ added in v1.1.0
func (self *Pingers) GetChannel() <-chan *PingResult
func (*Pingers) Listen ¶ added in v1.1.0
func (self *Pingers) Listen(network, laddr string, version SnmpVersion, community string) error
type PrivProtocol ¶
type PrivProtocol string
const ( Des PrivProtocol = "DES" Aes PrivProtocol = "AES" )
func ParsePrivProtocol ¶ added in v1.1.0
func ParsePrivProtocol(s string) (PrivProtocol, error)
type ResponseError ¶
type ResponseError struct { Cause error // Cause of the error Message string // Error message Detail string // Detail of the error for debugging }
A ResponseError suggests that the response from the remote agent is wrong or is not obtained
func (ResponseError) Error ¶
func (e ResponseError) Error() string
type SNMP ¶
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 VariableBinding list of all subtrees. however, if the ErrorStatus of PDU is not the NoError, return only the last query result.
func (*SNMP) InformRequest ¶
func (s *SNMP) InformRequest(VariableBindings VariableBindings) error
func (*SNMP) SetRequest ¶ added in v1.1.0
func (s *SNMP) SetRequest(variableBindings VariableBindings) (result PDU, err error)
func (*SNMP) V2Trap ¶
func (s *SNMP) V2Trap(VariableBindings VariableBindings) error
type ScopedPdu ¶
The ScopedPdu is used by SNMP V3. Includes the PduV1, and contains a SNMP context parameter
type Security ¶ added in v1.1.0
type Security interface { GenerateRequestMessage(*Arguments, Message) error ProcessIncomingMessage(*Arguments, Message) error //Discover(*Arguments) error String() string }
func NewCommunity ¶ added in v1.1.0
func NewCommunity() Security
type SecurityLevel ¶
type SecurityLevel int
const ( NoAuthNoPriv SecurityLevel = iota AuthNoPriv AuthPriv )
func ParseSecurityLevel ¶ added in v1.1.0
func ParseSecurityLevel(s string) (SecurityLevel, error)
func (SecurityLevel) String ¶
func (s SecurityLevel) String() string
type SnmpVersion ¶ added in v1.1.0
type SnmpVersion int
const ( V1 SnmpVersion = 0 V2c SnmpVersion = 1 V3 SnmpVersion = 3 )
func ParseVersion ¶ added in v1.1.0
func ParseVersion(v string) (SnmpVersion, error)
func (SnmpVersion) String ¶ added in v1.1.0
func (s SnmpVersion) String() string
func (SnmpVersion) ToString ¶ added in v1.1.0
func (s SnmpVersion) ToString() string
type TimeTicks ¶
type TimeTicks struct {
Counter32
}
func NewTimeTicks ¶
func (*TimeTicks) MarshalJSON ¶ added in v1.1.0
type Tree ¶ added in v1.1.0
type Tree struct {
// contains filtered or unexported fields
}
func NewMibTree ¶ added in v1.1.0
func NewMibTree() *Tree
func (*Tree) DeleteWithIterator ¶ added in v1.1.0
Delete the current item.
REQUIRES: !iter.Limit() && !iter.NegativeLimit()
func (*Tree) DeleteWithKey ¶ added in v1.1.0
Delete an item with the given key. Return true iff the item was found.
func (*Tree) FindGE ¶ added in v1.1.0
Find the smallest element N such that N >= key, and return the iterator pointing to the element. If no such element is found, return root.Limit().
func (*Tree) FindLE ¶ added in v1.1.0
Find the largest element N such that N <= key, and return the iterator pointing to the element. If no such element is found, return iter.NegativeLimit().
func (*Tree) Get ¶ added in v1.1.0
A convenience function for finding an element equal to key. Return nil if not found.
func (*Tree) Insert ¶ added in v1.1.0
Insert an item. If the item is already in the tree, do nothing and return false. Else return true.
func (*Tree) Limit ¶ added in v1.1.0
Create an iterator that points beyond the maximum item in the tree
func (*Tree) Max ¶ added in v1.1.0
Create an iterator that points at the maximum item in the tree
If the tree is empty, return NegativeLimit()
func (*Tree) Min ¶ added in v1.1.0
Create an iterator that points to the minimum item in the tree If the tree is empty, return Limit()
func (*Tree) NegativeLimit ¶ added in v1.1.0
Create an iterator that points before the minimum item in the tree
type USM ¶ added in v1.1.0
type USM struct { //DiscoveryStatus DiscoveryStatus AuthEngineId []byte AuthEngineBoots int64 AuthEngineTime int64 // AuthKey []byte // PrivKey []byte UpdatedTime time.Time }
func (*USM) CheckTimeliness ¶ added in v1.1.0
func (*USM) GenerateRequestMessage ¶ added in v1.1.0
func (*USM) IsDiscover ¶ added in v1.1.0
func (*USM) ProcessIncomingMessage ¶ added in v1.1.0
func (*USM) SynchronizeEngineBootsTime ¶ added in v1.1.0
func (*USM) UpdateEngineBootsTime ¶ added in v1.1.0
type UdpServer ¶ added in v1.1.0
type UdpServer struct {
// contains filtered or unexported fields
}
******************************************
It is for test.
func NewUdpServerFromFile ¶ added in v1.1.0
func NewUdpServerFromString ¶ added in v1.1.0
func (*UdpServer) GetIntPort ¶ added in v1.2.0
func (*UdpServer) GetNextValueByOid ¶ added in v1.1.0
func (*UdpServer) GetValueByOid ¶ added in v1.1.0
func (*UdpServer) LoadFileTo ¶ added in v1.1.0
func (*UdpServer) LoadMibsFromString ¶ added in v1.1.0
func (*UdpServer) LoadMibsIntoEngine ¶ added in v1.1.0
func (*UdpServer) ReloadMibsFromFile ¶ added in v1.1.0
func (*UdpServer) ReloadMibsFromString ¶ added in v1.1.0
func (*UdpServer) ReturnErrorIfOidNotExists ¶ added in v1.1.0
func (*UdpServer) SetCommunity ¶ added in v1.1.0
type Variable ¶
type Variable interface { Int() int64 Uint() uint64 Bytes() []byte // Return a string representation of this Variable ToString() string String() string IsError() bool ErrorMessage() string // Return a string of type Syntex() int Marshal() ([]byte, error) Unmarshal([]byte) (rest []byte, err error) }
func NewCounter32FromString ¶ added in v1.1.0
func NewCounter64FromString ¶ added in v1.1.0
func NewGauge32FromString ¶ added in v1.1.0
func NewIPAddressFromString ¶ added in v1.1.0
func NewIntegerFromString ¶ added in v1.1.0
func NewOctetStringFromString ¶ added in v1.1.0
func NewOidFromString ¶ added in v1.1.0
func NewOpaqueFromString ¶ added in v1.1.0
func NewTimeticksFromString ¶ added in v1.1.0
func NewVariable ¶ added in v1.1.0
func ParseHexString ¶ added in v1.1.0
type VariableBinding ¶ added in v1.1.0
func NewVarBind ¶
func NewVarBind(oid Oid, val Variable) VariableBinding
func (*VariableBinding) Marshal ¶ added in v1.1.0
func (v *VariableBinding) Marshal() (b []byte, err error)
func (*VariableBinding) String ¶ added in v1.1.0
func (v *VariableBinding) String() string
type VariableBindings ¶ added in v1.1.0
type VariableBindings []VariableBinding
func (VariableBindings) MatchBaseOids ¶ added in v1.1.0
func (v VariableBindings) MatchBaseOids(prefix Oid) VariableBindings
Gets a VariableBinding list that matches the prefix
func (VariableBindings) MatchOid ¶ added in v1.1.0
func (v VariableBindings) MatchOid(oid Oid) *VariableBinding
Gets a VariableBinding that matches
func (VariableBindings) Sort ¶ added in v1.1.0
func (v VariableBindings) Sort() VariableBindings
Sort a VariableBinding list by OID
func (VariableBindings) String ¶ added in v1.1.0
func (v VariableBindings) String() string
func (VariableBindings) Uniq ¶ added in v1.1.0
func (v VariableBindings) Uniq() VariableBindings
Filter out adjacent VariableBinding list