snmp

package
v0.0.0-...-c7f582f Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2016 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package snmp provides an implementation of the SNMP specification.

Index

Constants

This section is empty.

Variables

View Source
var Timeout = 30

Timeout is the number of seconds to use for conn.SetReadDeadline

Functions

func Get

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

Get is a wrapper for SNMP.Get.

Types

type Rows

type Rows struct {
	// 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 is a wrapper for SNMP.Walk.

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 SNMP

type SNMP struct {
	// Community is the SNMP community.
	Community string
	// Addr is the UDP address of the SNMP host.
	Addr *net.UDPAddr
}

SNMP performs SNMPv2 requests as defined by RFC 3416.

func New

func New(host, community string) (*SNMP, error)

New creates a new SNMP which connects to host with specified community.

func (*SNMP) Get

func (s *SNMP) Get(nameval ...interface{}) error

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

func (*SNMP) Walk

func (s *SNMP) Walk(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.

Directories

Path Synopsis
Package asn1 implements parsing of DER-encoded ASN.1 data structures, as defined in ITU-T Rec X.690.
Package asn1 implements parsing of DER-encoded ASN.1 data structures, as defined in ITU-T Rec X.690.
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