snmpquery

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2019 License: MIT Imports: 9 Imported by: 0

README

snmpquery

Wrapper around gosnmp and gosmi to make SNMP queries easier

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetIndexKey

func GetIndexKey(indexParts types.Oid) string

Types

type Client

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

Client is a snmpquery client

func NewV1

func NewV1(target, community string) (*Client, error)

NewV1 creates a new SNMPv1 Client

func NewV2

func NewV2(target, community string) (*Client, error)

NewV2 creates a new SNMPv2c Client

func NewV3

func NewV3(target, username, authPassword, privPassword string) (*Client, error)

NewV3 creates a mew SNMPv3 Client

func (Client) Close

func (c Client) Close() error

Close is used to close the connection to the target

func (Client) Connect

func (c Client) Connect() (err error)

Connect is used to open a connection to the target

func (*Client) Debug

func (c *Client) Debug(debug bool)

func (Client) Get

func (c Client) Get(node models.ScalarNode, format ...models.Format) (val models.Value, err error)

Get is used to get the given scalar node formatted with the given format

func (Client) GetAll

func (c Client) GetAll(q Query) (results map[string]models.Value, err error)

GetAll executes the given query

func (Client) GetIndex

func (c Client) GetIndex(node models.ColumnNode, index types.Oid, format ...models.Format) (val models.Value, err error)

Get is used to get the given column node with the given index formatted with the given format

func (*Client) SetCommunity

func (c *Client) SetCommunity(community string)

func (*Client) SetReusePort

func (c *Client) SetReusePort(reusePort bool)

func (*Client) SetSecurity

func (c *Client) SetSecurity(username, authPassword, privPassword string) error

func (*Client) SetTarget

func (c *Client) SetTarget(target string) error

func (*Client) SetTimeout

func (c *Client) SetTimeout(d time.Duration)

func (Client) Table

func (c Client) Table(table Table, index ...interface{}) (results map[string]Row, err error)

Table queries the client for the given table at the given index

type Column

type Column struct {
	Name   string
	Node   models.ColumnNode
	Format models.Format
}

Column represents a table column

func (Column) FormatValue

func (c Column) FormatValue(value interface{}) models.Value

type Query

type Query struct {
	DefaultFormat models.Format
	Items         []QueryItem
}

Query contains the items to query

func (*Query) Column

func (q *Query) Column(node models.ColumnNode, index types.Oid, format ...models.Format)

Column is a helper method to add an implicitly named column to the query

func (*Query) NamedColumn

func (q *Query) NamedColumn(name string, node models.ColumnNode, index types.Oid, format ...models.Format)

NamedColumn is a helper method to add an explicitly named column to the query

func (*Query) NamedScalar

func (q *Query) NamedScalar(name string, node models.ScalarNode, format ...models.Format)

NamedScalar is a helper method to add an explicitly named scalar to the query

func (*Query) Scalar

func (q *Query) Scalar(node models.ScalarNode, format ...models.Format)

Scalar is a helper method to add an implicitly named scalar to the query

type QueryItem

type QueryItem struct {
	Format models.ValueFormatter
	Name   string
	Oid    types.Oid
}

QueryItem contains the information for a single query item

type Row

type Row struct {
	Index  []models.Value
	Values map[string]models.Value
}

Row represents a table row

type Table

type Table struct {
	IndexFormat  models.Format
	ColumnFormat models.Format
	Node         models.TableNode
	// contains filtered or unexported fields
}

func NewTable

func NewTable(node models.TableNode, indexFormat ...models.Format) Table

func (*Table) Column

func (t *Table) Column(node models.ColumnNode, format ...models.Format)

func (*Table) Columns

func (t *Table) Columns() []Column

func (*Table) NamedColumn

func (t *Table) NamedColumn(name string, node models.ColumnNode, format ...models.Format)

Jump to

Keyboard shortcuts

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