forked from 1newstar/oracle-dba-scripts-1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FRA_CHECK.sh
65 lines (54 loc) · 2 KB
/
FRA_CHECK.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
#
#Created by jon Delmas 1/9/2018
#
DEBUG=0
#######################Environment_variables#####################################
source ~/.bash_profile
. /home/oracle/nethome/dba/config/config.env
export mail_file=$DBA_LOG/fra_mail_file.log
if [ $DEBUG -eq 1 ]; then export EMAIL_LIST='[email protected]'; fi
cd $DBA_LOG
########################LOOP_throught_databases###################################
if [ `hostname -a|sed 's/-.*//'` == 'ATXP' ]; then db_list=$PRIMARY_DG_DB_LIST
else db_list=$STANDBY_DG_DB_LIST;
fi
for i in $db_list; do
if [ $DEBUG -eq 1 ]; then echo $i;fi
function fun(){
sqlplus -s $SYSPASS@$i as sysdba <<EOF
SET head off PAGES 0
SET LINESIZE 10
SET FEEDBACK OFF
SET ECHO OFF
select round((SPACE_USED/SPACE_LIMIT)*100) from V\$RECOVERY_FILE_DEST;
exit;
EOF
}
Q=`fun`
if
[ $Q -ge $FRA_CRITICAL ]; then
echo "==============Attention======================" >> $mail_file
echo "Database $i FRA has low diskspace" >> $mail_file
echo "Severity: Critical" >> $mail_file
echo "Threshold is 95 for critical" >> $mail_file
echo "Hostname $node" >> $mail_file
echo "The FRA is current usage >>$Q% ---- Please take Action!! ---- " >> $mail_file
echo "End of email" >> $mail_file
echo "" >> $mail_file
cat -v $mail_file | mailx -s "Attention!! $i is low space in FRA! " $EMAIL_LIST
elif
[ $Q -ge $FRA_PROACTIVE ]; then
echo "==============Attention======================" >> $mail_file
echo "Database $i FRA has low diskspace" >> $mail_file
echo "Severity: Proactive" >> $mail_file
echo "Threshold is 85% for Proactive" >> $mail_file
echo "Hostname $node" >> $mail_file
echo "The FRA is current usage >$Q% ---- Please take Action!! ---- " >> $mail_file
echo "End of email" >> $mail_file
echo "" >> $mail_file
cat -v $mail_file | mailx -s "Attention!! $i is low space in FRA! " $EMAIL_LIST
fi
rm -f $mail_file
done
exit 0