gosnmp

package module
v0.0.0-...-cc29366 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 5, 2014 License: MIT Imports: 13 Imported by: 0

README

gosnmp

Documentation

Index

Constants

This section is empty.

Variables

View Source
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 NewAgentWithPort(name string, maxTargets int, port int, logger Logger, txnProvider TransactionProvider) *Agent

func (*Agent) GetStat

func (ctxt *Agent) GetStat(statType StatType, bin uint8) (int, error)

func (*Agent) GetStatsBin

func (ctxt *Agent) GetStatsBin(bin uint8) (*StatsBin, error)

func (*Agent) RegisterSingleVarOidHandler

func (agent *Agent) RegisterSingleVarOidHandler(oid ObjectIdentifier, handler SingleVarOidHandler) error

func (*Agent) SetDecodeErrorLogging

func (ctxt *Agent) SetDecodeErrorLogging(enabled bool)

func (*Agent) Shutdown

func (ctxt *Agent) Shutdown()

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

func NewBitString(numBits int) *BitString

func (*BitString) Clear

func (val *BitString) Clear(bitIdx int) error

func (*BitString) IsSet

func (val *BitString) IsSet(bitIdx int) bool

func (*BitString) Set

func (val *BitString) Set(bitIdx int) error

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

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) GetStat

func (ctxt *ClientContext) GetStat(statType StatType, bin uint8) (int, error)

func (*ClientContext) GetStatsBin

func (ctxt *ClientContext) GetStatsBin(bin uint8) (*StatsBin, error)

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 are fully resolved.

func (*ClientContext) SetDecodeErrorLogging

func (ctxt *ClientContext) SetDecodeErrorLogging(enabled bool)

func (*ClientContext) Shutdown

func (ctxt *ClientContext) Shutdown()

type CommunityRequest

type CommunityRequest interface {
	SnmpRequest
	// contains filtered or unexported methods
}

type Counter32Varbind

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

func NewCounter32Varbind

func NewCounter32Varbind(oid ObjectIdentifier) *Counter32Varbind

type Counter64Varbind

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

func NewCounter64Varbind

func NewCounter64Varbind(oid ObjectIdentifier) *Counter64Varbind

type EndOfMibViewVarbind

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

func NewEndOfMibViewVarbind

func NewEndOfMibViewVarbind(oid ObjectIdentifier) *EndOfMibViewVarbind

type Gauge32Varbind

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

func NewGauge32Varbind

func NewGauge32Varbind(oid ObjectIdentifier) *Gauge32Varbind

type IPv4AddressVarbind

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

func NewIPv4AddressVarbind

func NewIPv4AddressVarbind(oid ObjectIdentifier, val net.IP) *IPv4AddressVarbind

type IntOidHandler

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

IntOidHandler implements a very simple handler serving up a single int32 variable, and allowing non-transaction based updates of that value

func NewIntOidHandler

func NewIntOidHandler(val int32, writable bool) *IntOidHandler

func (*IntOidHandler) Get

func (handler *IntOidHandler) Get(oid ObjectIdentifier) (Varbind, error)

func (*IntOidHandler) Set

func (handler *IntOidHandler) Set(vb_base Varbind) error

func (*IntOidHandler) SetWritable

func (handler *IntOidHandler) SetWritable(writable bool)

func (*IntOidHandler) Writable

func (handler *IntOidHandler) Writable() bool

type IntegerVarbind

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

IntegerVarbind stuff

func NewIntegerVarbind

func NewIntegerVarbind(oid ObjectIdentifier, val int32) *IntegerVarbind

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

type NoSuchObjectVarbind

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

func NewNoSuchObjectVarbind

func NewNoSuchObjectVarbind(oid ObjectIdentifier) *NoSuchObjectVarbind

type NsapAddressVarbind

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

func NewNsapAddressVarbind

func NewNsapAddressVarbind(oid ObjectIdentifier) *NsapAddressVarbind

type NullVarbind

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

func NewNullVarbind

func NewNullVarbind(oid ObjectIdentifier) *NullVarbind

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

Equal returns true iff a and b represent the same identifier.

func (ObjectIdentifier) MatchLength

func (a ObjectIdentifier) MatchLength(b ObjectIdentifier) int

type ObjectIdentifierOidHandler

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

ObjectIdentifierOidHandler implements a very simple handler serving up a single ObjectIdentifer variable, and allowing non- transaction based updates of that value.

func NewObjectIdentifierOidHandler

func NewObjectIdentifierOidHandler(val ObjectIdentifier, writable bool) *ObjectIdentifierOidHandler

func (*ObjectIdentifierOidHandler) Get

func (handler *ObjectIdentifierOidHandler) Get(oid ObjectIdentifier, txn interface{}) (Varbind, error)

func (*ObjectIdentifierOidHandler) Set

func (handler *ObjectIdentifierOidHandler) Set(vb_base Varbind, txn interface{}) (Varbind, error)

func (*ObjectIdentifierOidHandler) SetWritable

func (handler *ObjectIdentifierOidHandler) SetWritable(writable bool)

func (*ObjectIdentifierOidHandler) Writable

func (handler *ObjectIdentifierOidHandler) Writable() bool

type ObjectIdentifierVarbind

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

type OctectString

type OctectString []byte

type OctetStringOidHandler

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

OctetStringOidHandler implements a very simple handler serving up a single []byte variable, and allowing non- transaction based updates of that value. This is also the correct simple handler for a string value

func NewOctetStringOidHandler

func NewOctetStringOidHandler(val []byte, writable bool) *OctetStringOidHandler

func NewStringOidHandler

func NewStringOidHandler(val string, writable bool) *OctetStringOidHandler

func (*OctetStringOidHandler) Get

func (handler *OctetStringOidHandler) Get(oid ObjectIdentifier, txn interface{}) (Varbind, error)

func (*OctetStringOidHandler) Set

func (handler *OctetStringOidHandler) Set(vb_base Varbind, txn interface{}) (Varbind, error)

func (*OctetStringOidHandler) SetWritable

func (handler *OctetStringOidHandler) SetWritable(writable bool)

func (*OctetStringOidHandler) Writable

func (handler *OctetStringOidHandler) Writable() bool

type OctetStringVarbind

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

func NewOctetStringVarbind

func NewOctetStringVarbind(oid ObjectIdentifier, val []byte) *OctetStringVarbind

func NewStringVarbind

func NewStringVarbind(oid ObjectIdentifier, val string) *OctetStringVarbind

type OpaqueVarbind

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

func NewOpaqueVarbind

func NewOpaqueVarbind(oid ObjectIdentifier) *OpaqueVarbind

type RequestProcessor

type RequestProcessor interface {
	// contains filtered or unexported methods
}

type SingleVarOidHandler

type SingleVarOidHandler interface {
	// contains filtered or unexported methods
}

type SnmpMessage

type SnmpMessage interface {
	GetLoggingId() string
	// contains filtered or unexported methods
}

type SnmpRequest

type SnmpRequest interface {
	SnmpMessage
	GetFlightTime() time.Duration

	GetError() error

	GetResponse() SnmpResponse
	// contains filtered or unexported methods
}

type SnmpResponse

type SnmpResponse interface {
	SnmpMessage
	// 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
)

func (StatType) String

func (statType StatType) String() string

type StatsBin

type StatsBin struct {
	Stats      map[StatType]int
	NumSeconds int
}

type TimeTicksVarbind

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

func NewTimeTicksVarbind

func NewTimeTicksVarbind(oid ObjectIdentifier) *TimeTicksVarbind

type TimeoutError

type TimeoutError struct {
}

func (TimeoutError) Error

func (t TimeoutError) Error() string

type TransactionProvider

type TransactionProvider interface {
	// StartTxn should begin a transaction and return an opaque reference to the new transaction. If a transaction can't
	// be started, a nil value should be returned.
	StartTxn() interface{}
	// CommitTxn should commit the given transaction. If the transaction can't be committed for any reason, it should be
	// aborted and CommitTxn should return false. Otherwise, CommitTxn should return true.
	CommitTxn(interface{}) bool
	// AbortTxn should abort 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) GetStat

func (ctxt *TrapReceiver) GetStat(statType StatType, bin uint8) (int, error)

func (*TrapReceiver) GetStatsBin

func (ctxt *TrapReceiver) GetStatsBin(bin uint8) (*StatsBin, error)

func (*TrapReceiver) SetDecodeErrorLogging

func (ctxt *TrapReceiver) SetDecodeErrorLogging(enabled bool)

func (*TrapReceiver) Shutdown

func (ctxt *TrapReceiver) Shutdown()

type Uint32Varbind

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

func NewUint32Varbind

func NewUint32Varbind(oid ObjectIdentifier) *Uint32Varbind

type V1Trap

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

func (*V1Trap) GetLoggingId

func (msg *V1Trap) GetLoggingId() string

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
	AddVarbind(Varbind)
}

type Varbind

type Varbind interface {
	// contains filtered or unexported methods
}

Jump to

Keyboard shortcuts

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