monit-general
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [monit] problem in calculating process wise CPU.


From: Martin Pala
Subject: Re: [monit] problem in calculating process wise CPU.
Date: Wed, 6 Jan 2010 22:09:38 +0100

On Jan 6, 2010, at 7:03 AM, Neelam Baliyan wrote:

> 
> Hi,
> 
> There is a problem in process wise CPU calculation ,
> by formula:-
> 
> pt[i].cpu_percent =
> (int)(1000*((double)(pt[i].cputime-pt[i].cputime_prev)/(pt[i].time-pt[i].time_prev))/
> systeminfo.cpus);
> 
> 1. It always give constant value.

The *time[_prev] value represents share of CPU time used by process during one 
monitoring cycle. It's value is not constant unless the process CPU usage is 
not constant. For example if you have 4 CPU cores (total 4 cores = 100% CPU 
resources, 1 CPU core = 25% CPU resources) and one single-threaded process 
utilizes one CPU core (which is max of what single-threaded process can do), 
Monit will report its CPU usage as 25% constantly (which corresponds to 1 CPU 
core).


> 
> 2. why we are deviding it by systeminfo.cpus?

Monit interprets sum of all available CPU resources (CPU cores) on system as 
100% - see above example.


> 
> 3. what is paronia ? monit used it like below but if our process is taking
> 100% CPU,monit will constant cpu_percent value to 50% why ?

"Paranoia" is just sanity check for virtually impossible case when CPU usage 
will exceed 100% ... hence this sanity check it is commented in code as 
paranoia.

In your case 50% is most probably reported because you have 2 CPU cores as 
explained above and the process hogs only one of them.



> 
> /* Just for paranoia! */
>        if(pt[i].cpu_percent > 1000 / systeminfo.cpus)
>        {
>            pt[i].cpu_percent = 1000 / systeminfo.cpus;
> 
>        }
> 
> Thanks & Regards
> Neelam
> 
> 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]