2017年(38)
分类: Oracle
2017-12-07 13:48:13
gnd-rac01$more checkdb.sh
echo "date:----------->";date
echo "uptime\CPU:----------->";uptime
echo "MEM:----------->";free -m
echo "process:----------->";ps -ef|wc -l
echo "user:----------->";cat /etc/passwd|wc -l
echo "disk usage:----------->";df -h
echo "crs status:----------->";crs_stat -t
echo "crontab status:----------->";crontab -l
echo "check-dblinks:----------->";
sqlplus -S '/as sysdba' <
col OWNER format a20;
col DB_LINK format a20;
col USERNAME format a20;
col HOST format a20;
select OWNER,DB_LINK,USERNAME,HOST from dba_db_links;
exit;
!
echo "check-invalid-objects:----------->";
sqlplus -S '/as sysdba' <col OWNER format a20;
col OBJECT_NAME format a20;
col OBJECT_TYPE format a20;
select OWNER,OBJECT_NAME,OBJECT_TYPE from dba_objects where status='INVALID' and object_type <> 'SYNONYM';
exit;
!
echo "check-jobs:----------->";
sqlplus -S '/as sysdba' <alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';
col SCHEMA_USER format a20;
col LAST_DATE format a20;
select JOB,SCHEMA_USER,LAST_DATE,NEXT_DATE,BROKEN from dba_jobs;
exit;
!
echo "check-sessions:----------->";
sqlplus -S '/as sysdba' <SELECT INST_ID,SESSIONS_CURRENT,SESSIONS_HIGHWATER FROM GV\$LICENSE;
exit
!
echo "<-----------Tablespace-free:----------->";
sqlplus -S '/as sysdba' <col TABLESPACE format a10;
SELECT UPPER(F.TABLESPACE_NAME) "TABLESPACE",
D.TOT_GROOTTE_MB "Total(M)",
D.TOT_GROOTTE_MB - F.TOTAL_BYTES "Used(M)",
TO_CHAR(ROUND((D.TOT_GROOTTE_MB - F.TOTAL_BYTES) / D.TOT_GROOTTE_MB * 100,0), '990')||'%' "Percentage",
F.TOTAL_BYTES "Free(M)",
F.MAX_BYTES "Max Size(M)"
FROM (SELECT TABLESPACE_NAME,
ROUND(SUM(BYTES) / (1024 * 1024), 2) TOTAL_BYTES,
ROUND(MAX(BYTES) / (1024 * 1024), 2) MAX_BYTES
FROM SYS.DBA_FREE_SPACE
GROUP BY TABLESPACE_NAME) F,
(SELECT DD.TABLESPACE_NAME,
ROUND(SUM(DD.BYTES) / (1024 * 1024), 2) TOT_GROOTTE_MB
FROM SYS.DBA_DATA_FILES DD
GROUP BY DD.TABLESPACE_NAME) D
WHERE D.TABLESPACE_NAME = F.TABLESPACE_NAME
ORDER BY 4 DESC;
exit
!
echo "archived log:----------->";
sqlplus -S '/as sysdba' <alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';
select thread#,max(first_time),max(sequence#) from v\$archived_log group by thread#;
exit
!
echo "TBS_COUNT:----------->";
sqlplus -S '/as sysdba' <select round(sum(a.bytes_alloc)/1024/1024/1024,2) "TBS_ALLOCT_TOTAL(G)",
round( (sum(a.bytes_alloc)-sum(nvl(b.bytes_free, 0)))/1024/1024/1024,3) "TBS_USED_TOTAL(G)"
from ( select f.tablespace_name,
sum(f.bytes) bytes_alloc
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 (+);
exit
!