ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 简单记录一下每天检查正式Server的一个脚本

简单记录一下每天检查正式Server的一个脚本

原创 Linux操作系统 作者:andyxu 时间:2011-09-08 15:19:18 0 删除 编辑
source /home/oracle/.bash_profile
echo "<-----------date:----------->";date
echo "<-----------uptime\CPU:----------->";uptime
echo "<-----------Mem Free:----------->";free
echo "<-----------processes:----------->";ps -ef|wc -l
echo "<-----------users:----------->";cat /etc/passwd|wc -l
echo "<-----------disk usage:----------->";df -h
echo "<-----------crontab status:----------->";crontab -l

echo "<-----------check-dblinks:----------->";
sqlplus -S '/as sysdba' <

col OWNER format a10;
col DB_LINK format a10;
col USERNAME format a10;
col HOST format a10;
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 OWNER,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/110321/viewspace-706924/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2009-06-26

  • 博文量
    167
  • 访问量
    292464