代码改变世界

巡检脚本OS+Oracle

2016-04-12 06:48  AlfredZhao  阅读(2081)  评论(0编辑  收藏  举报

巡检脚本

主机巡检脚本:OSWatcher.sh
Oracle巡检脚本:ORAWatcher.sh

脚本使用方法

1、建立脚本放置目录

# mkdir /var/collect

2、把脚本ORAWatcher.sh及OSWatcher.sh上传到以上目录

比如我这里使用sftp,
把我本机D:\Jingyu\Others\Daily Work\Periodic Inspection目录下的巡检脚本上传到数据库服务器的/var/collect目录下:

sftp> lcd "D:\Jingyu\Others\Daily Work\Periodic Inspection"
sftp> cd /var/collect
sftp> put *.sh
Uploading ORAWatcher.sh to /var/collect/ORAWatcher.sh
  100% 6KB      6KB/s 00:00:00     
D:/Jingyu/Others/Daily Work/Periodic Inspection/ORAWatcher.sh: 6362 bytes transferred in 0 seconds (6362 bytes/s)
Uploading OSWatcher.sh to /var/collect/OSWatcher.sh
  100% 18KB     18KB/s 00:00:00     
D:/Jingyu/Others/Daily Work/Periodic Inspection/OSWatcher.sh: 19151 bytes transferred in 0 seconds (18 KB/s)
sftp> 

修改脚本文件权限:

# chown -R oracle:dba /var/collect
# chmod u+x /var/collect/O*.sh

3、两脚本都用oracle用户执行

切换到oracle用户,执行两个脚本:

# su - oracle
% cd /var/collect
% ./OSWatcher.sh
% ./ORAWatcher.sh

执行巡检脚本的示例输出如下:
OS:

--执行OSWatcher.sh
xxoradb% ./OSWatcher.sh

OSWatcher Version:1.0.0

the PATH is://u01/oracle/bin:/usr/lib64/qt-3.3/bin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/oracle/bin:/usr/platform/x86_64/sbin/:/usr/sbin/

Testing for discovery of OS Utilities...
Starting Data Collection...

MEDIA found on your system.
BPPLLIST found on your system.
BPMEDIALIST found on your system.
TPCONFIG found on your system.
BPDBJOBS found on your system.
BPPS found on your system.
VCS found on your system.
SCSTAT found on your system.
SCRGADM found on your system.
SCINSTALL found on your system.
VXPRINT found on your system.
VXDISK found on your system.
METSTAT found on your system.
Warning... ENV not found on your system.
CRONTAB found on your system.
USERS found on your system.
HOSTS found on your system.
FSTAB found on your system.
SWAP found on your system.
SAR found on your system.
PRSTAT found on your system.
VMSTAT found on your system.
IOSTAT found on your system.
MPSTAT found on your system.
PSELF found on your system.
TOP found on your system.
meminfo found on your system.
slabinfo found on your system.

Discovery completed.
Collection completed.
The Collected result saved in ./archive/xxoradb_04.11.16.1400.dat.

Oracle:

--执行ORAWatcher.sh
xxoradb% ./ORAWatcher.sh  

ORAWatcher Version:1.0.1


Info...You did not enter a value for sqlstr.
Info...Using default value = system/system
system/system
Starting Data Collection...

########################  1.数据库版本
########################  2.控制文件
########################  3.pfile、spfile
########################  4.字符集
########################  5.归档状态
########################  6.参数设置
########################  7.回滚段存储位置
########################  8.redolog
########################  9.查看表空间大小及利用率
########################  10.数据文件
########################  11.查看数据文件的扩展方式
########################  12.查看表空间的扩展方式
########################  13.临时表空间
########################  14.用户默认表空间
########################  15.数据库缓冲区高速缓存命中率
########################  16.重写不等待比率
########################  17.库高速缓存命中率
########################  18.数据字典高速缓存Getmisses对gets的目标比例
########################  19.用户对像(表、索引、大小)
########################  20.检查是否有失效的索引
########################  21.检查数据库会话连接占用率
########################  22.检查数据库会话连接历史最高值
########################  23.检查数据库Job状态
Collection completed.
The Collected result saved in ./archive/xxoradb_oracle_04.11.16.1300.dat.

注意:

  • ORAWatcher.sh脚本中数据库的默认连接串是:system/system,如果system密码不是这个,
    可以这样执行:./ORAWatcher.sh system/password
  • 服务器及数据库的采集结果保存在./archive下面,每次执行完结果都会有提示输出文件具体位置。