077 rounding
This commit is contained in:
+1
-1
@@ -86,7 +86,7 @@
|
||||
|
||||
<!--- global settings --->
|
||||
<!--- *************************************************************************************************** --->
|
||||
<cfset request.APP_VERSION="0.00.076"/> <!--- *********************************************************** --->
|
||||
<cfset request.APP_VERSION="0.00.077"/> <!--- *********************************************************** --->
|
||||
<!--- *************************************************************************************************** --->
|
||||
<cfset request.STAND=getStand()/>
|
||||
<cfset request.RECORDS_PER_PAGE=500/>
|
||||
|
||||
+3
-4
@@ -333,7 +333,7 @@ ORDER BY d.siv_uid, p.__id
|
||||
FROM qCompute
|
||||
</cfquery>
|
||||
|
||||
<h3>Compute факт <cfif len(qCompute.ts)><cfoutput>#dateFormat(qCompute.ts,'YYYY-MM-DD')# #timeFormat(qCompute.ts,'HH:MM:SS')#</cfoutput></cfif></h3>
|
||||
<h3>Compute факт <cfif len(qCompute.ts)><cfoutput><b<cfif datediff("h", qCompute.ts, Now()) GT 24> class="err"</cfif>>#dateFormat(qCompute.ts,'YYYY-MM-DD')# #timeFormat(qCompute.ts,'HH:MM:SS')#</cfoutput></b></cfif></h3>
|
||||
<table class="worktable">
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -399,7 +399,7 @@ ORDER BY d.siv_uid, p.__id
|
||||
FROM qStorage
|
||||
</cfquery>
|
||||
|
||||
<h3>Storage факт <cfif len(qStorage.ts)><cfoutput>#dateFormat(qStorage.ts,'YYYY-MM-DD')# #timeFormat(qStorage.ts,'HH:MM:SS')#</cfoutput></cfif></h3>
|
||||
<h3>Storage факт <cfif len(qStorage.ts)><cfoutput><b<cfif datediff("h", qStorage.ts, Now()) GT 24> class="err"</cfif>>#dateFormat(qStorage.ts,'YYYY-MM-DD')# #timeFormat(qStorage.ts,'HH:MM:SS')#</cfoutput></b></cfif></h3>
|
||||
<table class="worktable">
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -449,11 +449,10 @@ ORDER BY d.siv_uid, p.__id
|
||||
FROM vmreports.vm_gpu g
|
||||
WHERE g.ts=(select max(ts) from vmreports.vm_gpu)
|
||||
AND lower(g."ClientID")=lower(<cfqueryparam cfsqltype="cf_sql_varchar" value="#d.id_klienta#"/>)
|
||||
|
||||
</cfquery>
|
||||
|
||||
|
||||
<h3>GPU факт <cfif len(qGpu.ts)><cfoutput>#dateFormat(qGpu.ts,'YYYY-MM-DD')# #timeFormat(qGpu.ts,'HH:MM:SS')#</cfoutput></cfif></h3>
|
||||
<h3>GPU факт <cfif len(qGpu.ts)><cfoutput><b<cfif datediff("h", qGpu.ts, Now()) GT 24> class="err"</cfif>>#dateFormat(qGpu.ts,'YYYY-MM-DD')# #timeFormat(qGpu.ts,'HH:MM:SS')#</cfoutput></b></cfif></h3>
|
||||
<table class="worktable">
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
|
||||
select upper(trim(vm.client_id)) as wz
|
||||
,item.key as gpu_model
|
||||
,sum(item.value::int*p.value)/12. as gpu_h -- 5 minute sampling
|
||||
,avg(item.value::int*p.value)*744 as gpu_ha -- 5 minute sampling
|
||||
from gpu.vm
|
||||
JOIN gpu.vm_power_state p on (vm.obj_uuid=p.obj_uuid)
|
||||
CROSS JOIN LATERAL jsonb_each(vm.gpu) AS item(key, value)
|
||||
where 1=1
|
||||
AND p.ts >= '2026-07-01'
|
||||
AND p.ts < '2026-07-31'
|
||||
group by vm.client_id, item.key
|
||||
order by vm.client_id, item.key;
|
||||
|
||||
--select * from gpu.vm_power_state limit 100;
|
||||
--select * from gpu.vm limit 100;
|
||||
|
||||
select count(*), sum(value) from gpu.vm_power_state p
|
||||
where 1=1
|
||||
AND p.ts >= '2026-07-01'
|
||||
AND p.ts < '2026-07-31'
|
||||
group by obj_uuid
|
||||
|
||||
select item.key as gpu_model,
|
||||
case
|
||||
WHEN org_vdc LIKE '%-v1cl1%' THEN 'iaas.ngc.i29'
|
||||
WHEN org_vdc LIKE '%-v1cl2%' THEN 'iaas.ngc.i31'
|
||||
WHEN org_vdc LIKE '%-v1cl4%' THEN 'iaas.ngc.a28'
|
||||
WHEN org_vdc LIKE '%-v1cl5%' THEN 'iaas.ngc.a45'
|
||||
WHEN org_vdc LIKE '%-v1cl6%' THEN 'iaas.ngc.i28'
|
||||
WHEN org_vdc LIKE '%-v1cl7%' THEN 'iaas.ngc.a40'
|
||||
--WHEN org_vdc LIKE '%-v2cl2-1c%' THEN '1c'
|
||||
else '['||org_vdc||']' end as code
|
||||
from gpu.vm
|
||||
CROSS JOIN LATERAL jsonb_each(vm.gpu) AS item(key, value)
|
||||
group by item.key, code
|
||||
ORDER BY 1
|
||||
|
||||
|
||||
select client_id, org, obj_id, org_vdc, item.key as gpu_model, item.value as gpu_cnt
|
||||
from gpu.vm
|
||||
CROSS JOIN LATERAL jsonb_each(vm.gpu) AS item(key, value)
|
||||
ORDER BY client_id, org, obj_id
|
||||
|
||||
|
||||
select
|
||||
count(distinct obj_id) as unique_vm_cnt,
|
||||
sum(p.value)/12. as vm_h, -- 5 minute sampling
|
||||
sum(p.value)/12.*32.18 as cost,
|
||||
sum(p.value)/12./744 as avg_month_vm -- в августе 744 часа
|
||||
from gpu.vm
|
||||
JOIN gpu.vm_power_state p on (vm.obj_uuid=p.obj_uuid)
|
||||
where 1=1
|
||||
AND p.ts >= '2026-08-01'
|
||||
AND p.ts < '2026-08-31'
|
||||
AND vm.client_id='WZ01516'
|
||||
-- упражнение: посчитать, сколько средних ВМ, включенных круглые сутки, создаст такой же движ за время оказания сервиса
|
||||
|
||||
select
|
||||
p.ts::date,
|
||||
count(distinct obj_id) as unique_vm_cnt,
|
||||
round((sum(p.value)/12.)::numeric,1) as vm_h, -- 5 minute sampling
|
||||
round((sum(p.value)/12.*32.18)::numeric,2) as cost,
|
||||
round((sum(p.value)/12./24)::numeric, 1) as avg_roundclock_vm
|
||||
from gpu.vm
|
||||
JOIN gpu.vm_power_state p on (vm.obj_uuid=p.obj_uuid)
|
||||
where 1=1
|
||||
AND p.ts >= '2026-08-01'
|
||||
AND p.ts < '2026-08-31'
|
||||
AND vm.client_id='WZ01516'
|
||||
GROUP BY p.ts::date
|
||||
ORDER BY 1
|
||||
|
||||
select
|
||||
p.ts::date,
|
||||
count(distinct obj_id) as unique_vm_cnt,
|
||||
round((sum(p.value)/12.)::numeric,1) as vm_h, -- 5 minute sampling
|
||||
round((sum(p.value)/12.*32.18)::numeric,2) as cost,
|
||||
round((sum(p.value)/12.*32.18*(1-0.02*400/32.18))::numeric,2) as cost_wo_disk,
|
||||
round((count(distinct obj_id)*0.02*400*24)::numeric,2) as disk_cost_simplified, -- считаем все ВМ, включавшиеся за данные сутки
|
||||
round((sum(p.value)/12./24)::numeric, 1) as avg_roundclock_vm
|
||||
from gpu.vm
|
||||
JOIN gpu.vm_power_state p on (vm.obj_uuid=p.obj_uuid)
|
||||
where 1=1
|
||||
AND p.ts >= '2026-08-01'
|
||||
AND p.ts < '2026-08-31'
|
||||
AND vm.client_id='WZ01516'
|
||||
GROUP BY p.ts::date
|
||||
ORDER BY 1
|
||||
|
||||
select
|
||||
p.ts::date,
|
||||
count(distinct obj_id) as unique_vm_cnt,
|
||||
(select count(distinct obj_id) from gpu.vm vm1
|
||||
JOIN gpu.vm_power_state p1 on (vm1.obj_uuid=p1.obj_uuid)
|
||||
WHERE vm1.client_id='WZ01516' AND p1.ts <= p.ts::date) as unique_vm_acc,
|
||||
round((sum(p.value)/12.)::numeric,1) as vm_h, -- 5 minute sampling
|
||||
round((sum(p.value)/12.*32.18)::numeric,2) as cost,
|
||||
round((sum(p.value)/12.*32.18*(1-0.02*400/32.18))::numeric,2) as cost_wo_disk,
|
||||
round((count(distinct obj_id)*0.02*400*24)::numeric,2) as disk_cost_simplified, -- считаем все ВМ, включавшиеся за данные сутки
|
||||
round((sum(p.value)/12./24)::numeric, 1) as avg_roundclock_vm
|
||||
from gpu.vm
|
||||
JOIN gpu.vm_power_state p on (vm.obj_uuid=p.obj_uuid)
|
||||
where 1=1
|
||||
AND p.ts >= '2026-08-01'
|
||||
AND p.ts < '2026-08-31'
|
||||
AND vm.client_id='WZ01516'
|
||||
GROUP BY p.ts::date
|
||||
ORDER BY 1
|
||||
|
||||
|
||||
with daily as (
|
||||
select
|
||||
p.ts::date as dt,
|
||||
count(distinct obj_id) as unique_vm_cnt,
|
||||
round((sum(p.value)/12.)::numeric,1) as vm_h, -- 5 minute sampling
|
||||
round((sum(p.value)/12.*32.18)::numeric,2) as cost,
|
||||
round((sum(p.value)/12.*32.18*(1-0.02*400/32.18))::numeric,2) as cost_wo_disk,
|
||||
round((count(distinct obj_id)*0.02*400*24)::numeric,2) as disk_cost_simplified, -- считаем все ВМ, включавшиеся за данные сутки
|
||||
round((sum(p.value)/12./24)::numeric, 1) as avg_roundclock_vm
|
||||
from gpu.vm
|
||||
JOIN gpu.vm_power_state p on (vm.obj_uuid=p.obj_uuid)
|
||||
where 1=1
|
||||
AND p.ts >= '2026-08-01'
|
||||
AND p.ts < '2026-08-31'
|
||||
AND vm.client_id='WZ01516'
|
||||
GROUP BY p.ts::date
|
||||
ORDER BY 1
|
||||
),
|
||||
acc as (select p.ts::date as dt, count(distinct obj_id) as unique_vm_accum from gpu.vm
|
||||
JOIN gpu.vm_power_state p on (vm.obj_uuid=p.obj_uuid)
|
||||
WHERE vm.client_id='WZ01516'
|
||||
group by p.ts::date)
|
||||
select * from daily join acc on daily.dt<=acc.dt
|
||||
@@ -144,6 +144,8 @@ select * from elma.deals_services where __id='019edf9c-c23d-7ad6-a990-643dd09579
|
||||
order by m.clientid, vdc.name;
|
||||
</cfquery>
|
||||
|
||||
<!--- recommended CREATE INDEX idx_tenant_metadata_tenant_ts_desc ON ngcloud_ru.tenant_metadata (tenant_id, ts DESC, metadata_id DESC); --->
|
||||
|
||||
<cfoutput>qComputing:#getTickCount()-request.startTickCount#</cfoutput><cfif !isDefined("output_xls") AND !isDefined("output_json")><cfflush/></cfif>
|
||||
|
||||
<cfif isDefined("DEBUG")>
|
||||
@@ -265,22 +267,13 @@ select
|
||||
OR category.name LIKE 'options%'
|
||||
) THEN ops ELSE 0 END
|
||||
) as get
|
||||
,ceil(sum(
|
||||
,(sum(
|
||||
CASE WHEN
|
||||
(category.name LIKE 'get%'
|
||||
OR category.name LIKE 'head%'
|
||||
OR category.name LIKE 'options%'
|
||||
) THEN ops ELSE 0 END
|
||||
)/10000) as get_10k
|
||||
,greatest(ceil(sum(
|
||||
CASE WHEN
|
||||
(category.name LIKE 'get%'
|
||||
OR category.name LIKE 'head%'
|
||||
OR category.name LIKE 'options%'
|
||||
) THEN ops ELSE 0 END
|
||||
)/10000) - CASE WHEN bucket_info.placement_id = 1 THEN 10 ELSE 0 END, 0
|
||||
) as get_10k_free_tier_subtracted
|
||||
|
||||
)/10000) as get_10k
|
||||
,sum(
|
||||
CASE WHEN
|
||||
(category.name LIKE 'put%'
|
||||
@@ -289,29 +282,16 @@ select
|
||||
OR category.name LIKE 'list%'
|
||||
) THEN ops ELSE 0 END
|
||||
) as put
|
||||
,ceil(sum(
|
||||
,(sum(
|
||||
CASE WHEN
|
||||
(category.name LIKE 'put%'
|
||||
OR category.name LIKE 'post%'
|
||||
OR category.name LIKE 'patch%'
|
||||
OR category.name LIKE 'list%'
|
||||
) THEN ops ELSE 0 END
|
||||
)/10000) as put_10k
|
||||
,greatest(ceil(sum(
|
||||
CASE WHEN
|
||||
(category.name LIKE 'put%'
|
||||
OR category.name LIKE 'post%'
|
||||
OR category.name LIKE 'patch%'
|
||||
OR category.name LIKE 'list%'
|
||||
) THEN ops ELSE 0 END
|
||||
)/10000) - CASE WHEN bucket_info.placement_id = 1 THEN 1 ELSE 0 END, 0
|
||||
) as put_10k_free_tier_subtracted
|
||||
|
||||
)/10000) as put_10k
|
||||
,(sum(bytes_sent)) as bytes_sent
|
||||
,ceil(sum(bytes_sent)/1024/1024/1024) as bytes_sent_GB
|
||||
,greatest(ceil(sum(bytes_sent)/1024/1024/1024) - CASE WHEN bucket_info.placement_id = 1 THEN 100 ELSE 0 END, 0
|
||||
) as bytes_sent_GB_free_tier_subtracted
|
||||
|
||||
,(sum(bytes_sent)/1024/1024/1024) as bytes_sent_GB
|
||||
,case
|
||||
when bucket_info.placement_id = 1 then 'paas.s3.ceph'
|
||||
when bucket_info.placement_id = 2 then 'paas.s3.cphc'
|
||||
@@ -525,10 +505,10 @@ WZ <input type="text" name="wz" value="#wz#"/> по вхождению подс
|
||||
</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>
|
||||
VCD Computing: <b<cfif datediff("h",qComputingAge.dt_load, Now()) GT 24> class="err"</cfif>>>#dateFormat(qComputingAge.dt_load,'YYYY-MM-DD')# #timeFormat(qComputingAge.dt_load,'HH:MM:SS')#</b>
|
||||
VCD Storage: <b<cfif datediff("h",qStorageAge.dt_load, Now()) GT 24> class="err"</cfif>>>#dateFormat(qStorageAge.dt_load,'YYYY-MM-DD')# #timeFormat(qStorageAge.dt_load,'HH:MM:SS')#</b>
|
||||
S3 хранение: <b<cfif datediff("h",qS3VolAge.dt_load, Now()) GT 24> class="err"</cfif>>>#dateFormat(qS3VolAge.dt_load,'YYYY-MM-DD')# #timeFormat(qS3VolAge.dt_load,'HH:MM:SS')#</b>
|
||||
S3 операции и трафик: <b<cfif datediff("h",qS3OpsTrfAge.dt_load, Now()) GT 24> class="err"</cfif>>>#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>
|
||||
|
||||
Reference in New Issue
Block a user