#!/bin/bash
# This script is to send mail for alerting ASM Disk Group free space and used space status.
# Assumption smtb confirgured,created DIR's
# Note : you have to have SSH connectivity between monitoring server and the ASM server,Enter the server details in asm_serv.txt:as format "+ASM1 10.95.10.101 oracle"
WORK_DIR=/u01/app/oracle/util/scripts
LOG_DIR=/u01/app/oracle/util/log
Server_details=$WORK_DIR/asm_serv.txt
temp_file=$WORK_DIR/asm_report_temp.log
final_report=$WORK_DIR/asm_full_report.html
export PATH=$PATH:/usr/sbin
CURR_DATE=`date '+%m/%d/%y_%H:%M'`
if [ -e $temp_file ]
then
`rm $temp_file `
fi
if [ -e $final_report ]
then
`rm $final_report `
fi
html_head="Subject: ASM Alert REPORT for ${CURR_DATE}
\nMIME-Version: 1.0 \nContent-Type: text/html \nContent-Disposition: inline \n
<html>
<head>
<meta http-equiv=\"Content-Type\" content=text/html; charset=\"UTF-8\">
<meta name=\"generator\" content=\"SQL*Plus 11.2.0\">
<style type=\"text/css\">
body {font:10pt Arial,Helvetica,sans-serif;
color:black; background:White;}
p {font:10pt Arial,Helvetica,sans-serif;
color:black; background:White;}
table,tr,td {font:10pt Arial,Helvetica,sans-serif;
color:Black; background:#f7f7e7;
padding:0px 0px 0px 0px; margin:0px 0px 0px 0px;}
th {font:bold 10pt Arial,Helvetica,sans-serif;
color:#336699; background:#cccc99; padding:0px 0px 0px 0px;}
h1 {font:13pt Arial,Helvetica,Geneva,sans-serif;
color:#336699;text-decoration:underline;background-color:White;
border-bottom:1px solid #cccc99;
margin-top:0pt; margin-bottom:0pt;
padding:0px 0px 0px 0px;}
h2 {font:bold 10pt Arial,Helvetica,Geneva,sans-serif;
color:#336699; background-color:White;
margin-top:4pt; margin-bottom:0pt;}
a {font:9pt Arial,Helvetica,sans-serif;
color:#663300; background:#ffffff;
margin-top:0pt; margin-bottom:0pt; vertical-align:top;}
</style>
<title>
ALL SERVER ASM DISKGROUPS REPORT:
</title>
</head><body><br><br>"
html_tail='<br><h2></h2><a><br>
</a></body></html>'
touch $final_report
echo -e $html_head >> $final_report
# Reads the value from asm_serv.txt
while read t
do
ASM_INST=`echo $t|awk '{print $1}'`
ASM_USER=`echo $t|awk '{print $3}'`
ASM_IP=`echo $t|awk '{print $2}'`
ssh -o StrictHostKeyChecking=no -n $ASM_USER@$ASM_IP 'export ORAENV_ASK=NO;export ORACLE_SID='$ASM_INST';. oraenv;sqlplus / as sysasm << EOM
set lines 230
set pages 200
set feed off term off trims on linesize 300 pages 300 echo off underline off heading on
set markup html on
col pct_used entmap off
SELECT
distinct name group_name
, sector_size sector_size
, block_size block_size
, allocation_unit_size allocation_unit_size
, state state
, type type
, round(total_mb/1024,2) total_gb
, round(((total_mb - free_mb)/1024),2) used_gb
, round((free_mb/1024),2) free_gb
,case
when ROUND((1- (free_mb / total_mb))*100, 2) <=90 then
'"'"'<font color="green">'"'"'||ROUND((1- (free_mb / total_mb))*100, 2)||'"'"'</font>'"'"'
when ROUND((1- (free_mb / total_mb))*100, 2) > 90 and ROUND((1- (free_mb / total_mb))*100, 2) < 95 then
'"'"'<font color="orange">'"'"'||ROUND((1- (free_mb / total_mb))*100, 2)||'"'"'</font>'"'"'
else
'"'"'<font color="red">'"'"'||ROUND((1- (free_mb / total_mb))*100, 2)||'"'"'</font>'"'"'
end
pct_used
,round((free_mb/total_mb)*100,2) pct_free
FROM
v\$asm_diskgroup
WHERE
TYPE is not NULL
ORDER BY
name;
EOM'|sed -n '/<p>/,/<p>/p' > $temp_file
echo -e "<BR><BR><h2> ASM DISKGROUP REPORT FOR $ASM_INST in server $ASM_IP :</h2><br><BR>" >> $final_report
cat $temp_file >> $final_report
done < $Server_details
echo -e $html_tail >> $final_report
sendmail -v username@mailid.com < $final_report
###############
Sample Output
# This script is to send mail for alerting ASM Disk Group free space and used space status.
# Assumption smtb confirgured,created DIR's
# Note : you have to have SSH connectivity between monitoring server and the ASM server,Enter the server details in asm_serv.txt:as format "+ASM1 10.95.10.101 oracle"
WORK_DIR=/u01/app/oracle/util/scripts
LOG_DIR=/u01/app/oracle/util/log
Server_details=$WORK_DIR/asm_serv.txt
temp_file=$WORK_DIR/asm_report_temp.log
final_report=$WORK_DIR/asm_full_report.html
export PATH=$PATH:/usr/sbin
CURR_DATE=`date '+%m/%d/%y_%H:%M'`
if [ -e $temp_file ]
then
`rm $temp_file `
fi
if [ -e $final_report ]
then
`rm $final_report `
fi
html_head="Subject: ASM Alert REPORT for ${CURR_DATE}
\nMIME-Version: 1.0 \nContent-Type: text/html \nContent-Disposition: inline \n
<html>
<head>
<meta http-equiv=\"Content-Type\" content=text/html; charset=\"UTF-8\">
<meta name=\"generator\" content=\"SQL*Plus 11.2.0\">
<style type=\"text/css\">
body {font:10pt Arial,Helvetica,sans-serif;
color:black; background:White;}
p {font:10pt Arial,Helvetica,sans-serif;
color:black; background:White;}
table,tr,td {font:10pt Arial,Helvetica,sans-serif;
color:Black; background:#f7f7e7;
padding:0px 0px 0px 0px; margin:0px 0px 0px 0px;}
th {font:bold 10pt Arial,Helvetica,sans-serif;
color:#336699; background:#cccc99; padding:0px 0px 0px 0px;}
h1 {font:13pt Arial,Helvetica,Geneva,sans-serif;
color:#336699;text-decoration:underline;background-color:White;
border-bottom:1px solid #cccc99;
margin-top:0pt; margin-bottom:0pt;
padding:0px 0px 0px 0px;}
h2 {font:bold 10pt Arial,Helvetica,Geneva,sans-serif;
color:#336699; background-color:White;
margin-top:4pt; margin-bottom:0pt;}
a {font:9pt Arial,Helvetica,sans-serif;
color:#663300; background:#ffffff;
margin-top:0pt; margin-bottom:0pt; vertical-align:top;}
</style>
<title>
ALL SERVER ASM DISKGROUPS REPORT:
</title>
</head><body><br><br>"
html_tail='<br><h2></h2><a><br>
</a></body></html>'
touch $final_report
echo -e $html_head >> $final_report
# Reads the value from asm_serv.txt
while read t
do
ASM_INST=`echo $t|awk '{print $1}'`
ASM_USER=`echo $t|awk '{print $3}'`
ASM_IP=`echo $t|awk '{print $2}'`
ssh -o StrictHostKeyChecking=no -n $ASM_USER@$ASM_IP 'export ORAENV_ASK=NO;export ORACLE_SID='$ASM_INST';. oraenv;sqlplus / as sysasm << EOM
set lines 230
set pages 200
set feed off term off trims on linesize 300 pages 300 echo off underline off heading on
set markup html on
col pct_used entmap off
SELECT
distinct name group_name
, sector_size sector_size
, block_size block_size
, allocation_unit_size allocation_unit_size
, state state
, type type
, round(total_mb/1024,2) total_gb
, round(((total_mb - free_mb)/1024),2) used_gb
, round((free_mb/1024),2) free_gb
,case
when ROUND((1- (free_mb / total_mb))*100, 2) <=90 then
'"'"'<font color="green">'"'"'||ROUND((1- (free_mb / total_mb))*100, 2)||'"'"'</font>'"'"'
when ROUND((1- (free_mb / total_mb))*100, 2) > 90 and ROUND((1- (free_mb / total_mb))*100, 2) < 95 then
'"'"'<font color="orange">'"'"'||ROUND((1- (free_mb / total_mb))*100, 2)||'"'"'</font>'"'"'
else
'"'"'<font color="red">'"'"'||ROUND((1- (free_mb / total_mb))*100, 2)||'"'"'</font>'"'"'
end
pct_used
,round((free_mb/total_mb)*100,2) pct_free
FROM
v\$asm_diskgroup
WHERE
TYPE is not NULL
ORDER BY
name;
EOM'|sed -n '/<p>/,/<p>/p' > $temp_file
echo -e "<BR><BR><h2> ASM DISKGROUP REPORT FOR $ASM_INST in server $ASM_IP :</h2><br><BR>" >> $final_report
cat $temp_file >> $final_report
done < $Server_details
echo -e $html_tail >> $final_report
sendmail -v username@mailid.com < $final_report
###############
Sample Output
ASM DISKGROUP REPORT FOR +ASM1 in server 10.96.10.101 :
GROUP_NAME
|
SECTOR_SIZE
|
BLOCK_SIZE
|
ALLOCATION_UNIT_SIZE
|
STATE
|
TYPE
|
TOTAL_GB
|
USED_GB
|
FREE_GB
|
PCT_USED
|
PCT_FREE
|
ASM_DATA01
|
512
|
4096
|
1048576
|
MOUNTED
|
EXTERN
|
1536
|
1432.59
|
103.41
|
93.27
|
6.73
|
ASM_FRA01
|
512
|
4096
|
1048576
|
MOUNTED
|
EXTERN
|
800
|
517.44
|
282.57
|
64.68
|
35.32
|
OCR_VOTE
|
512
|
4096
|
1048576
|
MOUNTED
|
EXTERN
|
10
|
.39
|
9.62
|
3.87
|
96.13
|
No comments:
Post a Comment