037 improvements

This commit is contained in:
2026-04-06 15:47:56 +03:00
parent 20fe4ad2fc
commit 8137eeb219
2 changed files with 130 additions and 36 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.036"/> <cfset request.APP_VERSION="0.00.037"/>
<cfset request.STAND=getStand()/> <cfset request.STAND=getStand()/>
<cflock scope="application" type="readonly" timeout=3> <cflock scope="application" type="readonly" timeout=3>
+129 -35
View File
@@ -7,13 +7,19 @@
<m:prepare_ls entity="crm2cloud" settingsKey="crm2cloud" accessObject="" pageInfoOut="pageInfo" trackOut="tr"/> <m:prepare_ls entity="crm2cloud" settingsKey="crm2cloud" accessObject="" pageInfoOut="pageInfo" trackOut="tr"/>
<cfquery name="qTS">
select
(select max(ts) from vmreports.compute) as ts_compute
,(select max(ts) from vmreports.host) as ts_host
</cfquery>
<cfquery name="qRead"> <cfquery name="qRead">
with with
capacity as ( capacity as (
select "Cluster" as cluster, count(*) as hosts, sum(cores) as cores, round(sum(ghz)) as ghz, round(sum(ram)) as ram select "Cluster" as cluster, count(*) as hosts, sum(cores) as cores, round(sum(ghz)::numeric,1) as ghz, round(sum(ram)) as ram
from ( from (
select "Cluster", "Host" select "Cluster", "Host"
, avg("Host_CPU_Cores") as cores, avg("Host_CPU_Cores"*"Host_CPU_Speed") as ghz, avg("Host_RAM"*.85) as ram , 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
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","Host" group by "Cluster","Host"
@@ -23,6 +29,7 @@ group by "Cluster"),
usage as ( usage as (
select "Cluster" as cluster select "Cluster" as cluster
,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 , round(sum("VM_vCPU_count"*"VDC_CPU_Speed")) as vm_ghz
, round(sum("VM_CPU_Reserv_GHz")) as vm_ghz_reserved , round(sum("VM_CPU_Reserv_GHz")) as vm_ghz_reserved
@@ -46,6 +53,7 @@ SELECT
,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 ,round(sum(CASE WHEN "Maintenance"='notInMaintenance' THEN "CPU_Cores"*"CPU_Sockets"*"CPU_Speed" ELSE 0 END)::numeric,1) as ghz_in_service
,round(sum(CASE WHEN "Maintenance"='notInMaintenance' THEN "RAM_Total" ELSE 0 END)::numeric,0) as ram_in_service
,round(avg(CASE WHEN "Maintenance"='notInMaintenance' THEN "CPU_Speed" ELSE 0 END)::numeric,1) as ghz ,round(avg(CASE WHEN "Maintenance"='notInMaintenance' THEN "CPU_Speed" ELSE 0 END)::numeric,1) as ghz
,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 ,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
FROM vmreports.host h FROM vmreports.host h
@@ -61,6 +69,15 @@ LEFT OUTER JOIN (
WHERE ts=(SELECT max(ts) FROM vmreports.host) WHERE ts=(SELECT max(ts) FROM vmreports.host)
GROUP BY h."Cluster", h."Cluster_v2", m.models GROUP BY h."Cluster", h."Cluster_v2", m.models
ORDER BY h."Cluster" ORDER BY h."Cluster"
),
cluster_naming (cluster,commercial_name) AS (VALUES
('cl01-vsan','msk1, Intel Cascade Lake 2,9 ГГц')
,('cl02','msk1, Intel Cascade Lake 3,1 ГГц')
,('cl04-vsan','msk1, AMD Milan 2,8 ГГц')
,('cl05-1c','msk1, AMD Raphael 4,5 ГГц')
,('cl06-vsan','msk1, Intel Ice Lake 2,8 ГГц')
,('cl07-vsan','msk1, AMD Genoa 4,0 ГГц')
) )
@@ -68,33 +85,58 @@ select
<d:field_set titleMapOut="titleMap" lengthOut="fieldCount"> <d:field_set titleMapOut="titleMap" lengthOut="fieldCount">
<d:field title="cluster v1">h.cluster as cluster_v1</d:field> <d:field title="cluster v1">h.cluster as cluster_v1</d:field>
<d:field title="cluster v2">h.cluster_v2</d:field> <d:field title="cluster v2">h.cluster_v2</d:field>
<d:field title="models">h.models</d:field> <d:field title="Коммерческое название">n.commercial_name</d:field>
<d:field title="hosts total">h.hosts_total</d:field> <d:field title="Models">h.models</d:field>
<d:field title="hosts in maintenance">h.hosts_in_maintenance</d:field> <d:field title="Hosts total">h.hosts_total</d:field>
<d:field title="hosts in service">h.hosts_in_service</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="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="ghz total">h.ghz</d:field> <d:field title="GHz">h.ghz</d:field>
<d:field title="cpu usage %">h.cpu_usage_perc</d:field> <d:field title="RAM GB in service">h.ram_in_service</d:field>
<d:field title="hosts по ВМ">c.hosts</d:field> <d:field title="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="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>
<d:field title="vm ghz reserved">u.vm_ghz_reserved</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="VM GHz обещанные">u.vm_ghz_promised</d:field>
<d:field title="GHz provision rate">round((u.vm_ghz_promised/c.ghz)::numeric,2) as GHz_provision_rate</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 Capacity">c.ram as RAM_Capacity</d:field> <d:field title="RAM GB Capacity">c.ram as RAM_Capacity</d:field>
<d:field title="vm ram alloc">u.vm_ram_alloc</d:field> <d:field title="VM RAM GB alloc">u.vm_ram_alloc</d:field>
<d:field title="vm ram used">u.vm_ram_used</d:field> <d:field title="VM RAM GB used">u.vm_ram_used</d:field>
<d:field title="GB provision rate">round((u.vm_ram_alloc/c.ram)::numeric,2) as GB_provision_rate</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="Пере&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">u.vms</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)
left outer join capacity c on (h.cluster=c.cluster) left outer join capacity c on (h.cluster=c.cluster)
<!--- where 1=1 <m:filter_build filter=#pageInfo.settings.filter#/>---> 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#/> order by <m:order_build sortArray=#pageInfo.settings.sort.sortArray# fieldCount=#fieldCount#/>
</cfquery> </cfquery>
<cfquery name="qTotal" dbtype="query">
select
sum(hosts_total) as hosts_total
,sum(cores_in_service) as cores_in_service
,sum(ghz_in_service) as ghz_in_service
,sum(GHz_Capacity) as GHz_Capacity
,sum(ram_in_service) as ram_in_service
,sum(RAM_Capacity) as RAM_Capacity
,sum(cores_in_service) as cores_in_service
,sum(vm_cores) as vm_cores
,sum(vm_ghz_reserved) as vm_ghz_reserved
,sum(vm_ghz_promised) as vm_ghz_promised
,sum(vm_ram_alloc) as vm_ram_alloc
,sum(vm_ram_used) as vm_ram_used
,sum(vms) as vms
from qRead
</cfquery>
@@ -105,16 +147,21 @@ order by <m:order_build sortArray=#pageInfo.settings.sort.sortArray# fieldCount=
</cfif><cfif isDefined("output_json")> </cfif><cfif isDefined("output_json")>
<layout:json qRead=#qRead# titleMap=#titleMap# filename="#pageInfo.entity#.json"/> <layout:json qRead=#qRead# titleMap=#titleMap# filename="#pageInfo.entity#.json"/>
<cfabort/> <cfabort/>
</cfif><!--- </cfif>
---><layout:page section="header" pageInfo=#pageInfo#> <layout:page section="header" pageInfo=#pageInfo#>
<layout:attribute name="title"> <layout:attribute name="title">
<cfoutput><b>Сверка CRM - Cloud</b></cfoutput> <cfoutput><b>Cloud Capacity</b></cfoutput>
</layout:attribute> </layout:attribute>
<layout:attribute name="controls"><!--- empty to remove controls (filter link) ---></layout:attribute>
</layout:page> </layout:page>
<!--- <cfdump var=#qRead#/> --->
<cfoutput query="qTS">
<h3 style="display:inline-block; margin-right:2em;">Актуальность данных</h3>
<b>VM:</b> #dateFormat(ts_compute,"YYYY-MM-DD")# #timeFormat(ts_compute,"HH:MM")#
<b>Хосты:</b> #dateFormat(ts_host,"YYYY-MM-DD")# #timeFormat(ts_host,"HH:MM")#
</cfoutput>
<!--- <cfdump var=#qRead#/> --->
<!--- Добавить время обновления наборов данных, итоги, коммерческие названия --->
<layout:grid_summary <layout:grid_summary
recordCount=#qRead.recordCount# recordCount=#qRead.recordCount#
@@ -126,8 +173,9 @@ order by <m:order_build sortArray=#pageInfo.settings.sort.sortArray# fieldCount=
<table class="worktable"> <table class="worktable">
<thead> <thead>
<layout:grid_head titleMap=#titleMap# sortArray=#pageInfo.settings.sort.sortArray#> <layout:grid_head titleMap=#titleMap# sortArray=#pageInfo.settings.sort.sortArray#>
<th width="10%"><layout:column_head name="cluster_v1"/></th> <th width="5%"><layout:column_head name="cluster_v1"/></th>
<th width="10%"><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="20%"><layout:column_head name="models"/></th> <th width="20%"><layout:column_head name="models"/></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_in_maintenance"/></th> <th width="3%"><layout:column_head name="hosts_in_maintenance"/></th>
@@ -135,18 +183,24 @@ order by <m:order_build sortArray=#pageInfo.settings.sort.sortArray# fieldCount=
<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="ghz"/></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="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>
<th width="3%"><layout:column_head name="Cores_Capacity"/></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_Capacity"/></th>
<th width="3%"><layout:column_head name="vm_ghz_reserved"/></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_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="GHz_provision_rate"/></th>
<th width="3%"><layout:column_head name="RAM_Capacity"/></th> <th width="3%"><layout:column_head name="RAM_Capacity"/></th>
<th width="3%"><layout:column_head name="vm_ram_alloc"/></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="vm_ram_used"/></th>
<th width="3%"><layout:column_head name="GB_provision_rate"/></th> <th width="3%"><layout:column_head name="GB_alloc_perc"/></th>
<th width="3%"><layout:column_head name="GB_usage_perc"/></th>
<th width="3%">ВМ шт.</th>
<th width="3%">Средн. ВМ core | GB</th>
</layout:grid_head> </layout:grid_head>
</thead> </thead>
@@ -154,31 +208,71 @@ order by <m:order_build sortArray=#pageInfo.settings.sort.sortArray# fieldCount=
<tr> <tr>
<td>#cluster_v1#</td> <td>#cluster_v1#</td>
<td>#cluster_v2#</td> <td>#cluster_v2#</td>
<td>#commercial_name#</td>
<td>#models#</td> <td>#models#</td>
<td class="r">#hosts_total#</td> <td class="r">#hosts_total#</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">#ghz_in_service#</td> <td class="r">#numberFormat(ghz_in_service,".0")#</td>
<td class="r">#ghz#</td> <td class="r">#numberFormat(ghz,".0")#</td>
<td class="r">#ram_in_service#</td>
<td class="r">#cpu_usage_perc#</td> <td class="r">#cpu_usage_perc#</td>
<td class="r">#oversubscription#</td>
<td></td> <td></td>
<td class="r">#hosts#</td> <td class="r">#hosts#</td>
<td class="r">#Cores_Capacity#</td> <td class="r">#Cores_Capacity#</td>
<td class="r">#GHz_Capacity#</td> <td class="r">#numberFormat(GHz_Capacity,".0")#</td>
<td class="r">#vm_ghz_reserved#</td> <td class="r">#numberFormat(vm_ghz_reserved,".0")#</td>
<td class="r">#vm_ghz_promised#</td> <td class="r">#numberFormat(vm_ghz_promised,".0")#</td>
<td class="r">#vm_cores#</td>
<td class="r">#GHz_provision_rate#</td> <td class="r">#GHz_provision_rate#</td>
<td class="r">#RAM_Capacity#</td> <td class="r">#RAM_Capacity#</td>
<td class="r">#vm_ram_alloc#</td> <td class="r">#vm_ram_alloc#</td>
<td class="r">#vm_ram_used#</td> <td class="r">#vm_ram_used#</td>
<td class="r">#GB_provision_rate#</td> <td class="r">#GB_alloc_perc#</td>
<td class="r">#GB_usage_perc#</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>
</tr>
</cfoutput>
<cfoutput query="qTotal">
<tr class="b">
<td colspan="4" class="r b"> Итого</td>
<td class="r">#hosts_total#</td>
<td class="r"></td>
<td class="r"></td>
<td class="r">#cores_in_service#</td>
<td class="r">#numberFormat(ghz_in_service,".0")#</td>
<td class="r"></td>
<td class="r">#ram_in_service#</td>
<td class="r"><!--- #cpu_usage_perc# ---></td>
<td class="r" style="font-size:130%;">#numberFormat(vm_cores/cores_in_service,".0")#</td>
<td></td>
<td class="r"></td>
<td class="r"></td>
<td class="r">#numberFormat(GHz_Capacity,".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">#RAM_Capacity#</td>
<td class="r">#vm_ram_alloc#</td>
<td class="r">#vm_ram_used#</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">#vms#</td>
<td class="r"><cftry>#numberFormat(vm_cores/vms,".0")# #numberFormat(vm_ram_alloc/vms,".0")#<cfcatch></cfcatch></cftry></td>
</tr> </tr>
</cfoutput> </cfoutput>
</table> </table>
<!--- <cfdump var=#qCharge#/> ---> <!--- <cfdump var=#qCharge#/> --->
<i>Пока выводим избыточный набор колонок для контроля. Кроме того, еще не выбрали, какие колонки удобнее и релевантнее</i>
<br/>
<i>* CPU GHz provision rate % - отношение зарезервированной частоты (с учетом 20% резерва по умолчанию) к наличной частоте процессоров</i>
<br/>
<i>* Расхождения в оценке объема RAM частично связаны с разной оценкой затрат памяти на собственные нужды гипервизора</i>
<layout:page section="footer"/> <layout:page section="footer"/>