v2

package
v0.0.0-...-a0c03a0 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2021 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HandlerRestarted = "handler_restarted"
)

Variables

This section is empty.

Functions

func InitCounters

func InitCounters(namespace string, log *logger.Logger) (map[string]*prometheus.Counter, map[string]*prometheus.CounterVec)

Create counters..

Types

type Alerter

type Alerter struct {
	Log            *logger.Logger
	Configs        *of_snmp.V2Config
	Receipts       *of.Receipts
	Value          *Value
	MR             of.MIBRegistry
	U              of.UUIDGen
	Cntr           map[string]*prometheus.Counter
	CntrVec        map[string]*prometheus.CounterVec
	LogUnknown     bool
	ForwardUnknown bool
}

Implements of_snmp.AlertGenerator

func (*Alerter) Alert

func (a *Alerter) Alert(cfgNames []string) []of.Alert

Iterate through configs in configNames and generate all possible Alerts.

func (*Alerter) AutoClear

func (a *Alerter) AutoClear(defEndsAt int, alertEndsAt int, alert *of.Alert)

func (*Alerter) EndsAt

func (a *Alerter) EndsAt(alert *of.Alert)

func (*Alerter) Fingerprint

func (a *Alerter) Fingerprint(al of.Alert) string

Fingerprint the alert.

func (*Alerter) StartsAt

func (a *Alerter) StartsAt(alert *of.Alert)

func (*Alerter) Unknown

func (a *Alerter) Unknown(level string) []of.Alert

Create alert for unknown SNMP trap.

type Handler

type Handler struct {
	Config *of.SNMPConfig

	SNMP *Service
	Log  *logger.Logger
	// contains filtered or unexported fields
}

func (*Handler) Run

func (h *Handler) Run()

func (*Handler) Shutdown

func (h *Handler) Shutdown() error

type Lookup

type Lookup struct {
	Configs of_snmp.V2Config // Concatenate list of configs
	MR      of.MIBRegistry
	Log     *logger.Logger
	// contains filtered or unexported fields
}

func (*Lookup) Build

func (l *Lookup) Build() error

Build lookup to match with SNMP Trap var

Ex: Sample config.
epc:                          - key in configs
  select:
  - type: equals
    oid: .1.3.6.1.6.3.1.1.4.1  - key in lookupMap
    as: value                  - key in asMap
    values:
    - .1.3.6.1.4.1.8164.2.13   - key in valueMap
    - .1.3.6.1.4.1.8164.2.4    - key in valueMap
  - type: equals
    oid: .1.3.6.1.6.3.1.1.4.1  - key in lookupMap
    as: valueStr               - key in asMap
    values:
    - name_of_oid              - keys in valueMap
nso:                          - key in configs
  - type: equals
    oid: .1.3.6.1.6.3.1.1.4.1  - key in lookupMap
    as: value                  - key in asMap
    values:
    - .1.3.6.1.4.1.8164.2.13   - key in valueMap

The lookup for above example config would be :

'.1.3.6.1.6.3.1.1.4.1' ->
		'value' ->
  		'.1.3.6.1.4.1.8164.2.13' ->
  			"epc" -> bool // bool value is irrelevant.
  			"nso" -> bool // bool value is irrelevant.
  		'.1.3.6.1.4.1.8164.2.4' ->
  			"epc" -> bool // bool value is irrelevant.
		'valueStr' ->
  		'name_of_oid' ->
  			"epc" -> bool // bool value is irrelevant.

func (*Lookup) Find

func (l *Lookup) Find(vars *[]of.TrapVar) ([]string, error)

Lookup configs that are applicable for given oid.

type Modifier

type Modifier struct {
	Map *map[string]string // Pointer to map to be modified
	V   *Value             // Gets value for given oid, based on the `of_snmp.As` type
}

func (*Modifier) Apply

func (m *Modifier) Apply(mods []of_snmp.Mod) error

Apply given mods to Map.

func (*Modifier) Copy

func (m *Modifier) Copy(mod of_snmp.Mod) error

Copy given mod to Map.

func (*Modifier) Set

func (m *Modifier) Set(mod of_snmp.Mod) error

Set given mod to Map.

type Service

type Service struct {
	Writer     of.Writer
	Log        *logger.Logger
	Configs    *of_snmp.V2Config
	MR         of.MIBRegistry
	U          of.UUIDGen
	Lookup     of_snmp.Lookup
	As         of.Notifier
	Cntr       map[string]*prometheus.Counter
	CntrVec    map[string]*prometheus.CounterVec
	SNMPConfig *of.SNMPConfig
}

func NewService

func NewService(l *logger.Logger, cfg *of.SNMPConfig, cntr map[string]*prometheus.Counter, cntrVec map[string]*prometheus.CounterVec) (*Service, error)

func (Service) AlertHandler

func (s Service) AlertHandler(w of.ResponseWriter, r of.Request)

HTTP handler func to recieve SNMP traps.

type Value

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

Implements of_snmp.ValueGenerator

func NewValue

func NewValue(trapVars *[]of.TrapVar, mr of.MIBRegistry) *Value

Initialize Value. trapVars are converted into a map[oid]value

func (*Value) OIDValue

func (v *Value) OIDValue(ptr string) (string, error)

Literal value for OID pointed by given OID,

func (*Value) OIDValueStr

func (v *Value) OIDValueStr(ptr string) (string, error)

String representation of the value, for OID pointed by given OID.

func (*Value) OIDValueStrShort

func (v *Value) OIDValueStrShort(ptr string) (string, error)

Short Name of the value, for OID pointed by given OID.

func (*Value) Value

func (v *Value) Value(oid string) (string, error)

Literal value for given OID.

func (*Value) ValueAs

func (v *Value) ValueAs(oid string, as of_snmp.As) (string, error)

Compute value as `As` for given OID.

func (*Value) ValueStr

func (v *Value) ValueStr(oid string) (string, error)

String representation of the value, for given OID.

func (*Value) ValueStrShort

func (v *Value) ValueStrShort(oid string) (string, error)

Short Name of the value, for given OID.

Jump to

Keyboard shortcuts

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