Recalculate Load Avg with PS, why is so different?

ari_yagui

New Member
Joined
Dec 20, 2022
Messages
1
Reaction score
0
Credits
27
Hi, i need some help with load avg, we registers the loadavg each 5 seconds, and inmediatly next the states off all processes with 'ps aux', al this it's done inside one script. In theroy the load avg of 1 minutne is L(t) = L(t-1)*(e^(-5/60) + A(1- e^(-5/60)), with L(t) is the actual load avg, L(t-1) is previous load avg, e^(-5/60) is a constant aprox 0.92004441462 ~ 0.92, so (1-e^(-5/60)) is ~ 0.08, and A is the numbers of all processes in state R or D.

Well, if we calculates the load avg based in the PS it is completly diferente of the load avg informed by top or some other command.

Here is a list with the data informed by the script.
Columns:
1) Load Avg informed by de system (1 minute):
2) Total processes in state R or D informed by de PS inmediatly next of get the load avg.
3) Processes in state D
4) Total Processes
5) Load Avg calculated based in the states informed by column 2, (The first line is filled with the load avg informed by the system at thats time, 9.08). This column should be very similar to the column 1, but is not the case. The diference is too much.

Plase can someone can explain me what happend? if i do something wrong o the formula of load avg is no thats?

This comparission was done many times in a lapse or 20 minutos each, and always show similar results, the load avg informed is very different of load avg calculated based in the processes informed by the 'ps' with state R or D.

Thanks.



1minProcesos Activos (R, D)Procesos DTotal ProcesosLoad Avg (Recalculado)
9,086015379,08
8,432015348,51
8,965015378,23
12,491015347,65
20,941015407,12
27,753015366,79
31,211015366,33
37,22015355,98
39,275015335,90
43,975115365,83
57,424015365,69
56,274015365,55
55,933015335,35
57,295015335,32
62,084015335,21
59,032015324,96
62,233015334,80
59,093015344,66
58,444015344,60
61,453015354,48
58,933015354,36
55,575115344,41
54,724015364,38
54,433015394,27
50,639015354,64
47,122015364,43
43,511015364,16
43,554015364,15
40,625015344,21
37,692015344,04
35,634015334,03
34,624015374,03
32,096015344,19
30,083015274,09
29,835015264,17
30,816015254,31
 


If I'm reading this right, it definitely looks like there's a problem with your formula. The first value matches up, that makes sense (9.08 9.08)
The second value goes down for both and are pretty close (8.43 8.51)
But on the third (8.96 8.23), the system load is higher than the previous value, while your recalculated is lower. This shouldn't happen in a weighted average.

Also, for what it's worth, Google says the load average for Unix systems is 1 - 1/e or 63% for t-1 and 1/e (37%) for average since startup. It doesn't explain the divergence above, but it might be part of the reason you're off.
 
That last term looks odd to me. Are you sure it's not supposed to be something like L(A)*(1 - e^(-5/60))
Instead of A(1 - e^(-5/60))?
 

Members online


Top