ITPub博客

首页 > Linux操作系统 > Linux操作系统 > sh checkdb.sh

sh checkdb.sh

原创 Linux操作系统 作者:guocun09 时间:2011-12-08 15:57:11 0 删除 编辑

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
!

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/25583515/viewspace-712962/,如需转载,请注明出处,否则将追究法律责任。

上一篇: sql checkdb
下一篇: rc.local
请登录后发表评论 登录
全部评论
DBA,掌握Oracle,SQLServer,MySQL,hadoop,casscandra等数据库。喜爱深入研究数据库技术原理,擅长管理和优化工作。

注册时间:2011-10-02

  • 博文量
    135
  • 访问量
    491624