mibs

package
v0.0.0-...-5607193 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2021 License: GPL-3.0 Imports: 9 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMibExists = errors.New("MIB already registered")
	ErrNilMib    = errors.New("MIB cannot be nil")
)

Errors for SNMP base plugin MIB operations.

Functions

func Clear

func Clear()

Clear removes all data from the global MIB collection.

Generally, this should not be used by a plugin implementation, however it is useful for testing.

func Register

func Register(mibs ...*MIB) error

Register MIBs defined by a plugin implementation with the SNMP base plugin.

If a MIB with the same name is already registered, an error is returned.

Types

type MIB

type MIB struct {
	Name    string
	RootOid string
	Devices []*SnmpDevice
}

MIB is a logical grouping of SnmpDevices which a SNMP plugin implementation should define. A single plugin implementation may define multiple MIBs. These MIBs are registered with the SNMP base plugin.

func Get

func Get(name string) *MIB

Get a registered MIB with the given name.

If there is no MIB registered with the provided name, nil is returned.

func GetAll

func GetAll() []*MIB

GetAll returns all of the MIBs which have been registered with the SNMP base plugin. The order in which the MIBs are returned is not guaranteed. If no MIBs have been registered, an empty slice is returned.

func NewMIB

func NewMIB(name string, rootOid string, devices ...*SnmpDevice) *MIB

NewMIB creates a new MIB with the specified devices.

func (*MIB) LoadDevices

func (mib *MIB) LoadDevices(cfg *core.SnmpTargetConfiguration, supported map[string]struct{}) ([]*sdk.Device, error)

LoadDevices loads Synse devices from the SNMP devices defined in the MIB.

func (*MIB) String

func (mib *MIB) String() string

String returns a human-readable string, useful for identifying the MIB in logs.

type SnmpDevice

type SnmpDevice struct {
	// Required fields
	OID     string
	Info    string
	Type    string
	Handler string
	Output  string

	// Optional fields
	Tags         []*sdk.Tag
	Data         map[string]interface{}
	Context      map[string]string
	Alias        string
	Transforms   []sdk.Transformer
	WriteTimeout time.Duration
}

SnmpDevice models a device and serves as the bridge between SNMP configuration and Synse device configuration.

Each SNMP plugin implementation which uses the plugin base should define these devices in the code base. A collection of SnmpDevices makes up a MIB. These devices are used to generate Synse devices on plugin init.

func (*SnmpDevice) String

func (device *SnmpDevice) String() string

String returns a human-readable string, useful for identifying the device in logs.

func (*SnmpDevice) ToDevice

func (device *SnmpDevice) ToDevice() (*sdk.Device, error)

ToDevice converts the plugin-specific SnmpDevice to a Synse SDK Device.

Jump to

Keyboard shortcuts

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