Running AHFCTL Commands to Limit CPU and Memory Usage
You need root access to ahfctl, or sudo access to run getresourcelimit, setresourcelimit, unsetresourcelimit commands.
Note:
The following commands are enabled only on Linux 64.
ahfctl getresourcelimit
Use the ahfctl getresourcelimit command to fetch details of Oracle Trace File Analyzer CPU and memory usage limitations.
Syntax
ahfctl getresourcelimit
[-tool tool_name]
[-resource resource_type]
Parameters
ahfctl getresourcelimit Command Parameters
| Parameter | Description |
|---|---|
tool | Currently, you can only specify tfa. |
resource | You can specify either CPU or memory. |
Example getresourcelimit Example
# ahfctl getresourcelimit
Tool TFA: Resource CPU: Limit value: 1
ahfctl setresourcelimit
Use the ahfctl setresourcelimit command to restrict the CPU and memory usage of Oracle Trace File Analyzer.
Note:
This feature is available only on Linux and only when Autonomous Health Framework is installed using a full installation by the root user.
AHF 25.1
CPU Resource Limiting on Oracle Linux 9
AHF now supports CPU resource limiting using cgroups v2, which is the default on Oracle Linux 9.
By default, AHF's CPU usage is automatically restricted through the Linux cgroups feature, ensuring it does not consume excessive CPU resources out of the box. Users can easily adjust the CPU allocation for AHF to meet their specific needs. Oracle Linux 9 introduces the new cgroups v2 as its default, and starting with AHF 25.1, both cgroups v1 and v2 are fully supported by AHF.
Syntax
ahfctl setresourcelimit [-h]
[-tool {tfa}]
[-resource {cpu,kmem,swmem}]
[-value VALUE]
[-debug]
[-force]
Parameters
ahfctl setresourcelimit Command Parameters
| Parameter | Description |
|---|---|
value | Set the limit to a minimum of 50% of a single CPU, and a maximum of 4 or 75% of the available CPUs, whichever is lower. By default, the CPU limit is set to the maximum. To limit TFA to a maximum of 50% of a single CPU: You can limit memory usage either at the system level using Set the kernel memory to a minimum of 500 MB, and a maximum of 2048 MB or 20% of the available memory, whichever is lower. By default, the kernel memory (kmem) limit is not set. Set the system and swap memory to a minimum of 1024 MB, and a maximum of 8192 MB or 50% of the available memory, whichever is lower. By default, the system and swap memory (swmem) limit is not set. |
tool | Currently, you can only specify Default: |
resource | You can specify either CPU or memory. |
value | Specify to limit the value.
|
debug | Specify to enable debugging. |
force | Specify to set the resource value beyond the max_value. |
Example setresourcelimit Examples
On a server with 10 CPUs, the default limit will be 4 CPUs:
# ahfctl setresourcelimit
Tool TFA: Resource CPU: Limit value: 4
On a server with 4 CPUs, the default limit will be 3 CPUs (75% of available CPUs):
ahfctl setresourcelimit
Tool TFA: Resource CPU: Limit value: 3
# ahfctl setresourcelimit -value 2
Tool TFA: Resource CPU: Limit value: 2
To limit the memory usage to only 500 MB of system memory run:
ahfctl setresourcelimit -resource kmem -value 500
To limit the combined total of system memory and the swap memory to 1 GB run:
ahfctl setresourcelimit -resource swmem -value 1024
ahfctl unsetresourcelimit
Use the ahfctl unsetresourcelimit command to unset the limitations set on Oracle Trace File Analyzer CPU and memory usage.
Syntax
ahfctl unsetresourcelimit
[-tool tool_name]
[-resource resource_type]
Parameters
ahfctl unsetresourcelimit Command Parameters
| Parameter | Description |
|---|---|
tool | Currently, you can only specify tfa. |
resource | You can specify either CPU or memory. |
Example unsetresourcelimit Example
# ahfctl unsetresourcelimit -tool tfa -resource cpu
ahfctl printresourcestats
Use the ahfctl printresourcestats command to view statistics of the specified resource.
Note:
You can run ahfctl printresourcestats only if you have run the corresponding setresourcelimit command. The resource is managed by Oracle Trace File Analyzer cgroups.
Syntax
ahfctl printresourcestats
[-tool tool_name]
[-resource resource_type]
Parameters
ahfctl printresourcestats Command Parameters
| Parameter | Description |
|---|---|
tool | Currently, you can only specify tfa. |
resource | You can specify either CPU or memory. |