039 cpu usage fix sockets discarded

This commit is contained in:
2026-04-07 10:35:46 +03:00
parent 990d678c14
commit a35f5a3ba2
2 changed files with 17 additions and 18 deletions
+16 -17
View File
@@ -19,7 +19,7 @@ capacity as (
select "Cluster" as cluster, count(*) as hosts, sum(cores) as cores, round(sum(ghz)::numeric,1) as ghz, round(sum(ram)) as ram
from (
select "Cluster", "Host"
, avg("Host_CPU_Cores"*"Host_CPU_Sockets") as cores, avg("Host_CPU_Cores"*"Host_CPU_Sockets"*"Host_CPU_Speed") as ghz, avg("Host_RAM"*.85) as ram
, avg("Host_CPU_Cores") as cores, avg("Host_CPU_Cores"*"Host_CPU_Speed") as ghz, avg("Host_RAM"*.85) as ram
from vmreports.compute
where ts=(select max(ts) from vmreports.compute)
group by "Cluster","Host"
@@ -52,13 +52,13 @@ SELECT
,COUNT(*)-1 as hosts_ha /*не вполне корректно, хосты разного размера, отказ по-разному влияет*/
,sum(CASE WHEN "Maintenance"='inMaintenance' THEN 1 ELSE 0 END) as hosts_in_maintenance
,sum(CASE WHEN "Maintenance"='notInMaintenance' THEN 1 ELSE 0 END) as hosts_in_service
,sum("CPU_Cores"*"CPU_Sockets") as cores
,sum(CASE WHEN "Maintenance"='notInMaintenance' THEN "CPU_Cores"*"CPU_Sockets" ELSE 0 END) as cores_in_service
,sum(CASE WHEN "Maintenance"='notInMaintenance' THEN "CPU_Cores"*"CPU_Sockets"*"CPU_Speed" ELSE 0 END) as ghz_in_service
,sum("CPU_Cores") as cores
,sum(CASE WHEN "Maintenance"='notInMaintenance' THEN "CPU_Cores" ELSE 0 END) as cores_in_service
,sum(CASE WHEN "Maintenance"='notInMaintenance' THEN "CPU_Cores"*"CPU_Speed" ELSE 0 END) as ghz_in_service
,sum("CPU_Used_AVG") as host_ghz_usage
,(sum(CASE WHEN "Maintenance"='notInMaintenance' THEN "RAM_Total" ELSE 0 END)) as ram_in_service
,(avg(CASE WHEN "Maintenance"='notInMaintenance' THEN "CPU_Speed" ELSE 0 END)) as ghz
,CASE WHEN sum("CPU_Cores"*"CPU_Sockets"*"CPU_Speed") > 0 THEN sum("CPU_Used_AVG")/sum("CPU_Cores"*"CPU_Sockets"*"CPU_Speed")*100 ELSE NULL END as cpu_usage_perc
,CASE WHEN sum("CPU_Cores"*"CPU_Speed") > 0 THEN sum("CPU_Used_AVG")/sum("CPU_Cores"*"CPU_Speed")*100 ELSE NULL END as cpu_usage_perc
FROM vmreports.host h
LEFT OUTER JOIN (
SELECT hi."Cluster", STRING_AGG(DISTINCT hi."Model" || ' [' || (hi.cnt::text) || '] ',', ') as models
@@ -190,12 +190,11 @@ from qRead
<th width="3%"><layout:column_head name="hosts_ha"/></th>
<th width="3%"><layout:column_head name="hosts_in_maintenance"/></th>
<th width="3%"><layout:column_head name="hosts_in_service"/></th>
<th width="3%"><layout:column_head name="ram_in_service"/></th>
<th width="3%"><layout:column_head name="cores_in_service"/></th>
<th width="3%"><layout:column_head name="ghz_in_service"/></th>
<th width="3%"><layout:column_head name="host_ghz_usage"/></th>
<th width="3%"><layout:column_head name="vm_ghz_usage"/></th>
<th width="3%"><layout:column_head name="ram_in_service"/></th>
<th width="3%"><layout:column_head name="vm_ghz_usage"/></th>
<th width="3%"><layout:column_head name="cpu_usage_perc"/></th>
<th width="3%"><layout:column_head name="vm_cpu_usage_perc"/></th>
<th width="3%"><layout:column_head name="oversubscription"/></th>
@@ -227,14 +226,14 @@ from qRead
<td class="r">#hosts_total#</td>
<td class="r">#hosts_ha#</td>
<td class="r">#hosts_in_maintenance#</td>
<td class="r">#hosts_in_service#</td>
<td class="r">#hosts_in_service#</td>
<td class="r">#numberFormat(ram_in_service,"0")#</td>
<td class="r">#cores_in_service#</td>
<td class="r">#numberFormat(ghz_in_service,".0")#</td>
<td class="r" style="background:lightcoral">#numberFormat(host_ghz_usage,".0")#</td>
<td class="r" style="background:lightcoral">#numberFormat(vm_ghz_usage,".0")#</td>
<td class="r">#numberFormat(ram_in_service,"0")#</td>
<td class="r" style="background:lightcoral">#numberFormat(cpu_usage_perc,"0")#</td>
<td class="r" style="background:lightcoral">#numberFormat(vm_cpu_usage_perc,"0")#</td>
<td class="r">#numberFormat(host_ghz_usage,".0")#</td> <!--- style="background:lightcoral" --->
<td class="r">#numberFormat(vm_ghz_usage,".0")#</td>
<td class="r">#numberFormat(cpu_usage_perc,"0")#</td>
<td class="r">#numberFormat(vm_cpu_usage_perc,"0")#</td>
<td class="r">#oversubscription#</td>
<td></td>
<td class="r">#hosts#</td>
@@ -260,12 +259,12 @@ from qRead
<td class="r">#hosts_ha#</td>
<td class="r"></td>
<td class="r"></td>
<td class="r"></td>
<td class="r"></td>
<td class="r">#numberFormat(ram_in_service,"0")#</td>
<td class="r">#cores_in_service#</td>
<td class="r">#numberFormat(ghz_in_service,".0")#</td>
<td class="r"></td>
<td class="r"></td>
<td class="r">#numberFormat(ram_in_service,"0")#</td>
<td class="r"></td>
<td class="r"></td>
<td class="r"><!--- #cpu_usage_perc# ---></td>
<td class="r" style="font-size:130%;">#numberFormat(vm_cores/cores_in_service,".0")#</td>