Index | Files | Directories

package snmp

import ""

Package snmp provides an implementation of the SNMP specification.


Package Files

get.go snmp.go walk.go


var Timeout = 30

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

func Get Uses

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

Get is a wrapper for SNMP.Get.

type Rows Uses

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 Uses

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

Walk is a wrapper for SNMP.Walk.

func (*Rows) Err Uses

func (rows *Rows) Err() error

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

func (*Rows) Next Uses

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 Uses

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 Uses

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 Uses

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

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

func (*SNMP) Get Uses

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 Uses

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.


asn1Package asn1 implements parsing of DER-encoded ASN.1 data structures, as defined in ITU-T Rec X.690.
mibPackage mib parses modules of the virtual management information store.

Package snmp imports 7 packages (graph) and is imported by 3 packages. Updated 2020-02-03. Refresh now. Tools for package owners.