051 cloud_capacity division by zero

This commit is contained in:
2026-06-18 11:41:59 +03:00
parent f1e4ee238e
commit 1f7ea5c3b1
7 changed files with 52 additions and 17 deletions
+1 -1
View File
@@ -76,7 +76,7 @@
<!--- global settings --->
<cfset request.RECORDS_PER_PAGE=500/>
<cfset request.APP_VERSION="0.00.050"/>
<cfset request.APP_VERSION="0.00.051"/>
<cfset request.STAND=getStand()/>
<cflock scope="application" type="readonly" timeout=3>
+10 -10
View File
@@ -270,9 +270,9 @@ from qRead
<td class="r<cfif safeCompareNum(gb_provisioned - vm_ram_used, "LE", 0)> err</cfif>" style="font-size:130%">#safeNumberFormat(gb_provisioned - vm_ram_used,"0")#</td>
<td class="r<cfif safeCompareNum(ghz_provisioned - vm_ghz_reserved, "LE", 0)> err</cfif>" style="font-size:130%">#safeNumberFormat(ghz_provisioned-vm_ghz_reserved,".0")#</td>
<td class="r<cfif safeCompareNum(ghz_provisioned - vm_ghz_reserved, "LE", 0)> err</cfif>" style="font-size:130%">#safeNumberFormat((ghz_provisioned-vm_ghz_reserved)/ghz/0.2,"0")#</td>
<td class="r<cfif safeCompareNum(ghz_provisioned - vm_ghz_reserved, "LE", 0)> err</cfif>" style="font-size:130%">#safeNumberFormat((ghz_provisioned-vm_ghz_reserved)/ghz/0.5,"0")#</td>
<td class="r<cfif safeCompareNum(ghz_provisioned - vm_ghz_reserved, "LE", 0)> err</cfif>" style="font-size:130%">#safeNumberFormat((ghz_provisioned-vm_ghz_reserved)/ghz/0.8,"0")#</td>
<td class="r<cfif safeCompareNum(ghz_provisioned - vm_ghz_reserved, "LE", 0)> err</cfif>" style="font-size:130%"><cfif ghz GT 0>#safeNumberFormat((ghz_provisioned-vm_ghz_reserved)/ghz/0.2,"0")#</cfif></td>
<td class="r<cfif safeCompareNum(ghz_provisioned - vm_ghz_reserved, "LE", 0)> err</cfif>" style="font-size:130%"><cfif ghz GT 0>#safeNumberFormat((ghz_provisioned-vm_ghz_reserved)/ghz/0.5,"0")#</cfif></td>
<td class="r<cfif safeCompareNum(ghz_provisioned - vm_ghz_reserved, "LE", 0)> err</cfif>" style="font-size:130%"><cfif ghz GT 0>#safeNumberFormat((ghz_provisioned-vm_ghz_reserved)/ghz/0.8,"0")#</cfif></td>
<!--- <td class="r<cfif safeCompareNum(ghz_provisioned - vm_ghz_promised, "LE", 0)> err</cfif>" style="font-size:130%">#safeNumberFormat(ghz_provisioned-vm_ghz_promised,".0")#</td>
<td class="r<cfif safeCompareNum(ghz_provisioned - vm_ghz_promised, "LE", 0)> err</cfif>" style="font-size:130%">#safeNumberFormat((ghz_provisioned-vm_ghz_promised)/ghz/0.2,"0")#</td>
@@ -381,7 +381,7 @@ from qRead
<td class="r">#numberFormat(vm_ghz_usage,".0")#</td>
<td class="r"></td>
<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" style="font-size:130%;"><cfif cores_in_service NEQ 0>#numberFormat(vm_cores/cores_in_service,".0")#</cfif></td>
<td class="r"></td>
<td class="r">#numberFormat(ghz_provisioned,".0")#</td>
<td class="r">#numberFormat(vm_ghz_reserved,".0")#</td>
@@ -391,15 +391,15 @@ from qRead
<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>
<td class="r" style="font-size:130%;">#numberFormat(vm_ram_used/ram_in_service*100,"0")#</td>
<td class="r" style="font-size:130%;"><cfif ram_in_service NEQ 0>#numberFormat(vm_ram_alloc/ram_in_service*100,"0")#</cfif></td>
<td class="r" style="font-size:130%;"><cfif ram_in_service NEQ 0>#numberFormat(vm_ram_used/ram_in_service*100,"0")#</cfif></td>
<td class="r">#vms#</td>
<td class="r">
<cftry>
#numberFormat(vm_cores/vms,".0")#&nbsp;core
#numberFormat(vm_ghz_usage/vms,".0")#&nbsp;GHz
#numberFormat(vm_ghz_usage/vm_cores/ghz*100,"0")#% <!--- *** тут не уверен --->
#numberFormat(vm_ram_alloc/vms,".0")#(#numberFormat(vm_ram_used/vms,".0")#)&nbsp;GB
<cfif vms NEQ 0>#numberFormat(vm_cores/vms,".0")#&nbsp;core</cfif>
<cfif vms NEQ 0>#numberFormat(vm_ghz_usage/vms,".0")#&nbsp;GHz</cfif>
<cfif vm_cores NEQ 0 AND ghz NEQ 0>#numberFormat(vm_ghz_usage/vm_cores/ghz*100,"0")#%</cfif> <!--- *** тут не уверен --->
<cfif vms NEQ 0>#numberFormat(vm_ram_alloc/vms,".0")#(#numberFormat(vm_ram_used/vms,".0")#)&nbsp;GB</cfif>
<cfcatch></cfcatch></cftry>
</td>
</tr>
+1 -1
View File
@@ -85,7 +85,7 @@
<div class="tr">
<div class="th">__name</div>
<div class="td">#d.__name#</div>
<div class="td">#d.__name# <a href="contragent_rpt.cfm?__id=#d.__id#&#tr.fwx#">Сводка по потреблению</a></div></div>
</div>
<div class="tr">
+7 -5
View File
@@ -112,8 +112,9 @@
<cfif len(d.__id)>
<cfquery name="qService">
with
status(status, status_id, probability_pc) as (VALUES
WITH
status(status, status_id, probability_pc)
AS (VALUES
('Закрыта неуспешно',7,0),('Закрыта успешно',6,100),('Договор подписан',5,100),('Договор на подписании',15,90),('Договор на согласовании',12,70),
('Тестирование',8,50),('Отправлено ТКП',10,20),('Внутреннее согласование',37,10),('Проработка решения',4,10),('Сбор потребностей',1,0)
)
@@ -154,11 +155,11 @@
AND d."__deletedAt" IS NULL
AND a."__deletedAt" IS NULL
AND s.probability_pc >= 50
--and a.is_actual *** возможно схема версионности противоречива
--and a.is_actual *** возможно, схема версионности противоречива
AND siv.type IN (2, 3)
AND d._companies = <cfqueryparam cfsqltype="cf_sql_other" value=#d.__id#/><!--- '019503f2-5774-7768-b5c9-566a71daedaa' --->
)
,component
,component
AS (
SELECT cnt
,code
@@ -170,7 +171,7 @@
FROM elma.service_parametrs
WHERE "__deletedAt" IS NULL
)
,stair
,stair
AS (
SELECT *
FROM (
@@ -192,6 +193,7 @@
WHERE t.dt_from = t.running_min_dt
--AND ( t.dt_to > CURRENT_TIMESTAMP OR t.dt_to IS NULL )
)
SELECT d.siv_uid::text as siv_uid
,d.siv_index
,d.deal
+2
View File
@@ -7,6 +7,8 @@
<m:prepare_ls entity="crm2cloud" settingsKey="crm2cloud" accessObject="" pageInfoOut="pageInfo" trackOut="tr"/>
<!--- *** нуждается в оптимизации, чтобы фильтр по контрагенту ускорял селект --->
<cfparam name="dt_report" default=#Now()#/>
+8
View File
@@ -0,0 +1,8 @@
CREATE INDEX ON ngcloud_ru.capacity_resource (timestamp);
CREATE INDEX ON ngcloud_ru.capacity_storage (timestamp);
CREATE INDEX ON s3billing.bucket_stat (timestamp_addition);
CREATE INDEX ON s3billing.usage_bucket_by_user (time);
CREATE INDEX ON gpu.vm (dt_load);
CREATE INDEX ON gpu.vm_power_state (ts);
+23
View File
@@ -29,6 +29,9 @@
where p.type=3 AND aa.is_actual
order by p.code
</cfquery>
<cfoutput> #getTickCount()-request.startTickCount#</cfoutput><cfflush/>
<!--- <cfdump var=#qCode#/> --->
<cfquery name="qContragent" datasource="dwh">
select k.id_klienta as wz, k.__id::text as contragent_uid, k.__name as contragent
@@ -36,6 +39,7 @@
where k."__deletedAt" IS NULL
</cfquery>
<cfoutput> #getTickCount()-request.startTickCount#</cfoutput><cfflush/>
<!--- нужны компании, которые есть в пейге --->
<cfquery name="qSpec" datasource="dwh">
select k.id_klienta as wz, k.__id::text as contragent_uid, p.code, p.price, p.discount, k.__name as contragent, a.__name as contract, a.__id::text as contract_uid, d.__name as deal, d.__id::text as deal_uid, siv.abstractive_service as abstract_service, siv.modifier, siv.user_description, siv.hash as line_key
@@ -53,10 +57,16 @@
AND (siv.date_end > <cfqueryparam cfsqltype="cf_sql_timestamp" value=#dt_start#/> OR siv.date_end IS NULL)
order by k.id_klienta, p.code
</cfquery>
<cfoutput> #getTickCount()-request.startTickCount#</cfoutput><cfflush/>
<!--- siv means specification item version --->
<cfquery name="qSivAge" datasource="dwh">
select max(dt_load) as dt_load from elma.deals_services
</cfquery>
<cfoutput> #getTickCount()-request.startTickCount#</cfoutput><cfflush/>
<!--- здесь имеем список кодов с ценами и WZ. Каждому коду можно поставить в соответствие запрос, который даст по нему выборку. Изредка один запрос может вывести 2 кода, но разбить на 2 запроса легко. Кроме того, запросы можно объединить через union в один - может быть, так будет лучше читаться (быстрее выполняться не будет) --->
<cfif isDefined("DEBUG")>
<cfdump var=#qSpec#/>
@@ -90,6 +100,8 @@
order by m.clientid, vdc.name;
</cfquery>
<cfoutput> #getTickCount()-request.startTickCount#</cfoutput><cfflush/>
<cfif isDefined("DEBUG")>
<cfdump var=#qComputing#/>
<cfflush/>
@@ -99,6 +111,8 @@
select max(capacity_resource.timestamp) as dt_load from ngcloud_ru.capacity_resource
</cfquery>
<cfoutput> #getTickCount()-request.startTickCount#</cfoutput><cfflush/>
<!--- переделать storage_profile_types с расшифровкой ssd, sata, можно прямо до каталожного кода --->
<cfquery name="qStorage" datasource="billing-vc">
@@ -134,6 +148,9 @@
group by m.clientid, vdc.name, storage_profile_types.name
order by m.clientid, vdc.name, storage_profile_types.name;
</cfquery>
<cfoutput> #getTickCount()-request.startTickCount#</cfoutput><cfflush/>
<cfquery name="qStorageAge" datasource="billing-vc">
select max(capacity_storage.timestamp) as dt_load from ngcloud_ru.capacity_storage
</cfquery>
@@ -143,6 +160,8 @@
<cfflush/>
</cfif>
<cfoutput> #getTickCount()-request.startTickCount#</cfoutput><cfflush/>
<!---
"placement" "size_gb" "get_10k" "put_10k" "bytes_sent_gb"
HOT_FREE_LIMIT 1 10 1 100
@@ -177,10 +196,14 @@ HOT_FREE_LIMIT 1 10 1 100
<cfflush/>
</cfif>
<cfoutput> #getTickCount()-request.startTickCount#</cfoutput><cfflush/>
<cfquery name="qS3VolAge" datasource="billing-s3">
select max(timestamp_addition) as dt_load from s3billing.bucket_stat
</cfquery>
<cfoutput> #getTickCount()-request.startTickCount#</cfoutput><cfflush/>
<cfquery name="qS3OpsTrf" datasource="billing-s3">
select
sum(