utils

package
v0.0.0-...-f93202d Latest Latest
Warning

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

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

Documentation

Overview

Package utils generate host metadata payloads ready to be sent.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetInformation

func GetInformation() *host.InfoStat

GetInformation returns an InfoStat object, filled in with various operating system metadata. This returns an empty host.InfoStat if gopsutil fails.

func GetOSVersion

func GetOSVersion() string

GetOSVersion returns the current OS version

func GetPlatformName

func GetPlatformName() string

GetPlatformName returns the name of the current platform

Types

type CommonPayload

type CommonPayload struct {
	APIKey           string `json:"apiKey"`
	AgentVersion     string `json:"agentVersion"`
	UUID             string `json:"uuid"`
	InternalHostname string `json:"internalHostname"`
}

CommonPayload handles the JSON unmarshalling of the metadata payload

func GetCommonPayload

func GetCommonPayload(hostname string, conf model.Reader) *CommonPayload

GetCommonPayload fills and return the common metadata payload

type InstallMethod

type InstallMethod struct {
	Tool             *string `json:"tool"`
	ToolVersion      string  `json:"tool_version"`
	InstallerVersion *string `json:"installer_version"`
}

InstallMethod is metadata about the agent's installation

type LogsMeta

type LogsMeta struct {
	Transport            string `json:"transport"`
	AutoMultilineEnabled bool   `json:"auto_multi_line_detection_enabled"`
}

LogsMeta is metadata about the host's logs agent

type Meta

type Meta struct {
	SocketHostname            string   `json:"socket-hostname"`
	Timezones                 []string `json:"timezones"`
	SocketFqdn                string   `json:"socket-fqdn"`
	EC2Hostname               string   `json:"ec2-hostname"`
	Hostname                  string   `json:"hostname"`
	HostAliases               []string `json:"host_aliases"`
	InstanceID                string   `json:"instance-id"`
	AgentHostname             string   `json:"agent-hostname,omitempty"`
	ClusterName               string   `json:"cluster-name,omitempty"`
	LegacyResolutionHostname  string   `json:"legacy-resolution-hostname,omitempty"`
	HostnameResolutionVersion int      `json:"hostname-resolution-version,omitempty"`
}

Meta is the metadata nested under the meta key

func GetMetaFromCache

func GetMetaFromCache(ctx context.Context, conf model.Reader) *Meta

GetMetaFromCache returns the metadata information about the host from the cache and returns it, if the cache is empty, then it queries the information directly

type NetworkMeta

type NetworkMeta struct {
	ID         string `json:"network-id"`
	PublicIPv4 string `json:"public-ipv4,omitempty"`
}

NetworkMeta is metadata about the host's network

type OtlpMeta

type OtlpMeta struct {
	Enabled bool `json:"enabled"`
}

OtlpMeta is metadata about the otlp pipeline

type Payload

type Payload struct {
	Os            string            `json:"os"`
	AgentFlavor   string            `json:"agent-flavor"`
	PythonVersion string            `json:"python"`
	SystemStats   *systemStats      `json:"systemStats"`
	Meta          *Meta             `json:"meta"`
	HostTags      *hosttags.Tags    `json:"host-tags"`
	ContainerMeta map[string]string `json:"container-meta,omitempty"`
	NetworkMeta   *NetworkMeta      `json:"network"`
	LogsMeta      *LogsMeta         `json:"logs"`
	InstallMethod *InstallMethod    `json:"install-method"`
	ProxyMeta     *ProxyMeta        `json:"proxy-info"`
	OtlpMeta      *OtlpMeta         `json:"otlp"`
}

Payload handles the JSON unmarshalling of the metadata payload

func GetFromCache

func GetFromCache(ctx context.Context, conf model.Reader) *Payload

GetFromCache returns the payload from the cache if it exists, otherwise it creates it. The metadata reporting should always grab it fresh. Any other uses, e.g. status, should use this

func GetPayload

func GetPayload(ctx context.Context, conf model.Reader) *Payload

GetPayload builds a metadata payload every time is called. Some data is collected only once, some is cached, some is collected at every call.

type ProxyMeta

type ProxyMeta struct {
	NoProxyNonexactMatch              bool `json:"no-proxy-nonexact-match"`
	ProxyBehaviorChanged              bool `json:"proxy-behavior-changed"`
	NoProxyNonexactMatchExplicitlySet bool `json:"no-proxy-nonexact-match-explicitly-set"`
}

ProxyMeta is metatdata about the proxy configuration

Jump to

Keyboard shortcuts

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