185 lines
7.9 KiB
Plaintext
185 lines
7.9 KiB
Plaintext
<cfsilent>
|
|
<cfimport prefix="m" taglib="lib"/>
|
|
<cfimport prefix="c" taglib="lib/controls"/>
|
|
<cfimport prefix="d" taglib="lib/data"/>
|
|
<cfimport prefix="layout" taglib="layout"/>
|
|
</cfsilent>
|
|
|
|
<m:prepare_ls entity="crm2cloud" settingsKey="crm2cloud" accessObject="" pageInfoOut="pageInfo" trackOut="tr"/>
|
|
|
|
<cfquery name="qRead">
|
|
with
|
|
capacity as (
|
|
select "Cluster" as cluster, count(*) as hosts, sum(cores) as cores, round(sum(ghz)) as ghz, round(sum(ram)) as ram
|
|
from (
|
|
select "Cluster", "Host"
|
|
, 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"
|
|
order by "Cluster","Host"
|
|
) host
|
|
group by "Cluster"),
|
|
|
|
usage as (
|
|
select "Cluster" as cluster
|
|
, sum("VM_vCPU_count") as vm_cores
|
|
, round(sum("VM_vCPU_count"*"VDC_CPU_Speed")) as vm_ghz
|
|
, round(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
|
|
, 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
|
|
-- promised - зарезервированные ГГц, если включить минимальное согласованное резервирование
|
|
, round(sum("VM_RAM_Allocated")) as vm_ram_alloc
|
|
, round(sum("VM_RAM_Used")) as vm_ram_used
|
|
from vmreports.compute
|
|
where ts=(select max(ts) from vmreports.compute)
|
|
group by "Cluster"),
|
|
|
|
cluster_stat as (
|
|
SELECT
|
|
h."Cluster" as cluster
|
|
,h."Cluster_v2" as cluster_v2
|
|
,m.models
|
|
,COUNT(*) as hosts_total
|
|
,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
|
|
,round(sum(CASE WHEN "Maintenance"='notInMaintenance' THEN "CPU_Cores"*"CPU_Sockets"*"CPU_Speed" ELSE 0 END)::numeric,1) as ghz_in_service
|
|
,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
|
|
FROM vmreports.host h
|
|
LEFT OUTER JOIN (
|
|
SELECT hi."Cluster", STRING_AGG(DISTINCT hi."Model" || ' [' || (hi.cnt::text) || '] ',', ') as models
|
|
FROM (
|
|
SELECT hii."Cluster", hii."Model", count(hii."Model") as cnt
|
|
FROM vmreports.host hii
|
|
WHERE hii.ts=(SELECT max(ts) FROM vmreports.host)
|
|
GROUP BY hii."Cluster", hii."Model"
|
|
) hi GROUP BY hi."Cluster"
|
|
) m ON (h."Cluster"=m."Cluster")
|
|
WHERE ts=(SELECT max(ts) FROM vmreports.host)
|
|
GROUP BY h."Cluster", h."Cluster_v2", m.models
|
|
ORDER BY h."Cluster"
|
|
)
|
|
|
|
|
|
select
|
|
<d:field_set titleMapOut="titleMap" lengthOut="fieldCount">
|
|
<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="models">h.models</d:field>
|
|
<d:field title="hosts total">h.hosts_total</d:field>
|
|
<d:field title="hosts in maintenance">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 in service">h.cores_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="cpu usage %">h.cpu_usage_perc</d:field>
|
|
<d:field title="hosts по ВМ">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="vm ghz reserved">u.vm_ghz_reserved</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="RAM 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 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_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)
|
|
<!--- where 1=1 <m:filter_build filter=#pageInfo.settings.filter#/>--->
|
|
order by <m:order_build sortArray=#pageInfo.settings.sort.sortArray# fieldCount=#fieldCount#/>
|
|
</cfquery>
|
|
|
|
|
|
|
|
|
|
|
|
<cfif isDefined("output_xls")>
|
|
<layout:xml qRead=#qRead# titleMap=#titleMap# filename="#pageInfo.entity#.xml"/>
|
|
<cfabort/>
|
|
</cfif><cfif isDefined("output_json")>
|
|
<layout:json qRead=#qRead# titleMap=#titleMap# filename="#pageInfo.entity#.json"/>
|
|
<cfabort/>
|
|
</cfif><!---
|
|
---><layout:page section="header" pageInfo=#pageInfo#>
|
|
|
|
<layout:attribute name="title">
|
|
<cfoutput><b>Сверка CRM - Cloud</b></cfoutput>
|
|
</layout:attribute>
|
|
|
|
</layout:page>
|
|
<!--- <cfdump var=#qRead#/> --->
|
|
|
|
|
|
<layout:grid_summary
|
|
recordCount=#qRead.recordCount#
|
|
footerOut="gridFooter"
|
|
excelLink="Yes"
|
|
jsonLink="Yes"
|
|
/>
|
|
|
|
<table class="worktable">
|
|
<thead>
|
|
<layout:grid_head titleMap=#titleMap# sortArray=#pageInfo.settings.sort.sortArray#>
|
|
<th width="10%"><layout:column_head name="cluster_v1"/></th>
|
|
<th width="10%"><layout:column_head name="cluster_v2"/></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_in_maintenance"/></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="ghz_in_service"/></th>
|
|
<th width="3%"><layout:column_head name="ghz"/></th>
|
|
<th width="3%"><layout:column_head name="cpu_usage_perc"/></th>
|
|
<th width="1%"></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="GHz_Capacity"/></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="GHz_provision_rate"/></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_used"/></th>
|
|
<th width="3%"><layout:column_head name="GB_provision_rate"/></th>
|
|
</layout:grid_head>
|
|
</thead>
|
|
|
|
<cfoutput query="qRead">
|
|
<tr>
|
|
<td>#cluster_v1#</td>
|
|
<td>#cluster_v2#</td>
|
|
<td>#models#</td>
|
|
<td class="r">#hosts_total#</td>
|
|
<td class="r">#hosts_in_maintenance#</td>
|
|
<td class="r">#hosts_in_service#</td>
|
|
<td class="r">#cores_in_service#</td>
|
|
<td class="r">#ghz_in_service#</td>
|
|
<td class="r">#ghz#</td>
|
|
<td class="r">#cpu_usage_perc#</td>
|
|
<td></td>
|
|
<td class="r">#hosts#</td>
|
|
<td class="r">#Cores_Capacity#</td>
|
|
<td class="r">#GHz_Capacity#</td>
|
|
<td class="r">#vm_ghz_reserved#</td>
|
|
<td class="r">#vm_ghz_promised#</td>
|
|
<td class="r">#GHz_provision_rate#</td>
|
|
<td class="r">#RAM_Capacity#</td>
|
|
<td class="r">#vm_ram_alloc#</td>
|
|
<td class="r">#vm_ram_used#</td>
|
|
<td class="r">#GB_provision_rate#</td>
|
|
</tr>
|
|
</cfoutput>
|
|
|
|
</table>
|
|
<!--- <cfdump var=#qCharge#/> --->
|
|
|
|
|
|
<layout:page section="footer"/>
|
|
|