Update tablespaceusage.pm

Add a spesific sql request for Oracle >= 11
The new sql request used Oracle View DBA_TABLESPACE_USAGE_METRICS
Reduces the time of the request by the 20 large database
This commit is contained in:
Yann Beulque 2016-01-25 16:36:27 +01:00
parent 0ec07f5846
commit caa31d76dd
1 changed files with 30 additions and 7 deletions

View File

@ -67,7 +67,24 @@ sub run {
$self->{sql}->connect();
my $query;
if ($self->{sql}->is_version_minimum(version => '9')) {
if ($self->{sql}->is_version_minimum(version => '11')) {
$query = q{
SELECT
tum.tablespace_name "Tablespace",
t.status "Status",
t.contents "Type",
t.extent_management "Extent Mgmt",
tum.used_space*t.block_size bytes,
tum.tablespace_size*t.block_size bytes_max
FROM
DBA_TABLESPACE_USAGE_METRICS tum
INNER JOIN
dba_tablespaces t on tum.tablespace_name=t.tablespace_name
WHERE
t.contents<>'UNDO'
OR (t.contents='UNDO' AND t.tablespace_name =(SELECT value FROM v$parameter WHERE name='undo_tablespace'))
};
} elsif ($self->{sql}->is_version_minimum(version => '9')) {
$query = q{
SELECT
a.tablespace_name "Tablespace",
@ -274,7 +291,13 @@ sub run {
$status = lc $status;
$type = lc $type;
my ($percent_used, $percent_free, $used, $free, $size);
if ((!defined($bytes_max)) || ($bytes_max == 0)) {
if ($self->{sql}->is_version_minimum(version => '11')) {
$percent_used = $bytes / $bytes_max * 100;
$size = $bytes_max;
$free = $bytes_max - $bytes;
$used = $bytes;
}
elsif ((!defined($bytes_max)) || ($bytes_max == 0)) {
$percent_used = ($bytes - $bytes_free) / $bytes * 100;
$size = $bytes;
$free = $bytes_free;