Created on
‎06-11-2024
06:15 AM
Edited on
‎09-03-2024
06:00 AM
By
Jean-Philippe_P
Description | This article describes how to analyze high CPU usage on a FortiGate. |
Scope | FortiGate, FortiOS. |
Solution |
It is important to understand how CPU usage is measured:
The CPU can be mainly used by 3 distinct spaces:
Better options to start investigating are 'get sys performance status' and 'diagnose sys mpstat <refresh seconds>'.
get sys performance status
Once the main type of usage has been identified, the focus can be moved to the specific use space.
At this point, 'diagnose system top' can be used to identify the application that is consuming all the CPU time and debug it with the specific application debug commands.
Additional information about a process (like the last CPU it ran, status, syscalls, memory usage, etc) can be gathered in the following underlying directories:
fnsysctl cat /proc/<pid>/status
Refer to the Linux man page to understand these files.
System: If high CPU usage is seen in system space, a CPU profiling can show what the most frequently called functions in the source code are, whether they are Linux kernel functions or Fortinet-specific system functions. This will give an idea of what is going on at the system level during a specific amount of time. After identifying which CPU is experiencing high system usage, run the following commands:
fnsysctl date diag sys profile start
Wait approximately 10 to 30 seconds.
diag sys profile stop diagnose sys profile show detail
Show order will print something like this:
0xffffffff8025fb50: 454 vprintk_emit+0x190/0x4f0
Note that poll_idle is the kernel function executed when no other function is being executed to measure the actual CPU usage, as stated at the beginning. For further investigation, it will be necessary to involve Fortinet support.
Interrupts (hardware or software interrupts) are special functions triggered when certain events occur. They order the CPU to interrupt the current operation to execute the actual raised interrupt handler. This means the CPU is not waiting for the event to occur, but the interrupt sends the signal to the CPU upon being triggered and executes an interrupt of related code (a real-life analogy would be ringing a doorbell, so when the door rings the people inside stop what they are doing to check who is at the door).
On a firewall or network devices in general, the main source of interrupts is network packets received on interfaces.
High IRQ could mean an L2 issue such as L2 broadcast storms, a high number of non-offloaded sessions, or just a high session setup rate. To investigate high softirq or irq, obtain useful information about session setup rate and offloaded vs non-offloaded sessions with 'get sys performance status'.
get sys performance status
Additionally, use the command 'diagnose sys session stat':
diagnose sys session stat
EG --> 0xffffffffa0164feb: 1 np6_clean_rx+0xcb/0xe30
To have an idea on how interrupts are distributed among CPUs, run the following:
diagnose hardware sysinfo interrupts
Or:
fnsysctl cat /proc/interrupts
fnsysctl cat /proc/interrupts ...
Each line of the above output represents an interrupt with its unique ID a counter for each CPU so that the user can see on which CPU the interrupt is executed. Every interrupt is configured with an affinity to a CPU or a set of CPUs, this affinity can be reviewed with the below commands:
fnsysctl cat /proc/irq/<IRQ ID>/smp_affinity_list --> decimal fnsysctl cat /proc/irq/<IRQ ID>/smp_affinity --> HEX mask
So, as per the previous output, it is possible to see that the configured affinity for interrupt NP6_0_tx-rx3 (ID:145, this interrupt is raised when NP6 0 is sending non-offloaded traffic to the kernel or when non-offloaded traffic processed by the kernel needs to be sent out through an interface) has an affinity with CPU 3 and it has been executed on CPU 3 3319842 times.
fnsysctl cat /proc/irq/145/smp_affinity
fnsysctl cat /proc/irq/145/smp_affinity_list |
The Fortinet Security Fabric brings together the concepts of convergence and consolidation to provide comprehensive cybersecurity protection for all users, devices, and applications and across all network edges.
Copyright 2025 Fortinet, Inc. All Rights Reserved.