conf

package
v2.0.0-...-ca652af Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultAPIVersion = "1.3"
	DefaultTimeout    = "30s"
	DefaultConfPath   = "conf"
	HarvestYML        = "harvest.yml"
	BasicAuth         = "basic_auth"
	CertificateAuth   = "certificate_auth"
	HomeEnvVar        = "HARVEST_CONF"
)

Variables

View Source
var (
	Config = HarvestConfig{}
)

Functions

func ConfigPath

func ConfigPath(path string) string

func DecodeConfig

func DecodeConfig(contents []byte) error

func ExpandVars

func ExpandVars(in []byte) ([]byte, error)

func GetLastPromPort

func GetLastPromPort(pollerName string, validatePortInUse bool) (int, error)

GetLastPromPort returns the Prometheus port for the given poller If a poller has multiple Prometheus exporters in its `exporters` section, the port for the last exporter in the list is used.

func GetUniqueExporters

func GetUniqueExporters(exporterNames []string) []string

GetUniqueExporters returns the unique set of exporter types from the list of export names. For example, if two Prometheus exporters are configured for a poller, the last one is returned. Multiple InfluxDB exporters are allowed.

func LoadHarvestConfig

func LoadHarvestConfig(configPath string) (string, error)

func Path

func Path(aPath string) string

Path returns a path based on aPath and the HARVEST_CONF environment variable. If aPath is absolute, it is returned unchanged. When the HARVEST_CONF environment variable is set, a new path is returned relative to HARVEST_CONF. Otherwise, a new path is returned relative to the current working directory.

func ReadCredentialFile

func ReadCredentialFile(credPath string, p *Poller) error

func TestLoadHarvestConfig

func TestLoadHarvestConfig(configPath string)

TestLoadHarvestConfig loads a new config - used by testing code

Types

type Admin

type Admin struct {
	Httpsd Httpsd `yaml:"httpsd,omitempty"`
}

type CertificateScript

type CertificateScript struct {
	Path    string `yaml:"path,omitempty"`
	Timeout string `yaml:"timeout,omitempty"`
}

type Collector

type Collector struct {
	Name      string    `yaml:"-"`
	Templates *[]string `yaml:"-"`
}

func NewCollector

func NewCollector(name string) Collector

func (*Collector) UnmarshalYAML

func (c *Collector) UnmarshalYAML(n *yaml.Node) error

type CredentialsScript

type CredentialsScript struct {
	Path     string `yaml:"path,omitempty"`
	Schedule string `yaml:"schedule,omitempty"`
	Timeout  string `yaml:"timeout,omitempty"`
}

type Exporter

type Exporter struct {
	Port              *int      `yaml:"port,omitempty"`
	PortRange         *IntRange `yaml:"port_range,omitempty"`
	Type              string    `yaml:"exporter,omitempty"`
	Addr              *string   `yaml:"addr,omitempty"`
	URL               *string   `yaml:"url,omitempty"`
	LocalHTTPAddr     string    `yaml:"local_http_addr,omitempty"`
	GlobalPrefix      *string   `yaml:"global_prefix,omitempty"`
	AllowedAddrs      *[]string `yaml:"allow_addrs,omitempty"`
	AllowedAddrsRegex *[]string `yaml:"allow_addrs_regex,omitempty"`
	CacheMaxKeep      *string   `yaml:"cache_max_keep,omitempty"`
	ShouldAddMetaTags *bool     `yaml:"add_meta_tags,omitempty"`

	// Prometheus specific
	HeartBeatURL string `yaml:"heart_beat_url,omitempty"`
	SortLabels   bool   `yaml:"sort_labels,omitempty"`
	TLS          TLS    `yaml:"tls,omitempty"`

	// InfluxDB specific
	Bucket        *string `yaml:"bucket,omitempty"`
	Org           *string `yaml:"org,omitempty"`
	Token         *string `yaml:"token,omitempty"`
	Precision     *string `yaml:"precision,omitempty"`
	ClientTimeout *string `yaml:"client_timeout,omitempty"`
	Version       *string `yaml:"version,omitempty"`

	IsTest     bool // true when run from unit tests
	IsEmbedded bool // true when the exporter is embedded in a poller
}

type ExporterDef

type ExporterDef struct {
	Name string
	Exporter
}

func (*ExporterDef) UnmarshalYAML

func (e *ExporterDef) UnmarshalYAML(n *yaml.Node) error

type HarvestConfig

type HarvestConfig struct {
	Tools          *Tools              `yaml:"Tools,omitempty"`
	Exporters      map[string]Exporter `yaml:"Exporters,omitempty"`
	Pollers        map[string]*Poller  `yaml:"Pollers,omitempty"`
	PollerFiles    []string            `yaml:"Poller_files,omitempty"`
	Defaults       *Poller             `yaml:"Defaults,omitempty"`
	Admin          Admin               `yaml:"Admin,omitempty"`
	PollersOrdered []string            // poller names in same order as yaml config
}

type Httpsd

type Httpsd struct {
	Listen    string `yaml:"listen,omitempty"`
	AuthBasic struct {
		Username string `yaml:"username,omitempty"`
		Password string `yaml:"password,omitempty"`
	} `yaml:"auth_basic,omitempty"`
	TLS         TLS    `yaml:"tls,omitempty"`
	HeartBeat   string `yaml:"heart_beat,omitempty"`
	ExpireAfter string `yaml:"expire_after,omitempty"`
}

type IntRange

type IntRange struct {
	Min int
	Max int
}

func (*IntRange) UnmarshalYAML

func (i *IntRange) UnmarshalYAML(n *yaml.Node) error

type OrderedConfig

type OrderedConfig struct {
	Pollers Pollers `yaml:"Pollers,omitempty"`
}

type Poller

type Poller struct {
	APIVersion        string               `yaml:"api_version,omitempty"`
	APIVfiler         string               `yaml:"api_vfiler,omitempty"`
	Addr              string               `yaml:"addr,omitempty"`
	AuthStyle         string               `yaml:"auth_style,omitempty"`
	CaCertPath        string               `yaml:"ca_cert,omitempty"`
	CertificateScript CertificateScript    `yaml:"certificate_script,omitempty"`
	ClientTimeout     string               `yaml:"client_timeout,omitempty"`
	Collectors        []Collector          `yaml:"collectors,omitempty"`
	ConfPath          string               `yaml:"conf_path,omitempty"`
	CredentialsFile   string               `yaml:"credentials_file,omitempty"`
	CredentialsScript CredentialsScript    `yaml:"credentials_script,omitempty"`
	Datacenter        string               `yaml:"datacenter,omitempty"`
	IsDisabled        bool                 `yaml:"disabled,omitempty"`
	ExporterDefs      []ExporterDef        `yaml:"exporters,omitempty"`
	Exporters         []string             `yaml:"-"`
	IsKfs             bool                 `yaml:"is_kfs,omitempty"`
	Labels            *[]map[string]string `yaml:"labels,omitempty"`
	LogMaxBytes       int64                `yaml:"log_max_bytes,omitempty"`
	LogMaxFiles       int                  `yaml:"log_max_files,omitempty"`
	LogSet            *[]string            `yaml:"log,omitempty"`
	Password          string               `yaml:"password,omitempty"`
	PollerLogSchedule string               `yaml:"poller_log_schedule,omitempty"`
	PollerSchedule    string               `yaml:"poller_schedule,omitempty"`
	PreferZAPI        bool                 `yaml:"prefer_zapi,omitempty"`
	PromPort          int                  `yaml:"prom_port,omitempty"`
	Recorder          Recorder             `yaml:"recorder,omitempty"`
	SslCert           string               `yaml:"ssl_cert,omitempty"`
	SslKey            string               `yaml:"ssl_key,omitempty"`
	TLSMinVersion     string               `yaml:"tls_min_version,omitempty"`
	UseInsecureTLS    *bool                `yaml:"use_insecure_tls,omitempty"`
	Username          string               `yaml:"username,omitempty"`

	Name string
	// contains filtered or unexported fields
}

func PollerNamed

func PollerNamed(name string) (*Poller, error)

func ZapiPoller

func ZapiPoller(n *node.Node) *Poller

ZapiPoller creates a poller out of a node, this is a bridge between the node and struct-based code Used by ZAPI based code

func (*Poller) IsRecording

func (p *Poller) IsRecording() bool

func (*Poller) Union

func (p *Poller) Union(defaults *Poller)

Union merges a poller's config with the defaults. For all keys in default, copy them to the poller if the poller does not already include them

type Pollers

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

func (*Pollers) UnmarshalYAML

func (i *Pollers) UnmarshalYAML(n *yaml.Node) error

type PortMap

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

func PortMapFromRange

func PortMapFromRange(address string, portRange *IntRange, validatePortInUse bool) PortMap

type Recorder

type Recorder struct {
	Path     string `yaml:"path,omitempty"`
	Mode     string `yaml:"mode,omitempty"`      // record or replay
	KeepLast string `yaml:"keep_last,omitempty"` // number of records to keep before overwriting
}

type Remote

type Remote struct {
	Name            string
	Model           string
	UUID            string
	Version         string
	Release         string
	Serial          string
	IsSanOptimized  bool
	IsDisaggregated bool
	ZAPIsExist      bool
	HasREST         bool
	IsClustered     bool
}

func (Remote) IsKeyPerf

func (r Remote) IsKeyPerf() bool

func (Remote) IsZero

func (r Remote) IsZero() bool

type TLS

type TLS struct {
	CertFile string `yaml:"cert_file,omitempty"`
	KeyFile  string `yaml:"key_file,omitempty"`
}

type Tools

type Tools struct {
	GrafanaAPIToken string `yaml:"grafana_api_token,omitempty"`
	AsupDisabled    bool   `yaml:"autosupport_disabled,omitempty"`
}

Jump to

Keyboard shortcuts

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