config

package
v0.80.0 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 License: Apache-2.0 Imports: 17 Imported by: 71

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PostMetricsInterval = 1 * time.Minute

PostMetricsInterval XXX

Functions

This section is empty.

Types

type CheckPlugin added in v0.39.4

type CheckPlugin struct {
	Command               Command
	CustomIdentifier      *string
	NotificationInterval  *int32
	CheckInterval         *int32
	MaxCheckAttempts      *int32
	PreventAlertAutoClose bool
	Action                *Command
	Memo                  string
}

CheckPlugin represents the configuration of a check plugin The User option is ignored on Windows

type CloudPlatform added in v0.48.0

type CloudPlatform int

CloudPlatform is an enum to represent which cloud platform the host is running on.

const (
	CloudPlatformAuto CloudPlatform = iota
	CloudPlatformNone
	CloudPlatformEC2
	CloudPlatformGCE
	CloudPlatformAzureVM
)

CloudPlatform enum values

func (CloudPlatform) String added in v0.48.0

func (c CloudPlatform) String() string

func (*CloudPlatform) UnmarshalText added in v0.48.0

func (c *CloudPlatform) UnmarshalText(text []byte) error

UnmarshalText is used by toml unmarshaller

type Command added in v0.47.0

type Command struct {
	cmdutil.CommandOption
	Cmd  string
	Args []string
}

Command represents an executable command.

func (*Command) CommandString added in v0.47.0

func (cmd *Command) CommandString() string

CommandString returns the command string for log messages

func (*Command) Run added in v0.47.0

func (cmd *Command) Run() (stdout, stderr string, exitCode int, err error)

Run the Command.

func (*Command) RunWithEnv added in v0.47.0

func (cmd *Command) RunWithEnv(env []string) (stdout, stderr string, exitCode int, err error)

RunWithEnv runs the Command with Environment.

type CommandConfig added in v0.47.0

type CommandConfig struct {
	Raw            any    `toml:"command"`
	User           string `toml:"user"`
	Env            Env    `toml:"env"`
	TimeoutSeconds int64  `toml:"timeout_seconds"`
}

CommandConfig represents an executable command configuration.

type Config

type Config struct {
	Apibase       string
	Apikey        string
	Root          string
	Pidfile       string
	Conffile      string
	Roles         []string
	Verbose       bool
	Silent        bool
	Diagnostic    bool          `toml:"diagnostic"`
	DisplayName   string        `toml:"display_name"`
	HostStatus    HostStatus    `toml:"host_status" conf:"parent"`
	Disks         Disks         `toml:"disks" conf:"parent"`
	Filesystems   Filesystems   `toml:"filesystems" conf:"parent"`
	Interfaces    Interfaces    `toml:"interfaces"  conf:"parent"`
	HTTPProxy     string        `toml:"http_proxy"`
	HTTPSProxy    string        `toml:"https_proxy"`
	CloudPlatform CloudPlatform `toml:"cloud_platform"`

	// This Plugin field is used to decode the toml file. After reading the
	// configuration from file, this field is set to nil.
	// Please consider using MetricPlugins, CheckPlugins and MetadataPlugins.
	Plugin map[string]map[string]*PluginConfig `conf:"parent"`

	Include string

	// Cannot exist in configuration files
	HostIDStorage   HostIDStorage              `conf:"ignore"`
	MetricPlugins   map[string]*MetricPlugin   `conf:"ignore"`
	CheckPlugins    map[string]*CheckPlugin    `conf:"ignore"`
	MetadataPlugins map[string]*MetadataPlugin `conf:"ignore"`
	AutoShutdown    bool                       `conf:"ignore"`
}

Config represents mackerel-agent's configuration file.

var DefaultConfig *Config

DefaultConfig stores standard settings for each environment

func LoadConfig

func LoadConfig(conffile string) (*Config, error)

LoadConfig loads a Config from a file.

func (*Config) DeleteSavedHostID added in v0.26.0

func (conf *Config) DeleteSavedHostID() error

DeleteSavedHostID deletes the host id saved by SaveHostID.

func (*Config) ListCustomIdentifiers added in v0.39.4

func (conf *Config) ListCustomIdentifiers() []string

ListCustomIdentifiers returns a list of customIdentifiers.

func (*Config) LoadHostID added in v0.26.0

func (conf *Config) LoadHostID() (string, error)

LoadHostID loads the previously saved host id.

func (*Config) SaveHostID added in v0.26.0

func (conf *Config) SaveHostID(id string) error

SaveHostID saves the host id, which may be restored by LoadHostID.

type Disks added in v0.76.0

type Disks struct {
	Ignore Regexpwrapper `toml:"ignore"`
}

Disks configure disks related settings

type Env added in v0.48.0

type Env map[string]string

Env represents environments.

func (Env) ConvertToStrings added in v0.48.0

func (e Env) ConvertToStrings() ([]string, error)

ConvertToStrings converts to a slice of the form "key=value".

type FileSystemHostIDStorage added in v0.26.0

type FileSystemHostIDStorage struct {
	Root string
}

FileSystemHostIDStorage is the default HostIDStorage which saves/loads the host id using an id file on the local filesystem. The file will be located at /var/lib/mackerel-agent/id by default on linux.

func (FileSystemHostIDStorage) DeleteSavedHostID added in v0.26.0

func (s FileSystemHostIDStorage) DeleteSavedHostID() error

DeleteSavedHostID deletes the mackerel-agent's id file.

func (FileSystemHostIDStorage) HostIDFile added in v0.26.0

func (s FileSystemHostIDStorage) HostIDFile() string

HostIDFile is the location of the host id file.

func (FileSystemHostIDStorage) LoadHostID added in v0.26.0

func (s FileSystemHostIDStorage) LoadHostID() (string, error)

LoadHostID loads the current host ID from the mackerel-agent's id file.

func (FileSystemHostIDStorage) SaveHostID added in v0.26.0

func (s FileSystemHostIDStorage) SaveHostID(id string) error

SaveHostID saves the host ID to the mackerel-agent's id file.

type Filesystems added in v0.28.0

type Filesystems struct {
	Ignore        Regexpwrapper `toml:"ignore"`
	UseMountpoint bool          `toml:"use_mountpoint"`
}

Filesystems configure filesystem related settings

type HostIDStorage added in v0.26.0

type HostIDStorage interface {
	LoadHostID() (string, error)
	SaveHostID(id string) error
	DeleteSavedHostID() error
}

HostIDStorage is an interface which maintains persistency of the "Host ID" for the current host where the agent is running on. The ID is always generated and given by Mackerel (mackerel.io).

type HostStatus added in v0.17.0

type HostStatus struct {
	OnStart string `toml:"on_start"`
	OnStop  string `toml:"on_stop"`
}

HostStatus configure host status on agent start/stop

type Interfaces added in v0.71.0

type Interfaces struct {
	Ignore Regexpwrapper `toml:"ignore"`
}

Interfaces configure intefaces related settings

type MetadataPlugin added in v0.40.0

type MetadataPlugin struct {
	Command           Command
	ExecutionInterval *int32
}

MetadataPlugin represents the configuration of a metadata plugin The User option is ignored on Windows

type MetricPlugin added in v0.39.4

type MetricPlugin struct {
	Command          Command
	CustomIdentifier *string
	IncludePattern   *regexp.Regexp
	ExcludePattern   *regexp.Regexp
}

MetricPlugin represents the configuration of a metric plugin The User option is ignored on Windows

type PluginConfig

type PluginConfig struct {
	CommandConfig
	NotificationInterval  *duration     `toml:"notification_interval"`
	CheckInterval         *duration     `toml:"check_interval"`
	ExecutionInterval     *duration     `toml:"execution_interval"`
	MaxCheckAttempts      *int32        `toml:"max_check_attempts"`
	CustomIdentifier      *string       `toml:"custom_identifier"`
	PreventAlertAutoClose bool          `toml:"prevent_alert_auto_close"`
	IncludePattern        *string       `toml:"include_pattern"`
	ExcludePattern        *string       `toml:"exclude_pattern"`
	Action                CommandConfig `toml:"action" conf:"parent"`
	Memo                  string        `toml:"memo"`
}

PluginConfig represents a plugin configuration.

type Regexpwrapper added in v0.28.0

type Regexpwrapper struct {
	*regexp.Regexp
}

Regexpwrapper is a wrapper type for marshalling string

func (*Regexpwrapper) UnmarshalText added in v0.28.0

func (r *Regexpwrapper) UnmarshalText(text []byte) error

UnmarshalText for compiling regexp string while loading toml

type UnexpectedKey added in v0.73.2

type UnexpectedKey struct {
	Key        string
	SuggestKey string
}

UnexpectedKey represents result of validation

func ValidateConfigFile added in v0.73.2

func ValidateConfigFile(file string) ([]UnexpectedKey, error)

ValidateConfigFile detect unexpected key in configfile

Jump to

Keyboard shortcuts

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