# Oracle Database Inspection Commands

# OS

hostname
ip a
cat /etc/os-release
cat /etc/hosts
df -hT
free -g
grep Huge /proc/meminfo
cat /proc/cmdline
cat /proc/net/bonding/bond0
cat /proc/net/bonding/bond1
vmstat 2 5
iostat 1 2
top -n 1
lsnrctl status

# CRS

ocrcheck
ocrconfig -showbackup
crsctl stat res -t
asmcmd lsdg

# DB

set lines 200 pages 100
select name,open_mode,log_mode from v$database;
select * from v$version;
select * from nls_database_parameters;
select 'DB Size/Used/Rate',
trunc(sum(a.bytes)/1024/1024/1024,2)||'G/'||trunc((sum(a.bytes)-sum(b.bytes))/1024/1024/1024,2)||'G/'||trunc((1-sum(b.bytes)/sum(a.bytes))*100,2)||'%'
from dba_data_files a, (select tablespace_name,file_id,sum(bytes) bytes from dba_free_space group by tablespace_name,file_id) b
where a.tablespace_name=b.tablespace_name(+) and a.file_id=b.file_id(+);
show parameter sga;
show parameter db_block_size;
archive log list;
col name for a60
select name,status from v$controlfile;
select group#,bytes/1024/1024,members from v$log;
select tablespace_name,
       max_gb,
       used_gb,
       round(100 * used_gb / max_gb) pct_used
  from (select 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 (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(+)
        union all
        select 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 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
         group by h.tablespace_name)
order by 4;
col file_name for a50
select tablespace_name,
       file_name,
       file_id,
       maxbytes/1024/1024/1024 MaxSize_GB,
       bytes/1024/1024/1024 Size_GB,
       status,
       autoextensible,
       increment_by
 from dba_data_files
union
select tablespace_name,
       file_name, file_id,
       maxbytes/1024/1024/1024 MaxSize_GB,
       bytes/1024/1024/1024 Size_GB,
       status,
       autoextensible,
       increment_by
 from dba_temp_files
order by 1;
col path for a20
col state for a10
col failgroup for a15
col name for a20
select dg.name,dg.state,dg.type,d.disk_number,d.path,d.mount_status,d.failgroup,d.name,d.state
from v$asm_diskgroup dg, v$asm_disk d
where dg.group_number=d.group_number
order by dg.name,d.disk_number;
Edited on