os

package
v0.0.1-alpha9 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

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

Index

Constants

View Source
const (
	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"
)
View Source
const Name = "os"

Variables

This section is empty.

Functions

func Get

func Get(ctx context.Context) (_ any, e error)

func New

Types

type Config

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

func ParseConfig

func ParseConfig(b any, db *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 Output

type Output struct {
	Host     Host     `json:"host"`
	Kernel   Kernel   `json:"kernel"`
	Platform Platform `json:"platform"`
	Uptimes  Uptimes  `json:"uptimes"`
}

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)

Jump to

Keyboard shortcuts

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