agent

package
v0.0.0-...-2b44270 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2017 License: Apache-2.0 Imports: 40 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitFlags

func InitFlags(c *Config)

InitFlags binds set of flags to variables in Agent config

func Start

func Start(a *Agent)

Start checks for errors in configuration, initializes nodeid and starts the agent

Types

type Agent

type Agent struct {
	Skipmap          map[string]struct{} // collectors to skip
	MetricFrequency  time.Duration       // frequency of metric collection
	InvFrequency     time.Duration       // frequency of inventory collection
	CollectorTimeout time.Duration       // time to wait on collection before timing out

	ID int // ID of the inventory blob

	TimeoutLimit int // max number of times a collector can timeout before being skipped
	ErrorLimit   int // max number of times a collector can error out before being skipped

	SendCh    chan []byte    // channel for sending data to Server
	WaitGroup sync.WaitGroup // wait for collectors to finish
	WaitTime  time.Duration  // number of seconds between attempting to reconnect to remote server
	Config    *Config        // the agent config object

	SigChan     chan os.Signal
	Destination *Destination // currnet destination
	// contains filtered or unexported fields
}

Agent represents information of agent like metric, inventory etc

func (*Agent) Initialize

func (a *Agent) Initialize() error

Initialize initializes the Agent

func (*Agent) NonBlockingSend

func (a *Agent) NonBlockingSend(data []byte)

NonBlockingSend sends data to stdout and over channel and is non-blocking

func (*Agent) ProcessInv

func (a *Agent) ProcessInv(sha1cache map[string]string, inventoryResults []Inventory) error

ProcessInv collects, formats, and sends inventory.

func (*Agent) Stop

func (a *Agent) Stop()

Stop the agent:

type BaseCollector

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

BaseCollector contains common information for collectors

func (*BaseCollector) Precheck

func (u *BaseCollector) Precheck(a *Agent) error

Precheck validates dependencies needed for collection by collectors

type Blob

type Blob struct {
	Type           string
	ID             int
	Digest, NodeID string
	Timestamp      string
	Content        json.RawMessage
}

Blob defines format of message sent to stdout or sendBuffer

func (*Blob) Format

func (b *Blob) Format() []byte

Format encodes blob into JSON format

type Config

type Config struct {
	NodeID           string `json:"-"` // ID of host machine
	Chdir            string `json:"chdir"`
	CollectorTimeout int    `json:"collection-timeout"` // number of seconds before a collector times out
	Destination      string `json:"destination"`
	DryRun           bool   `json:"dry-run"`
	Duration         int    `json:"duration"` // How many seconds to run agent for
	Freq             int    `json:"frequency"`
	SkipStr          string `json:"skipStr"`
	Stdout           bool   `json:"stdout"`
	WaitTime         int    `json:"retrywait"` // number of seconds between attempting to reconnect to remote server
}

Config settings saved in external storage

so we can run hds-agent without command line flags

func NewDefaultConfig

func NewDefaultConfig() *Config

NewDefaultConfig sets the default flags for the Agent so we can support passing no flags from the command line

func (*Config) CheckErrs

func (c *Config) CheckErrs() error

CheckErrs validates values of Config fields

func (*Config) InitializeNodeID

func (c *Config) InitializeNodeID() error

InitializeNodeID will set nodeID if agent doesn't already have node.id file with valid value

func (*Config) ReadNodeID

func (c *Config) ReadNodeID() (string, error)

ReadNodeID reads the node.id file when available

func (*Config) WriteNodeID

func (c *Config) WriteNodeID() error

WriteNodeID writes the node.id file

type Destination

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

Destination contains information of destination server where metric/inventory data needs to be sent

type Inventory

type Inventory struct {
	Name, Type string
	Data       json.RawMessage

	Timeout bool
	// contains filtered or unexported fields
}

Inventory contains information of inventory of machine

type InventoryCollector

type InventoryCollector struct {
	BaseCollector
	// contains filtered or unexported fields
}

InventoryCollector contains information of inventory collector

type Metadata

type Metadata struct {
	HostType string
}

Metadata is wrapper struct for hosttype

type MetricCollector

type MetricCollector struct {
	BaseCollector
	// contains filtered or unexported fields
}

MetricCollector contains information of metric collector

type Syslog

type Syslog struct {
	Tag, Hostname, Message string
	Timestamp              time.Time
	Facility, Severity     int
}

Syslog contains different fileds to format log message into more readable

Directories

Path Synopsis
apps
cpu
net
Package log implements logging with 2 rule: a.
Package log implements logging with 2 rule: a.

Jump to

Keyboard shortcuts

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