Collectd: How we can see the CPU usage of processes as percentage?

Created on 16 Jul 2018  路  4Comments  路  Source: collectd/collectd

  • Version of collectd: collectd-5.8.0
  • Operating system / distribution: Ubuntu 14.04 and ARM_Linux

Expected behavior

I am monitoring the CPU usage of different processes running on the target board (using Processes plugin)
I would like to see the user and system CPU usage of the processes in percentage.

Actual behavior

The user and system CPU usage of the processes are displayed as some numbers (like MAX = 6.88 K ) in grafana.

How we can see the CPU usage of processes as percentage?

user question

Most helpful comment

Hi!

Processes plugin, like other plugins, report ps_cputime metric in microseconds of used CPU time.
So, value of 1 000 000 is 100% of one core - e.g. process used 1 second of CPU time per 1 second of wallclock, but it can use 200%, 300%, 400%, etc if it uses threads (for example) and your system has multiple CPU units/cores.

So, if you need to know percentage related to all available CPU, when you have to divide this value to this number of available cores.

Collectd has a metric for number of available cores for simplifier solution of this task, provided by cpu plugin.

All 4 comments

Hi!

Processes plugin, like other plugins, report ps_cputime metric in microseconds of used CPU time.
So, value of 1 000 000 is 100% of one core - e.g. process used 1 second of CPU time per 1 second of wallclock, but it can use 200%, 300%, 400%, etc if it uses threads (for example) and your system has multiple CPU units/cores.

So, if you need to know percentage related to all available CPU, when you have to divide this value to this number of available cores.

Collectd has a metric for number of available cores for simplifier solution of this task, provided by cpu plugin.

Thanks for the reply.

Could you please answer below queries too?
1) Is there any method to get the sum of user and system time of these processes?

2) In my case, the interval is set to 20 in the collectd.conf file. So should I divide the value by 20 also?
Is the below given formula correct?
The percentage of CPU at 2018-07-17 17:35:00 = (6500 * 100 )/(20 * 1000000)
The percentage of CPU at 2018-07-17 17:35:20 = (8000 * 100 )/(20 * 1000000)

        <!-- 2018-07-17 17:35:00 IST / 1531829100 --> <row><v>6.5000000000e+03</v><v>2.5000000000e+03</v></row>
        <!-- 2018-07-17 17:35:20 IST / 1531829120 --> <row><v>8.0000000000e+03</v><v>2.5000000000e+03</v></row>
        <!-- 2018-07-17 17:35:40 IST / 1531829140 --> <row><v>7.0000000000e+03</v><v>3.5000000000e+03</v></row>
        <!-- 2018-07-17 17:36:00 IST / 1531829160 --> <row><v>3.5000000000e+03</v><v>5.5000000000e+03</v></row>
        <!-- 2018-07-17 17:36:20 IST / 1531829180 --> <row><v>8.0000000000e+03</v><v>2.5000000000e+03</v></row>

In my case, the interval is set to 20 in the collectd.conf file. So should I divide the value by 20 also?

Default Interval value is 10, but I don't remember we have to divide by 10.
AFAIK, Collectd knows about interval when it produces DERIVE values, so, as said before, value is microseconds of used CPU core per second of real time.

Is there any method to get the sum of user and system time of these processes?

AFAIK, Graphana can to do math.?

No need to divide by interval.
And to confirm what @rpv-tomsk said: you can either stack the two series in grafana, or your datasource might do the math for you

Was this page helpful?
0 / 5 - 0 ratings

Related issues

octo picture octo  路  38Comments

shastah picture shastah  路  11Comments

kszarlej picture kszarlej  路  4Comments

rpv-tomsk picture rpv-tomsk  路  5Comments

shastah picture shastah  路  11Comments