snmp

package
v0.0.0-...-a9fffeb Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2015 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package snmp provides an implementation of the SNMP specification.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get(host, community string, nameval ...interface{}) error

Get retrieves an object by its name. Nameval is a pair of: object name (string), and the corresponding target value (pointer to int, string, etc.). To retrieve multiple objects in a single transaction, provide multiple name, value pairs.

Types

type Binding

type Binding struct {
	Name  asn1.ObjectIdentifier
	Value asn1.RawValue
}

Binding represents an assignment to a variable, a.k.a. managed object.

type Request

type Request struct {
	ID             int32
	Type           string // "Get", "GetNext", "GetBulk"
	Bindings       []Binding
	NonRepeaters   int
	MaxRepetitions int
}

A Request represents an SNMP request to be sent over a Transport.

type Response

type Response struct {
	ID          int32
	ErrorStatus int
	ErrorIndex  int
	Bindings    []Binding
}

Response represents the response from an SNMP request.

type RoundTripper

type RoundTripper interface {
	RoundTrip(*Request) (*Response, error)
}

RoundTripper is an interface representing the ability to execute a single SNMP transaction, obtaining the Response for a given Request.

A RoundTripper must be safe for concurrent use by multiple goroutines.

type Rows

type Rows struct {
	Transport RoundTripper
	// contains filtered or unexported fields
}

Rows is the result of a walk. Its cursor starts before the first row of the result set. Use Next to advance through the rows:

rows, err := snmp.Walk(host, community, "ifName")
...
for rows.Next() {
    var name []byte
    err = rows.Scan(&name)
    ...
}
err = rows.Err() // get any error encountered during iteration
...

func Walk

func Walk(host, community string, oids ...string) (*Rows, error)

Walk executes a query against host authenticated by the community string, retrieving the MIB sub-tree defined by the the given root oids.

func (*Rows) Err

func (rows *Rows) Err() error

Err returns the error, if any, that was encountered during iteration.

func (*Rows) Next

func (rows *Rows) Next() bool

Next prepares the next result row for reading with the Scan method. It returns true on success, false if there is no next result row. Every call to Scan, even the first one, must be preceded by a call to Next.

func (*Rows) Scan

func (rows *Rows) Scan(v ...interface{}) (id interface{}, err error)

Scan copies the columns in the current row into the values pointed at by v. On success, the id return variable will hold the row id of the current row. It is typically an integer or a string.

type Transport

type Transport struct {
	Conn      net.Conn
	Community string
}

Transport is an implementation of RoundTripper that supports SNMPv2 as defined by RFC 3416.

func (*Transport) RoundTrip

func (tr *Transport) RoundTrip(req *Request) (*Response, error)

RoundTrip implements the RoundTripper interface.

Directories

Path Synopsis
Package mib parses modules of the virtual management information store.
Package mib parses modules of the virtual management information store.

Jump to

Keyboard shortcuts

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