modules

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2019 License: GPL-3.0 Imports: 9 Imported by: 1

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"
)

Variables

View Source
var DefaultRegistry = Registry{}

DefaultRegistry DefaultRegistry

Functions

func CheckCharts

func CheckCharts(charts ...*Chart) error

CheckCharts checks charts

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) SetLogger

func (b *Base) SetLogger(l *logger.Logger)

SetLogger SetLogger

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) 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 changes 'remove' chart flag 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 Charts

type Charts []*Chart

Charts is a collection of ChartsFunc.

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 {
	UpdateEvery       int
	DisabledByDefault bool
	Create            func() Module
}

Creator is a Job builder

type Dim

type Dim struct {
	ID     string
	Name   string
	Algo   dimAlgo
	Mul    dimDivMul
	Div    dimDivMul
	Hidden dimHidden
}

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

type Dims

type Dims []*Dim

Dims is a collection of dims.

type Job

type Job struct {
	*logger.Logger

	Nam             string `yaml:"name"`
	UpdateEvery     int    `yaml:"update_every" validate:"gte=1"`
	AutoDetectRetry int    `yaml:"autodetection_retry" validate:"gte=0"`
	// contains filtered or unexported fields
}

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

func NewJob

func NewJob(modName string, module Module, out io.Writer, observer Observer) *Job

NewJob returns new job.

func (Job) AutoDetectionRetry

func (j Job) AutoDetectionRetry() int

AutoDetectionRetry returns value of AutoDetectRetry.

func (*Job) Check

func (j *Job) Check() bool

Check calls module Check and returns its value. It handles panic. In case of panic it calls module Cleanup.

func (Job) FullName

func (j Job) FullName() string

FullName returns full name. If name isn't specified or equal to module name it returns module name.

func (*Job) Init

func (j *Job) Init() bool

Init calls module Init and returns its value.

func (*Job) MainLoop

func (j *Job) MainLoop()

MainLoop is a job main function.

func (Job) ModuleName

func (j Job) ModuleName() string

ModuleName returns module name.

func (Job) Name

func (j Job) Name() string

Name returns name. If name isn't specified it returns module name.

func (Job) Panicked

func (j Job) Panicked() bool

Panicked returns 'panicked' flag value.

func (*Job) PostCheck

func (j *Job) PostCheck() bool

PostCheck calls module Charts. If the result is nil it calls module Cleanup.

func (*Job) Start

func (j *Job) Start()

Start simply invokes MainLoop.

func (*Job) Stop

func (j *Job) Stop()

Stop stops MainLoop

func (*Job) Tick

func (j *Job) Tick(clock int)

Tick Tick

type MockModule

type MockModule struct {
	Base

	InitFunc    func() bool
	CheckFunc   func() bool
	ChartsFunc  func() *Charts
	CollectFunc func() map[string]int64
	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

	// SetLogger SetLogger
	SetLogger(l *logger.Logger)

	// Cleanup Cleanup
	Cleanup()
}

Module is an interface that represents a module.

type Observer

type Observer interface {
	RemoveFromQueue(fullName string)
}

Observer Observer

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