0

https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/receiver/hostmetricsreceiver/internal/scraper/processscraper/documentation.md

I have been using this library which gives me 3 values for a single process :

user time, system time & wait time

One example value is : 0.05, 0.01, 0.00

How can I calculate CPU percent of the particular process ?

Keval Bhogayata
  • 4,422
  • 3
  • 13
  • 36

1 Answers1

2

To calculate the total CPU load/utilization percent of the system, we need to calculate "total system cpu time (during the period)" + "total user cpu time (during the period)" / "period"

In your case, suppose you take sample every 2 seconds, then for every sample, you need to calculate:

= ( (process.cpu.time.sys - previous_process.cpu.time.sys) + (process.cpu.time.user - previous_process.cpu.time.user) ) / 2
lprakashv
  • 1,121
  • 10
  • 19