snmp

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2023 License: GPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureValidOid added in v1.3.0

func EnsureValidOid(oid string) (string, error)

Test an OID, but prefix a missing dot

Useful to be compatible with the base implementation of SNMP, where it is optional.

func GetSubOid

func GetSubOid(oid string, baseOid string) string

func IsOid

func IsOid(oid string) bool

func IsOidPartOf

func IsOidPartOf(oid string, baseOid string) bool

IsOidPartOf tests if an OID is equal of below another OID

func IsValidOid added in v1.3.0

func IsValidOid(oid string) error

Test if an OID is in a valid format like `.1.23.456`

func ParseWalkLine added in v1.3.0

func ParseWalkLine(line string) (pdu *gosnmp.SnmpPDU, err error)

nolint: funlen

func SortOIDs

func SortOIDs(list []string) []string

func VersionFromString added in v1.3.0

func VersionFromString(version string) (v gosnmp.SnmpVersion, err error)

Types

type FileHandler added in v1.3.0

type FileHandler struct {
	Data WalkData

	gosnmp.Handler
}

Provides a GoSNMP like data interface, but with data from a snmpwalk output

Anyone can generate an output by running:

snmpwalk -c public -v2c -On HOST .1.3.6.1 >snmp-data.txt

Warning: This does not implement all functions of gosnmp.Handler

func NewFileHandler added in v1.3.0

func NewFileHandler(r io.Reader) (h *FileHandler, err error)

Create a new file handler and initialize it with data from an io.Reader

func NewFileHandlerFromFile added in v1.3.0

func NewFileHandlerFromFile(filePath string) (h *FileHandler, err error)

Create a new file handler and initialize it with data by reading from a file

func (*FileHandler) BulkWalk added in v1.3.0

func (h *FileHandler) BulkWalk(rootOid string, walkFn gosnmp.WalkFunc) error

Not yet implemented

func (*FileHandler) BulkWalkAll added in v1.3.0

func (h *FileHandler) BulkWalkAll(rootOid string) (results []gosnmp.SnmpPDU, err error)

Not yet implemented

func (*FileHandler) Close added in v1.3.0

func (h *FileHandler) Close() error

Simulate Close behavior by returning no error

func (*FileHandler) Connect added in v1.3.0

func (h *FileHandler) Connect() error

Simulate Connect behavior by returning no error

func (*FileHandler) ConnectIPv4 added in v1.3.0

func (h *FileHandler) ConnectIPv4() error

Simulate ConnectIPv4 behavior by returning no error

func (*FileHandler) ConnectIPv6 added in v1.3.0

func (h *FileHandler) ConnectIPv6() error

Simulate ConnectIPv6 behavior by returning no error

func (*FileHandler) Get added in v1.3.0

func (h *FileHandler) Get(oids []string) (result *gosnmp.SnmpPacket, err error)

Simulating Get() behavior by searching read in data

func (*FileHandler) GetBulk added in v1.3.0

func (h *FileHandler) GetBulk(oids []string, nonRepeaters uint8,
	maxRepetitions uint32) (result *gosnmp.SnmpPacket, err error)

Not yet implemented

func (*FileHandler) GetNext added in v1.3.0

func (h *FileHandler) GetNext(oids []string) (result *gosnmp.SnmpPacket, err error)

Not yet implemented

func (*FileHandler) ReadFromWalk added in v1.3.0

func (h *FileHandler) ReadFromWalk(r io.Reader) error

Read data from a io.Reader and parse it for PDUs

They will be stored in Data for later use.

func (*FileHandler) Walk added in v1.3.0

func (h *FileHandler) Walk(rootOid string, walkFn gosnmp.WalkFunc) (err error)

Simulating Walk() behavior by searching read in data

func (*FileHandler) WalkAll added in v1.3.0

func (h *FileHandler) WalkAll(rootOid string) (results []gosnmp.SnmpPDU, err error)

Not yet implemented

type IndexedIds

type IndexedIds map[string]string

type Table

type Table struct {
	Client  gosnmp.Handler
	Oid     string
	Columns IndexedIds
	Values  TableRows
}

func (*Table) GetIntValue

func (t *Table) GetIntValue(id string, oid string) (int, error)

func (*Table) GetSortedOIDs

func (t *Table) GetSortedOIDs() []string

func (*Table) GetStringValue

func (t *Table) GetStringValue(id string, oid string) (string, error)

func (*Table) GetUintValue

func (t *Table) GetUintValue(id string, oid string) (uint, error)

func (*Table) GetValue

func (t *Table) GetValue(id string, oid string) (interface{}, error)

func (*Table) Reset

func (t *Table) Reset()

func (*Table) Walk

func (t *Table) Walk() error

type TableColumns

type TableColumns map[string]gosnmp.SnmpPDU

type TableRows

type TableRows map[string]TableColumns

type WalkData added in v1.3.0

type WalkData map[string]*gosnmp.SnmpPDU

func ReadWalk added in v1.3.0

func ReadWalk(r io.Reader) (pduList WalkData, err error)

Jump to

Keyboard shortcuts

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