078 improvements

This commit is contained in:
2026-08-21 22:01:53 +03:00
parent beeb83cda5
commit 98af1aa4b9
4 changed files with 121 additions and 115 deletions
+1 -1
View File
@@ -86,7 +86,7 @@
<!--- global settings --->
<!--- *************************************************************************************************** --->
<cfset request.APP_VERSION="0.00.077"/> <!--- *********************************************************** --->
<cfset request.APP_VERSION="0.00.078"/> <!--- *********************************************************** --->
<!--- *************************************************************************************************** --->
<cfset request.STAND=getStand()/>
<cfset request.RECORDS_PER_PAGE=500/>
+33 -112
View File
@@ -10,25 +10,13 @@
<cfquery name="qVM" cachedWithin=#createTimeSpan(0, 0, 25, 0)#>
select "Name", "Object_UUID", "UUID_VM",
"VDC", "Organization_UUID", "Organization", "WZ", "Cluster", "Host",
"Host_Model", "CPU_Model", "Host_CPU_Cores", "Host_CPU_Sockets", "Host_CPU_Speed", "Host_RAM",
"Host_CPU_Used", "Host_CPU_Used_Avg",
"VDC_CPU_Reserv", "VDC_CPU_Speed",
"VM_vCPU_count", "VM_CPU_Used", "VM_CPU_Used_AVG", "VM_CPU_Reserv_GHz", "VM_CPU_Reserv_perc",
"VM_RAM_Allocated", "VM_RAM_Used",
"VM_is_ON",
k.__id as company_uid
from vmreports.compute c
left outer join elma.companies k ON (lower(k.id_klienta)=lower(c."WZ"))
where c.ts=(select max(ts) from vmreports.compute)
--order by "WZ"
<cfquery name="qGPU" datasource="billing-vc" cachedWithin=#createTimeSpan(0, 0, 25, 0)#>
select obj_uuid, obj_id, client_id as WZ, vcd, org, org_vdc, vcenter, gpu, dt_load, dt_load_ts, org_status, cluster as clus, is_template
from gpu.vm
order by client_id
</cfquery>
<!--- <cfdump var=#qVM# abort=true/> --->
<!--- <cfdump var=#qGPU# abort=true/> --->
<cfif isDefined("output_xls")>
<layout:xml qRead=#qCharge# titleMap=#titleMap# filename="#pageInfo.entity#.xml"/>
@@ -40,7 +28,7 @@ where c.ts=(select max(ts) from vmreports.compute)
---><layout:page section="header" pageInfo=#pageInfo#>
<layout:attribute name="title">
<cfoutput><b>Сверка CRM - Cloud</b></cfoutput>
<cfoutput><b>VM с GPU</b></cfoutput>
</layout:attribute>
<layout:attribute name="controls">
<!---skip filter link, filter is not implemented--->
@@ -51,111 +39,44 @@ where c.ts=(select max(ts) from vmreports.compute)
<!--- <cfdump var=#qReconciliation# abort=true/> --->
<cfoutput>
<!--- <form method="post" action="">
Период с <input type="text" name="dt_start" value="#dateFormat(dt_start,'YYYY-MM-DD')#"/>
по <input type="text" name="dt_finish" value="#dateFormat(dt_finish,'YYYY-MM-DD')#"/>
<input type="submit" style="cursor:pointer;"/>
<input type="submit" name="DEBUG" value="DEBUG" style="cursor:pointer;"/>
</form> --->
<!--- Часов в периоде: <b>#hours#</b> Строк в отчете: <b>#qCharge.recordCount#</b><br/>
Актуальность данных:
VCD Computing: <b>#dateFormat(qComputingAge.dt_load,'YYYY-MM-DD')# #timeFormat(qComputingAge.dt_load,'HH:MM:SS')#</b>
VCD Storage: <b>#dateFormat(qStorageAge.dt_load,'YYYY-MM-DD')# #timeFormat(qStorageAge.dt_load,'HH:MM:SS')#</b>
S3 хранение: <b>#dateFormat(qS3VolAge.dt_load,'YYYY-MM-DD')# #timeFormat(qS3VolAge.dt_load,'HH:MM:SS')#</b>
S3 операции и трафик: <b>#dateFormat(qS3OpsTrfAge.dt_load,'YYYY-MM-DD')# #timeFormat(qS3OpsTrfAge.dt_load,'HH:MM:SS')#</b>
--->
<br/>
<a href="#request.thisPage#?output_xls" title="экспорт в Excel" style="margin-left:.5em; height:100%;" target="_blank"><img src="img/xls.gif" style="vertical-align:text-bottom;"/></a>
<a href="#request.thisPage#?output_json" title="экспорт в json" style="margin-left:.5em; height:100%;" target="_blank"><img src="img/json.svg" style="vertical-align:text-bottom;" width="13" height="13"/></a>
</cfoutput>
<cfoutput><b>#qVM.recordCount#</b></cfoutput>
<cfoutput><b>#qGPU.recordCount#</b></cfoutput>
<table class="worktable">
<thead>
<tr>
<th width="5%">WZ</th>
<th width="5%">Имя</th>
<th width="5%">Уникальное имя</th>
<th width="3%">Organization</th>
<th width="3%">VDC</th>
<th width="3%">VDC CPU Reserv</th>
<th width="3%">VDC CPU Speed GHz</th>
<th width="3%">Cluster</th>
<th width="3%">Host</th>
<th width="7%">Host Model</th>
<th width="7%">CPU Model</th>
<th width="3%">Host CPU Cores</th>
<th width="3%">Host CPU Sockets</th>
<th width="3%">Host CPU Speed GHz</th>
<th width="3%">Host RAM GB</th>
<th width="3%">Host CPU Used</th>
<th width="3%">Host CPU Used_Avg</th>
<th width="3%">VM vCPU count</th>
<th width="3%">VM CPU Used</th>
<th width="3%">VM CPU Used AVG</th>
<th width="3%">VM CPU Reserv GHz</th>
<th width="3%">VM CPU Reserv perc</th>
<th width="3%">VM RAM Allocated GB</th>
<th width="3%">VM RAM Used GB</th>
<th width="3%">VM is ON</th>
<th width="5%">WZ</th>
<th width="5%">obj_uuid</th>
<th width="5%">obj_id</th>
<th width="3%">org</th>
<th width="3%">org_vdc</th>
<th width="3%">gpu</th>
<th width="3%">dt_load</th>
<th width="3%">dt_load_ts</th>
<th width="7%">cluster</th>
<th width="3%">is_template</th>
</tr>
</thead>
<cfoutput query="qVM">
<tr>
<td><a href="contragent.cfm?__id=#company_uid#&#tr.fwx#">#WZ#</a><a href="contragent_rpt.cfm?__id=#company_uid#&#tr.fwx#" style="float:right"><img src="img/view.gif" title="сводка по контрагенту"/></a></td>
<td>#Name#</td>
<td>#UUID_VM#</td>
<td>#Organization#</td>
<td>#VDC#</td>
<td><cftry>#round(VDC_CPU_Reserv,3)#<cfcatch></cfcatch></cftry></td>
<td><cftry>#round(VDC_CPU_Speed,3)#<cfcatch></cfcatch></cftry></td>
<td>#qVM.Cluster#</td>
<td>#Host#</td>
<td>#Host_Model#</td>
<td>#CPU_Model#</td>
<td>#Host_CPU_Cores#</td>
<td>#Host_CPU_Sockets#</td>
<td>#round(Host_CPU_Speed,3)#</td>
<td>#round(Host_RAM)#</td>
<td><cftry>#round(Host_CPU_Used,1)#<cfcatch></cfcatch></cftry></td>
<td><cftry>#round(Host_CPU_Used_Avg,1)#<cfcatch></cfcatch></cftry></td>
<td>#VM_vCPU_count#</td>
<td><cftry>#round(VM_CPU_Used,1)#<cfcatch></cfcatch></cftry></td>
<td><cftry>#round(VM_CPU_Used_AVG,1)#<cfcatch></cfcatch></cftry></td>
<td><cftry>#round(VM_CPU_Reserv_GHz,1)#<cfcatch></cfcatch></cftry></td>
<td>#VM_CPU_Reserv_perc#</td>
<td>#VM_RAM_Allocated#</td>
<td><cftry>#round(VM_RAM_Used)#<cfcatch></cfcatch></cftry></td>
<td>#VM_is_ON#</td>
<!--- <td><a href="contragent.cfm?__id=#company_uid#&#tr.fwx#">#client_sold#</a></td> --->
</tr>
<cfoutput query="qGPU">
<tr>
<td><a href="contragent.cfm?wz=#WZ#&#tr.fwx#">#WZ#</a></td>
<td>#obj_uuid#</td>
<td>#obj_id#</td>
<td>#org#</td>
<td>#org_vdc#</td>
<td>#gpu#</td>
<td>#dateFormat(dt_load, "YYYY-MM-DD")# #timeFormat(dt_load, "HH:MM")#</td>
<td>#dateFormat(dt_load_ts, "YYYY-MM-DD")# #timeFormat(dt_load_ts, "HH:MM")#</td>
<td>#clus#</td>
<td>#is_template#</td>
</tr>
</cfoutput>
</table>
<!--- <cfdump var=#qCharge#/> --->
+1
View File
@@ -18,6 +18,7 @@
<c:menu_item acl="" page="deal_ls.cfm" label="Сделки"/>
<c:menu_item acl="" page="vm_ls.cfm" label="VM"/>
<c:menu_item acl="" page="gpu_ls.cfm" label="GPU"/>
<li class="menu-title">Отчеты</li>
<c:menu_item acl="" page="crm2cloud.cfm" label="CRM - Cloud"/>
+86 -2
View File
@@ -15,6 +15,7 @@
<cfset hours=dateDiff('h', dt_start, dateAdd('d', 1, dt_finish))/>
<cfparam name="only_articles_in_spec" type="boolean" default=false/>
<cfparam name="wz" default=""/>
<cfparam name="code" default=""/>
<!--- *** коды лучше взять из каталога --->
<cfquery name="qCode" datasource="dwh" cachedWithin=#createTimeSpan(0, 0, 20, 0)#>
@@ -89,6 +90,9 @@
AND p.cnt <> 0 --похоже, только так можно отфильтровать паразитные строки с нулем
<cfif len(wz)>
AND k.id_klienta like <cfqueryparam cfsqltype="cf_sql_varchar" value="%#wz#%"/>
</cfif>
<cfif len(code)>
AND p.code like <cfqueryparam cfsqltype="cf_sql_varchar" value="%#code#%"/>
</cfif>
--AND k.id_klienta='WZ01031'
--AND k.id_klienta='WZ01112'
@@ -329,33 +333,112 @@ select
<cfoutput>qS3OpsTrfAge:#getTickCount()-request.startTickCount#</cfoutput><cfif !isDefined("output_xls") AND !isDefined("output_json")><cfflush/></cfif>
<!--- выданы права на схему и таблицы, чтобы без толку не плодить источники данных --->
<!--- считаются часы работы ВМ с GPU --->
<cfquery name="qGpu" datasource="billing-vc" cachedWithin=#createTimeSpan(0, 0, 31, 0)#>
WITH card (model, cluster, code) as (VALUES
('A100', 'msk1-pub02-i31', 'iaas.ngc.i31.gpu80'),
('H100', 'msk1-pub07-a40', 'iaas.ngc.a40.gpuh100'), -- h200 нет в отчете
('RTX 4090', 'msk1-pcs05-a45', 'iaas.ngc.a45.gpu4090'), -- нет такого в каталоге
('RTX 5090', 'msk1-pcs05-a45', 'iaas.ngc.a45.gpu5090'),
('RTX 6000', 'msk1-pub07-a40', 'iaas.ngc.a40.gpu6k'),
('nvidia_a16-16q', 'msk1-pub07-a40', 'iaas.ngc.a40.gpu16'),
('nvidia_a16-16q', 'msk1-pub01-i29', 'iaas.ngc.i29.gpu16'),
('nvidia_a16-1b', 'msk1-pub07-a40', 'iaas.ngc.a40.gpu1'),
('nvidia_a16-2q', 'msk1-pub07-a40', 'iaas.ngc.a40.gpu2'),
('nvidia_a16-4q', 'msk1-pub07-a40', 'iaas.ngc.a40.gpu4'),
('nvidia_rtx_pro_6000_blackwell_dc-4q', 'msk1-pub07-a40', 'iaas.ngc.a40.gpu6k4')
)
SELECT item.key AS gpu_model, c.code
,SUM(item.value::int*p.value)/12. AS gpu_h -- 5 minute sampling
,vm.obj_id, upper(trim(vm.client_id)) as WZ
FROM gpu.vm
CROSS JOIN LATERAL jsonb_each(vm.gpu) AS item(key, value)
LEFT OUTER JOIN card c ON (item.key=c.model)
JOIN gpu.vm_power_state p ON (vm.obj_uuid=p.obj_uuid)
WHERE NOT vm.is_template
AND p.ts >= <cfqueryparam cfsqltype="cf_sql_timestamp" value=#dt_start#/>
AND p.ts < <cfqueryparam cfsqltype="cf_sql_timestamp" value=#dateAdd("d",1,dt_finish)#/>
GROUP BY vm.client_id, item.key, c.code, vm.obj_id
ORDER BY vm.client_id, item.key, c.code, vm.obj_id;
</cfquery>
<cfoutput>qGpu:#getTickCount()-request.startTickCount#</cfoutput><cfif !isDefined("output_xls") AND !isDefined("output_json")><cfflush/></cfif>
<cfif isDefined("DEBUG")>
<cfdump var=#qGpu#/>
<cfif !isDefined("output_xls") AND !isDefined("output_json")><cfflush/></cfif>
</cfif>
<cfquery name="qGpuAge" datasource="billing-vc" cachedWithin=#createTimeSpan(0, 0, 31, 0)#>
select max(dt_load) as dt_load from gpu.vm
</cfquery>
<cfoutput>qGpuAge:#getTickCount()-request.startTickCount#</cfoutput><cfif !isDefined("output_xls") AND !isDefined("output_json")><cfflush/></cfif>
<cfquery name="qUnifiedMetric" dbType="query">
select wz, code || '.vcpu' as code, core_h as raw_metric, core_h as metric, 'core-h' as unit, vdc as dimension1
from qComputing
<cfif len(code)>
where code || '.vcpu' like <cfqueryparam cfsqltype="cf_sql_varchar" value="%#code#%"/>
</cfif>
union all
select wz, code || '.ram', gb_h as raw_metric, gb_h as metric, 'GByte-h' as unit, vdc as dimension1
from qComputing
<cfif len(code)>
where code || '.ram' like <cfqueryparam cfsqltype="cf_sql_varchar" value="%#code#%"/>
</cfif>
union all
select wz, code, gb_m_used as raw_metric, gb_m_used as metric, 'GByte-m' as unit, vdc ||':'|| profile as dimension1
from qStorage
<cfif len(code)>
where code like <cfqueryparam cfsqltype="cf_sql_varchar" value="%#code#%"/>
</cfif>
union all
select wz, code || '.vol', vol_b as raw_metric, vol_gb as metric, 'GByte-m' as unit, bucket as dimension1
from qS3Vol
<cfif len(code)>
where code || '.vol' like <cfqueryparam cfsqltype="cf_sql_varchar" value="%#code#%"/>
</cfif>
union all
select wz, code || '.get', get as raw_metric, get_10k as metric, '10k' as unit, bucket as dimension1
select wz, code || '.vol', get as raw_metric, get_10k as metric, '10k' as unit, bucket as dimension1
from qS3OpsTrf
<cfif len(code)>
where code || '.vol' like <cfqueryparam cfsqltype="cf_sql_varchar" value="%#code#%"/>
</cfif>
union all
select wz, code || '.put', put as raw_metric, put_10k as metric, '10k' as unit, bucket as dimension1
from qS3OpsTrf
<cfif len(code)>
where code || '.put' like <cfqueryparam cfsqltype="cf_sql_varchar" value="%#code#%"/>
</cfif>
union all
select wz, code || '.trf', bytes_sent as raw_metric, bytes_sent_gb as metric, 'GByte' as unit, bucket as dimension1
from qS3OpsTrf
<cfif len(code)>
where code || '.trf' like <cfqueryparam cfsqltype="cf_sql_varchar" value="%#code#%"/>
</cfif>
union all
select wz, code, gpu_h as raw_metric, gpu_h as metric, 'h' as unit, obj_id as dimension1
from qGpu
<cfif len(code)>
where code like <cfqueryparam cfsqltype="cf_sql_varchar" value="%#code#%"/>
</cfif>
order by wz, code
</cfquery>
@@ -499,7 +582,8 @@ ORDER BY coalesce(coalesce(c.wz, m.wz), s.wz), coalesce(s.code, m.code)
Период с <input type="text" name="dt_start" value="#dateFormat(dt_start,'YYYY-MM-DD')#"/>
по <input type="text" name="dt_finish" value="#dateFormat(dt_finish,'YYYY-MM-DD')#"/>
Только PAYG <input type="checkbox" name="only_articles_in_spec" value="1"<cfif only_articles_in_spec> checked</cfif>/>
WZ <input type="text" name="wz" value="#wz#"/> по вхождению подстроки, с учетом регистра
WZ <input type="text" name="wz" value="#wz#"/>по вхождению, с регистром
Код <input type="text" name="code" value="#code#"/>>по вхождению
<input type="submit" style="cursor:pointer;"/>
<input type="submit" name="DEBUG" value="DEBUG" style="cursor:pointer;"/>
</form>