---
title: "How does the process plugin compute the percent CPU in Linux?"
description: "The process plugin computes percent CPU in Linux using values from the /proc/[pid]/stat file. It calculates CPU usage by comparing jiffies between samples and adjusts for logical CPUs, with debug options available for detailed data."
url: "https://docs.itrsgroup.com/docs/faq/geneos/115004020165-geneos-how-does-the-process-plugin-compute-the-percent-cpu-in-linux/index.html"
---
**The percentCPU of the process plugin is computed from a series of variables within the code.** **The values are taken from the "/proc/<pid>/stat" file (in Linux); it is used to get the number of jiffies used since the process started.** **It takes the utime and adds it to the stime. It takes the difference between the last sample and this sample, then divides by the number of seconds between samples. An adjustment happens for the number of logical CPUs.**

**Additional Notes**

- If less than three jiffies have been used, then the

value will be reported as 0. - The fields in the /proc/<pid>/stat file can

be seen by doing 'man proc'. - The data is shared between multiple instances of

the sampler on the same probe - running multiple

at very fast sample rates will hit the 'more than

three jiffies needed' limit.

The values used in the calculation can be seen by enabling debug: This is set in the probe debug 'Debug' section where the Module is processes, and setting is \*

The debug output looks like this:

```
DEBUG: *:pcpu Proc: 12864 [210 - 187 = 23] [1217495784 - 1217495764 = 20] 1.150000 /home/example/example -foo bar
```

The fields are:

<pid> [<jiffies> - <jiffies last sample> = <jiffies
used this sample>] [<time> - <last sample time> = <time
since last sample>] <cpu usage> <args>


