Skip to main content

Behaviors

A behavior is one thing that osapi manages on a host, for example kernel parameters. You define it one time, in Go. osapi builds its routes, commands, permissions, spec, docs and tests from that definition. Behaviors in the architecture tells how. It also tells about behaviors that only other behaviors use, and about behaviors that use other behaviors.

Every behavior in this build​

Behaviors (18)​

NAMEGROUPMETHODSDESCRIPTIONINTERNAL
diskgetGet the disk usage of target hosts
hostnameget, updateGet or set the hostname of target hosts
loadgetGet the load averages of target hosts
managedfileget, update, deleteFiles osapi writes on a host and keeps a record ofyes
memorygetGet the memory usage of target hosts
netplanupdate, delete, getThe netplan files osapi writes, validated and appliedyes
objectgetThe objects of the object store of the fleet, such as a file uploaded with osapi client file uploadyes
osgetGet the operating system of target hosts
packagelist, get, create, deleteThe packages installed on the host
servicelist, get, create, update, delete, start, stop, restart, enable, disableThe systemd services of the host
statusgetThe status summary of a node
sysctllist, get, create, update, deleteKernel parameters, written to sysctl.d files and applied
timezoneget, updateThe timezone of the host
updatepackageslist, updateThe updates the package index has for the host
uptimegetGet the uptime of target hosts
dnsnetworkget, update, deleteThe DNS resolvers of each interface of the host
interfacenetworklist, get, create, update, deleteThe network interfaces of the host
routenetworklist, get, create, update, deleteThe routes of the host

osapi does not serve an internal behavior. Other behaviors require it and call it on the same host. Uses and Used by show those chains.

See what a binary has​

The binary describes its own behaviors. Thus the answer is always correct for the build that you run:

osapi behavior list # every behavior, internal ones marked
osapi behavior get --name sysctl # surfaces, platforms, chains, methods, settings
osapi behavior method get --name sysctl --method create # one method's input and output
osapi behavior validate # the rules every definition must meet

behavior get --json prints the input and the output of each method as JSON Schema. It also prints the route, the command, the permission, the examples and the refusals. An agent reads this before it calls a method.

Where they are defined​

Each behavior is a directory under internal/behavior/, and internal/behaviors/sysctl is the reference. Building a behavior covers the layout, the tags and what is generated.