[pve-devel] [PATCH manager] fix #1030: calculate correct cpu usage of pools

Fabian Grünbichler f.gruenbichler at proxmox.com
Fri Jul 1 11:15:01 CEST 2016


verified and applied.

> Dominik Csapak <d.csapak at proxmox.com> hat am 20. Juni 2016 um 12:36 geschrieben:
> 
> 
> we only added the % of the vms in a pool
> which lead to wrong results
> e.g. having a pool with 3 vms with 4 cores each and a
> cpu usage of 50% each (2 cores at 100%)
> lead to :
> 
> vm1	50%
> vm2	50%
> vm3	50%
> pool	150%
> 
> instead we new calculate the percentage for the whole pool
> 
> Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
> ---
>  PVE/API2/Cluster.pm | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/PVE/API2/Cluster.pm b/PVE/API2/Cluster.pm
> index 008674d..aeba934 100644
> --- a/PVE/API2/Cluster.pm
> +++ b/PVE/API2/Cluster.pm
> @@ -203,7 +203,13 @@ __PACKAGE__->register_method({
>  			    $pe->{maxmem} = 0 if !$pe->{maxmem};
>  			    $pe->{maxmem} += $entry->{maxmem};
>  			    $pe->{cpu} = 0 if !$pe->{cpu};
> -			    $pe->{cpu} += $entry->{cpu};
> +			    # explanation:
> +			    # we do not know how much cpus there are in the cluster at this moment
> +			    # so we calculate the current % of the cpu
> +			    # but we had already the old cpu % before this vm, so:
> +			    # new% = (old%*oldmax + cur%*curmax) / (oldmax+curmax)
> +			    $pe->{cpu} = $entry->{cpu} if !$pe->{maxcpu};
> +			    $pe->{cpu} = (($pe->{cpu} * $pe->{maxcpu}) + ($entry->{cpu} * $entry->{maxcpu})) / ($pe->{maxcpu} + $entry->{maxcpu});
>  			    $pe->{maxcpu} = 0 if !$pe->{maxcpu};
>  			    $pe->{maxcpu} += $entry->{maxcpu};
>  			}
> -- 
> 2.1.4
> 
> 
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
>



More information about the pve-devel mailing list