plugin

package
v1.2.2-0...-b23510b Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Metrics map[string]*Metric  = make(map[string]*Metric)
	Plugins map[string]Accessor = make(map[string]Accessor)
)
View Source
var UnsupportedMetricError = errs.New("unsupported item key")

Functions

func ClearRegistry

func ClearRegistry()

func ClearUserParamMetrics

func ClearUserParamMetrics() map[string]*Metric

func RegisterMetrics

func RegisterMetrics(impl Accessor, name string, params ...string) error

RegisterMetrics registers metrics for the given plugin.

func RestoreUserParamMetrics

func RestoreUserParamMetrics(metrics map[string]*Metric)

Types

type Accessor

type Accessor interface {
	Init(name string)
	Name() string
	MaxCapacity() int
	SetMaxCapacity(capacity int)
	HandleTimeout() bool
	SetHandleTimeout(enable bool)
	IsExternal() bool
}

func Get

func Get(key string) (acc Accessor, err error)

func GetByName

func GetByName(name string) (acc Accessor, err error)

type Base

type Base struct {
	log.Logger
	// contains filtered or unexported fields
}

func (*Base) HandleTimeout

func (b *Base) HandleTimeout() bool

HandleTimeout returns handle timeout.

func (*Base) Init

func (b *Base) Init(name string)

Init initializes base structure with name and logger.

func (*Base) IsExternal

func (b *Base) IsExternal() bool

IsExternal returns whether plugin is set to be external or not.

func (*Base) MaxCapacity

func (b *Base) MaxCapacity() int

MaxCapacity returns base structures max capacity.

func (*Base) Name

func (b *Base) Name() string

Name returns base structures name.

func (*Base) SetExternal

func (b *Base) SetExternal(isExternal bool)

SetExternal sets external bool to provided value.

func (*Base) SetHandleTimeout

func (b *Base) SetHandleTimeout(handleTimeout bool)

SetHandleTimeout sets handle timeout.

func (*Base) SetMaxCapacity

func (b *Base) SetMaxCapacity(capacity int)

SetMaxCapacity sets max capacity plugin can have.

type Collector

type Collector interface {
	Collect() error
	Period() int
}

Collector - interface for periodical metric collection

type Configurator

type Configurator interface {
	// Configure method passes global and private plugin configuration after it has been activated.
	Configure(globalOptions *GlobalOptions, privateOptions interface{})
	// Validate method validates private plugin configuration during agent startup.
	Validate(privateOptions interface{}) error
}

Configurator - interface for plugin configuration in agent conf files

type ContextProvider

type ContextProvider interface {
	ClientID() uint64
	ItemID() uint64
	Output() ResultWriter
	Meta() *Meta
	GlobalRegexp() RegexpMatcher
	Timeout() int
	Delay() string
}

type Exporter

type Exporter interface {
	// Export method exports data based on the key 'key' and its parameters 'params'.
	Export(
		key string, params []string, context ContextProvider,
	) (interface{}, error)
}

Exporter - interface for exporting collected metrics

type GlobalOptions

type GlobalOptions struct {
	Timeout  int    `json:"Timeout"`  //nolint:tagliatelle
	SourceIP string `json:"SourceIP"` //nolint:tagliatelle
}

GlobalOptions are global agent configuration parameters that can be accessed by plugins. In most cases it's recommended to allow plugins overriding global configuration parameters they are using with plugin specific parameters.

type Item

type Item struct {
	Itemid      uint64
	Key         string
	Delay       string
	LastLogsize *uint64
	Mtime       *int
	Timeout     int
}

type Meta

type Meta struct {
	Data interface{}
	// contains filtered or unexported fields
}

func (*Meta) LastLogsize

func (m *Meta) LastLogsize() uint64

func (*Meta) Mtime

func (m *Meta) Mtime() int32

func (*Meta) SetLastLogsize

func (m *Meta) SetLastLogsize(value uint64)

func (*Meta) SetMtime

func (m *Meta) SetMtime(value int32)

type Metric

type Metric struct {
	Plugin      Accessor
	Key         string
	Description string
	UsrPrm      bool
}

type RegexpMatcher

type RegexpMatcher interface {
	Match(value, pattern string, mode int, output_template *string) (match bool, output string)
}

type Result

type Result struct {
	Itemid uint64
	Value  *string

	// additional windows eventlog fields
	EventSource    *string
	EventID        *int
	EventTimestamp *int
	EventSeverity  *int

	Ts          time.Time
	Error       error
	LastLogsize *uint64
	Mtime       *int
	Persistent  bool
}

type ResultWriter

type ResultWriter interface {
	Write(result *Result)
	Flush()
	SlotsAvailable() int
	PersistSlotsAvailable() int
}

type Runner

type Runner interface {
	// Start method activates plugin.
	Start()
	// Stop method deactivates plugin.
	Stop()
}

Runner - interface for managing background processes

type SystemOptions deprecated

type SystemOptions struct {
	Path                     string `conf:"optional"`
	Capacity                 string `conf:"optional"`
	ForceActiveChecksOnStart string `conf:"optional"`
}

SystemOptions contains System Options of plugin.

Deprecated: SystemOptions exists for historical compatibility with older Zabbix agent 2 versions. Currently System options are parsed and removed in Zabix agent 2.

type Watcher

type Watcher interface {
	// Watch method instructs plugin to watch for events based on item configuration.
	Watch(items []*Item, context ContextProvider)
}

Watcher - interface for fully custom monitoring

Source Files

  • base.go
  • registry.go
  • types.go

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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