legacy

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2022 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Overview

Copyright 2020 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0

Copyright 2020 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0

Copyright 2020 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0

Copyright 2020 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0

Copyright 2020 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0

Copyright 2020 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0

Index

Constants

View Source
const (
	V1_DEFAULT_PLUGIN_CATEGORY = "integration"
	V1_DEFAULT_EVENT_CATEGORY  = "notifications"
	V1_REQUIRED_EVENT_FIELD    = "summary"
	V1_EVENT_EVENT_TYPE        = "InfrastructureEvent"
)

Variables

This section is empty.

Functions

func ArgumentsToEnvVars

func ArgumentsToEnvVars(verbose int, arguments map[string]string) map[string]string

ArgumentsToEnvVars returns the environment variables that will be passed to the external plugin command. This implies that the plugin arguments are passed as environment variables to the integrations.

func BuildInventoryDataSet

func BuildInventoryDataSet(
	entryLog log.Entry,
	inventoryData map[string]protocol.InventoryData,
	labels map[string]string,
	integrationUser string,
	pluginName string,
	entityKey string) agent.PluginInventoryDataset

func EmitDataSet

func EmitDataSet(
	ctx agent.AgentContext,
	emitter agent.PluginEmitter,
	pluginName string,
	pluginVersion string,
	integrationUser string,
	dataSet protocol.PluginDataSetV3,
	extraAnnotations map[string]string,
	labels map[string]string,
	entityRewrite []data.EntityRewrite,
	protocolVersion int,
) error

func NormalizeEvent

func NormalizeEvent(
	entryLog log.Entry,
	event protocol.EventData,
	labels map[string]string,
	extraAnnotations map[string]string,
	integrationUser string,
	entityKey string) protocol.EventData

func ParsePayload

func ParsePayload(raw []byte, forceV2ToV3Upgrade bool) (dataV3 protocol.PluginDataV3, protocolVersion int, err error)

ParsePayload parses a string containing a JSON payload with the format of our SDK for v1, v2 and v3 protocols. Protocol v4 is not supported because this function is only used by v3 integration format and older.

Types

type Plugin

type Plugin struct {
	Name            string                      `yaml:"name"`             // Name of the plugin (required)
	Description     string                      `yaml:"description"`      // A short plugin description (optional)
	Commands        map[string]*PluginV1Command `yaml:"commands"`         // Map of commands for v1 plugins
	Sources         []*PluginSource             `yaml:"source"`           // List of sources to execute for the plugin to gather data.
	OS              string                      `yaml:"os"`               // OS (or comma-separated list of OSes) supported for the plugin
	Properties      []PluginProperty            `yaml:"property"`         // Properties to control behavior of this plugin
	ProtocolVersion int                         `yaml:"protocol_version"` // Protocol version (0 == original version)

	SourceFilePath string
	// contains filtered or unexported fields
}

Plugin represents a single plugin, with all associated metadata

type PluginConfig

type PluginConfig struct {
	PluginName      string              `yaml:"name"`
	PluginInstances []map[string]string `yaml:"instance"`
}

PluginConfig represents configuration for a single instance of a running plugin

type PluginInstance

type PluginInstance struct {
	// contains filtered or unexported fields
}

PluginInstance represents a running instance of a plugin with configured properties

type PluginInstanceWrapper

type PluginInstanceWrapper struct {
	IntegrationName string              `yaml:"integration_name"`
	Instances       []*PluginV1Instance `yaml:"instances"`
	DataBind        databind.YAMLConfig `yaml:"-"` // binding of fetched variables and discovery data
}

type PluginProperty

type PluginProperty struct {
	Name        string `yaml:"name"`
	Description string `yaml:"description"`
}

PluginProperty specifies a configuration parameter for a plugin

type PluginRegistry

type PluginRegistry struct {
	// contains filtered or unexported fields
}

func NewPluginRegistry

func NewPluginRegistry(pluginSourceDirs, pluginInstanceDirs []string) *PluginRegistry

func (*PluginRegistry) GetPlugin

func (pr *PluginRegistry) GetPlugin(pluginName string) (*Plugin, error)

func (*PluginRegistry) GetPluginDir

func (pr *PluginRegistry) GetPluginDir(plugin *Plugin) string

GetPluginDir gets the plugin directory so the plugin runner knows where to run the command

func (*PluginRegistry) GetPluginInstances

func (pr *PluginRegistry) GetPluginInstances() []*PluginV1Instance

func (*PluginRegistry) LoadPluginInstances

func (pr *PluginRegistry) LoadPluginInstances() (err error)

func (*PluginRegistry) LoadPluginSources

func (pr *PluginRegistry) LoadPluginSources() (err error)

LoadPlugins scans all plugins in the plugin storage dir and loads their source details into the registry. Maintains backward compatible

func (*PluginRegistry) LoadPlugins

func (pr *PluginRegistry) LoadPlugins() (err error)

type PluginRunner

type PluginRunner struct {
	// contains filtered or unexported fields
}

func NewPluginRunner

func NewPluginRunner(registry *PluginRegistry, agent iAgent) *PluginRunner

func (*PluginRunner) ConfigurePlugin

func (pr *PluginRunner) ConfigurePlugin(pluginConfig PluginConfig, activeEntitiesChannel chan string) (err error)

ConfigurePlugin sets up the plugin to run all data sources as configured. This function will create numerous goroutines responsible for running the data sources on schedule.

func (*PluginRunner) ConfigureV1Plugins

func (pr *PluginRunner) ConfigureV1Plugins(_ agent.AgentContext) (err error)

func (*PluginRunner) Wait

func (pr *PluginRunner) Wait()

type PluginSource

type PluginSource struct {
	Command  []string          `yaml:"command"`  // Command to execute, run from the plugin's directory. The first element is the executable, subsequent elements are arguments.
	Prefix   ids.PluginID      `yaml:"prefix"`   // "Plugin path" for inventory data produced by the plugin. Not applicable for event sources.
	Interval int               `yaml:"interval"` // Number of seconds to wait between invocations of the source.
	Env      map[string]string `yaml:"env"`      // V1: Optional environment K/V pairs
}

PluginSource is an inventory or event data source in a plugin, representing an executable to be invoked periodically to produce inventory data

type PluginSourceInstance

type PluginSourceInstance struct {
	// contains filtered or unexported fields
}

PluginSourceInstance represents a running instance of a plugin data source within a plugin instance

type PluginV1Command

type PluginV1Command struct {
	Command  []string     `yaml:"command"`  // Command to execute, run from the plugin's directory.
	Prefix   ids.PluginID `yaml:"prefix"`   // "Plugin path" for inventory data produced by the plugin. Not applicable for event sources.
	Interval int          `yaml:"interval"` // Number of seconds to wait between invocations of the source.
}

type PluginV1Instance

type PluginV1Instance struct {
	Name      string            `yaml:"name"`
	Command   string            `yaml:"command"`
	Arguments map[string]string `yaml:"arguments"`
	Labels    map[string]string `yaml:"labels"`
	// System user for running the integration, if set to something different
	// than "" the integration binary will be executed as
	// `sudo -n -u <become> <integration_binary> <args>`
	IntegrationUser string `yaml:"integration_user"`
	// contains filtered or unexported fields
}

type PluginsToml

type PluginsToml struct {
	PluginConfigs []PluginConfig `yaml:"plugin"`
}

PluginsToml represents the data model for the a plugin configuration file, listing one or more plugins and configuration for them

func LoadPluginConfig

func LoadPluginConfig(registry *PluginRegistry, configFiles []string) (*PluginsToml, error)

LoadPluginConfig reads the given config file and parses it into a PluginsToml object specifying configuration of plugins to use

Directories

Path Synopsis
fixtures

Jump to

Keyboard shortcuts

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