module

package
v0.25.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2020 License: GPL-3.0 Imports: 10 Imported by: 79

Documentation

Index

Constants

View Source
const (
	// Line chart type.
	Line ChartType = "line"
	// Area chart type.
	Area ChartType = "area"
	// Stacked chart type.
	Stacked ChartType = "stacked"

	// Absolute dimension algorithm.
	// The value is to drawn as-is (interpolated to second boundary).
	Absolute dimAlgo = "absolute"
	// Incremental dimension algorithm.
	// The value increases over time, the difference from the last value is presented in the chart,
	// the server interpolates the value and calculates a per second figure.
	Incremental dimAlgo = "incremental"
	// PercentOfAbsolute dimension algorithm.
	// The percent of this value compared to the total of all dimensions.
	PercentOfAbsolute dimAlgo = "percentage-of-absolute-row"
	// PercentOfIncremental dimension algorithm.
	// The percent of this value compared to the incremental total of all dimensions
	PercentOfIncremental dimAlgo = "percentage-of-incremental-row"
)
View Source
const (
	UpdateEvery        = 1
	AutoDetectionRetry = 0
	Priority           = 70000
)
View Source
const RRD_ID_LENGTH_MAX = 200

https://github.com/netdata/netdata/blob/ab0ffcebf802803d1e88f6a5e47a314c292b45e3/database/rrd.h#L59 Chart type.id (job.FullName() + '.' + chart.ID)

Variables

View Source
var DefaultRegistry = Registry{}

DefaultRegistry DefaultRegistry.

Functions

func Register

func Register(name string, creator Creator)

Register registers a module in the DefaultRegistry.

Types

type Base

type Base struct {
	*logger.Logger
}

Base is a helper struct. All modules should embed this struct.

func (*Base) GetBase

func (b *Base) GetBase() *Base

type Chart

type Chart struct {
	ID       string
	OverID   string
	Title    string
	Units    string
	Fam      string
	Ctx      string
	Type     ChartType
	Priority int
	Opts

	Dims Dims
	Vars Vars

	Retries int
	// contains filtered or unexported fields
}

Chart represents a chart. For the full description please visit https://docs.netdata.cloud/collectors/plugins.d/#chart

func (*Chart) AddDim

func (c *Chart) AddDim(newDim *Dim) error

AddDim adds new dimension to the chart dimensions.

func (*Chart) AddVar

func (c *Chart) AddVar(newVar *Var) error

AddVar adds new variable to the chart variables.

func (Chart) Copy

func (c Chart) Copy() *Chart

Copy returns a deep copy of the chart.

func (*Chart) GetDim

func (c *Chart) GetDim(dimID string) *Dim

GetDim returns dimension by ID.

func (Chart) HasDim

func (c Chart) HasDim(dimID string) bool

HasDim returns true if the chart contains dimension with the given ID, false otherwise.

func (*Chart) MarkDimRemove

func (c *Chart) MarkDimRemove(dimID string, hide bool) error

MarkDimRemove sets 'remove' flag, Obsolete and optionally Hidden options to true. Use it to remove dimension in runtime.

func (*Chart) MarkNotCreated

func (c *Chart) MarkNotCreated()

MarkNotCreated changes 'created' chart flag to false. Use it to add dimension in runtime.

func (*Chart) MarkRemove

func (c *Chart) MarkRemove()

MarkRemove sets 'remove' flag and Obsolete option to true. Use it to remove chart in runtime.

func (*Chart) RemoveDim

func (c *Chart) RemoveDim(dimID string) error

RemoveDim removes dimension by ID. Avoid to use it in runtime.

type ChartType added in v0.25.0

type ChartType string

func (ChartType) String added in v0.25.0

func (c ChartType) String() string

type Charts

type Charts []*Chart

Charts is a collection of Charts.

func (*Charts) Add

func (c *Charts) Add(charts ...*Chart) error

Add adds (appends) a variable number of Charts.

func (Charts) Copy

func (c Charts) Copy() *Charts

Copy returns a deep copy of ChartsFunc.

func (Charts) Get

func (c Charts) Get(chartID string) *Chart

Get returns the chart by ID.

func (Charts) Has

func (c Charts) Has(chartID string) bool

Has returns true if ChartsFunc contain the chart with the given ID, false otherwise.

func (*Charts) Remove

func (c *Charts) Remove(chartID string) error

Remove removes the chart from Charts by ID. Avoid to use it in runtime.

type Creator

type Creator struct {
	Defaults
	Create func() Module
}

Creator is a Job builder.

type Defaults

type Defaults struct {
	UpdateEvery        int
	AutoDetectionRetry int
	Priority           int
	Disabled           bool
}

Defaults is a set of module default parameters.

type Dim

type Dim struct {
	ID   string
	Name string
	Algo dimAlgo
	Mul  int
	Div  int
	DimOpts
	// contains filtered or unexported fields
}

Dim represents a chart dimension. For detailed description please visit https://docs.netdata.cloud/collectors/plugins.d/#dimension.

type DimOpts

type DimOpts struct {
	Obsolete   bool
	Hidden     bool
	NoReset    bool
	NoOverflow bool
}

DimOpts represents dimension options.

func (DimOpts) String

func (o DimOpts) String() string

type Dims

type Dims []*Dim

Dims is a collection of dims.

type Job

type Job struct {
	AutoDetectEvery int
	AutoDetectTries int

	*logger.Logger
	// contains filtered or unexported fields
}

Job represents a job. It's a module wrapper.

func NewJob

func NewJob(cfg JobConfig) *Job

func (*Job) AutoDetection

func (j *Job) AutoDetection() (ok bool)

AutoDetection invokes init, check and postCheck. It handles panic.

func (Job) AutoDetectionEvery

func (j Job) AutoDetectionEvery() int

AutoDetectionEvery returns value of AutoDetectEvery.

func (Job) FullName

func (j Job) FullName() string

FullName returns job full name.

func (Job) ModuleName

func (j Job) ModuleName() string

ModuleName returns job module name.

func (Job) Name

func (j Job) Name() string

Name returns job name.

func (Job) Panicked

func (j Job) Panicked() bool

Panicked returns 'panicked' flag value.

func (Job) RetryAutoDetection

func (j Job) RetryAutoDetection() bool

RetryAutoDetection returns whether it is needed to retry autodetection.

func (*Job) Start

func (j *Job) Start()

Start starts job main loop.

func (*Job) Stop

func (j *Job) Stop()

Stop stops job main loop. It blocks until the job is stopped.

func (*Job) Tick

func (j *Job) Tick(clock int)

Tick Tick.

type JobConfig

type JobConfig struct {
	PluginName      string
	Name            string
	ModuleName      string
	FullName        string
	Module          Module
	Out             io.Writer
	UpdateEvery     int
	AutoDetectEvery int
	Priority        int
}

type MockModule

type MockModule struct {
	Base

	InitFunc    func() bool
	CheckFunc   func() bool
	ChartsFunc  func() *Charts
	CollectFunc func() map[string]int64
	CleanupFunc func()
	CleanupDone bool
}

MockModule MockModule.

func (MockModule) Charts

func (m MockModule) Charts() *Charts

Charts invokes ChartsFunc.

func (MockModule) Check

func (m MockModule) Check() bool

Check invokes CheckFunc.

func (*MockModule) Cleanup

func (m *MockModule) Cleanup()

Cleanup sets CleanupDone to true.

func (MockModule) Collect

func (m MockModule) Collect() map[string]int64

Collect invokes CollectDunc.

func (MockModule) Init

func (m MockModule) Init() bool

Init invokes InitFunc.

type Module

type Module interface {
	// Init does initialization.
	// If it return false, the job will be disabled.
	Init() bool

	// Check is called after Init.
	// If it return false, the job will be disabled.
	Check() bool

	// Charts returns the chart definition.
	// Make sure not to share returned instance.
	Charts() *Charts

	// Collect collects metrics.
	Collect() map[string]int64

	// Cleanup Cleanup
	Cleanup()

	GetBase() *Base
}

Module is an interface that represents a module.

type Opts

type Opts struct {
	Obsolete   bool
	Detail     bool
	StoreFirst bool
	Hidden     bool
}

Opts represents chart options.

func (Opts) String

func (o Opts) String() string

type Registry

type Registry map[string]Creator

Registry is a collection of Creators.

func (Registry) Register

func (r Registry) Register(name string, creator Creator)

Register registers a module.

type Var

type Var struct {
	ID    string
	Value int64
}

Var represents a chart variable. For detailed description please visit https://docs.netdata.cloud/collectors/plugins.d/#variable

type Vars

type Vars []*Var

Vars is a collection of vars.

Jump to

Keyboard shortcuts

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