Documentation ¶
Index ¶
- Constants
- Variables
- type Agent
- func (ctxt *Agent) GetStat(statType StatType, bin uint8) (int, error)
- func (ctxt *Agent) GetStatsBin(bin uint8) (*StatsBin, error)
- func (agent *Agent) RegisterSingleVarOidHandler(oid ObjectIdentifier, handler SingleVarOidHandler) error
- func (ctxt *Agent) SetDecodeErrorLogging(enabled bool)
- func (ctxt *Agent) Shutdown()
- type BitString
- type BitStringVarbind
- type ClientContext
- func (ctxt *ClientContext) AllocateV2cGetNextRequest() V2cGetRequest
- func (ctxt *ClientContext) AllocateV2cGetRequest() V2cGetRequest
- func (ctxt *ClientContext) AllocateV2cGetRequestWithOids(oids []ObjectIdentifier) V2cGetRequest
- func (ctxt *ClientContext) AllocateV2cSetRequest() V2cSetRequest
- func (ctxt *ClientContext) FreeV2cRequest(req CommunityRequest)
- func (ctxt *ClientContext) GetStat(statType StatType, bin uint8) (int, error)
- func (ctxt *ClientContext) GetStatsBin(bin uint8) (*StatsBin, error)
- func (ctxt *ClientContext) NewV2cClient(community string, address string) (*V2cClient, error)
- func (ctxt *ClientContext) NewV2cClientWithPort(community string, address string, port int) (*V2cClient, error)
- func (ctxt *ClientContext) SetDecodeErrorLogging(enabled bool)
- func (ctxt *ClientContext) Shutdown()
- type CommunityRequest
- type Counter32Varbind
- type Counter64Varbind
- type EndOfMibViewVarbind
- type Gauge32Varbind
- type IPv4AddressVarbind
- type IntegerVarbind
- type InvalidStateError
- type Logger
- type NoSuchInstanceVarbind
- type NoSuchObjectVarbind
- type NsapAddressVarbind
- type NullVarbind
- type ObjectIdentifier
- type ObjectIdentifierVarbind
- type OctectString
- type OctetStringVarbind
- type OpaqueVarbind
- type RequestProcessor
- type SingleVarOidHandler
- type SnmpMessage
- type SnmpRequest
- type SnmpRequestErrorType
- type SnmpResponse
- type SnmpVersion
- type StatType
- type StatsBin
- type TimeTicksVarbind
- type TimeoutError
- type TransactionProvider
- type TrapReceiver
- type Uint32Varbind
- type V1Trap
- type V2cClient
- type V2cGetRequest
- type V2cMessage
- type V2cSetRequest
- type Varbind
Constants ¶
const ( SnmpRequestErrorType_NO_ERROR SnmpRequestErrorType = 0 SnmpRequestErrorType_TOO_BIG = 1 SnmpRequestErrorType_NO_SUCH_NAME = 2 SnmpRequestErrorType_BAD_VALUE = 3 SnmpRequestErrorType_READ_ONLY = 4 SnmpRequestErrorType_GENERIC_ERROR = 5 SnmpRequestErrorType_NO_ACCESS = 6 SnmpRequestErrorType_WRONG_TYPE = 7 SnmpRequestErrorType_WRONG_LENGTH = 8 SnmpRequestErrorType_WRONG_ENCODING = 9 SnmpRequestErrorType_WRONG_VALUE = 10 SnmpRequestErrorType_NO_CREATION = 11 SnmpRequestErrorType_INCONSISTENT_VALUE = 12 SnmpRequestErrorType_RESOURCE_UNAVAILABLE = 13 SnmpRequestErrorType_COMMIT_FAILED = 14 SnmpRequestErrorType_UNDO_FAILED = 15 SnmpRequestErrorType_AUTHORIZATION_ERROR = 16 SnmpRequestErrorType_NOT_WRITABLE = 17 SnmpRequestErrorType_INCONSISTENT_NAME = 18 SnmpRequestErrorType_MAX = 18 )
Variables ¶
var ( SYS_DESCR_OID = ObjectIdentifier{1, 3, 6, 1, 2, 1, 1, 1, 0} SYS_OBJECT_ID_OID = ObjectIdentifier{1, 3, 6, 1, 2, 1, 1, 2, 0} SYS_UPTIME_OID = ObjectIdentifier{1, 3, 6, 1, 2, 1, 1, 3, 0} SYS_CONTACT_OID = ObjectIdentifier{1, 3, 6, 1, 2, 1, 1, 4, 0} SYS_NAME_OID = ObjectIdentifier{1, 3, 6, 1, 2, 1, 1, 5, 0} SYS_LOCATION_OID = ObjectIdentifier{1, 3, 6, 1, 2, 1, 1, 6, 0} )
A bunch of commonly used MIB-2 oids.
Functions ¶
This section is empty.
Types ¶
type Agent ¶
type Agent struct {
// contains filtered or unexported fields
}
func NewAgent ¶
func NewAgent(name string, maxTargets int, logger Logger, txnProvider TransactionProvider) *Agent
func NewAgentWithPort ¶
func (*Agent) GetStatsBin ¶
func (*Agent) RegisterSingleVarOidHandler ¶
func (agent *Agent) RegisterSingleVarOidHandler(oid ObjectIdentifier, handler SingleVarOidHandler) error
func (*Agent) SetDecodeErrorLogging ¶
func (ctxt *Agent) SetDecodeErrorLogging(enabled bool)
type BitString ¶
type BitString struct {
// contains filtered or unexported fields
}
BitString is the structure to use when you want an ASN.1 BIT STRING type. A bit string is padded up to the nearest byte in memory and the number of valid bits is recorded. Padding bits will be zero
func NewBitString ¶
type BitStringVarbind ¶
type BitStringVarbind struct {
// contains filtered or unexported fields
}
BitStringVarbind is the structure to use when you want an ASN.1 BIT STRING type. A bit string is padded up to the nearest byte in memory and the number of valid bits is recorded. Padding bits will be zero
func NewBitStringVarbind ¶
func NewBitStringVarbind(oid ObjectIdentifier, val *BitString) *BitStringVarbind
func (*BitStringVarbind) GetOid ¶
func (vb *BitStringVarbind) GetOid() ObjectIdentifier
type ClientContext ¶
type ClientContext struct {
// contains filtered or unexported fields
}
func NewClientContext ¶
func NewClientContext(name string, maxTargets int, logger Logger) *ClientContext
func (*ClientContext) AllocateV2cGetNextRequest ¶
func (ctxt *ClientContext) AllocateV2cGetNextRequest() V2cGetRequest
func (*ClientContext) AllocateV2cGetRequest ¶
func (ctxt *ClientContext) AllocateV2cGetRequest() V2cGetRequest
func (*ClientContext) AllocateV2cGetRequestWithOids ¶
func (ctxt *ClientContext) AllocateV2cGetRequestWithOids(oids []ObjectIdentifier) V2cGetRequest
func (*ClientContext) AllocateV2cSetRequest ¶
func (ctxt *ClientContext) AllocateV2cSetRequest() V2cSetRequest
func (*ClientContext) FreeV2cRequest ¶
func (ctxt *ClientContext) FreeV2cRequest(req CommunityRequest)
func (*ClientContext) GetStatsBin ¶
func (*ClientContext) NewV2cClient ¶
func (ctxt *ClientContext) NewV2cClient(community string, address string) (*V2cClient, error)
NewV2cClient creates a new v2c client, using the default snmp port (161). It is equivalent to calling NewV2cClientWithPort(community, address, 161)
func (*ClientContext) NewV2cClientWithPort ¶
func (ctxt *ClientContext) NewV2cClientWithPort(community string, address string, port int) (*V2cClient, error)
NewV2cClientWithPort creates a new v2c client, with the initial community, host address and port as specified. It uses default TimeoutSeconds and Retries values of 10 and 2, meaning that by default, requests sent through this client will be sent 3 times, with 10 seconds in between sends, for an overall timeout of 30 seconds. This client is only intended to be used by a single goroutine, and as such, all calls to SendRequest() when a request is already in flight will cause the the calling goroutine to be blocked until all preceding calls to SendRequest return.
func (*ClientContext) SetDecodeErrorLogging ¶
func (ctxt *ClientContext) SetDecodeErrorLogging(enabled bool)
type CommunityRequest ¶
type CommunityRequest interface { SnmpRequest // contains filtered or unexported methods }
type Counter32Varbind ¶
type Counter32Varbind struct { Value uint32 // contains filtered or unexported fields }
func NewCounter32Varbind ¶
func NewCounter32Varbind(oid ObjectIdentifier) *Counter32Varbind
func (*Counter32Varbind) GetOid ¶
func (vb *Counter32Varbind) GetOid() ObjectIdentifier
type Counter64Varbind ¶
type Counter64Varbind struct { Value uint64 // contains filtered or unexported fields }
func NewCounter64Varbind ¶
func NewCounter64Varbind(oid ObjectIdentifier) *Counter64Varbind
func (*Counter64Varbind) GetOid ¶
func (vb *Counter64Varbind) GetOid() ObjectIdentifier
type EndOfMibViewVarbind ¶
type EndOfMibViewVarbind struct {
// contains filtered or unexported fields
}
func NewEndOfMibViewVarbind ¶
func NewEndOfMibViewVarbind(oid ObjectIdentifier) *EndOfMibViewVarbind
func (*EndOfMibViewVarbind) GetOid ¶
func (vb *EndOfMibViewVarbind) GetOid() ObjectIdentifier
type Gauge32Varbind ¶
type Gauge32Varbind struct { Value uint32 // contains filtered or unexported fields }
func NewGauge32Varbind ¶
func NewGauge32Varbind(oid ObjectIdentifier) *Gauge32Varbind
func (*Gauge32Varbind) GetOid ¶
func (vb *Gauge32Varbind) GetOid() ObjectIdentifier
type IPv4AddressVarbind ¶
func NewIPv4AddressVarbind ¶
func NewIPv4AddressVarbind(oid ObjectIdentifier, val net.IP) *IPv4AddressVarbind
func (*IPv4AddressVarbind) GetOid ¶
func (vb *IPv4AddressVarbind) GetOid() ObjectIdentifier
type IntegerVarbind ¶
type IntegerVarbind struct { Value int32 // contains filtered or unexported fields }
IntegerVarbind stuff
func NewIntegerVarbind ¶
func NewIntegerVarbind(oid ObjectIdentifier, val int32) *IntegerVarbind
func (*IntegerVarbind) GetOid ¶
func (vb *IntegerVarbind) GetOid() ObjectIdentifier
type InvalidStateError ¶
type InvalidStateError struct {
// contains filtered or unexported fields
}
func (InvalidStateError) Error ¶
func (e InvalidStateError) Error() string
type Logger ¶
type Logger interface { // Tracef formats message according to format specifier // and writes to log with level = Trace. Tracef(format string, params ...interface{}) // Debugf formats message according to format specifier // and writes to log with level = Debug. Debugf(format string, params ...interface{}) // Infof formats message according to format specifier // and writes to log with level = Info. Infof(format string, params ...interface{}) // Warnf formats message according to format specifier // and writes to log with level = Warn. Warnf(format string, params ...interface{}) error // Errorf formats message according to format specifier // and writes to log with level = Error. Errorf(format string, params ...interface{}) error // Criticalf formats message according to format specifier // and writes to log with level = Critical. Criticalf(format string, params ...interface{}) error // Trace formats message using the default formats for its operands // and writes to log with level = Trace Trace(v ...interface{}) // Debug formats message using the default formats for its operands // and writes to log with level = Debug Debug(v ...interface{}) // Info formats message using the default formats for its operands // and writes to log with level = Info Info(v ...interface{}) // Warn formats message using the default formats for its operands // and writes to log with level = Warn Warn(v ...interface{}) error // Error formats message using the default formats for its operands // and writes to log with level = Error Error(v ...interface{}) error // Critical formats message using the default formats for its operands // and writes to log with level = Critical Critical(v ...interface{}) error }
LoggerInterface is the interface that snmp-go expects to be able to use to produce debug logging. It matches exactly with the interface presented by SeeLog (github.com/cihub/seelog), but should be very simple to adapt to pretty much any reasonable logging infrastructure.
type NoSuchInstanceVarbind ¶
type NoSuchInstanceVarbind struct {
// contains filtered or unexported fields
}
func NewNoSuchInstanceVarbindVarbind ¶
func NewNoSuchInstanceVarbindVarbind(oid ObjectIdentifier) *NoSuchInstanceVarbind
func (*NoSuchInstanceVarbind) GetOid ¶
func (vb *NoSuchInstanceVarbind) GetOid() ObjectIdentifier
type NoSuchObjectVarbind ¶
type NoSuchObjectVarbind struct {
// contains filtered or unexported fields
}
func NewNoSuchObjectVarbind ¶
func NewNoSuchObjectVarbind(oid ObjectIdentifier) *NoSuchObjectVarbind
func (*NoSuchObjectVarbind) GetOid ¶
func (vb *NoSuchObjectVarbind) GetOid() ObjectIdentifier
type NsapAddressVarbind ¶
type NsapAddressVarbind struct { Value [6]byte // contains filtered or unexported fields }
func NewNsapAddressVarbind ¶
func NewNsapAddressVarbind(oid ObjectIdentifier) *NsapAddressVarbind
func (*NsapAddressVarbind) GetOid ¶
func (vb *NsapAddressVarbind) GetOid() ObjectIdentifier
type NullVarbind ¶
type NullVarbind struct {
// contains filtered or unexported fields
}
func NewNullVarbind ¶
func NewNullVarbind(oid ObjectIdentifier) *NullVarbind
func (*NullVarbind) GetOid ¶
func (vb *NullVarbind) GetOid() ObjectIdentifier
type ObjectIdentifier ¶
type ObjectIdentifier []uint32
An ObjectIdentifier represents an ASN.1 OBJECT IDENTIFIER.
func (ObjectIdentifier) Compare ¶
func (a ObjectIdentifier) Compare(b ObjectIdentifier) int
Compare returns -1 if a comes before b in the oid tree, 0 if a and b represent exactly the same node in the oid tree and 1 if a comes after b in the oid tree.
func (ObjectIdentifier) Equal ¶
func (a ObjectIdentifier) Equal(b ObjectIdentifier) bool
Equal returns true iff a and b represent the same identifier.
func (ObjectIdentifier) MatchLength ¶
func (a ObjectIdentifier) MatchLength(b ObjectIdentifier) int
type ObjectIdentifierVarbind ¶
type ObjectIdentifierVarbind struct { Value ObjectIdentifier // contains filtered or unexported fields }
func NewObjectIdentifierVarbind ¶
func NewObjectIdentifierVarbind(oid ObjectIdentifier, val ObjectIdentifier) *ObjectIdentifierVarbind
func (*ObjectIdentifierVarbind) GetOid ¶
func (vb *ObjectIdentifierVarbind) GetOid() ObjectIdentifier
type OctectString ¶
type OctectString []byte
type OctetStringVarbind ¶
type OctetStringVarbind struct { Value []byte // contains filtered or unexported fields }
func NewOctetStringVarbind ¶
func NewOctetStringVarbind(oid ObjectIdentifier, val []byte) *OctetStringVarbind
func NewStringVarbind ¶
func NewStringVarbind(oid ObjectIdentifier, val string) *OctetStringVarbind
func (*OctetStringVarbind) GetOid ¶
func (vb *OctetStringVarbind) GetOid() ObjectIdentifier
type OpaqueVarbind ¶
type OpaqueVarbind struct { Value []byte // contains filtered or unexported fields }
func NewOpaqueVarbind ¶
func NewOpaqueVarbind(oid ObjectIdentifier) *OpaqueVarbind
func (*OpaqueVarbind) GetOid ¶
func (vb *OpaqueVarbind) GetOid() ObjectIdentifier
type RequestProcessor ¶
type RequestProcessor interface {
// contains filtered or unexported methods
}
type SingleVarOidHandler ¶
type SingleVarOidHandler interface {
// contains filtered or unexported methods
}
type SnmpMessage ¶
type SnmpRequest ¶
type SnmpRequest interface { SnmpMessage FlightTime() time.Duration TransportError() error Response() SnmpResponse AddVarbind(Varbind) // contains filtered or unexported methods }
type SnmpRequestErrorType ¶
type SnmpRequestErrorType int32
type SnmpResponse ¶
type SnmpResponse interface { SnmpMessage Varbinds() []Varbind ErrorVal() SnmpRequestErrorType // contains filtered or unexported methods }
type SnmpVersion ¶
type SnmpVersion int
const ( Version1 SnmpVersion = 0x00 Version2c = 0x01 )
func (SnmpVersion) String ¶
func (version SnmpVersion) String() string
type StatType ¶
type StatType int
const ( StatType_INBOUND_CONNECTION_DEATH StatType = iota StatType_INBOUND_CONNECTION_CLOSE StatType_OUTBOUND_CONNECTION_DEATH StatType_OUTBOUND_CONNECTION_CLOSE StatType_INBOUND_MESSAGES_RECEIVED StatType_INBOUND_MESSAGES_UNDECODABLE StatType_OUTBOUND_MESSAGES_SENT StatType_RESPONSES_RELEASED_TO_CLIENT StatType_RESPONSES_DROPPED_BY_REQUEST_TRACKER StatType_REQUESTS_SENT StatType_REQUESTS_FORWARDED_TO_FLOW_CONTROL StatType_UNKNOWN_REQUESTS_TIMED_OUT StatType_REQUESTS_TIMED_OUT StatType_REQUEST_RETRIES_EXHAUSTED StatType_GET_REQUESTS_RECEIVED StatType_GET_NEXT_REQUESTS_RECEIVED StatType_GET_BULK_REQUESTS_RECEIVED StatType_SET_REQUESTS_RECEIVED StatType_RESPONSES_RECEIVED StatType_V1_TRAPS_RECEIVED StatType_V2_TRAPS_RECEIVED StatType_COMMUNITY_REQUEST_RECEIVED_WITH_NO_REQUEST_PROCESSOR )
type TimeTicksVarbind ¶
type TimeTicksVarbind struct { Value uint32 // contains filtered or unexported fields }
func NewTimeTicksVarbind ¶
func NewTimeTicksVarbind(oid ObjectIdentifier) *TimeTicksVarbind
func (*TimeTicksVarbind) GetOid ¶
func (vb *TimeTicksVarbind) GetOid() ObjectIdentifier
type TimeoutError ¶
type TimeoutError struct { }
func (TimeoutError) Error ¶
func (t TimeoutError) Error() string
type TransactionProvider ¶
type TransactionProvider interface { // StartTxn creates a new transaction and returns an opaque reference to it. If a transaction can't // be started, a nil value will be returned. StartTxn() interface{} // CommitTxn commits the given transaction. If the transaction can't be committed for any reason, it will be // aborted and CommitTxn will return false. Otherwise, CommitTxn will return true. CommitTxn(interface{}) bool // AbortTxn aborts the given transaction, performing any rollback required. AbortTxn(interface{}) }
type TrapReceiver ¶
type TrapReceiver struct {
// contains filtered or unexported fields
}
func NewTrapReceiver ¶
func NewTrapReceiver(name string, queueDepth int, port int, logger Logger) *TrapReceiver
func (*TrapReceiver) GetStatsBin ¶
func (*TrapReceiver) SetDecodeErrorLogging ¶
func (ctxt *TrapReceiver) SetDecodeErrorLogging(enabled bool)
type Uint32Varbind ¶
type Uint32Varbind struct {
// contains filtered or unexported fields
}
func NewUint32Varbind ¶
func NewUint32Varbind(oid ObjectIdentifier) *Uint32Varbind
func (*Uint32Varbind) GetOid ¶
func (vb *Uint32Varbind) GetOid() ObjectIdentifier
type V2cClient ¶
type V2cClient struct { Address *net.UDPAddr TimeoutSeconds int Retries int Community string // contains filtered or unexported fields }
func (*V2cClient) SendRequest ¶
func (client *V2cClient) SendRequest(req CommunityRequest)
SendRequest sends one request to the host associated with this client and waits for a response or a timeout. The values currently set on this client for TimeoutSeconds and Retries will be used to control the request. On return, the request will either have a response attached, or it's error field will be filled in.
type V2cGetRequest ¶
type V2cGetRequest interface { CommunityRequest AddOid(ObjectIdentifier) AddOids([]ObjectIdentifier) }
type V2cMessage ¶
type V2cMessage interface { }
type V2cSetRequest ¶
type V2cSetRequest interface { CommunityRequest }
type Varbind ¶
type Varbind interface { GetOid() ObjectIdentifier // contains filtered or unexported methods }