agents

package
v0.2.9 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2023 License: BSD-3-Clause Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	START     = "start"
	STOP      = "stop"
	RESTART   = "restart"
	STATUS    = "status"
	RELOAD    = "reload"
	INVENTORY = "inventory"
	VERSION   = "version"
)
View Source
const (
	// action types.
	CONFIG  = "config"
	COMMAND = "command"

	STATUS_ACTIVE = "active" //nolint:revive,nosnakecase,stylecheck
	STATUS_ERROR  = "error"  //nolint:revive,nosnakecase,stylecheck
)

Variables

This section is empty.

Functions

func CheckForAgents

func CheckForAgents(ctx context.Context) error

func FetchAgents

func FetchAgents(ctx context.Context) error

func SaveAgents

func SaveAgents(aa Agents) error

Types

type APIAction

type APIAction struct {
	ConfigAssignmentID string         `json:"config_assignment_id"`
	Config             APIConfig      `json:"configuration"`
	Agent              APIConfigAgent `json:"agent"`
}

type APIActions

type APIActions []APIAction

type APIAgent

type APIAgent struct {
	Platforms []Platform `json:"platforms"`
}

type APIAgents

type APIAgents []APIAgent

type APIConfig

type APIConfig struct {
	FileID   string `json:"config_file_id"`
	Contents string `json:"config"`
}

type APIConfigAgent

type APIConfigAgent struct {
	ID string `json:"agent_type_id"`
}

type Action

type Action struct {
	Configs  map[string][]Config `json:"configs"  yaml:"configs"`
	ID       string              `json:"id"       yaml:"id"` // not used yet, api only supports configs
	Type     string              `json:"type"     yaml:"type"`
	Commands []Command           `json:"commands" yaml:"commands"`
}

type Actions

type Actions []Action

func ParseAPIActions

func ParseAPIActions(data []byte) (Actions, error)

type Agent

type Agent struct {
	ConfigFiles map[string]string `json:"config_files" yaml:"config_files"`
	Binary      string            `json:"binary"       yaml:"binary"`
	Start       string            `json:"start"        yaml:"start"`
	Stop        string            `json:"stop"         yaml:"stop"`
	Restart     string            `json:"restart"      yaml:"restart"`
	Reload      string            `json:"reload"       yaml:"reload"`
	Status      string            `json:"status"       yaml:"status"`
	Version     string            `json:"version"      yaml:"version"`
}

type Agents

type Agents map[string]map[string]Agent

key1 is platform (GOOS) e.g. darwin, windows, linux, freebsd, etc. key2 is agent e.g. fluent-bit, telegraf, etc.

func LoadAgents

func LoadAgents() (Agents, error)

func ParseAPIAgents

func ParseAPIAgents(data []byte) (Agents, error)

type Command

type Command struct {
	ID      string `json:"id"      yaml:"id"`
	Agent   string `json:"agent"   yaml:"agent"`
	Command string `json:"command" yaml:"command"`
}

not OS commands, commands the agent knows (e.g. restart_agent, agent_status, etc.). how to restart an agent is in the agent inventory. agent status would be the result of running `systemctl status <agent>`.

type CommandData

type CommandData struct {
	Output   string `json:"output"    yaml:"output"`
	Error    string `json:"error"     yaml:"error"`
	ExitCode int    `json:"exit_code" yaml:"exit_code"`
}

type CommandResult

type CommandResult struct {
	ID          string      `json:"id"     yaml:"id"`
	Status      string      `json:"status" yaml:"status"` // active or error
	CommandData CommandData `json:"data"   yaml:"data"`
}

Output will be base64 encoded.

type Commands

type Commands struct {
	Command string `json:"command" yaml:"command"`
	Name    string `json:"name"    yaml:"name"`
}

type Config

type Config struct {
	ID       string `json:"id"       yaml:"id"`
	Path     string `json:"path"     yaml:"path"`
	Contents string `json:"contents" yaml:"contents"`
}

Contest should be base64 encoded.

type ConfigData

type ConfigData struct {
	WriteResult  string `json:"write_result,omitempty"  yaml:"write_result,omitempty"`
	ReloadResult string `json:"reload_result,omitempty" yaml:"reload_result,omitempty"`
}

type ConfigFile

type ConfigFile struct {
	ConfigFileID string `json:"config_file_id" yaml:"config_file_id"`
	Path         string `json:"path"           yaml:"path"`
}

type ConfigResult

type ConfigResult struct {
	ID         string     `json:"config_assignment_id" yaml:"config_assignment_id"`
	Status     string     `json:"status"               yaml:"status"` // STATUS_ACTIVE or STATUS_ERROR
	Info       string     `json:"info,omitempty"       yaml:"info,omitempty"`
	ConfigData ConfigData `json:"data,omitempty"       yaml:"data,omitempty"`
}

write result will be "OK" or the err received when trying to write the file. reload result will be empty or base64 encoded as it may be multi-line output.

type InstalledAgent

type InstalledAgent struct {
	AgentTypeID string `json:"agent_type_id"`
	Version     string `json:"version"`
}

type InstalledAgents

type InstalledAgents []InstalledAgent

type Platform

type Platform struct {
	ID          string       `json:"platform_id"   yaml:"platform_id"`
	AgentTypeID string       `json:"agent_type_id" yaml:"agent_type_id"`
	Executable  string       `json:"executable"    yaml:"executable"`
	Commands    []Commands   `json:"commands"      yaml:"commands"`
	Start       string       `json:"start"         yaml:"start"`
	Stop        string       `json:"stop"          yaml:"stop"`
	Restart     string       `json:"restart"       yaml:"restart"`
	Reload      string       `json:"reload"        yaml:"reload"`
	Status      string       `json:"status"        yaml:"status"`
	Version     string       `json:"version"       yaml:"version"`
	ConfigFiles []ConfigFile `json:"config_files"  yaml:"config_files"`
}

type Poller

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

func NewPoller

func NewPoller() (*Poller, error)

func (*Poller) Start

func (p *Poller) Start(ctx context.Context)

type Result

type Result struct {
	ActionID      string        `json:"action_id"      yaml:"action_id"` // not used at this time, api only supports configs
	ConfigResult  ConfigResult  `json:"config_result"  yaml:"config_result"`
	CommandResult CommandResult `json:"command_result" yaml:"command_result"`
}

Jump to

Keyboard shortcuts

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