巡檢指令碼OS+Oracle

weixin_34321977發表於2016-04-12

巡檢指令碼

主機巡檢指令碼: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下面,每次執行完結果都會有提示輸出檔案具體位置。

相關文章