#!/bin/bash
# Define the list of Oracle databases
databases=("abc" "bcd" "cde" "def" )
# Define the SQL query
sql_query=$(cat <<'EOF'
SET PAGESIZE 0
SET LONG 50000
SET FEEDBACK OFF
SET HEADING ON
SET LINESIZE 120
SET PAGESIZE 50000
SELECT a.tablespace_name,
ROUND(((a.bytes_alloc - NVL(b.bytes_free, 0)) / maxbytes) * 100) || '%' Pct_Used_Max
FROM
(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 (+)
ORDER BY 1;
EOF
)
# Create a temporary file to store the consolidated results
temp_file="tablespaces.txt"
# Loop through eac
linux shell脚本监控多台oracle 表空间使用
于 2024-05-21 16:27:16 首次发布