Documentation ¶
Index ¶
- Constants
- Variables
- func CommandString(t Command) string
- func Dumper(conn net.PacketConn) error
- func TypeString(t Type) string
- type Client
- func (c *Client) Call(addr net.Addr, p *PDU) (_ *PDU, err error)
- func (c *Client) Close() error
- func (c *Client) Read(buf []byte, p *PDU) (net.Addr, *PDU, error)
- func (c *Client) Run()
- func (c *Client) Send(addr net.Addr, p *PDU) error
- func (c *Client) Walk(addr net.Addr, root asn1.OID, args ...interface{}) (*PDU, error)
- type Command
- type PDU
- type Packet
- type Telemetry
- type Type
- type Var
- type Version
Constants ¶
View Source
const ( NoError = iota TooBigError NoSuchNameError BadValueError ReadOnlyError GeneralError )
Variables ¶
Functions ¶
func Dumper ¶
func Dumper(conn net.PacketConn) error
Types ¶
type Client ¶
type Client struct { Receive chan<- Packet ReadTimeout time.Duration Retries int Version Version Community string NonRepeaters int MaxRepetitions int // contains filtered or unexported fields }
func NewClient ¶
func NewClient(conn net.PacketConn) *Client
NewClient creates SNMP client with default options
func (*Client) Call ¶
Call sends Protocol Data Unit to address and waits for response for c.ReadTimeout
func (*Client) Run ¶
func (c *Client) Run()
Run does background tasks reqiured for work. It's blocked until Client Closed
func (*Client) Walk ¶
Walk scans addr for variables with prefix root. It retries on fail and downgrade protocol version if no answer. Additional arguments are supported:
*PDU - use that pdu instead of default Version - set protocol version Command - set command *Telemetry - collect telemetry of requests
type Command ¶
type Command = Type
const ( Get Command = asn1.Context | asn1.Constructor | 0x00 GetNext Command = asn1.Context | asn1.Constructor | 0x01 Response Command = asn1.Context | asn1.Constructor | 0x02 Set Command = asn1.Context | asn1.Constructor | 0x03 Trap Command = asn1.Context | asn1.Constructor | 0x04 GetBulk Command = asn1.Context | asn1.Constructor | 0x05 )
type PDU ¶
type PDU struct { Version Version Community string Command Command ReqID int32 NonRepeaters, MaxRepetitions int ErrorStatus, ErrorIndex int Vars []Var }
type Type ¶
const ( Boolean Type = asn1.Universal | 0x1 Integer Type = asn1.Universal | 0x2 BitString Type = asn1.Universal | 0x3 OctetString Type = asn1.Universal | 0x4 Null Type = asn1.Universal | 0x5 ObjectID Type = asn1.Universal | 0x6 Sequence Type = asn1.Universal | 0x10 TypeSet Type = asn1.Universal | 0x11 IPAddress Type = asn1.Application | 0x0 Counter Type = asn1.Application | 0x1 Gauge Type = asn1.Application | 0x2 Timeticks Type = asn1.Application | 0x3 Opaque Type = asn1.Application | 0x4 Counter64 Type = asn1.Application | 0x6 Float Type = asn1.Application | 0x8 Double Type = asn1.Application | 0x9 Integer64 Type = asn1.Application | 0x10 Unsigned64 Type = asn1.Application | 0x11 NoSuchObject Type = asn1.Context | asn1.Primitive | 0x0 NoSuchInstance Type = asn1.Context | asn1.Primitive | 0x1 EndOfMIBView Type = asn1.Context | asn1.Primitive | 0x2 )
Click to show internal directories.
Click to hide internal directories.