agent

package
v0.0.0-...-1402089 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: Apache-2.0 Imports: 66 Imported by: 9

Documentation

Overview

Package agent runs tasks on differents runtime environments, such as hosts and containers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

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

Agent manages the data necessary to run tasks in a runtime environment.

func New

func New(ctx context.Context, opts Options, serverURL string) (*Agent, error)

New creates a new Agent with some Options and a client.Communicator. Call the Agent's Start method to begin listening for tasks to run. Users should call Close when the agent is finished.

func (*Agent) Close

func (a *Agent) Close(ctx context.Context)

func (*Agent) GetSender

func (a *Agent) GetSender(ctx context.Context, output globals.LogOutputType, prefix string, taskID string, taskExecution int) (send.Sender, error)

GetSender configures the agent's local logging, which can go to Splunk, a file, or stdout.

func (*Agent) SetDefaultLogger

func (a *Agent) SetDefaultLogger(sender send.Sender)

func (*Agent) SetHomeDirectory

func (a *Agent) SetHomeDirectory()

SetHomeDirectory sets the agent's home directory to the user's home directory if it is not already set.

func (*Agent) Start

func (a *Agent) Start(ctx context.Context) error

Start starts the agent loop. The agent polls the API server for new tasks at interval agentSleepInterval and runs them.

type Options

type Options struct {
	// Mode determines which mode the agent will run in.
	Mode globals.Mode
	// HostID and HostSecret only apply in host mode.
	HostID     string
	HostSecret string
	// PodID and PodSecret only apply in pod mode.
	PodID                  string
	PodSecret              string
	StatusPort             int
	LogPrefix              string
	LogOutput              globals.LogOutputType
	WorkingDirectory       string
	HeartbeatInterval      time.Duration
	Cleanup                bool
	SetupData              apimodels.AgentSetupData
	CloudProvider          string
	TraceCollectorEndpoint string
	// SendTaskLogsToGlobalSender indicates whether task logs should also be
	// sent to the global agent file log.
	SendTaskLogsToGlobalSender bool
	HomeDirectory              string
}

Options contains startup options for an Agent.

func (*Options) AddLoggableInfo

func (o *Options) AddLoggableInfo(msg message.Fields) message.Fields

AddLoggableInfo is a helper to add relevant information about the agent runtime to the log message. This is typically to make high priority error logs more informative.

type StatsCollector

type StatsCollector struct {
	Cmds []string
	// indicates the sampling frequency
	Interval time.Duration
	// contains filtered or unexported fields
}

StatsCollector samples machine statistics and logs them back to the API server at regular intervals.

func NewSimpleStatsCollector

func NewSimpleStatsCollector(logger client.LoggerProducer, jpm jasper.Manager, interval time.Duration, cmds ...string) *StatsCollector

NewSimpleStatsCollector creates a StatsCollector that runs the given commands at the given interval and sends the results to the given logger.

Directories

Path Synopsis
Package command defines the behavior of commands invoked by project configuration files.
Package command defines the behavior of commands invoked by project configuration files.
taskoutput
Task Output Directory
Task Output Directory
Package util provides utility methods for the agent.
Package util provides utility methods for the agent.

Jump to

Keyboard shortcuts

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