sync SVN r18017/r18018: diagnoza spatiu - autoextend si prag disc

Continut adus prin svn update din alta copie de lucru, identic cu 04a7d05 de
pe origin/main. Doua gauri prin care o baza blocata putea sa nu alerteze:
tablespace fara autoextend (maxbytes = 0 il scotea din verificare, acum
plafonul e GREATEST(maxbytes, bytes)) si disc plin sub datafile
autoextensibil (sectiunea DISC are prag propriu si ruleaza mereu, prima).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013gYCNE26G1G7UoGu2ju7aS
This commit is contained in:
2026-08-20 16:42:49 +03:00
parent b9a14bcb9c
commit 5637fc2fa5
3 changed files with 80 additions and 22 deletions

View File

@@ -174,21 +174,29 @@ with ts_free as (
sum(greatest(f.maxbytes - f.bytes, 0)) creste_bytes
from dba_data_files f
group by f.tablespace_name
), calc as (
select a.tablespace_name, a.alocat_bytes, a.max_bytes,
nvl(tf.free_bytes,0) free_bytes,
nvl(tf.free_bytes,0) + a.creste_bytes creste_total_bytes,
greatest(a.max_bytes, a.alocat_bytes) limita_bytes
from agg a, ts_free tf
where a.tablespace_name = tf.tablespace_name(+)
)
select a.tablespace_name,
round(a.alocat_bytes/1048576) mb_alocat,
round(a.max_bytes/1048576) mb_max,
round(nvl(tf.free_bytes,0)/1048576) mb_liber,
round((nvl(tf.free_bytes,0) + a.creste_bytes)/1048576) mb_poate_creste,
case when a.max_bytes > 0 and (nvl(tf.free_bytes,0) + a.creste_bytes) <
greatest($PragTsMb * 1048576, a.max_bytes * $PragTsPct / 100)
select c.tablespace_name,
round(c.alocat_bytes/1048576) mb_alocat,
round(c.max_bytes/1048576) mb_max,
round(c.free_bytes/1048576) mb_liber,
round(c.creste_total_bytes/1048576) mb_poate_creste,
case when c.limita_bytes > 0 and c.creste_total_bytes <
case when c.limita_bytes <= $PragTsMb * 1048576
then c.limita_bytes * $PragTsPct / 100
else greatest($PragTsMb * 1048576, c.limita_bytes * $PragTsPct / 100) end
then 'ATENTIE: APROAPE FARA LOC' end stare
from agg a, ts_free tf
where a.tablespace_name = tf.tablespace_name(+)
order by a.tablespace_name;
from calc c
order by c.tablespace_name;
exit
"@
Show-Section -Title '2. SPATIU TABLESPACE (detaliu pe datafile + cat mai poate creste)' -Text ('mb_poate_creste = liber curent + (maxbytes - alocat) - spatiul real disponibil inainte de ORA-01653, nu doar liberul de acum.' + "`n" + ('Prag de atentie: sub ' + $PragTsMb + ' MB ramasi sau sub ' + $PragTsPct + '% din maximul tablespace-ului.') + "`n`n" + $r2.Text)
Show-Section -Title '2. SPATIU TABLESPACE (detaliu pe datafile + cat mai poate creste)' -Text ('mb_poate_creste = liber curent + (maxbytes - alocat) - spatiul real disponibil inainte de ORA-01653, nu doar liberul de acum.' + "`n" + ('Prag de atentie: sub ' + $PragTsMb + ' MB ramasi sau sub ' + $PragTsPct + '% din maximul tablespace-ului; pe cele cu maximul sub prag (UNDO, SYSTEM mic) doar procentul, iar la datafile fara autoextend maximul e chiar spatiul alocat.') + "`n`n" + $r2.Text)
# tablespace-urile care au trecut pragul de atentie - top segmente acolo
$r2m = Invoke-Sql -Sql @"
@@ -196,16 +204,24 @@ set pagesize 0 linesize 100 trimspool on feedback off heading off
with ts_free as (
select tablespace_name, sum(bytes) free_bytes from dba_free_space group by tablespace_name
), agg as (
select f.tablespace_name, sum(f.maxbytes) max_bytes, sum(greatest(f.maxbytes - f.bytes, 0)) creste_bytes
select f.tablespace_name, sum(f.bytes) alocat_bytes, sum(f.maxbytes) max_bytes,
sum(greatest(f.maxbytes - f.bytes, 0)) creste_bytes
from dba_data_files f
group by f.tablespace_name
), calc as (
select a.tablespace_name,
nvl(tf.free_bytes,0) + a.creste_bytes creste_total_bytes,
greatest(a.max_bytes, a.alocat_bytes) limita_bytes
from agg a, ts_free tf
where a.tablespace_name = tf.tablespace_name(+)
)
select 'TS_ATENTIE|' || a.tablespace_name
from agg a, ts_free tf
where a.tablespace_name = tf.tablespace_name(+)
and a.max_bytes > 0
and (nvl(tf.free_bytes,0) + a.creste_bytes) <
greatest($PragTsMb * 1048576, a.max_bytes * $PragTsPct / 100);
select 'TS_ATENTIE|' || c.tablespace_name
from calc c
where c.limita_bytes > 0
and c.creste_total_bytes <
case when c.limita_bytes <= $PragTsMb * 1048576
then c.limita_bytes * $PragTsPct / 100
else greatest($PragTsMb * 1048576, c.limita_bytes * $PragTsPct / 100) end;
exit
"@
$tsProblema = @($r2m.Text -split "`r?`n" | ForEach-Object { $_.Trim() } | Where-Object { $_.StartsWith('TS_ATENTIE|') } | ForEach-Object { $_.Substring(11) } | Where-Object { $_ -match '^[A-Z0-9_]+$' })