被动式监控oracle的rman备份情况
dbbackup.sh
-
[oracle@db rman]$ cat dbbackup.sh
-
cd /home/db/oracle/
-
. ./.bash_profile
-
mv /oradata/rman/db_* /oradata/rmanbak/db_*
-
logName=db_rman_`date +\'%Y%m%d%H%M%S\'`_full.log
-
find /oradata/rmanbak -name \"db_*\" -mtime +0 -exec rm -rf {} \\;
-
cd /oradata/rman
-
rman target / CMDFILE rman_db.rcv >> $logName
-
-
##################################
-
sh check_backup.sh
-
##################################
RMAN_db.rcv
-
[oracle@db rman]$ cat rman_db.rcv
-
run{
-
crosscheck archivelog all;
-
allocate channel c1 type disk;
-
allocate channel c2 type disk;
-
allocate channel c3 type disk;
-
allocate channel c4 type disk;
-
backup as compressed backupset database format \'/oradata/rman/hxpif_full_%U\'
-
plus archivelog skip inaccessible format \'/oradata/rman/hxpif_ARC_%U\';
-
delete noprompt archivelog all completed before \'sysdate-1/8\';
-
backup current controlfile format \'/oradata/rman/hxpif_control_bak_%T\';
-
backup spfile format \'/oradata/rman/hxpif_spfile_bak_%T\';
-
release channel c1;
-
release channel c2;
-
release channel c3;
-
release channel c4;
-
}
-
check_backup.sh
-
[oracle@db rman]$ cat check_backup.sh
-
IP=192.168.0.56
-
SID=db
-
-
status=`sqlplus -silent \"/as sysdba\" <<eof
-
set feedback off
-
set verify off
-
set heading off
-
set echo off
-
set pagesize 0
-
SELECT /*+ rule */ DECODE (
-
TRUNC (SYSDATE - start_time),
-
0, DECODE (
-
status,
-
\'COMPLETED\', \'0\',
-
\'COMPLETED WITH WARNINGS\',\'1\',
-
\'2\'),
-
\'2\')
-
backup_status
-
FROM v\\\\$rman_backup_job_details
-
WHERE start_time = (SELECT MAX (start_time) FROM v\\\\$rman_backup_job_details);
-
exit;
-
eof`
-
output=`sqlplus -silent \"/as sysdba\" <<eof
-
set feedback off
-
set verify off
-
set heading off
-
set echo off
-
set pagesize 0
-
SELECT /*+ rule */ DECODE (
-
TRUNC (SYSDATE - start_time),
-
0, DECODE (status,
-
\'COMPLETED\', \'Backup Suess!\',
-
\'COMPLETED WITH WARNINGS\', \'Backup With Warnings!\',
-
\'Backup Failed!\'),
-
\'No Backup!\')
-
backup_status
-
FROM v\\\\$rman_backup_job_details
-
WHERE start_time = (SELECT MAX (start_time) FROM v\\\\$rman_backup_job_details);
-
exit;
-
eof`
-
hostip=$IP
-
checkname=\"Rman_Backup_\"$SID
-
echo -e \"$hostip\\t$checkname\\t$status\\t$output\" > backup_status.log
-
-
/usr/local/nagios/bin/send_nsca 192.168.128.45 -c /usr/local/nagios/etc/send_nsca.cfg < backup_status.log
[oracle@db rman]$ cat backup_status.log
192.168.0.56 Rman_Backup_DB 0 Backup Suess!
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/30936525/viewspace-2097971/
,如需转载,请注明出处,否则将追究法律责任。