os

package
v0.3.8 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2025 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package os queries the host OS information (e.g., kernel version).

Index

Constants

View Source
const (
	StateNameVirtualizationEnvironment         = "virtualization_environment"
	StateKeyVirtualizationEnvironmentType      = "type"
	StateKeyVirtualizationEnvironmentVM        = "vm"
	StateKeyVirtualizationEnvironmentContainer = "container"
	StateKeyVirtualizationEnvironmentIsKVM     = "is_kvm"

	StateNameSystemManufacturer = "system_manufacturer"
	StateKeySystemManufacturer  = "system_manufacturer"

	StateNameMachineMetadata             = "machine_metadata"
	StateKeyMachineMetadataBootID        = "boot_id"
	StateKeyMachineMetadataDmidecodeUUID = "dmidecode_uuid"
	StateKeyMachineMetadataOSMachineID   = "os_machine_id"

	StateNameHost  = "host"
	StateKeyHostID = "id"

	StateNameKernel       = "kernel"
	StateKeyKernelArch    = "arch"
	StateKeyKernelVersion = "version"

	StateNamePlatform       = "platform"
	StateKeyPlatformName    = "name"
	StateKeyPlatformFamily  = "family"
	StateKeyPlatformVersion = "version"

	StateNameUptimes                   = "uptimes"
	StateKeyUptimesSeconds             = "uptime_seconds"
	StateKeyUptimesHumanized           = "uptime_humanized"
	StateKeyUptimesBootTimeUnixSeconds = "boot_time_unix_seconds"
	StateKeyUptimesBootTimeHumanized   = "boot_time_humanized"

	StateNameProcessCountsByStatus      = "process_counts_by_status"
	StateKeyProcessCountZombieProcesses = "process_count_zombie_processes"
)

Variables

View Source
var DefaultZombieProcessCountThreshold = 1000

Functions

func CreateGet added in v0.3.5

func CreateGet(cfg Config) func(ctx context.Context) (_ any, e error)

func New

func ParseStateProcessCountZombieProcesses added in v0.1.5

func ParseStateProcessCountZombieProcesses(m map[string]string) (int, error)

func ParseStateSystemManufacturer added in v0.3.5

func ParseStateSystemManufacturer(m map[string]string) (string, error)

func ParseStateVirtualizationEnvironment added in v0.3.5

func ParseStateVirtualizationEnvironment(m map[string]string) (pkg_host.VirtualizationEnvironment, error)

Types

type Config

type Config struct {
	Query query_config.Config `json:"query"`
}

func ParseConfig

func ParseConfig(b any, dbRW *sql.DB, dbRO *sql.DB) (*Config, error)

func (Config) Validate

func (cfg Config) Validate() error

type Host

type Host struct {
	ID string `json:"id"`
}

func ParseStateHost

func ParseStateHost(m map[string]string) (Host, error)

type Kernel

type Kernel struct {
	Arch    string `json:"arch"`
	Version string `json:"version"`
}

func ParseStateKernel

func ParseStateKernel(m map[string]string) (Kernel, error)

type MachineMetadata added in v0.3.5

type MachineMetadata struct {
	BootID        string `json:"boot_id"`
	DmidecodeUUID string `json:"dmidecode_uuid"`
	OSMachineID   string `json:"os_machine_id"`
}

func ParseStateMachineMetadata added in v0.3.5

func ParseStateMachineMetadata(m map[string]string) (MachineMetadata, error)

type Output

type Output struct {
	VirtualizationEnvironment   pkg_host.VirtualizationEnvironment `json:"virtualization_environment"`
	SystemManufacturer          string                             `json:"system_manufacturer"`
	MachineMetadata             MachineMetadata                    `json:"machine_metadata"`
	MachineRebooted             bool                               `json:"machine_rebooted"`
	Host                        Host                               `json:"host"`
	Kernel                      Kernel                             `json:"kernel"`
	Platform                    Platform                           `json:"platform"`
	Uptimes                     Uptimes                            `json:"uptimes"`
	ProcessCountZombieProcesses int                                `json:"process_count_zombie_processes"`
}

func ParseOutputJSON

func ParseOutputJSON(data []byte) (*Output, error)

func ParseStatesToOutput

func ParseStatesToOutput(states ...components.State) (*Output, error)

func (*Output) JSON

func (o *Output) JSON() ([]byte, error)

func (*Output) States

func (o *Output) States() ([]components.State, error)

type Platform

type Platform struct {
	Name    string `json:"name"`
	Family  string `json:"family"`
	Version string `json:"version"`
}

func ParseStatePlatform

func ParseStatePlatform(m map[string]string) (Platform, error)

type Uptimes

type Uptimes struct {
	Seconds          uint64 `json:"seconds"`
	SecondsHumanized string `json:"seconds_humanized"`

	BootTimeUnixSeconds uint64 `json:"boot_time_unix_seconds"`
	BootTimeHumanized   string `json:"boot_time_humanized"`
}

func ParseStateUptimes

func ParseStateUptimes(m map[string]string) (Uptimes, error)

Directories

Path Synopsis
Package id represents the OS ID.
Package id represents the OS ID.

Jump to

Keyboard shortcuts

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