038 cpu usage resaerch

This commit is contained in:
2026-04-07 08:35:08 +03:00
parent 8137eeb219
commit 990d678c14
2 changed files with 79 additions and 33 deletions
+1 -1
View File
@@ -76,7 +76,7 @@
<!--- global settings ---> <!--- global settings --->
<cfset request.RECORDS_PER_PAGE=500/> <cfset request.RECORDS_PER_PAGE=500/>
<cfset request.APP_VERSION="0.00.037"/> <cfset request.APP_VERSION="0.00.038"/>
<cfset request.STAND=getStand()/> <cfset request.STAND=getStand()/>
<cflock scope="application" type="readonly" timeout=3> <cflock scope="application" type="readonly" timeout=3>
+78 -32
View File
@@ -30,14 +30,15 @@ group by "Cluster"),
usage as ( usage as (
select "Cluster" as cluster select "Cluster" as cluster
,count("UUID_VM") as vms ,count("UUID_VM") as vms
, sum("VM_vCPU_count") as vm_cores ,sum("VM_vCPU_count") as vm_cores
, round(sum("VM_vCPU_count"*"VDC_CPU_Speed")) as vm_ghz ,(sum("VM_vCPU_count"*"VDC_CPU_Speed")) as vm_ghz
, round(sum("VM_CPU_Reserv_GHz")) as vm_ghz_reserved ,(sum("VM_CPU_Reserv_GHz")) as vm_ghz_reserved
, round(sum("VM_vCPU_count"*"VDC_CPU_Speed"*"VM_CPU_Reserv_perc"/100)) as vm_ghz_reserved_c ,(sum("VM_vCPU_count"*"VDC_CPU_Speed"*"VM_CPU_Reserv_perc"/100)) as vm_ghz_reserved_c
, round(sum("VM_vCPU_count"*"VDC_CPU_Speed"*(case when "VM_CPU_Reserv_perc" IS null then 20 when "VM_CPU_Reserv_perc"<=20 then 20 else "VM_CPU_Reserv_perc" end)/100)) as vm_ghz_promised ,(sum("VM_vCPU_count"*"VDC_CPU_Speed"*(case when "VM_CPU_Reserv_perc" IS null then 20 when "VM_CPU_Reserv_perc"<=20 then 20 else "VM_CPU_Reserv_perc" end)/100)) as vm_ghz_promised
-- promised - зарезервированные ГГц, если включить минимальное согласованное резервирование -- promised - зарезервированные ГГц, если включить минимальное согласованное резервирование
, round(sum("VM_RAM_Allocated")) as vm_ram_alloc ,(sum("VM_RAM_Allocated")) as vm_ram_alloc
, round(sum("VM_RAM_Used")) as vm_ram_used ,(sum("VM_RAM_Used")) as vm_ram_used
,sum("VM_CPU_Used_AVG") as vm_ghz_usage
from vmreports.compute from vmreports.compute
where ts=(select max(ts) from vmreports.compute) where ts=(select max(ts) from vmreports.compute)
group by "Cluster"), group by "Cluster"),
@@ -48,14 +49,16 @@ SELECT
,h."Cluster_v2" as cluster_v2 ,h."Cluster_v2" as cluster_v2
,m.models ,m.models
,COUNT(*) as hosts_total ,COUNT(*) as hosts_total
,COUNT(*)-1 as hosts_ha /*не вполне корректно, хосты разного размера, отказ по-разному влияет*/
,sum(CASE WHEN "Maintenance"='inMaintenance' THEN 1 ELSE 0 END) as hosts_in_maintenance ,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(CASE WHEN "Maintenance"='notInMaintenance' THEN 1 ELSE 0 END) as hosts_in_service
,sum("CPU_Cores"*"CPU_Sockets") as cores ,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" ELSE 0 END) as cores_in_service
,round(sum(CASE WHEN "Maintenance"='notInMaintenance' THEN "CPU_Cores"*"CPU_Sockets"*"CPU_Speed" ELSE 0 END)::numeric,1) as ghz_in_service ,sum(CASE WHEN "Maintenance"='notInMaintenance' THEN "CPU_Cores"*"CPU_Sockets"*"CPU_Speed" ELSE 0 END) as ghz_in_service
,round(sum(CASE WHEN "Maintenance"='notInMaintenance' THEN "RAM_Total" ELSE 0 END)::numeric,0) as ram_in_service ,sum("CPU_Used_AVG") as host_ghz_usage
,round(avg(CASE WHEN "Maintenance"='notInMaintenance' THEN "CPU_Speed" ELSE 0 END)::numeric,1) as ghz ,(sum(CASE WHEN "Maintenance"='notInMaintenance' THEN "RAM_Total" ELSE 0 END)) as ram_in_service
,CASE WHEN sum("CPU_Cores"*"CPU_Sockets") > 0 THEN round((sum("CPU_Used_AVG"*"CPU_Cores"*"CPU_Sockets")/sum("CPU_Cores"*"CPU_Sockets"))::numeric,0) ELSE NULL END as cpu_usage_perc ,(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
FROM vmreports.host h FROM vmreports.host h
LEFT OUTER JOIN ( LEFT OUTER JOIN (
SELECT hi."Cluster", STRING_AGG(DISTINCT hi."Model" || ' [' || (hi.cnt::text) || '] ',', ') as models SELECT hi."Cluster", STRING_AGG(DISTINCT hi."Model" || ' [' || (hi.cnt::text) || '] ',', ') as models
@@ -88,14 +91,17 @@ select
<d:field title="Коммерческое название">n.commercial_name</d:field> <d:field title="Коммерческое название">n.commercial_name</d:field>
<d:field title="Models">h.models</d:field> <d:field title="Models">h.models</d:field>
<d:field title="Hosts total">h.hosts_total</d:field> <d:field title="Hosts total">h.hosts_total</d:field>
<d:field title="Hosts HA">h.hosts_ha</d:field>
<d:field title="Hosts in mainte&shy;nance">h.hosts_in_maintenance</d:field> <d:field title="Hosts in mainte&shy;nance">h.hosts_in_maintenance</d:field>
<d:field title="Hosts in service">h.hosts_in_service</d:field> <d:field title="Hosts in service">h.hosts_in_service</d:field>
<d:field title="Cores Total">h.cores</d:field> <d:field title="Cores Total">h.cores</d:field>
<d:field title="Cores in service">h.cores_in_service</d:field> <d:field title="Cores in service">h.cores_in_service</d:field>
<d:field title="GHz in service">h.ghz_in_service</d:field> <d:field title="GHz in service">h.ghz_in_service</d:field>
<d:field title="Host GHz usage">h.host_ghz_usage</d:field>
<d:field title="VM GHz usage">u.vm_ghz_usage</d:field>
<d:field title="GHz">h.ghz</d:field> <d:field title="GHz">h.ghz</d:field>
<d:field title="RAM GB in service">h.ram_in_service</d:field> <d:field title="RAM GB in service">h.ram_in_service</d:field>
<d:field title="CPU usage %">h.cpu_usage_perc</d:field> <d:field title="Host CPU usage %">h.cpu_usage_perc</d:field>
<d:field title="Hosts in use">c.hosts</d:field> <d:field title="Hosts in use">c.hosts</d:field>
<d:field title="Cores Capacity">c.cores as Cores_Capacity</d:field> <d:field title="Cores Capacity">c.cores as Cores_Capacity</d:field>
<d:field title="GHz Capacity">c.ghz as GHz_Capacity</d:field> <d:field title="GHz Capacity">c.ghz as GHz_Capacity</d:field>
@@ -108,8 +114,9 @@ select
<d:field title="RAM alloc %">round((u.vm_ram_alloc/c.ram)::numeric,2)*100 as GB_alloc_perc</d:field> <d:field title="RAM alloc %">round((u.vm_ram_alloc/c.ram)::numeric,2)*100 as GB_alloc_perc</d:field>
<d:field title="RAM usage %">round((u.vm_ram_used/c.ram)::numeric,2)*100 as GB_usage_perc</d:field> <d:field title="RAM usage %">round((u.vm_ram_used/c.ram)::numeric,2)*100 as GB_usage_perc</d:field>
<d:field title="Пере&shy;подписка">round((u.vm_cores/c.cores)::numeric,1) as oversubscription</d:field> <d:field title="Пере&shy;подписка">round((u.vm_cores/c.cores)::numeric,1) as oversubscription</d:field>
<d:field title= "VM cores">u.vm_cores</d:field> <d:field title="VM cores">u.vm_cores</d:field>
<d:field title= "VM">u.vms</d:field> <d:field title="VM">u.vms</d:field>
<d:field title="VM CPU Usage %">u.vm_ghz_usage/h.ghz_in_service*100 as vm_cpu_usage_perc</d:field>
</d:field_set> </d:field_set>
from cluster_stat h from cluster_stat h
left outer join usage u on (h.cluster=u.cluster) left outer join usage u on (h.cluster=u.cluster)
@@ -122,6 +129,7 @@ order by <m:order_build sortArray=#pageInfo.settings.sort.sortArray# fieldCount=
<cfquery name="qTotal" dbtype="query"> <cfquery name="qTotal" dbtype="query">
select select
sum(hosts_total) as hosts_total sum(hosts_total) as hosts_total
,sum(hosts_ha) as hosts_ha
,sum(cores_in_service) as cores_in_service ,sum(cores_in_service) as cores_in_service
,sum(ghz_in_service) as ghz_in_service ,sum(ghz_in_service) as ghz_in_service
,sum(GHz_Capacity) as GHz_Capacity ,sum(GHz_Capacity) as GHz_Capacity
@@ -176,15 +184,20 @@ from qRead
<th width="5%"><layout:column_head name="cluster_v1"/></th> <th width="5%"><layout:column_head name="cluster_v1"/></th>
<th width="7%"><layout:column_head name="cluster_v2"/></th> <th width="7%"><layout:column_head name="cluster_v2"/></th>
<th width="12%"><layout:column_head name="commercial_name"/></th> <th width="12%"><layout:column_head name="commercial_name"/></th>
<th width="20%"><layout:column_head name="models"/></th> <th width="20%"><layout:column_head name="models"/></th>
<th width="3%"><layout:column_head name="ghz"/></th>
<th width="3%"><layout:column_head name="hosts_total"/></th> <th width="3%"><layout:column_head name="hosts_total"/></th>
<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_maintenance"/></th>
<th width="3%"><layout:column_head name="hosts_in_service"/></th> <th width="3%"><layout:column_head name="hosts_in_service"/></th>
<th width="3%"><layout:column_head name="cores_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="ghz_in_service"/></th>
<th width="3%"><layout:column_head name="ghz"/></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="ram_in_service"/></th>
<th width="3%"><layout:column_head name="cpu_usage_perc"/></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> <th width="3%"><layout:column_head name="oversubscription"/></th>
<th width="1%"></th> <th width="1%"></th>
<th width="3%"><layout:column_head name="hosts"/></th> <th width="3%"><layout:column_head name="hosts"/></th>
@@ -209,15 +222,19 @@ from qRead
<td>#cluster_v1#</td> <td>#cluster_v1#</td>
<td>#cluster_v2#</td> <td>#cluster_v2#</td>
<td>#commercial_name#</td> <td>#commercial_name#</td>
<td>#models#</td> <td>#models#</td>
<td class="r">#numberFormat(ghz,".0")#</td>
<td class="r">#hosts_total#</td> <td class="r">#hosts_total#</td>
<td class="r">#hosts_ha#</td>
<td class="r">#hosts_in_maintenance#</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">#cores_in_service#</td> <td class="r">#cores_in_service#</td>
<td class="r">#numberFormat(ghz_in_service,".0")#</td> <td class="r">#numberFormat(ghz_in_service,".0")#</td>
<td class="r">#numberFormat(ghz,".0")#</td> <td class="r" style="background:lightcoral">#numberFormat(host_ghz_usage,".0")#</td>
<td class="r">#ram_in_service#</td> <td class="r" style="background:lightcoral">#numberFormat(vm_ghz_usage,".0")#</td>
<td class="r">#cpu_usage_perc#</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">#oversubscription#</td> <td class="r">#oversubscription#</td>
<td></td> <td></td>
<td class="r">#hosts#</td> <td class="r">#hosts#</td>
@@ -226,12 +243,12 @@ from qRead
<td class="r">#numberFormat(vm_ghz_reserved,".0")#</td> <td class="r">#numberFormat(vm_ghz_reserved,".0")#</td>
<td class="r">#numberFormat(vm_ghz_promised,".0")#</td> <td class="r">#numberFormat(vm_ghz_promised,".0")#</td>
<td class="r">#vm_cores#</td> <td class="r">#vm_cores#</td>
<td class="r">#GHz_provision_rate#</td> <td class="r">#numberFormat(GHz_provision_rate,"0")#</td>
<td class="r">#RAM_Capacity#</td> <td class="r">#numberFormat(RAM_Capacity,"0")#</td>
<td class="r">#vm_ram_alloc#</td> <td class="r">#numberFormat(vm_ram_alloc,"0")#</td>
<td class="r">#vm_ram_used#</td> <td class="r">#numberFormat(vm_ram_used,"0")#</td>
<td class="r">#GB_alloc_perc#</td> <td class="r">#numberFormat(GB_alloc_perc,"0")#</td>
<td class="r">#GB_usage_perc#</td> <td class="r">#numberFormat(GB_usage_perc,"0")#</td>
<td class="r">#vms#</td> <td class="r">#vms#</td>
<td class="r"><cftry>#numberFormat(vm_cores/vms,".0")# #numberFormat(vm_ram_alloc/vms,".0")#<cfcatch></cfcatch></cftry></td> <td class="r"><cftry>#numberFormat(vm_cores/vms,".0")# #numberFormat(vm_ram_alloc/vms,".0")#<cfcatch></cfcatch></cftry></td>
</tr> </tr>
@@ -240,12 +257,16 @@ from qRead
<tr class="b"> <tr class="b">
<td colspan="4" class="r b"> Итого</td> <td colspan="4" class="r b"> Итого</td>
<td class="r">#hosts_total#</td> <td class="r">#hosts_total#</td>
<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"></td>
<td class="r">#cores_in_service#</td> <td class="r">#cores_in_service#</td>
<td class="r">#numberFormat(ghz_in_service,".0")#</td> <td class="r">#numberFormat(ghz_in_service,".0")#</td>
<td class="r"></td>
<td class="r"></td> <td class="r"></td>
<td class="r">#ram_in_service#</td> <td class="r">#numberFormat(ram_in_service,"0")#</td>
<td class="r"></td>
<td class="r"><!--- #cpu_usage_perc# ---></td> <td class="r"><!--- #cpu_usage_perc# ---></td>
<td class="r" style="font-size:130%;">#numberFormat(vm_cores/cores_in_service,".0")#</td> <td class="r" style="font-size:130%;">#numberFormat(vm_cores/cores_in_service,".0")#</td>
<td></td> <td></td>
@@ -256,9 +277,9 @@ from qRead
<td class="r">#numberFormat(vm_ghz_promised,".0")#</td> <td class="r">#numberFormat(vm_ghz_promised,".0")#</td>
<td class="r">#vm_cores#</td> <td class="r">#vm_cores#</td>
<td class="r"></td> <td class="r"></td>
<td class="r">#RAM_Capacity#</td> <td class="r">#numberFormat(RAM_Capacity,"0")#</td>
<td class="r">#vm_ram_alloc#</td> <td class="r">#numberFormat(vm_ram_alloc,"0")#</td>
<td class="r">#vm_ram_used#</td> <td class="r">#numberFormat(vm_ram_used,"0")#</td>
<td class="r" style="font-size:130%;">#numberFormat(vm_ram_alloc/ram_in_service*100,"0")#</td> <td class="r" style="font-size:130%;">#numberFormat(vm_ram_alloc/ram_in_service*100,"0")#</td>
<td class="r" style="font-size:130%;">#numberFormat(vm_ram_used/ram_in_service*100,"0")#</td> <td class="r" style="font-size:130%;">#numberFormat(vm_ram_used/ram_in_service*100,"0")#</td>
<td class="r">#vms#</td> <td class="r">#vms#</td>
@@ -273,6 +294,31 @@ from qRead
<i>* CPU GHz provision rate % - отношение зарезервированной частоты (с учетом 20% резерва по умолчанию) к наличной частоте процессоров</i> <i>* CPU GHz provision rate % - отношение зарезервированной частоты (с учетом 20% резерва по умолчанию) к наличной частоте процессоров</i>
<br/> <br/>
<i>* Расхождения в оценке объема RAM частично связаны с разной оценкой затрат памяти на собственные нужды гипервизора</i> <i>* Расхождения в оценке объема RAM частично связаны с разной оценкой затрат памяти на собственные нужды гипервизора</i>
<br/>
<!--- <cfchart
format="png"
chartWidth="500"
chartHeight="300"
seriesplacement="stacked"
title="Population Distribution: Males vs Females"
scalefrom="-100"
scaleto="100"
labelformat="number">
<!--- Left Side: Males (Negative Values) --->
<cfchartseries type="bar" seriesLabel="Males" seriesColor="##3366CC">
<cfchartdata item="Age 0-10" value="-85">
<cfchartdata item="Age 11-20" value="-70">
<cfchartdata item="Age 21-30" value="-55">
</cfchartseries>
<!--- Right Side: Females (Positive Values) --->
<cfchartseries type="bar" seriesLabel="Females" seriesColor="##FF99CC">
<cfchartdata item="Age 0-10" value="82">
<cfchartdata item="Age 11-20" value="75">
<cfchartdata item="Age 21-30" value="60">
</cfchartseries>
</cfchart> --->
<layout:page section="footer"/> <layout:page section="footer"/>