Documentation ¶
Index ¶
- Constants
- Variables
- func GetBuiltinPlugin(name string, abc *plugin.AbstractPlugin) plugin.Plugin
- func GetOSName() string
- func ImportTemplate(confPaths []string, templateName, collectorName string) (*node.Node, error)
- func Init(c Collector) error
- func RecordKeepLast(n *node.Node, logger *slog.Logger) int
- func SendAutosupport(collectors []Collector, status *matrix.Matrix, pollerName string, ...) error
- func Sha1Sum(s string) string
- type AbstractCollector
- func (c *AbstractCollector) AddCollectCount(n uint64)
- func (c *AbstractCollector) CollectAutoSupport(_ *Payload)
- func (c *AbstractCollector) GetCollectCount() uint64
- func (c *AbstractCollector) GetLogger() *slog.Logger
- func (c *AbstractCollector) GetMetadata() *matrix.Matrix
- func (c *AbstractCollector) GetName() string
- func (c *AbstractCollector) GetObject() string
- func (c *AbstractCollector) GetOptions() *options.Options
- func (c *AbstractCollector) GetParams() *node.Node
- func (c *AbstractCollector) GetRemote() conf.Remote
- func (c *AbstractCollector) GetStatus() (uint8, string, string)
- func (c *AbstractCollector) ImportSubTemplate(model, filename, jitter string, verWithDots string) (*node.Node, string, error)
- func (c *AbstractCollector) LinkExporter(e exporter.Exporter)
- func (c *AbstractCollector) LoadPlugin(_ string, _ *plugin.AbstractPlugin) plugin.Plugin
- func (c *AbstractCollector) LoadPlugins(params *node.Node, collector Collector, key string) error
- func (c *AbstractCollector) SetMatrix(m map[string]*matrix.Matrix)
- func (c *AbstractCollector) SetMetadata(m *matrix.Matrix)
- func (c *AbstractCollector) SetSchedule(s *schedule.Schedule)
- func (c *AbstractCollector) SetStatus(status uint8, msg string)
- func (c *AbstractCollector) Start(wg *sync.WaitGroup)
- func (c *AbstractCollector) WantedExporters(exporters []string) []string
- type AsupCollector
- type Collector
- type Counters
- type ID
- type InstanceInfo
- type MemMetrics
- type Payload
- type Process
- type Schedule
- type TargetInfo
Constants ¶
const (
DefaultRecordsToSave = 60
)
const (
HundredMB = 104_857_600
)
Variables ¶
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 ImportTemplate ¶
ImportTemplate looks for a collector's template by searching confPaths for the first template that exists in confPath/collectorName/templateName
func Init ¶
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 SendAutosupport ¶
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 (c *AbstractCollector) LoadPlugin(_ string, _ *plugin.AbstractPlugin) plugin.Plugin
func (*AbstractCollector) LoadPlugins ¶
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 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 InstanceInfo ¶
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 (*Payload) AddCollectorAsup ¶
func (p *Payload) AddCollectorAsup(a AsupCollector)