oracle健康巡检脚本,oracle 巡检脚本

#!/bin/sh

# Get Hostname

HOSTNAME=`hostname`

logfile=xunjian_`date +%y%m%d`.log

hostinfodir=/home/oracle/xunjian

if [[ ! -d  $hostinfodir ]]

then

mkdir -p $hostinfodir

fi

date >> $hostinfodir/$logfile

echo " hostname " >> $hostinfodir/$logfile

hostname >> $hostinfodir/$logfile

echo " uname -a " >> $hostinfodir/$logfile

uname -a >> $hostinfodir/$logfile

echo " ulimit -a " >> $hostinfodir/$logfile

ulimit -a >> $hostinfodir/$logfile

echo " cat /proc/cpuinfo " >> $hostinfodir/$logfile

cat /proc/cpuinfo >> $hostinfodir/$logfile

echo " cat /proc/meminfo " >> $hostinfodir/$logfile

cat /proc/meminfo >> $hostinfodir/$logfile

echo " vmstat 3 10 " >> $hostinfodir/$logfile

vmstat 3 10 >> $hostinfodir/$logfile

echo " df -ha " >> $hostinfodir/$logfile

df -ha >>$hostinfodir/$logfile

echo " ifconfig -a " >> $hostinfodir/$logfile

ifconfig -a >> $hostinfodir/$logfile

echo " env | grep ORACLE " >> $hostinfodir/$logfile

env | grep ORACLE >> $hostinfodir/$logfile

echo " cat $ORACLE_HOME/network/admin/listener.ora " >> $hostinfodir/$logfile

cat $ORACLE_HOME/network/admin/listener.ora >> $hostinfodir/$logfile

echo " cat $ORACLE_HOME/network/admin/tnsnames.ora " >> $hostinfodir/$logfile

cat $ORACLE_HOME/network/admin/tnsnames.ora >> $hostinfodir/$logfile

echo "======osinfo end================"

echo "=========oracleinfo begin========"

cd $hostinfodir

sqlplus /nolog << EOF

conn / as sysdba;

SET TERMOUT OFF;

set echo off;

spool oracle.txt;

set linesize 200;

col name format a20;

col value format a30;

--log file size mb:

select 'log file size unit mb:' infoterm from dual;

select round(bytes/(1024*1024),2) total_g from v\$log where rownum<2;

--log file total number:

select 'log file total number:' infoterm from dual;

select count(*) from v\$log;

--log file number in one group:

select 'log file number in one group:' infoterm from dual;

select num from (select count(*) num from v\$logfile group by GROUP#) where rownum<2;

--sga info:

show sga

select 'sga info:' infoterm from dual;

select name,value from v\$parameter where name

in('shared_pool_size','db_cache_size','db_block_buffers','log_buffer','large_pool_size','java_pool_size','pga_aggregate_target');

--database name

select 'database name:' infoterm from dual;

select name from v\$database;

--DB_BLOCK_SIZE

select 'DB_BLOCK_SIZE:' infoterm from dual;

select value from v\$parameter where name in('db_block_size');

--database version

select 'database version:' infoterm from dual;

select version from v\$instance;

--datafile size;

select 'datafile size:' infoterm from dual;

select round((sum(bytes)/1024/1024/1024)) total_g from dba_data_files;

--datafile characterset

select 'datafile characterset:' infoterm from dual;

select  value from nls_database_parameters where parameter = 'NLS_CHARACTERSET';

--archive

select 'archive:' infoterm from dual;

select log_mode from  v\$database;

archive log list;

--datafile number:

select 'datafile number:' infoterm from dual;

select count(*) from dba_data_files;

--tablespace number:

select 'tablespace number:' infoterm from dual;

select count(*) from dba_tablespaces;

--controlfile number:

select 'controlfile number:' infoterm from dual;

select count(*) from v\$controlfile;

--controlfile info:

select 'controlfile info:' infoterm from dual;

col NAME format a60

select * from v\$controlfile;

--logfile info:

select 'logfile info:' infoterm from dual;

col member format a50;

select * from v\$logfile order by GROUP#;

select * from v\$log order by GROUP#;

--block_size info:

select 'block_size info:' infoterm from dual;

select distinct block_size from dba_tablespaces;

--datafile info:

select 'datafile info:' infoterm from dual;

set linesize 500 pagesize 200

col file_id for 9999999

col file_name for a55

col ts_name for a18

col cur_mb for 99999

col max_mb for 99999

select file_id,tablespace_name ts_name,file_name,status, autoextensible,

blocks/128 cur_mb, maxblocks/128 max_mb

from dba_data_files order by file_id;

--tempfile info:

select 'tempfile info:' infoterm from dual;

select file_id,tablespace_name ts_name,file_name,status, autoextensible,

blocks/128 cur_mb, maxblocks/128 max_mb

from dba_temp_files order by file_id;

--tablespace info:

select 'tablespace info:' infoterm from dual;

set linesize 500 pagesize 200

col tablespace_name format a20

col contents for a9

col ext_mgmt for a8

col alloc_type for a9

col ext_kb format 999999

col ssm for a6

col total_mb format a12

col free_mb format a12

col free_pct format a7

select c.tablespace_name, c.contents, c.extent_management ext_mgmt,

c.allocation_type alloc_type, c.initial_extent/1024 ext_kb,

c.segment_space_management SSM, a.total_mb, b.free_mb,

to_char(100*b.free_mb/a.total_mb, '999.99') free_pct

from

(select tablespace_name, to_char(sum(bytes)/1048576, '99999999.99') total_mb

from dba_data_files group by tablespace_name) a,

(select tablespace_name, to_char(sum(bytes)/1048576, '99999999.99') free_mb,

count(*) free_exts, to_char(max(bytes)/1048576, '99999999') max_mb,

to_char(min(bytes)/1048576, '99999999') min_mb

from dba_free_space group by tablespace_name) b,

dba_tablespaces c

where a.tablespace_name=b.tablespace_name(+) and c.tablespace_name=b.tablespace_name

order by free_pct, tablespace_name;

--system tablespace info:

select 'system tablespace info:' infoterm from dual;

select owner,count(*) from dba_segments where tablespace_name='SYSTEM' group by owner;

select username, default_tablespace, temporary_tablespace from dba_users

where default_tablespace='SYSTEM' or temporary_tablespace='SYSTEM';

--invalid object info:

select 'invalid object info:' infoterm from dual;

select count(*),owner from dba_objects where status='INVALID' group by owner;

select 'invalid index info:'  infoterm from dual;

select owner,index_name from dba_indexes where status='UNUSABLE';

--auth info:

select 'auth info:' infoterm from dual;

select * from v\$pwfile_users;

col grantee for a15;

col granted_role for a15;

col admin_option for a20;

col default_role for a20;

select * from dba_role_privs where granted_role='DBA';

spool off;

exit

EOF

echo "=========oracleinfo end============"

exit 0

本文乃原创文章,请勿转载。如须转载请详细标明转载出处

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
资源包主要包含以下内容: ASP项目源码:每个资源包中都包含完整的ASP项目源码,这些源码采用了经典的ASP技术开发,结构清晰、注释详细,帮助用户轻松理解整个项目的逻辑和实现方式。通过这些源码,用户可以学习到ASP的基本语法、服务器端脚本编写方法、数据库操作、用户权限管理等关键技术。 数据库设计文件:为了方便用户更好地理解系统的后台逻辑,每个项目中都附带了完整的数据库设计文件。这些文件通常包括数据库结构图、数据表设计文档,以及示例数据SQL脚本。用户可以通过这些文件快速搭建项目所需的数据库环境,并了解各个数据表之间的关系和作用。 详细的开发文档:每个资源包都附有详细的开发文档,文档内容包括项目背景介绍、功能模块说明、系统流程图、用户界面设计以及关键代码解析等。这些文档为用户提供了深入的学习材料,使得即便是从零开始的开发者也能逐步掌握项目开发的全过程。 项目演示与使用指南:为帮助用户更好地理解和使用这些ASP项目,每个资源包中都包含项目的演示文件和使用指南。演示文件通常以视频或图文形式展示项目的主要功能和操作流程,使用指南则详细说明了如何配置开发环境、部署项目以及常见问题的解决方法。 毕业设计参考:对于正在准备毕业设计的学生来说,这些资源包是绝佳的参考材料。每个项目不仅功能完善、结构清晰,还符合常见的毕业设计要求和标准。通过这些项目,学生可以学习到如何从零开始构建一个完整的Web系统,并积累丰富的项目经验。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值