package coresys

import "github.com/purpleidea/mgmt/lang/core/sys"

Index

Constants

const (
	// CPUCountFuncName is the name this fact is registered as. It's still a
	// Func Name because this is the name space the fact is actually using.
	CPUCountFuncName = "cpu_count"
)
const (
	// HostnameFuncName is the name this fact is registered as. It's still a
	// Func Name because this is the name space the fact is actually using.
	HostnameFuncName = "hostname"
)
const (
	// LoadFuncName is the name this fact is registered as. It's still a
	// Func Name because this is the name space the fact is actually using.
	LoadFuncName = "load"
)
const (
	// LoadScale factor scales the output from sysinfo to the correct float
	// value.
	LoadScale = 65536 // XXX: is this correct or should it be 65535?
)
const (
	// ModuleName is the prefix given to all the functions in this module.
	ModuleName = "sys"
)
const (
	// UptimeFuncName is the name this fact is registered as. It's still a
	// Func Name because this is the name space the fact is actually using.
	UptimeFuncName = "uptime"
)

Functions

func DefaultEnv

func DefaultEnv(ctx context.Context, input []types.Value) (types.Value, error)

DefaultEnv gets environment variable by name or returns default if non existing.

func Env

func Env(ctx context.Context, input []types.Value) (types.Value, error)

Env returns a map of all keys and their values.

func GetEnv

func GetEnv(ctx context.Context, input []types.Value) (types.Value, error)

GetEnv gets environment variable by name or returns empty string if non existing.

func HasEnv

func HasEnv(ctx context.Context, input []types.Value) (types.Value, error)

HasEnv returns true if environment variable exists.

Types

type CPUCountFact

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

CPUCountFact is a fact that returns the current CPU count.

func (*CPUCountFact) Call

func (obj *CPUCountFact) Call(ctx context.Context) (types.Value, error)

Call this fact and return the value if it is possible to do so at this time.

func (*CPUCountFact) Info

func (obj *CPUCountFact) Info() *facts.Info

Info returns static typing info about what the fact returns.

func (*CPUCountFact) Init

func (obj *CPUCountFact) Init(init *facts.Init) error

Init runs startup code for this fact and sets the facts.Init variable.

func (CPUCountFact) Stream

func (obj CPUCountFact) Stream(ctx context.Context) error

Stream returns the changing values that this fact has over time. It will first poll sysfs to get the initial cpu count, and then receives UEvents from the kernel as CPUs are added/removed.

func (*CPUCountFact) String

func (obj *CPUCountFact) String() string

String returns a simple name for this fact. This is needed so this struct can satisfy the pgraph.Vertex interface.

type HostnameFact

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

HostnameFact is a function that returns the hostname. TODO: support hostnames that change in the future.

func (*HostnameFact) Call

func (obj *HostnameFact) Call(ctx context.Context) (types.Value, error)

Call returns the result of this function.

func (*HostnameFact) Info

func (obj *HostnameFact) Info() *facts.Info

Info returns some static info about itself.

func (*HostnameFact) Init

func (obj *HostnameFact) Init(init *facts.Init) error

Init runs some startup code for this fact.

func (*HostnameFact) Stream

func (obj *HostnameFact) Stream(ctx context.Context) error

Stream returns the single value that this fact has, and then closes.

func (*HostnameFact) String

func (obj *HostnameFact) String() string

String returns a simple name for this fact. This is needed so this struct can satisfy the pgraph.Vertex interface.

type LoadFact

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

LoadFact is a fact which returns the current system load.

func (*LoadFact) Call

func (obj *LoadFact) Call(ctx context.Context) (types.Value, error)

Call this fact and return the value if it is possible to do so at this time.

func (*LoadFact) Info

func (obj *LoadFact) Info() *facts.Info

Info returns some static info about itself.

func (*LoadFact) Init

func (obj *LoadFact) Init(init *facts.Init) error

Init runs some startup code for this fact.

func (*LoadFact) Stream

func (obj *LoadFact) Stream(ctx context.Context) error

Stream returns the changing values that this fact has over time.

func (*LoadFact) String

func (obj *LoadFact) String() string

String returns a simple name for this fact. This is needed so this struct can satisfy the pgraph.Vertex interface.

type UptimeFact

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

UptimeFact is a fact which returns the current uptime of your system.

func (*UptimeFact) Call

func (obj *UptimeFact) Call(ctx context.Context) (types.Value, error)

Call this fact and return the value if it is possible to do so at this time.

func (*UptimeFact) Info

func (obj *UptimeFact) Info() *facts.Info

Info returns some static info about itself.

func (*UptimeFact) Init

func (obj *UptimeFact) Init(init *facts.Init) error

Init runs some startup code for this fact.

func (*UptimeFact) Stream

func (obj *UptimeFact) Stream(ctx context.Context) error

Stream returns the changing values that this fact has over time.

func (*UptimeFact) String

func (obj *UptimeFact) String() string

String returns a simple name for this fact. This is needed so this struct can satisfy the pgraph.Vertex interface.

Source Files

cpucount_fact.go env.go hostname_fact.go load_fact.go load_fact_posix.go sys.go uptime_fact.go uptime_fact_posix.go

Version
v0.0.0-20250322185616-c50a578426f1 (latest)
Published
Mar 22, 2025
Platform
linux/amd64
Imports
19 packages
Last checked
4 days ago

Tools for package owners.