首页 > Linux操作系统 > Linux操作系统 > awk for循环 监控
检查磁盘空间
FS=`df -h|sed '1d'|awk 'sub("%","",$4) {if($4>80) print $5}'|xargs`
for i in $FS
do
echo "The $i filesystem percent more than 80%" >>$files
done
检查警告日志文件
cd $ORACLE_BASE/admin/$ORACLE_SID/bdump
if [ -f alert_$ORACLE_SID.log ]
then
touch alert_$ORACLE_SID.log
cat alert_work.log>>alert_$ORACLE_SID.hist
grep -i "ORA-" alert_work.log >alert.err
fi
if [ `cat alert.err|wc -l` -gt 0 ]
then
cat alert.err>>$files
fi
rm -rf alert.err
rm -rf alert_work.log
检查数据库状态
$ORACLE_HOME/bin/sqlplus -S /nolog <
conn / as sysdba
select log_mode,name,open_mode from v\$database;
quit
EOF
if [ $? = 0 ]
then
echo "The database is normal">>$files
else
echo "The database is not available!!!!">>$files
fi
检查表空间状态
$ORACLE_HOME/bin/sqlplus -S / as sysdba <
set pagesize 0
set feedback off
set term off
set termout off
set trimspool on;
set trimout on;
set linesize 100
col tablespace_name for a15;
col status for a10;
spool /u/oracle/tablespace_status.txt
select tablespace_name,status from dba_tablespaces;
spool off;
exit;
EOF
cat /u/oracle/tablespace_status.txt|awk '{if ($2 == "OFFLINE") {print $1" is OFFLINE"} else if ($2 == "RECOVER") {print $1" is RECOVER"} else if (($2 == "READ") && ($3 == "ONLY")) {print $1" is READ ONLY"}}'>>$files
rm -rf /u/oracle/tablespace_status.txt
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/16566331/viewspace-682273/ ,如需转载,请注明出处,否则将追究法律责任。