Skip to main content

Sysctl

Kernel parameters, written to sysctl.d files and applied. osapi behavior get --name sysctl and osapi behavior method get show the same. Its chain shows each call that its examples make.

Behavior​

Namesysctl
DescriptionKernel parameters, written to sysctl.d files and applied
Placementnode
Internalno
APIyes
CLIyes
Nextno
Platformsdebian
Sudosysctl
Runsnone
Writes/etc/sysctl.d/osapi-*.conf
Keeps stateno
Usesmanagedfile
Used bynone

Methods (5)​

NAMEVERBHTTPROUTEPERMISSIONDESCRIPTION
listreadGET/api/node/{hostname}/sysctlsysctl:readList the kernel's parameters and which osapi manages
getreadGET/api/node/{hostname}/sysctl/{key}sysctl:readGet a kernel parameter's current value, and whether osapi manages it
createwritePOST/api/node/{hostname}/sysctlsysctl:writeManage a kernel parameter and apply it
updatewritePUT/api/node/{hostname}/sysctl/{key}sysctl:writeSet a kernel parameter, manage it, and apply it
deletewriteDELETE/api/node/{hostname}/sysctl/{key}sysctl:writeStop the management of a kernel parameter

Types (5)​

NAMEINPUTOUTPUT
listListInput { prefix }[]Entry { key, value, managed }
getGetInput { key* }Entry { key, value, managed }
createCreateInput { key*, value* }MutationResult { key, changed }
updateUpdateInput { key*, value* }MutationResult { key, changed }
deleteDeleteInput { key* }MutationResult { key, changed }

Settings (1)​

KEYAGENT FLAGTYPEDEFAULT
behaviors.sysctl.dir--sysctl-dirstring/etc/sysctl.d

Telemetry​

Spanbehavior.sysctl.<method>
Child spansbehavior.managedfile.<method>, exec sysctl, exec chown, exec stat, file.write, file.remove, file.chmod, kv.get, kv.put
Metricsosapi_behavior_calls_total, osapi_behavior_duration_seconds, osapi_behavior_changes_total
Attributesosapi.behavior.name, osapi.behavior.method, osapi.behavior.verb, osapi.behavior.outcome, osapi.behavior.changed
Recorded inputskey (get, create, update, delete)

Method list​

Namelist
Verbread
DescriptionList the kernel's parameters and which osapi manages
DetailLists every parameter the kernel shows under /proc/sys, with its current value, as sysctl -a does, and marks the ones osapi manages. A prefix, such as net.ipv4, limits the list to that part of the tree. The kernel can lack a parameter that osapi manages, for example when its module is not loaded. Then the list shows the value that osapi wrote.
HTTPGET
Route/api/node/{hostname}/sysctl
Permissionsysctl:read
Commandosapi client node sysctl list
Input typeListInput
Output type[]Entry

Input (1)​

FIELDTYPEREQUIREDCONSTRAINTSDESCRIPTION
prefixstringnopattern ^[a-zA-Z0-9][a-zA-Z0-9._-]*$Only this parameter and the ones under it, such as net.ipv4

Output (3)​

FIELDTYPEDESCRIPTION
keystringParameter name
valuestringCurrent runtime value
managedbooleanWhether osapi manages it: a file of its own sets it at boot

Examples (3)​

EXAMPLEINPUTOUTPUT
Every parameter, and which osapi managesprefix=[key=kernel.panic, managed=false, value=0] [key=net.ipv4.ip_forward, managed=true, value=1] [key=net.ipv4.ping_group_range, managed=false, value=0 2147483647]
One part of the treeprefix=net.ipv4[key=net.ipv4.ip_forward, managed=true, value=1] [key=net.ipv4.ping_group_range, managed=false, value=0 2147483647]
A managed parameter the kernel does not have right nowprefix=net.bridge[key=net.bridge.bridge-nf-call-iptables, managed=true, value=1]

Method get​

Nameget
Verbread
DescriptionGet a kernel parameter's current value, and whether osapi manages it
HTTPGET
Route/api/node/{hostname}/sysctl/{key}
Permissionsysctl:read
Commandosapi client node sysctl get
Input typeGetInput
Output typeEntry

Input (1)​

FIELDTYPEREQUIREDCONSTRAINTSDESCRIPTION
keystringyespattern ^[a-zA-Z0-9][a-zA-Z0-9._-]*$, min length 1Parameter name, such as net.ipv4.ip_forward

Output (3)​

FIELDTYPEDESCRIPTION
keystringParameter name
valuestringCurrent runtime value
managedbooleanWhether osapi manages it: a file of its own sets it at boot

Examples (4)​

EXAMPLEINPUTOUTPUT
A parameter osapi manageskey=vm.swappinesskey=vm.swappiness, value=10, managed=true
A parameter osapi does not managekey=vm.swappinesskey=vm.swappiness, value=60, managed=false
A value of several fieldskey=net.ipv4.ping_group_rangekey=net.ipv4.ping_group_range, value=0 2147483647, managed=false
A managed parameter the kernel does not have right nowkey=net.bridge.bridge-nf-call-iptableskey=net.bridge.bridge-nf-call-iptables, value=1, managed=true

Method create​

Namecreate
Verbwrite
DescriptionManage a kernel parameter and apply it
DetailWrites osapi-net.ipv4.ip_forward.conf for net.ipv4.ip_forward to behaviors.sysctl.dir, /etc/sysctl.d by default, and applies it with sysctl -p. It fails when sysctl -p fails, because the value is not set. A second run with the same value changes nothing and reports changed: false. If the kernel has a different value, for example after a failed apply, it applies the value again.
HTTPPOST
Route/api/node/{hostname}/sysctl
Permissionsysctl:write
Commandosapi client node sysctl create
Input typeCreateInput
Output typeMutationResult

Input (2)​

FIELDTYPEREQUIREDCONSTRAINTSDESCRIPTION
keystringyespattern ^[a-zA-Z0-9][a-zA-Z0-9._-]*$, min length 1Parameter name, such as net.ipv4.ip_forward
valuestringyespattern ^[^\r\n]*$Value to set

Output (2)​

FIELDTYPEDESCRIPTION
keystringParameter name
changedbooleanWhether the host changed

Examples (1)​

EXAMPLEINPUTOUTPUT
Turn on IP forwardingkey=net.ipv4.ip_forward, value=1key=net.ipv4.ip_forward, changed=true

Method update​

Nameupdate
Verbwrite
DescriptionSet a kernel parameter, manage it, and apply it
DetailThe same as create, addressed by the parameter: osapi manages the parameter from then on whether it did before or not. Setting the value it already has reports changed: false.
HTTPPUT
Route/api/node/{hostname}/sysctl/{key}
Permissionsysctl:write
Commandosapi client node sysctl update
Input typeUpdateInput
Output typeMutationResult

Input (2)​

FIELDTYPEREQUIREDCONSTRAINTSDESCRIPTION
keystringyespattern ^[a-zA-Z0-9][a-zA-Z0-9._-]*$, min length 1Parameter name, such as net.ipv4.ip_forward
valuestringyespattern ^[^\r\n]*$Value to set

Output (2)​

FIELDTYPEDESCRIPTION
keystringParameter name
changedbooleanWhether the host changed

Examples (2)​

EXAMPLEINPUTOUTPUT
Lower swappinesskey=vm.swappiness, value=10key=vm.swappiness, changed=true
A parameter osapi did not managekey=vm.swappiness, value=10key=vm.swappiness, changed=true

Method delete​

Namedelete
Verbwrite
DescriptionStop the management of a kernel parameter
DetailRemoves the file that osapi wrote for it and reloads with sysctl --system. Then a setting for the key in a different file takes effect. If there is no such setting, the parameter keeps its current value until the next reboot. A delete of a parameter that osapi does not manage reports changed: false.
HTTPDELETE
Route/api/node/{hostname}/sysctl/{key}
Permissionsysctl:write
Commandosapi client node sysctl delete
Input typeDeleteInput
Output typeMutationResult

Input (1)​

FIELDTYPEREQUIREDCONSTRAINTSDESCRIPTION
keystringyespattern ^[a-zA-Z0-9][a-zA-Z0-9._-]*$, min length 1Parameter name, such as net.ipv4.ip_forward

Output (2)​

FIELDTYPEDESCRIPTION
keystringParameter name
changedbooleanWhether the host changed

Examples (3)​

EXAMPLEINPUTOUTPUT
Remove a parameterkey=vm.swappinesskey=vm.swappiness, changed=true
A parameter osapi does not managekey=vm.swappinesskey=vm.swappiness, changed=false
A parameter osapi already stopped managingkey=vm.swappinesskey=vm.swappiness, changed=false