plugins

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(name string, f InitFormatter, p InitParser) error

Register registers a formatter and parser with the given plugin name. It returns an error if a formatter or parser with the same name has already been registered.

Types

type Config

type Config struct {
	DevName        string
	PlugName       string
	CustomLabel    string
	DescSanitize   string
	UseGoDefaults  bool
	CacheData      bool
	ScrapeInterval time.Duration
}

type Formatter

type Formatter interface {
	Describe() []exporter.GMetric
	Collect() []exporter.GMetric
	GetPaths() FormatterPaths
	ScrapeEvent(ys ygot.GoStruct) func()
}

Formatter is an interface that defines the methods required from a formatter object. A formatter object is responsible for building metrics pulling values from the chosen yGot GoStruct.

type FormatterPaths

type FormatterPaths struct {
	XPaths     []string
	Datamodels []string
}

FormatterPaths represents the paths to be subscribed by the client on behalf of the formatter needs.

type InitFormatter

type InitFormatter func(cfg Config) (Formatter, error)

InitFormatter is a function type that takes a `Config` object as input and returns a `Formatter` and an error. It is used to initialize and register formatters.

type InitParser

type InitParser func(cfg Config) (Parser, error)

InitParser is a function type that takes a `Config` object as input and returns a `Parser` and an error. It is used to initialize and register parsers.

type Parser

type Parser interface {
	Describe() []exporter.GMetric
	Collect() []exporter.GMetric
	CheckOut() ygot.GoStruct
	ParseNotification(nf *gnmi.Notification)
	ClearCache()
}

Parser represents an interface that defines the methods required from a parser object. A parser object is responsible for loading the received GNMI data into the chosen yGot GoStruct.

type ParserMon

type ParserMon struct {
	Cfg Config
	// contains filtered or unexported fields
}

func (*ParserMon) Collect

func (p *ParserMon) Collect() []exporter.GMetric

Collect implements the plugin's parser interface. It uses reflection to iterate over the pmCounters struct and creates a new GMetric for each counter.

func (*ParserMon) Configure

func (p *ParserMon) Configure(cfg Config) error

Configure takes a Config struct and assigns it to the Cfg field of the ParserMon struct.

func (*ParserMon) ContainerNotFound

func (p *ParserMon) ContainerNotFound()

func (*ParserMon) DeleteNotFound

func (p *ParserMon) DeleteNotFound()

func (*ParserMon) Describe

func (p *ParserMon) Describe() []exporter.GMetric

Describe implements the plugin's parser interface. It returns an GMetric to describe the metric itself.

func (*ParserMon) InvalidPath

func (p *ParserMon) InvalidPath()

func (*ParserMon) LeafNotFound

func (p *ParserMon) LeafNotFound()

func (*ParserMon) UpdateDuplicates

func (p *ParserMon) UpdateDuplicates(dups uint64)

UpdateDuplicates takes an uint64 parameter representing the value of the duplicates field of the update.

type Plugin

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

Plugin represents a plugin that collects metrics using a formatter and parser.

func New

func New(cfg Config) (*Plugin, error)

func (*Plugin) GetDataModels

func (p *Plugin) GetDataModels() []string

GetDataModels returns the list of data models associated with the plugin's formatter xPaths.

func (*Plugin) GetMetrics

func (p *Plugin) GetMetrics(ch chan<- exporter.GMetric)

GetMetrics implements the exporter GMetricSource interface It is called by the exporter, and it sends the output of the formatter object.

func (*Plugin) GetPathsToSubscribe

func (p *Plugin) GetPathsToSubscribe() []string

GetPathsToSubscribe retrieves the list of XPaths that the plugin should subscribe to for data collection.

func (*Plugin) GetPlugName

func (p *Plugin) GetPlugName() string

GetPlugName retrieves the name of the plugin from its configuration.

func (*Plugin) Notification

func (p *Plugin) Notification(nf *gnmi.Notification)

Notification sends the received GNMI notification to the parser, if cache mode is enabled. If Passthrough mode is engaged, notifications are temporarily stored into a buffer. The buffer content is then sent to the parser when a scrape event occurs.

func (*Plugin) OnSync

func (p *Plugin) OnSync(status bool)

OnSync sets the synchronization status of the plugin. If the previous synchronization status is true and the new status is false, it clears the cache in the parser and the uBuffer

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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