simplification et bouclage sur toutes les bases

This commit is contained in:
Yacine31
2023-01-27 18:02:41 +01:00
parent a535751e26
commit a36dae724b
2 changed files with 253 additions and 281 deletions

View File

@@ -1,47 +1,9 @@
. /home/oracle/.bash_profile
SCRIPTDIR=/home/oracle/Daily
LOGDIR=${SCRIPTDIR}/logs
DATETIME=`date +%Y%m%d%H%M`
mv $LOGDIR/DailyCheck.html $LOGDIR/DailyCheck_${DATETIME}.html
rm $LOGDIR/diskspacereport.html
rm $LOGDIR/diskspacereport.txt
rm $LOGDIR/dbnodecpudetails.lst
rm $LOGDIR/diskspacereport1.html
sqlplus -s "/ as sysdba" @$SCRIPTDIR/DailyCheck_html.sql
HOST=$(hostname)
IPADDR=$(hostname -i)
>$LOGDIR/diskspacereport.txt
string1="CPU, Memory and Space Usage Report for DB Server ($HOST | $IPADDR) : \n"
echo -e $string1>> $LOGDIR/diskspacereport.txt
printf "\n"
for i in `seq 1 5` ; do
>$LOGDIR/dbnodecpudetails.lst
top -bn 1 | head -n 3 >> $LOGDIR/dbnodecpudetails.lst
sleep 3
for r in $(ps -eaf | grep pmon | egrep -v 'grep|ASM1|APX1' | cut -d '_' -f3)
do
export ORACLE_SID=$r
. oraenv -s
echo $ORACLE_SID $ORACLE_HOME
sqlplus -s "/ as sysdba" @DailyCheck_html.sql > DailyCheck_${DATETIME}.html
done
cat $LOGDIR/dbnodecpudetails.lst >> $LOGDIR/diskspacereport.txt
echo "<br />" >> $LOGDIR/diskspacereport.txt
free | grep Mem | awk '{ printf("Free Memory: %.2f %\n", ($4+$7)/$2 * 100.0) }' >> $LOGDIR/diskspacereport.txt
echo "<br />" >> $LOGDIR/diskspacereport.txt
df -h >> $LOGDIR/diskspacereport.txt
echo "<br />" >> $LOGDIR/diskspacereport.txt
echo "*******************************************END OF REPORT****************************************************">> $LOGDIR/diskspacereport.txt
cat $LOGDIR/diskspacereport.txt > $LOGDIR/diskspacereport.html
sed 's/$/<br>/g' $LOGDIR/diskspacereport.html>$LOGDIR/diskspacereport1.html
cat $LOGDIR/diskspacereport1.html >> $LOGDIR/DailyCheck.html
EMAIL_LIST=daily_report@gmail.com
SEND_MAIL()
{
{
echo "To: $EMAIL_LIST"
echo "Subject:Health Check : $ORACLE_SID@`hostname`"
echo "MIME-Version: 1.0"
echo "Content-Type: text/html"
echo "Content-Disposition: inline"
cat $LOGDIR/DailyCheck.html
} | /usr/sbin/sendmail $EMAIL_LIST
}
SEND_MAIL
[oracle@dbnode1 Daily]$