gosnmp

package module
v0.0.0-...-46752f3 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2013 License: MIT Imports: 12 Imported by: 0

README

gosnmp

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SYS_DESCR_OID     = []uint32{1, 3, 5, 1, 2, 1, 1, 1}
	SYS_OBJECT_ID_OID = []uint32{1, 3, 5, 1, 2, 1, 1, 2}
	SYS_UPTIME_OID    = []uint32{1, 3, 5, 1, 2, 1, 1, 3}
	SYS_CONTACT_OID   = []uint32{1, 3, 5, 1, 2, 1, 1, 4}
	SYS_NAME_OID      = []uint32{1, 3, 5, 1, 2, 1, 1, 5}
	SYS_LOCATION_OID  = []uint32{1, 3, 5, 1, 2, 1, 1, 6}
)

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) *Agent

func NewAgentWithPort

func NewAgentWithPort(name string, maxTargets int, port int, logger Logger) *Agent

func (*Agent) GetStat

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

func (*Agent) GetStatsBin

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

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() *CommunityRequest

func (*ClientContext) AllocateV2cGetRequest

func (ctxt *ClientContext) AllocateV2cGetRequest() *CommunityRequest

func (*ClientContext) AllocateV2cGetRequestWithOids

func (ctxt *ClientContext) AllocateV2cGetRequestWithOids(oids []ObjectIdentifier) *CommunityRequest

func (*ClientContext) AllocateV2cSetRequest

func (ctxt *ClientContext) AllocateV2cSetRequest() *CommunityRequest

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) (*SnmpStatsBin, 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) Shutdown

func (ctxt *ClientContext) Shutdown()

type CommunityRequest

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

func (*CommunityRequest) AddOid

func (req *CommunityRequest) AddOid(oid ObjectIdentifier)

func (*CommunityRequest) AddOids

func (req *CommunityRequest) AddOids(oids []ObjectIdentifier)

func (*CommunityRequest) GetError

func (req *CommunityRequest) GetError() (err error)

func (*CommunityRequest) GetFlightTime

func (req *CommunityRequest) GetFlightTime() time.Duration

func (*CommunityRequest) GetLoggingId

func (msg *CommunityRequest) GetLoggingId() string

func (*CommunityRequest) GetRequestType

func (req *CommunityRequest) GetRequestType() (requestType pduType)

func (*CommunityRequest) GetResponse

func (req *CommunityRequest) GetResponse() (resp SnmpResponse)

type CommunityResponse

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

func (*CommunityResponse) GetLoggingId

func (msg *CommunityResponse) GetLoggingId() string

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

func (oid ObjectIdentifier) Equal(other ObjectIdentifier) bool

Equal returns true iff oi and other represent the same identifier.

type ObjectIdentifierVarbind

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

type OctectString

type OctectString []byte

type OctetStringVarbind

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

func NewOctetStringVarbind

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

type OpaqueVarbind

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

func NewOpaqueVarbind

func NewOpaqueVarbind(oid ObjectIdentifier) *OpaqueVarbind

type SnmpMessage

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

type SnmpRequest

type SnmpRequest interface {
	SnmpMessage
	AddOid(oid ObjectIdentifier)
	AddOids(oids []ObjectIdentifier)
	GetFlightTime() time.Duration
	// contains filtered or unexported methods
}

type SnmpResponse

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

type SnmpStatsBin

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

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_RECEIVED
	StatType_RESPONSES_RECEIVED_AFTER_REQUEST_TIMED_OUT
	StatType_REQUESTS_SENT
	StatType_REQUESTS_FORWARDED_TO_FLOW_CONTROL
	StatType_REQUESTS_TIMED_OUT_AFTER_RESPONSE_PROCESSED
	StatType_REQUESTS_TIMED_OUT
	StatType_REQUESTS_RETRIES_EXHAUSTED
	StatType_UNDECODABLE_MESSAGES_RECEIVED
	StatType_GET_REQUESTS_RECEIVED
	StatType_GET_BULK_REQUESTS_RECEIVED
	StatType_SET_REQUESTS_RECEIVED
	StatType_GET_RESPONSES_RECEIVED
)

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 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) (*SnmpStatsBin, error)

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 V2cMessage

type V2cMessage interface {
}

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