Skip to main content
Contributor
August 12, 2022

Technical Tip: FortiOS process to CPU association

  • August 12, 2022
  • 0 replies
  • 2328 views
Description This article describes how to identify which CPU is handling a process at a given time.
Scope FortiGate v6.2, v6.4, v7.0, and v7.2 GA releases.
Solution

Let's assume a user wants to identify which is the physical CPU is handling the OSPF process.

 

  1. It is necessary to identify the process ID [PID] of OSPFd. To use the global command in case it is operated in the VDOM environment:

 

diagnose sys process pidof ospfd

182

 

From the above result, the PID of ospfd is 182.

 

  1. The command fnsysctl cat /proc/<pid>/stat needs to be issued, it will replace the <pid> with the number generated on Step 1):

 

fnsysctl cat /proc/182/stat

 

182 (ospfd) S 178 178 178 0 -1 4202752 2204 0 0 0 3 0 0 0 5 -15 1 0 5928 213377024 1976 18446744073709551615 4194304 44303833 140736593983088 140736593982408 140663142887446 0 0 3676160 25216747 0 0 0 17 3 0 0 0 0 0

 

In the 'fnsysctl cat /proc/182/stat' output, each value separated by a space represents a field. The value at position 39th (Field 39 => Processor) indicates the CPU core on which the process last executed. The OSPFd is bound to the CPU core 3.

For a complete description of the Field Names and their corresponding Field numbers, refer to proc_pid_stat(5) Linux manual page.
 

Alternatively, the command 'diagnose sys top' can be used to check. Process ospfd below is running on CPU 5:

 

diagnose sys top 1 1000 1 | grep ospf
ospfd  231 S <  0.0 0.1 5
ospf6d 233 S    0.0 0.1 3

 

In case a user cannot remember the name of the process by heart, use this alternative global command:

 

fnsysctl ps

PID UID GID STATE CMD

228 0 0 S /bin/acd
229 0 0 S /bin/src-vis
230 0 0 S /bin/wf_monitor
231 0 0 S /bin/iotd

182 0 0 S /bin/ospfd
232 0 0 S /bin/ntpd
233 0 0 S /bin/sshd

 

The particular command generates a matrix of the running processes and the PIDs associated with them.

 

Note:

Super Admin privilege is required to run the 'fnsysctl' command. Otherwise, FortiGate will return an error as mentioned in this article: Technical Tip: fnsysctl command returns Unknown action 0.

 

Related article:

Troubleshooting Tip: How to check which CPU core is used by each daemon