collector

package
v2.0.0-...-27a1933 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: Apache-2.0 Imports: 50 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultRecordsToSave = 60
)
View Source
const (
	HundredMB = 104_857_600
)

Variables

View Source
var Status = [3]string{
	"up",
	"standby",
	"failed",
}

Status defines the possible states of a collector

Functions

func GetBuiltinPlugin

func GetBuiltinPlugin(name string, abc *plugin.AbstractPlugin) plugin.Plugin

GetBuiltinPlugin returns built-in plugin with name if it exists, otherwise nil

func GetOSName

func GetOSName() string

func ImportTemplate

func ImportTemplate(confPaths []string, templateName, collectorName string) (*node.Node, error)

ImportTemplate looks for a collector's template by searching confPaths for the first template that exists in confPath/collectorName/templateName

func Init

func Init(c Collector) error

Init initializes a collector and does the trick of "inheritance", hence a function and not a method. A collector can choose to call this function inside its Init method, or leave it to be called by the poller during dynamic load.

The important thing done here is to look what tasks are defined in the "schedule" parameter of the collector and create a pointer to the corresponding method of the collector. Example, parameter is:

schedule:

data: 10s
instance: 20s

then we expect that the collector has methods PollData and PollInstance that need to be invoked every 10 and 20 seconds respectively. Names of the polls are arbitrary, only "data" is a special case, since plugins are executed after the data poll (this might change).

func RecordKeepLast

func RecordKeepLast(n *node.Node, logger *slog.Logger) int

func SendAutosupport

func SendAutosupport(collectors []Collector, status *matrix.Matrix, pollerName string, maxRss uint64) error

func Sha1Sum

func Sha1Sum(s string) string

Types

type AbstractCollector

type AbstractCollector struct {
	Name    string           // name of the collector, CamelCased
	Object  string           // object of the collector, describes what that collector is collecting
	Logger  *slog.Logger     // logger used for logging
	Status  uint8            // current state of th
	Message string           // reason if a collector is in failed state
	Options *options.Options // poller options
	Params  *node.Node       // collector parameters
	// note that this is a merge of poller parameters, collector conf and object conf ("subtemplate")
	Schedule  *schedule.Schedule         // schedule of the collector
	Matrix    map[string]*matrix.Matrix  // the data storage of the collector
	Metadata  *matrix.Matrix             // metadata of the collector, such as poll duration, collected data points etc.
	Exporters []exporter.Exporter        // the exporters that the collector will emit data to
	Plugins   map[string][]plugin.Plugin // built-in or custom plugins

	Auth   *auth.Credentials // used for authing the collector
	Remote conf.Remote
	// contains filtered or unexported fields
}

AbstractCollector implements all required attributes of Collector. A "real" collector will "inherit" all these attributes and has the option to override them. The real collector should implement at least one poll function (usually PollData). AbstractCollector will link these functions to its Schedule and make sure that they are properly and timely executed.

func New

func New(name, object string, o *options.Options, params *node.Node, credentials *auth.Credentials, remote conf.Remote) *AbstractCollector

func (*AbstractCollector) AddCollectCount

func (c *AbstractCollector) AddCollectCount(n uint64)

AddCollectCount adds n to collectCount atomically

func (*AbstractCollector) CollectAutoSupport

func (c *AbstractCollector) CollectAutoSupport(_ *Payload)

CollectAutoSupport allows a Collector to add autosupport information

func (*AbstractCollector) GetCollectCount

func (c *AbstractCollector) GetCollectCount() uint64

GetCollectCount retrieves and resets count of collected data this and next method are only to report the poller how much data we have collected (independent of poll interval)

func (*AbstractCollector) GetLogger

func (c *AbstractCollector) GetLogger() *slog.Logger

GetLogger returns logger of the collector

func (*AbstractCollector) GetMetadata

func (c *AbstractCollector) GetMetadata() *matrix.Matrix

func (*AbstractCollector) GetName

func (c *AbstractCollector) GetName() string

GetName returns name of the collector

func (*AbstractCollector) GetObject

func (c *AbstractCollector) GetObject() string

GetObject returns object of the collector

func (*AbstractCollector) GetOptions

func (c *AbstractCollector) GetOptions() *options.Options

GetOptions returns the poller options passed to the collector

func (*AbstractCollector) GetParams

func (c *AbstractCollector) GetParams() *node.Node

GetParams returns the parameters of the collector

func (*AbstractCollector) GetRemote

func (c *AbstractCollector) GetRemote() conf.Remote

func (*AbstractCollector) GetStatus

func (c *AbstractCollector) GetStatus() (uint8, string, string)

GetStatus returns current state of the collector

func (*AbstractCollector) ImportSubTemplate

func (c *AbstractCollector) ImportSubTemplate(model, filename, jitter string, verWithDots string) (*node.Node, string, error)

ImportSubTemplate retrieves the best matching subtemplate of a collector object. This method is applicable to collectors which have multiple objects. Each object is forked as a separate collector. The sub-templates exist in subdirectories named after ONTAP versions. These directories are sorted, and we try to return the subtemplate that most closely matches the ONTAP version. Model is cdot or 7mode, filename is the name of the subtemplate, and ver is the ONTAP version triple (generation, major, minor)

func (*AbstractCollector) LinkExporter

func (c *AbstractCollector) LinkExporter(e exporter.Exporter)

LinkExporter appends exporter e to the receiver's list of exporters

func (*AbstractCollector) LoadPlugin

func (*AbstractCollector) LoadPlugins

func (c *AbstractCollector) LoadPlugins(params *node.Node, collector Collector, key string) error

LoadPlugins loads built-in plugins or dynamically loads custom plugins and adds them to the collector

func (*AbstractCollector) SetMatrix

func (c *AbstractCollector) SetMatrix(m map[string]*matrix.Matrix)

SetMatrix set Matrix m as a field of the collector

func (*AbstractCollector) SetMetadata

func (c *AbstractCollector) SetMetadata(m *matrix.Matrix)

SetMetadata set the metadata Matrix m as a field of the collector

func (*AbstractCollector) SetSchedule

func (c *AbstractCollector) SetSchedule(s *schedule.Schedule)

SetSchedule set Schedule s as a field of the collector

func (*AbstractCollector) SetStatus

func (c *AbstractCollector) SetStatus(status uint8, msg string)

SetStatus sets the current state of the collector to one of the values defined by CollectorStatus

func (*AbstractCollector) Start

func (c *AbstractCollector) Start(wg *sync.WaitGroup)

Start will run the collector in an infinite loop

func (*AbstractCollector) WantedExporters

func (c *AbstractCollector) WantedExporters(exporters []string) []string

WantedExporters returns the list of exporters the receiver will export data to

type AsupCollector

type AsupCollector struct {
	Name          string
	Query         string
	BatchSize     string `json:"BatchSize,omitempty"`
	ClientTimeout string
	Schedules     []Schedule
	Exporters     []string
	Counters      Counters
	InstanceInfo  *InstanceInfo `json:"InstanceInfo,omitempty"`
}

type Collector

type Collector interface {
	Init(*AbstractCollector) error
	Start(*sync.WaitGroup)
	GetName() string
	GetObject() string
	GetLogger() *slog.Logger
	GetParams() *node.Node
	GetOptions() *options.Options
	GetCollectCount() uint64
	AddCollectCount(uint64)
	GetStatus() (uint8, string, string)
	SetStatus(uint8, string)
	SetSchedule(*schedule.Schedule)
	SetMatrix(map[string]*matrix.Matrix)
	SetMetadata(*matrix.Matrix)
	WantedExporters([]string) []string
	LinkExporter(exporter.Exporter)
	LoadPlugins(*node.Node, Collector, string) error
	LoadPlugin(string, *plugin.AbstractPlugin) plugin.Plugin
	CollectAutoSupport(p *Payload)
	GetRemote() conf.Remote
}

Collector defines the attributes of a collector The poll functions (PollData, PollInstance, etc.) are not part of the interface and are linked dynamically All required functions are implemented by AbstractCollector

Note that many of the functions required by the interface are only there to facilitate "inheritance" through AbstractCollector.

type Counters

type Counters struct {
	Count int
	List  []string
}

type ID

type ID struct {
	SerialNumber string `json:"serial-number"`
	SystemID     string `json:"system-id"`
}

type InstanceInfo

type InstanceInfo struct {
	Count           int64
	DataPoints      int64
	PollTime        int64
	APITime         int64
	ParseTime       int64
	PluginTime      int64
	PluginInstances int64
	Ids             []ID `json:"Ids,omitempty"` // revive:disable-line var-naming
}

type MemMetrics

type MemMetrics struct {
	RSSBytes          uint64
	VMSBytes          uint64
	SwapBytes         uint64
	PercentageRssUsed float64
	LiveHeapBytes     uint64
	HeapSizeBytes     uint64
	HeapGoalBytes     uint64
}

func MemoryMetrics

func MemoryMetrics() MemMetrics

type Payload

type Payload struct {
	Target     *TargetInfo
	Harvest    *harvestInfo
	Platform   *platformInfo
	Nodes      *InstanceInfo `json:"Nodes,omitempty"`
	Volumes    *InstanceInfo `json:"Volumes,omitempty"`
	Quotas     *InstanceInfo `json:"Quotas,omitempty"`
	Tenants    *InstanceInfo `json:"Tenants,omitempty"`
	Collectors *[]AsupCollector
	// contains filtered or unexported fields
}

func BuildAndWriteAutoSupport

func BuildAndWriteAutoSupport(collectors []Collector, status *matrix.Matrix, pollerName string, maxRss uint64) (*Payload, error)

func (*Payload) AddCollectorAsup

func (p *Payload) AddCollectorAsup(a AsupCollector)

type Process

type Process struct {
	Pid      int32
	User     string
	Ppid     int32
	Ctime    int64
	RssBytes uint64
	Threads  int32
	Cmdline  string
}

type Schedule

type Schedule struct {
	Name     string
	Schedule string
}

type TargetInfo

type TargetInfo struct {
	Version     string
	Model       string
	Serial      string
	Ping        float64
	ClusterUUID string
}

Jump to

Keyboard shortcuts

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