gen

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: MIT Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Group = endpoint.Define(
	"memory",
	"Get the memory usage of target hosts",
	endpoint.Area(area.Hardware),
	endpoint.Prefix("node/{hostname}"),
	endpoint.Uses[dispatch.Deps](),
	endpoint.Tag("memory_operations", "Memory", "Get the memory usage of target hosts"),
	endpoint.CommandNotes("The [memory behavior](../../../../../reference/behaviors/hardware/memory/memory.md) page tells where the behavior runs, what it is built on and its settings."),
	endpoint.Doc[types.RowStatus](dispatch.RowStatusDoc),
	endpoint.Get[GetRequest, MemoryGetResponse]("get").
		Handle(HandleGet).
		ID("GetNodeMemory").
		Describe("Get the memory usage of the host").
		Permission("memory:read").
		Returns("Each target host's result.").
		Explain("Reads the total, the free and the used memory, in bytes. Used is the total less what is available, which includes the cache, as free(1) reports it.").
		Example("--target web-01", "A host with 8 GiB, 2 GiB of it free").
		Result("A host with 8 GiB, 2 GiB of it free, on one host:\n\n```ansi\n$ osapi client node memory get --target web-01\n\x1b[1;38;2;0;213;255mResults:\x1b[0m\n  \x1b[38;2;10;143;176mHOSTNAME  \x1b[0m\x1b[38;2;10;143;176mSTATUS  \x1b[0m\x1b[38;2;10;143;176mMEMORY\x1b[0m\n  \x1b[1mweb-01\x1b[0m    \x1b[38;2;103;234;147mok\x1b[0m      8.0 GB 2.0 GB 4.0 GB\n\n  1 host: \x1b[38;2;103;234;147m1 ok\x1b[0m   \x1b[38;2;138;138;138mjob 550e8400-e29b-41d4-a716-446655440000\x1b[0m   \x1b[38;2;138;138;138mtrace 26e448c9dbe1c4a8d216a98c675079c9\x1b[0m\n```\n\nOn each host, where one cannot run it:\n\n```ansi\n$ osapi client node memory get --target _all\n\x1b[1;38;2;0;213;255mResults:\x1b[0m\n  \x1b[38;2;10;143;176mHOSTNAME  \x1b[0m\x1b[38;2;10;143;176mSTATUS  \x1b[0m\x1b[38;2;10;143;176mMEMORY\x1b[0m\n  \x1b[1mweb-01\x1b[0m    \x1b[38;2;103;234;147mok\x1b[0m      8.0 GB 2.0 GB 4.0 GB\n  \x1b[1mweb-02\x1b[0m    \x1b[38;2;103;234;147mok\x1b[0m      8.0 GB 2.0 GB 4.0 GB\n\n  3 hosts: \x1b[38;2;103;234;147m2 ok\x1b[0m, \x1b[38;5;222m1 skipped\x1b[0m   \x1b[38;2;138;138;138mjob 550e8400-e29b-41d4-a716-446655440000\x1b[0m   \x1b[38;2;138;138;138mtrace 26e448c9dbe1c4a8d216a98c675079c9\x1b[0m\n\n\x1b[1;38;2;255;0;255mDetails:\x1b[0m\n  \x1b[1mmac-01\x1b[0m  \x1b[38;5;222mskipped\x1b[0m  operation not supported on this OS family\n```\n\nWith `--json`, the API's response:\n\n```json\n{\n  \"job_id\": \"550e8400-e29b-41d4-a716-446655440000\",\n  \"results\": [\n    {\n      \"hostname\": \"web-01\",\n      \"memory\": {\n        \"free\": 2147483648,\n        \"total\": 8589934592,\n        \"used\": 4294967296\n      },\n      \"status\": \"ok\"\n    }\n  ]\n}\n```").
		Errors(endpoint.NotFound(behavior.ErrNotFound, "The host does not have what the request names, such as the object of a deploy."), endpoint.Conflict(behavior.ErrNotManaged, "osapi did not deploy the item, so it does not change it, or the host does not have a program that the method needs.").Because(types.ReasonNotManaged), endpoint.Conflict(behavior.ErrNotInstalled, "osapi did not deploy the item, so it does not change it, or the host does not have a program that the method needs.").Because(types.ReasonNotInstalled), endpoint.Invalid(dispatch.ErrInvalid, "The request is not valid, or the host refuses the input, such as a path that is a directory.")),
)

Group is memory as an endpoint group, which its spec comes from.

Functions

func Routes

func Routes(
	s *server.Server,
) []server.Route

Routes are the memory group's endpoints, as its definition declares them.

Types

type GetRequest

type GetRequest struct {
	Hostname string `` /* 182-byte string literal not displayed */
}

GetRequest is the request of memory get: its target and its input.

type MemoryEntry

type MemoryEntry struct {
	Hostname string          `doc:"Hostname of the agent that produced this result." json:"hostname"`
	Status   types.RowStatus `doc:"The status of the operation for this host." json:"status"`
	Memory   *memory.Usage   `doc:"The memory of the host" json:"memory,omitempty"`
	Error    *string         `doc:"Error message if the agent failed." json:"error,omitempty"`
}

MemoryEntry is the result of memory on one host.

type MemoryGetResponse

type MemoryGetResponse struct {
	JobID   string        `` /* 133-byte string literal not displayed */
	Results []MemoryEntry `json:"results"`
}

MemoryGetResponse is each target host's result.

func HandleGet

func HandleGet(
	ctx context.Context,
	d dispatch.Deps,
	in GetRequest,
) (MemoryGetResponse, error)

HandleGet runs memory get on the target, for the endpoint server.

Jump to

Keyboard shortcuts

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