#!/bash
echo 监控服务器磁盘空间
df -h|sed 's/%//g'|awk '$5>0 {print $NF,$(NF-1),$(NF-2),$(NF-3),$(NF-4),$(NF-5)}'>monitor.log
echo监控ORACLE数据库日志文件
awk /ORA-/ /u01/app/oracle/diag/rdbms/dfi/DFI/trace/alert_DFI.log >monitor.log
----监控表空间脚本
#!/bin/bash
PATH=$PATH:$HOME/bin
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product
export ORACLE_SID=DFNFDB
PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
export TNS_ADMIN=$ORACLE_HOME/network/admin
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
sqlplus system/syssys <<EOF
set head off
set echo off
set termout off
set trimspool on
set pagesize 0
set feedback off
set linesize 1024
spool d:\1.log
with a1 as
(select tablespace_name, sum(bytes) / (1024 * 1024 * 1024) total
from dba_data_files
group by tablespace_name),
a2 as
(select tablespace_name, sum(bytes) / (1024 * 1024 * 1024) free
from dba_free_space
group by tablespace_name)
select a1.tablespace_name "表空间名称",
a1.total - a2.free "已使用大小(G)",
a2.free "剩余大小(G)",
a1.total "总大小(G)",
(a1.total - a2.free) / a1.total "已使用%"
from a1, a2
where a1.tablespace_name = a2.tablespace_name;
spool off
exit;
<<EOF
awk '$5>0.87 {print $0}' monitor1.log >> monitor.log
联系客服