<?php
$monitorsql=array(
"product_component_version"=>"SELECT PRODUCT, VERSION FROM PRODUCT_COMPONENT_VERSION WHERE PRODUCT like '%Database%'",
"tablespace"=>"select tablespace_name,
max_gb,
used_gb,
round(100 * used_gb / max_gb) pct_used,
status,LOGGING,FORCE_LOGGING,EXTENT_MANAGEMENT,ALLOCATION_TYPE
from (
select t.status status,t.LOGGING LOGGING,t.FORCE_LOGGING FORCE_LOGGING,t.EXTENT_MANAGEMENT EXTENT_MANAGEMENT,t.ALLOCATION_TYPE ALLOCATION_TYPE,a.tablespace_name tablespace_name,
round((a.bytes_alloc - nvl(b.bytes_free, 0)) / power(2, 30),
2) used_gb,
round(a.maxbytes / power(2, 30), 2) max_gb
from dba_tablespaces t,(select f.tablespace_name,
sum(f.bytes) bytes_alloc,
sum(decode(f.autoextensible,
'YES',
f.maxbytes,
'NO',
f.bytes)) maxbytes
from dba_data_files f
group by tablespace_name) a,
(select f.tablespace_name, sum(f.bytes) bytes_free
from dba_free_space f
group by tablespace_name) b
where a.tablespace_name = b.tablespace_name(+) and a.tablespace_name = t.tablespace_name
union all
select t.status status,t.LOGGING LOGGING,t.FORCE_LOGGING FORCE_LOGGING,t.EXTENT_MANAGEMENT EXTENT_MANAGEMENT,t.ALLOCATION_TYPE ALLOCATION_TYPE,h.tablespace_name tablespace_name,
round(sum(nvl(p.bytes_used, 0)) / power(2, 30), 2) used_gb,
round(sum(decode(f.autoextensible,
'YES',
f.maxbytes,
'NO',
f.bytes)) / power(2, 30),
2) max_gb
from dba_tablespaces t,v\$temp_space_header h, v\$temp_extent_pool p, dba_temp_files f
where p.file_id(+) = h.file_id
and p.tablespace_name(+) = h.tablespace_name
and f.file_id = h.file_id
and f.tablespace_name = h.tablespace_name
and t.tablespace_name = h.tablespace_name
group by h.tablespace_name,t.status,t.LOGGING,t.FORCE_LOGGING,t.EXTENT_MANAGEMENT,t.ALLOCATION_TYPE
)
order by 4",
"datafiles"=>"SELECT FILE_NAME,FILE_ID,TABLESPACE_NAME,BYTES,STATUS,AUTOEXTENSIBLE,MAXBYTES,INCREMENT_BY,ONLINE_STATUS FROM dba_data_files");
//foreach($age as $x=>$x_value)
//{
//echo "Key=" . $x . ", Value=" . $x_value;
//echo "<br>";
//}
?>