43 speed and filter and totals

This commit is contained in:
2026-04-13 23:18:41 +03:00
parent 515b6cd90d
commit ade4071eb8
4 changed files with 317 additions and 171 deletions
+33 -34
View File
@@ -15,7 +15,7 @@
<cfquery name="qRead">
with
capacity as (
<!--- 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"
@@ -25,7 +25,7 @@ from (
group by "Cluster","Host"
order by "Cluster","Host"
) host
group by "Cluster"),
group by "Cluster"), --->
usage as (
select "Cluster" as cluster
@@ -55,6 +55,8 @@ SELECT
,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(CASE WHEN "Maintenance"='notInMaintenance' THEN "CPUtoVM" ELSE 0 END) as ghz_provisioned
,sum(CASE WHEN "Maintenance"='notInMaintenance' THEN "RAMtoVM" ELSE 0 END) as gb_provisioned
,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
@@ -102,25 +104,26 @@ select
<d:field title="CPU GHz">h.ghz</d:field>
<d:field title="RAM GB in service">h.ram_in_service</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="Cores Capacity">c.cores as Cores_Capacity</d:field>
<d:field title="GHz Capacity">c.ghz as GHz_Capacity</d:field>
<!--- <d:field title="Hosts in use">h.hosts</d:field> --->
<d:field title="Cores Capacity">h.cores as Cores_Capacity</d:field>
<!--- <d:field title="GHz Capacity">c.ghz as GHz_Capacity</d:field> --->
<d:field title="GHz Provisioned">h.ghz_provisioned as GHz_Provisioned</d:field><!--- за вычетом согласованных резервов --->
<d:field title="GB Provisioned">h.gb_provisioned as GB_Provisioned</d:field><!--- за вычетом согласованных резервов --->
<d:field title="VM GHz reserved">u.vm_ghz_reserved</d:field>
<d:field title="VM GHz обещанные">u.vm_ghz_promised</d:field>
<d:field title="CPU GHz provision rate %">round((u.vm_ghz_promised/c.ghz)::numeric,2)*100 as GHz_provision_rate</d:field>
<d:field title="RAM GB Capacity">c.ram as RAM_Capacity</d:field>
<d:field title="CPU GHz provision rate %">round((u.vm_ghz_promised/h.ghz_provisioned)::numeric,2)*100 as GHz_provision_rate</d:field>
<!--- <d:field title="RAM GB Capacity">h.ram as RAM_Capacity</d:field> --->
<d:field title="VM RAM GB alloc">u.vm_ram_alloc</d:field>
<d:field title="VM RAM GB used">u.vm_ram_used</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="Пере подписка vCPU">round((u.vm_cores/c.cores)::numeric,1) as oversubscription</d:field>
<d:field title="RAM alloc %">round((u.vm_ram_alloc/h.gb_provisioned)::numeric,2)*100 as GB_alloc_perc</d:field>
<d:field title="RAM usage %">round((u.vm_ram_used/h.gb_provisioned)::numeric,2)*100 as GB_usage_perc</d:field>
<d:field title="Пере подписка vCPU">round((u.vm_cores/h.cores)::numeric,1) as oversubscription</d:field>
<d:field title="VM cores">u.vm_cores</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>
from cluster_stat h
left outer join usage u on (h.cluster=u.cluster)
left outer join capacity c on (h.cluster=c.cluster)
left outer join cluster_naming n on (h.cluster=n.cluster)
where 1=1 <!--- <m:filter_build filter=#pageInfo.settings.filter#/> --->
order by <m:order_build sortArray=#pageInfo.settings.sort.sortArray# fieldCount=#fieldCount#/>
@@ -131,13 +134,12 @@ select
sum(hosts_total) as hosts_total
,sum(hosts_ha) as hosts_ha
,sum(hosts_in_maintenance) as hosts_in_maintenance
,sum(hosts) as hosts
,sum(host_ghz_usage) as host_ghz_usage
,sum(cores_in_service) as cores_in_service
,sum(ghz_in_service) as ghz_in_service
,sum(GHz_Capacity) as GHz_Capacity
,sum(ghz_provisioned) as ghz_provisioned
,sum(ram_in_service) as ram_in_service
,sum(RAM_Capacity) as RAM_Capacity
,sum(gb_provisioned) as gb_provisioned
,sum(cores_in_service) as cores_in_service
,sum(vm_cores) as vm_cores
,sum(vm_ghz_usage) as vm_ghz_usage
@@ -208,17 +210,17 @@ from qRead
<!--- <td class="r" style="font-size:120%">#numberFormat(ghz,".0")#</td> --->
<td class="r">#hosts_total#</td>
<td class="r<cfif RAM_Capacity-vm_ram_alloc LE 0> err</cfif>" style="font-size:130%">#numberFormat(RAM_Capacity-vm_ram_alloc,"0")#</td>
<td class="r<cfif gb_provisioned-vm_ram_alloc LE 0> err</cfif>" style="font-size:130%">#numberFormat(gb_provisioned-vm_ram_alloc,"0")#</td>
<td class="r<cfif GHz_Capacity-vm_ghz_reserved LE 0> err</cfif>" style="font-size:130%">#numberFormat(GHz_Capacity-vm_ghz_reserved,".0")#</td>
<td class="r<cfif GHz_Capacity-vm_ghz_reserved LE 0> err</cfif>" style="font-size:130%">#numberFormat((GHz_Capacity-vm_ghz_reserved)/ghz/0.2,"0")#</td>
<td class="r<cfif GHz_Capacity-vm_ghz_reserved LE 0> err</cfif>" style="font-size:130%">#numberFormat((GHz_Capacity-vm_ghz_reserved)/ghz/0.5,"0")#</td>
<td class="r<cfif GHz_Capacity-vm_ghz_reserved LE 0> err</cfif>" style="font-size:130%">#numberFormat((GHz_Capacity-vm_ghz_reserved)/ghz/0.8,"0")#</td>
<td class="r<cfif ghz_provisioned-vm_ghz_reserved LE 0> err</cfif>" style="font-size:130%">#numberFormat(ghz_provisioned-vm_ghz_reserved,".0")#</td>
<td class="r<cfif ghz_provisioned-vm_ghz_reserved LE 0> err</cfif>" style="font-size:130%">#numberFormat((ghz_provisioned-vm_ghz_reserved)/ghz/0.2,"0")#</td>
<td class="r<cfif ghz_provisioned-vm_ghz_reserved LE 0> err</cfif>" style="font-size:130%">#numberFormat((ghz_provisioned-vm_ghz_reserved)/ghz/0.5,"0")#</td>
<td class="r<cfif ghz_provisioned-vm_ghz_reserved LE 0> err</cfif>" style="font-size:130%">#numberFormat((ghz_provisioned-vm_ghz_reserved)/ghz/0.8,"0")#</td>
<td class="r<cfif GHz_Capacity-vm_ghz_promised LE 0> err</cfif>" style="font-size:130%">#numberFormat(GHz_Capacity-vm_ghz_promised,".0")#</td>
<td class="r<cfif GHz_Capacity-vm_ghz_promised LE 0> err</cfif>" style="font-size:130%">#numberFormat((GHz_Capacity-vm_ghz_promised)/ghz/0.2,"0")#</td>
<td class="r<cfif GHz_Capacity-vm_ghz_promised LE 0> err</cfif>" style="font-size:130%">#numberFormat((GHz_Capacity-vm_ghz_promised)/ghz/0.5,"0")#</td>
<td class="r<cfif GHz_Capacity-vm_ghz_promised LE 0> err</cfif>" style="font-size:130%">#numberFormat((GHz_Capacity-vm_ghz_promised)/ghz/0.8,"0")#</td>
<td class="r<cfif ghz_provisioned-vm_ghz_promised LE 0> err</cfif>" style="font-size:130%">#numberFormat(ghz_provisioned-vm_ghz_promised,".0")#</td>
<td class="r<cfif ghz_provisioned-vm_ghz_promised LE 0> err</cfif>" style="font-size:130%">#numberFormat((ghz_provisioned-vm_ghz_promised)/ghz/0.2,"0")#</td>
<td class="r<cfif ghz_provisioned-vm_ghz_promised LE 0> err</cfif>" style="font-size:130%">#numberFormat((ghz_provisioned-vm_ghz_promised)/ghz/0.5,"0")#</td>
<td class="r<cfif ghz_provisioned-vm_ghz_promised LE 0> err</cfif>" style="font-size:130%">#numberFormat((ghz_provisioned-vm_ghz_promised)/ghz/0.8,"0")#</td>
<td class="r">#vms#</td>
@@ -247,8 +249,7 @@ from qRead
<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_ha"/></th>
<th width="3%"><layout:column_head name="hosts_in_maintenance"/></th>
<th width="3%"><layout:column_head name="hosts"/></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>
@@ -259,12 +260,12 @@ from qRead
<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="Cores_Capacity"/></th>
<th width="3%"><layout:column_head name="GHz_Capacity"/></th>
<th width="3%"><layout:column_head name="ghz_provisioned"/></th>
<th width="3%"><layout:column_head name="vm_ghz_reserved"/></th>
<th width="3%"><layout:column_head name="vm_ghz_promised"/></th>
<th width="3%"><layout:column_head name="vm_cores"/></th>
<th width="3%"><layout:column_head name="GHz_provision_rate"/></th>
<th width="3%"><layout:column_head name="RAM_Capacity"/></th>
<th width="3%"><layout:column_head name="gb_provisioned"/></th>
<th width="3%"><layout:column_head name="vm_ram_alloc"/></th>
<th width="3%"><layout:column_head name="vm_ram_used"/></th>
<th width="3%"><layout:column_head name="GB_alloc_perc"/></th>
@@ -284,7 +285,6 @@ from qRead
<td class="r">#hosts_total#</td>
<td class="r">#hosts_ha#</td>
<td class="r"><cfif hosts_in_maintenance NEQ 0>#hosts_in_maintenance#</cfif></td> <!--- style="background:lightcoral" --->
<td class="r">#hosts#</td>
<!--- <td class="r">#hosts_in_service#</td>
<td class="r">#numberFormat(ram_in_service,"0")#</td>
<td class="r">#cores_in_service#</td>
@@ -295,12 +295,12 @@ from qRead
<td class="c" style="font-size:130%;">#numberFormat(vm_cpu_usage_perc,"0")#</td>
<td class="r">#oversubscription#</td>
<td class="r">#Cores_Capacity#</td>
<td class="r">#numberFormat(GHz_Capacity,".0")#</td>
<td class="r">#numberFormat(ghz_provisioned,".0")#</td>
<td class="r">#numberFormat(vm_ghz_reserved,".0")#</td>
<td class="r">#numberFormat(vm_ghz_promised,".0")#</td>
<td class="r">#vm_cores#</td>
<td class="r">#numberFormat(GHz_provision_rate,"0")#</td>
<td class="r">#numberFormat(RAM_Capacity,"0")#</td>
<td class="r">#numberFormat(gb_provisioned,"0")#</td>
<td class="r">#numberFormat(vm_ram_alloc,"0")#</td>
<td class="r">#numberFormat(vm_ram_used,"0")#</td>
<td class="r">#numberFormat(GB_alloc_perc,"0")#</td>
@@ -315,8 +315,7 @@ from qRead
<td class="r">#numberFormat(ghz,".0")#</td>
<td class="r">#hosts_total#</td>
<td class="r">#hosts_ha#</td>
<td class="r">#hosts_in_maintenance#</td>
<td class="r">#hosts#</td>
<td class="r">#hosts_in_maintenance#</td>
<!--- <td class="r"></td>
<td class="r">#numberFormat(ram_in_service,"0")#</td>
<td class="r">#cores_in_service#</td>
@@ -327,12 +326,12 @@ from qRead
<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"></td>
<td class="r">#numberFormat(GHz_Capacity,".0")#</td>
<td class="r">#numberFormat(ghz_provisioned,".0")#</td>
<td class="r">#numberFormat(vm_ghz_reserved,".0")#</td>
<td class="r">#numberFormat(vm_ghz_promised,".0")#</td>
<td class="r">#vm_cores#</td>
<td class="r"></td>
<td class="r">#numberFormat(RAM_Capacity,"0")#</td>
<td class="r">#numberFormat(gb_provisioned,"0")#</td>
<td class="r">#numberFormat(vm_ram_alloc,"0")#</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>